diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index eb74930dec50..43a5bb05803e 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -7,3 +7,4 @@ # java-vertexai has maintainers /java-vertexai/ @googleapis/vertex-java-sdk @googleapis/cloud-java-team-teamsync +/java-datastore/ @googleapis/cloud-native-db-dpes @googleapis/api-datastore-sdk @googleapis/api-firestore-partners @googleapis/cloud-java-team-teamsync diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml index 1716ff0b495d..58f0df638e71 100644 --- a/.github/workflows/hermetic_library_generation.yaml +++ b/.github/workflows/hermetic_library_generation.yaml @@ -36,10 +36,10 @@ jobs: if: env.SHOULD_RUN == 'true' with: fetch-depth: 0 - token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + token: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }} - uses: googleapis/sdk-platform-java/.github/scripts@v2.65.1 if: env.SHOULD_RUN == 'true' with: base_ref: ${{ github.base_ref }} head_ref: ${{ github.head_ref }} - token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + token: ${{ secrets.CLOUD_JAVA_BOT_GITHUB_TOKEN }} diff --git a/.github/workflows/java-datastore-ci.yaml b/.github/workflows/java-datastore-ci.yaml new file mode 100644 index 000000000000..0b080099fabd --- /dev/null +++ b/.github/workflows/java-datastore-ci.yaml @@ -0,0 +1,147 @@ +# 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. +# Github action job to test core java library features on +# downstream client libraries before they are released. +on: + push: + branches: + - main + pull_request: +name: java-datastore ci +env: + BUILD_SUBDIR: java-datastore +jobs: + filter: + runs-on: ubuntu-latest + outputs: + library: ${{ steps.filter.outputs.library }} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + library: + - 'java-datastore/**' + units: + needs: filter + if: ${{ needs.filter.outputs.library == 'true' }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + java: [11, 17, 21, 25] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{matrix.java}} + - run: java -version + - run: .kokoro/build.sh + env: + JOB_TYPE: test + units-java8: + needs: filter + if: ${{ needs.filter.outputs.library == 'true' }} + # Building using Java 17 and run the tests with Java 8 runtime + name: "units (8)" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 8 + distribution: temurin + - name: "Set jvm system property environment variable for surefire plugin (unit tests)" + # Maven surefire plugin (unit tests) allows us to specify JVM to run the tests. + # https://maven.apache.org/surefire/maven-surefire-plugin/test-mojo.html#jvm + run: echo "SUREFIRE_JVM_OPT=-Djvm=${JAVA_HOME}/bin/java -P !java17" >> $GITHUB_ENV + shell: bash + - uses: actions/setup-java@v4 + with: + java-version: 17 + distribution: temurin + - run: .kokoro/build.sh + env: + JOB_TYPE: test + windows: + needs: filter + if: ${{ needs.filter.outputs.library == 'true' }} + # Building using Java 11 and run the tests with Java 8 runtime + runs-on: windows-latest + steps: + - name: Support longpaths + run: git config --system core.longpaths true + - name: Support longpaths + run: git config --system core.longpaths true + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + java-version: 8 + distribution: temurin + - name: "Set jvm system property environment variable for surefire plugin (unit tests)" + run: echo "SUREFIRE_JVM_OPT=-Djvm=${JAVA_HOME}\bin\java -P !java17" >> $GITHUB_ENV + shell: bash + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 11 + - run: java -version + - run: .kokoro/build.sh + env: + JOB_TYPE: test + dependencies: + needs: filter + if: ${{ needs.filter.outputs.library == 'true' }} + runs-on: ubuntu-latest + strategy: + matrix: + java: [17] + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: ${{matrix.java}} + - run: java -version + - run: .kokoro/dependencies.sh + javadoc: + needs: filter + if: ${{ needs.filter.outputs.library == 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + - run: java -version + - run: .kokoro/build.sh + env: + JOB_TYPE: javadoc + lint: + needs: filter + if: ${{ needs.filter.outputs.library == 'true' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: 17 + - run: java -version + - run: .kokoro/build.sh + env: + JOB_TYPE: lint diff --git a/.kokoro/build.sh b/.kokoro/build.sh index e604c8768b86..675fd276cbcd 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -33,10 +33,17 @@ if [ -f "${KOKORO_GFILE_DIR}/secret_manager/java-bigqueryconnection-samples-secr source "${KOKORO_GFILE_DIR}/secret_manager/java-bigqueryconnection-samples-secrets" fi +if [[ -n "${BUILD_SUBDIR}" ]] +then + echo "Running in subdir: ${BUILD_SUBDIR}" + pushd "${BUILD_SUBDIR}" +fi + RETURN_CODE=0 case ${JOB_TYPE} in test) + echo "SUREFIRE_JVM_OPT: ${SUREFIRE_JVM_OPT}" retry_with_backoff 3 10 \ mvn test \ -B -ntp \ @@ -48,7 +55,7 @@ case ${JOB_TYPE} in -Dflatten.skip=true \ -Danimal.sniffer.skip=true \ -Dmaven.wagon.http.retryHandler.count=5 \ - -T 1C + -T 1C ${SUREFIRE_JVM_OPT} RETURN_CODE=$? echo "Finished running unit tests" ;; @@ -125,6 +132,12 @@ case ${JOB_TYPE} in esac +if [[ -n "${BUILD_SUBDIR}" ]] +then + echo "restoring directory" + popd +fi + if [ "${REPORT_COVERAGE}" == "true" ]; then bash ${KOKORO_GFILE_DIR}/codecov.sh fi diff --git a/.kokoro/dependencies.sh b/.kokoro/dependencies.sh index bd8960246f66..1ea066f5bf77 100755 --- a/.kokoro/dependencies.sh +++ b/.kokoro/dependencies.sh @@ -49,6 +49,12 @@ function determineMavenOpts() { export MAVEN_OPTS=$(determineMavenOpts) +if [[ -n "${BUILD_SUBDIR}" ]] +then + echo "Running in subdir: ${BUILD_SUBDIR}" + pushd "${BUILD_SUBDIR}" +fi + # this should run maven enforcer retry_with_backoff 3 10 \ mvn install -B -V -ntp \ @@ -57,3 +63,9 @@ retry_with_backoff 3 10 \ -Dclirr.skip=true mvn -B dependency:analyze -DfailOnWarning=true + +if [[ -n "${BUILD_SUBDIR}" ]] +then + echo "Leaving subdir: ${BUILD_SUBDIR}" + popd +fi diff --git a/gapic-libraries-bom/pom.xml b/gapic-libraries-bom/pom.xml index e7b3efd5a591..0eaac79fc531 100644 --- a/gapic-libraries-bom/pom.xml +++ b/gapic-libraries-bom/pom.xml @@ -497,6 +497,13 @@ pom import + + com.google.cloud + google-cloud-datastore-bom + 2.33.2 + pom + import + com.google.cloud google-cloud-datastream-bom diff --git a/generation/check_non_release_please_versions.sh b/generation/check_non_release_please_versions.sh index bb7e2f0e88e0..0a0e32c22874 100755 --- a/generation/check_non_release_please_versions.sh +++ b/generation/check_non_release_please_versions.sh @@ -19,6 +19,10 @@ for pomFile in $(find . -mindepth 2 -name pom.xml | sort ); do echo "Skipping version check for java-samples directory" continue fi + if [[ "${pomFile}" =~ .*/samples/.* ]]; then + echo "Skipping version check for samples directory" + continue + fi if grep -n '.*' "$pomFile" | grep -v 'x-version-update'; then echo "Found version declaration(s) without x-version-update in: $pomFile" diff --git a/generation_config.yaml b/generation_config.yaml index 76a9c95606a8..5fc94c0c14de 100644 --- a/generation_config.yaml +++ b/generation_config.yaml @@ -1,10 +1,6 @@ gapic_generator_version: 2.65.1 googleapis_commitish: 415914bd49d41beaae8a9adb348ee2587c93aa70 libraries_bom_version: 26.73.0 - -# the libraries are ordered with respect to library name, which is -# java-{library.library_name} or java-{library.api-shortname} when -# library.library_name is not defined. libraries: - api_shortname: accessapproval name_pretty: Access Approval @@ -14,7 +10,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/accessapproval/v1 - - api_shortname: accesscontextmanager name_pretty: Identity Access Context Manager product_documentation: n/a @@ -24,7 +19,6 @@ libraries: GAPICs: - proto_path: google/identity/accesscontextmanager/v1 - proto_path: google/identity/accesscontextmanager/type - - api_shortname: admanager name_pretty: Google Ad Manager API product_documentation: https://developers.google.com/ad-manager/api/beta @@ -40,7 +34,6 @@ libraries: GAPICs: - proto_path: google/ads/admanager/v1 requires_billing: true - - api_shortname: advisorynotifications name_pretty: Advisory Notifications API product_documentation: https://cloud.google.com/advisory-notifications/ @@ -48,7 +41,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/advisorynotifications/v1 - - api_shortname: aiplatform name_pretty: Vertex AI product_documentation: https://cloud.google.com/vertex-ai/docs @@ -61,7 +53,6 @@ libraries: GAPICs: - proto_path: google/cloud/aiplatform/v1 - proto_path: google/cloud/aiplatform/v1beta1 - - api_shortname: alloydb name_pretty: AlloyDB product_documentation: https://cloud.google.com/alloydb/ @@ -73,7 +64,6 @@ libraries: - proto_path: google/cloud/alloydb/v1 - proto_path: google/cloud/alloydb/v1alpha - proto_path: google/cloud/alloydb/v1beta - - api_shortname: alloydb name_pretty: AlloyDB connectors product_documentation: https://cloud.google.com/alloydb/docs @@ -88,7 +78,6 @@ libraries: - proto_path: google/cloud/alloydb/connectors/v1 - proto_path: google/cloud/alloydb/connectors/v1alpha - proto_path: google/cloud/alloydb/connectors/v1beta - - api_shortname: analyticsadmin name_pretty: Analytics Admin product_documentation: https://developers.google.com/analytics @@ -100,7 +89,6 @@ libraries: GAPICs: - proto_path: google/analytics/admin/v1alpha - proto_path: google/analytics/admin/v1beta - - api_shortname: analyticsdata name_pretty: Analytics Data product_documentation: https://developers.google.com/analytics/trusted-testing/analytics-data @@ -114,7 +102,6 @@ libraries: GAPICs: - proto_path: google/analytics/data/v1alpha - proto_path: google/analytics/data/v1beta - - api_shortname: analyticshub name_pretty: Analytics Hub API product_documentation: https://cloud.google.com/bigquery/TBD @@ -122,7 +109,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/bigquery/analyticshub/v1 - - api_shortname: apigateway name_pretty: API Gateway product_documentation: https://cloud.google.com/api-gateway/docs @@ -137,7 +123,6 @@ libraries: rest_documentation: https://cloud.google.com/api-gateway/docs/reference/rest GAPICs: - proto_path: google/cloud/apigateway/v1 - - api_shortname: apigeeconnect name_pretty: Apigee Connect product_documentation: https://cloud.google.com/apigee/docs/hybrid/v1.3/apigee-connect/ @@ -148,7 +133,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/apigeeconnect/v1 - - api_shortname: apigee-registry name_pretty: Registry API product_documentation: https://cloud.google.com/apigee/docs/api-hub/get-started-registry-api @@ -157,7 +141,6 @@ libraries: api_id: apigeeregistry.googleapis.com GAPICs: - proto_path: google/cloud/apigeeregistry/v1 - - api_shortname: apihub name_pretty: API hub API product_documentation: https://cloud.google.com/apigee/docs/apihub/what-is-api-hub @@ -183,7 +166,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/api/apikeys/v2 - - api_shortname: appengine name_pretty: App Engine Admin API product_documentation: https://cloud.google.com/appengine/docs/admin-api/ @@ -193,7 +175,6 @@ libraries: codeowner_team: '@googleapis/aap-dpes' GAPICs: - proto_path: google/appengine/v1 - - api_shortname: apphub name_pretty: App Hub API product_documentation: https://cloud.google.com/app-hub/docs/overview @@ -202,7 +183,6 @@ libraries: rpc_documentation: https://cloud.google.com/app-hub/docs/reference/rpc GAPICs: - proto_path: google/cloud/apphub/v1 - - api_shortname: area120tables name_pretty: Area 120 Tables product_documentation: https://area120.google.com/ @@ -212,7 +192,6 @@ libraries: distribution_name: com.google.area120:google-area120-tables GAPICs: - proto_path: google/area120/tables/v1alpha1 - - api_shortname: artifactregistry name_pretty: Artifact Registry product_documentation: https://cloud.google.com/artifact-registry @@ -229,7 +208,6 @@ libraries: GAPICs: - proto_path: google/devtools/artifactregistry/v1 - proto_path: google/devtools/artifactregistry/v1beta2 - - api_shortname: cloudasset name_pretty: Cloud Asset Inventory product_documentation: https://cloud.google.com/resource-manager/docs/cloud-asset-inventory/overview @@ -247,7 +225,6 @@ libraries: - proto_path: google/cloud/asset/v1p2beta1 - proto_path: google/cloud/asset/v1p5beta1 - proto_path: google/cloud/asset/v1p7beta1 - - api_shortname: assuredworkloads name_pretty: Assured Workloads for Government product_documentation: https://cloud.google.com/assured-workloads/ @@ -260,7 +237,6 @@ libraries: GAPICs: - proto_path: google/cloud/assuredworkloads/v1 - proto_path: google/cloud/assuredworkloads/v1beta1 - - api_shortname: automl name_pretty: Cloud Auto ML product_documentation: https://cloud.google.com/automl/docs/ @@ -276,14 +252,12 @@ libraries: GAPICs: - proto_path: google/cloud/automl/v1 - proto_path: google/cloud/automl/v1beta1 - - api_shortname: backupdr name_pretty: Backup and DR Service API product_documentation: https://cloud.google.com/backup-disaster-recovery/docs/concepts/backup-dr api_description: 'Backup and DR Service is a powerful, centralized, cloud-first backup and disaster recovery solution for cloud-based and hybrid workloads. ' - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-backupdr/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-backupdr/latest/overview release_level: stable distribution_name: com.google.cloud:google-cloud-backupdr api_id: backupdr.googleapis.com @@ -303,7 +277,6 @@ libraries: rpc_documentation: https://cloud.google.com/bare-metal/docs/reference/rpc GAPICs: - proto_path: google/cloud/baremetalsolution/v2 - - api_shortname: batch name_pretty: Cloud Batch product_documentation: https://cloud.google.com/ @@ -311,7 +284,6 @@ libraries: GAPICs: - proto_path: google/cloud/batch/v1 - proto_path: google/cloud/batch/v1alpha - - api_shortname: beyondcorp-appconnections name_pretty: BeyondCorp AppConnections product_documentation: https://cloud.google.com/beyondcorp-enterprise/ @@ -322,7 +294,6 @@ libraries: need for a traditional VPN. GAPICs: - proto_path: google/cloud/beyondcorp/appconnections/v1 - - api_shortname: beyondcorp-appconnectors name_pretty: BeyondCorp AppConnectors product_documentation: cloud.google.com/beyondcorp-enterprise/ @@ -330,7 +301,6 @@ libraries: AppConnectors. GAPICs: - proto_path: google/cloud/beyondcorp/appconnectors/v1 - - api_shortname: beyondcorp-appgateways name_pretty: BeyondCorp AppGateways product_documentation: https://cloud.google.com/beyondcorp-enterprise/ @@ -339,7 +309,6 @@ libraries: api_id: beyondcorp.googleapis.com GAPICs: - proto_path: google/cloud/beyondcorp/appgateways/v1 - - api_shortname: beyondcorp-clientconnectorservices name_pretty: BeyondCorp ClientConnectorServices product_documentation: https://cloud.google.com/beyondcorp-enterprise/ @@ -348,7 +317,6 @@ libraries: api_id: beyondcorp.googleapis.com GAPICs: - proto_path: google/cloud/beyondcorp/clientconnectorservices/v1 - - api_shortname: beyondcorp-clientgateways name_pretty: BeyondCorp ClientGateways product_documentation: https://cloud.google.com/beyondcorp-enterprise/ @@ -357,7 +325,6 @@ libraries: api_id: beyondcorp.googleapis.com GAPICs: - proto_path: google/cloud/beyondcorp/clientgateways/v1 - - api_shortname: biglake name_pretty: BigLake product_documentation: https://cloud.google.com/biglake @@ -368,7 +335,6 @@ libraries: - proto_path: google/cloud/bigquery/biglake/v1 - proto_path: google/cloud/biglake/v1 - proto_path: google/cloud/bigquery/biglake/v1alpha1 - - api_shortname: analyticshub name_pretty: Analytics Hub product_documentation: https://cloud.google.com/analytics-hub @@ -378,18 +344,15 @@ libraries: library_name: bigquery-data-exchange GAPICs: - proto_path: google/cloud/bigquery/dataexchange/v1beta1 - - api_shortname: bigqueryconnection name_pretty: Cloud BigQuery Connection product_documentation: https://cloud.google.com/bigquery/docs/reference/bigqueryconnection/rest api_description: allows users to manage BigQuery connections to external data sources. release_level: stable - client_documentation: - https://cloud.google.com/bigquery/docs/reference/reservations/rpc/google.cloud.bigquery.reservation.v1beta1 + client_documentation: https://cloud.google.com/bigquery/docs/reference/reservations/rpc/google.cloud.bigquery.reservation.v1beta1 GAPICs: - proto_path: google/cloud/bigquery/connection/v1 - proto_path: google/cloud/bigquery/connection/v1beta1 - - api_shortname: bigquerydatapolicy name_pretty: BigQuery DataPolicy API product_documentation: https://cloud.google.com/bigquery/docs/reference/datapolicy/ @@ -399,7 +362,6 @@ libraries: - proto_path: google/cloud/bigquery/datapolicies/v1beta1 - proto_path: google/cloud/bigquery/datapolicies/v2beta1 - proto_path: google/cloud/bigquery/datapolicies/v2 - - api_shortname: bigquerydatatransfer name_pretty: BigQuery Data Transfer Service product_documentation: https://cloud.google.com/bigquery/transfer/ @@ -409,7 +371,6 @@ libraries: issue_tracker: https://issuetracker.google.com/savedsearches/559654 GAPICs: - proto_path: google/cloud/bigquery/datatransfer/v1 - - api_shortname: bigquerymigration name_pretty: BigQuery Migration product_documentation: https://cloud.google.com/bigquery/docs @@ -418,7 +379,6 @@ libraries: GAPICs: - proto_path: google/cloud/bigquery/migration/v2 - proto_path: google/cloud/bigquery/migration/v2alpha - - api_shortname: bigqueryreservation name_pretty: Cloud BigQuery Reservation product_documentation: https://cloud.google.com/bigquery/docs/reference/reservations/rpc @@ -426,7 +386,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/bigquery/reservation/v1 - - api_shortname: cloudbilling name_pretty: Cloud Billing product_documentation: https://cloud.google.com/billing/docs @@ -439,7 +398,6 @@ libraries: rpc_documentation: https://cloud.google.com/billing/docs/reference/rpc GAPICs: - proto_path: google/cloud/billing/v1 - - api_shortname: billingbudgets name_pretty: Cloud Billing Budgets product_documentation: https://cloud.google.com/billing/docs/how-to/budgets @@ -449,7 +407,6 @@ libraries: GAPICs: - proto_path: google/cloud/billing/budgets/v1 - proto_path: google/cloud/billing/budgets/v1beta1 - - api_shortname: binaryauthorization name_pretty: Binary Authorization product_documentation: https://cloud.google.com/binary-authorization/docs @@ -465,13 +422,11 @@ libraries: GAPICs: - proto_path: google/cloud/binaryauthorization/v1 - proto_path: google/cloud/binaryauthorization/v1beta1 - - api_shortname: capacityplanner name_pretty: Capacity Planner API product_documentation: https://cloud.google.com/capacity-planner/docs api_description: Provides programmatic access to Capacity Planner features. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-capacityplanner/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-capacityplanner/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-capacityplanner api_id: capacityplanner.googleapis.com @@ -490,7 +445,6 @@ libraries: api_id: certificatemanager.googleapis.com GAPICs: - proto_path: google/cloud/certificatemanager/v1 - - api_shortname: cloudchannel name_pretty: Channel Services product_documentation: https://cloud.google.com/channel/docs @@ -504,7 +458,6 @@ libraries: rpc_documentation: https://cloud.google.com/channel/docs/reference/rpc GAPICs: - proto_path: google/cloud/channel/v1 - - api_shortname: chat name_pretty: Google Chat API product_documentation: https://developers.google.com/chat/concepts @@ -514,15 +467,13 @@ libraries: rest_documentation: https://developers.google.com/chat/api/reference/rest GAPICs: - proto_path: google/chat/v1 - - api_shortname: chronicle name_pretty: Chronicle API product_documentation: https://cloud.google.com/chronicle/docs/secops/secops-overview api_description: The Google Cloud Security Operations API, popularly known as the Chronicle API, serves endpoints that enable security analysts to analyze and mitigate a security threat throughout its lifecycle - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-chronicle/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-chronicle/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-chronicle api_id: chronicle.googleapis.com @@ -538,8 +489,7 @@ libraries: api_description: Cloud API Registry lets you discover, govern, use, and monitor Model Context Protocol (MCP) servers and tools provided by Google, or by your organization through Apigee API hub. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-cloudapiregistry/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-cloudapiregistry/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-cloudapiregistry api_id: cloudapiregistry.googleapis.com @@ -562,7 +512,6 @@ libraries: GAPICs: - proto_path: google/devtools/cloudbuild/v1 - proto_path: google/devtools/cloudbuild/v2 - - api_shortname: cloudcommerceconsumerprocurement name_pretty: Cloud Commerce Consumer Procurement product_documentation: https://cloud.google.com/marketplace/ @@ -573,7 +522,6 @@ libraries: GAPICs: - proto_path: google/cloud/commerce/consumer/procurement/v1 - proto_path: google/cloud/commerce/consumer/procurement/v1alpha1 - - api_shortname: cloudcontrolspartner name_pretty: Cloud Controls Partner API product_documentation: https://cloud.google.com/sovereign-controls-by-partners/docs/sovereign-partners @@ -583,27 +531,23 @@ libraries: GAPICs: - proto_path: google/cloud/cloudcontrolspartner/v1 - proto_path: google/cloud/cloudcontrolspartner/v1beta - - api_shortname: cloudquotas name_pretty: Cloud Quotas API product_documentation: https://cloud.google.com/cloudquotas/docs/ - api_description: "Cloud Quotas API provides GCP service consumers with management - and\n observability for resource usage, quotas, and restrictions of the services\n\ + api_description: "Cloud Quotas API provides GCP service consumers with management\ + \ and\n observability for resource usage, quotas, and restrictions of the services\n\ \ they consume." release_level: stable GAPICs: - proto_path: google/api/cloudquotas/v1 - proto_path: google/api/cloudquotas/v1beta - - api_shortname: cloudsecuritycompliance name_pretty: Cloud Security Compliance API - product_documentation: - https://cloud.google.com/security-command-center/docs/compliance-manager-overview + product_documentation: https://cloud.google.com/security-command-center/docs/compliance-manager-overview api_description: Compliance Manager uses software-defined controls that let you assess support for multiple compliance programs and security requirements within a Google Cloud organization - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-cloudsecuritycompliance/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-cloudsecuritycompliance/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-cloudsecuritycompliance api_id: cloudsecuritycompliance.googleapis.com @@ -621,21 +565,19 @@ libraries: GAPICs: - proto_path: google/cloud/support/v2 - proto_path: google/cloud/support/v2beta - - api_shortname: compute name_pretty: Compute Engine product_documentation: https://cloud.google.com/compute/ - api_description: "delivers virtual machines running in Google's innovative data - centers and worldwide fiber network. Compute Engine's tooling and workflow support + api_description: 'delivers virtual machines running in Google''s innovative data + centers and worldwide fiber network. Compute Engine''s tooling and workflow support enable scaling from single instances to global, load-balanced cloud computing. - Compute Engine's VMs boot quickly, come with persistent disk storage, deliver - consistent performance and are available in many configurations. " + Compute Engine''s VMs boot quickly, come with persistent disk storage, deliver + consistent performance and are available in many configurations. ' release_level: stable excluded_poms: grpc-google-cloud-compute-v1 excluded_dependencies: grpc-google-cloud-compute-v1 GAPICs: - proto_path: google/cloud/compute/v1 - - api_shortname: confidentialcomputing name_pretty: Confidential Computing API product_documentation: https://cloud.google.com/confidential-computing/ @@ -644,15 +586,12 @@ libraries: GAPICs: - proto_path: google/cloud/confidentialcomputing/v1 - proto_path: google/cloud/confidentialcomputing/v1alpha1 - - api_shortname: configdelivery name_pretty: Config Delivery API - product_documentation: - https://cloud.google.com/kubernetes-engine/enterprise/config-sync/docs/concepts/fleet-packages + product_documentation: https://cloud.google.com/kubernetes-engine/enterprise/config-sync/docs/concepts/fleet-packages api_description: ConfigDelivery service manages the deployment of kubernetes configuration to a fleet of kubernetes clusters. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-configdelivery/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-configdelivery/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-configdelivery api_id: configdelivery.googleapis.com @@ -660,19 +599,16 @@ libraries: group_id: com.google.cloud cloud_api: true requires_billing: true - rest_documentation: - https://cloud.google.com/kubernetes-engine/enterprise/config-sync/docs/reference/rest + rest_documentation: https://cloud.google.com/kubernetes-engine/enterprise/config-sync/docs/reference/rest GAPICs: - proto_path: google/cloud/configdelivery/v1beta - proto_path: google/cloud/configdelivery/v1 - api_shortname: connectgateway name_pretty: Connect Gateway API - product_documentation: - https://cloud.google.com/kubernetes-engine/enterprise/multicluster-management/gateway + product_documentation: https://cloud.google.com/kubernetes-engine/enterprise/multicluster-management/gateway api_description: The Connect Gateway service allows connectivity from external parties to connected Kubernetes clusters. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-connectgateway/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-connectgateway/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-connectgateway api_id: connectgateway.googleapis.com @@ -692,7 +628,6 @@ libraries: codeowner_team: '@googleapis/api-contact-center-insights' GAPICs: - proto_path: google/cloud/contactcenterinsights/v1 - - api_shortname: container name_pretty: Kubernetes Engine product_documentation: https://cloud.google.com/kubernetes-engine/ @@ -708,7 +643,6 @@ libraries: GAPICs: - proto_path: google/container/v1 - proto_path: google/container/v1beta1 - - api_shortname: containeranalysis name_pretty: Cloud Container Analysis product_documentation: https://cloud.google.com/container-registry/docs/container-analysis @@ -724,7 +658,6 @@ libraries: GAPICs: - proto_path: google/devtools/containeranalysis/v1 - proto_path: google/devtools/containeranalysis/v1beta1 - - api_shortname: contentwarehouse name_pretty: Document AI Warehouse product_documentation: https://cloud.google.com/document-warehouse/docs/overview @@ -733,7 +666,6 @@ libraries: metadata. GAPICs: - proto_path: google/cloud/contentwarehouse/v1 - - api_shortname: datafusion name_pretty: Cloud Data Fusion product_documentation: https://cloud.google.com/data-fusion/docs @@ -745,19 +677,17 @@ libraries: GAPICs: - proto_path: google/cloud/datafusion/v1 - proto_path: google/cloud/datafusion/v1beta1 - - api_shortname: databasecenter name_pretty: Database Center API product_documentation: https://cloud.google.com/database-center/docs/overview - api_description: Database Center provides an organization-wide, cross-product fleet - health platform to eliminate the overhead, complexity, and risk associated with - aggregating and summarizing health signals through custom dashboards. Through - Database Center’s fleet health dashboard and API, database platform teams that - are responsible for reliability, compliance, security, cost, and administration - of database fleets will now have a single pane of glass that pinpoints issues - relevant to each team. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-databasecenter/latest/overview + api_description: "Database Center provides an organization-wide, cross-product fleet\ + \ health platform to eliminate the overhead, complexity, and risk associated with\ + \ aggregating and summarizing health signals through custom dashboards. Through\ + \ Database Center\u2019s fleet health dashboard and API, database platform teams\ + \ that are responsible for reliability, compliance, security, cost, and administration\ + \ of database fleets will now have a single pane of glass that pinpoints issues\ + \ relevant to each team." + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-databasecenter/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-databasecenter api_id: databasecenter.googleapis.com @@ -777,7 +707,6 @@ libraries: GAPICs: - proto_path: google/cloud/datacatalog/v1 - proto_path: google/cloud/datacatalog/v1beta1 - - api_shortname: dataflow name_pretty: Dataflow product_documentation: https://cloud.google.com/dataflow/docs @@ -787,7 +716,6 @@ libraries: rpc_documentation: https://cloud.google.com/dataflow/docs/reference/rpc GAPICs: - proto_path: google/dataflow/v1beta3 - - api_shortname: dataform name_pretty: Cloud Dataform product_documentation: https://cloud.google.com/dataform/docs @@ -795,7 +723,6 @@ libraries: GAPICs: - proto_path: google/cloud/dataform/v1beta1 - proto_path: google/cloud/dataform/v1 - - api_shortname: datalabeling name_pretty: Data Labeling product_documentation: https://cloud.google.com/ai-platform/data-labeling/docs/ @@ -807,7 +734,6 @@ libraries: rpc_documentation: https://cloud.google.com/ai-platform/data-labeling/docs/reference/rpc GAPICs: - proto_path: google/cloud/datalabeling/v1beta1 - - api_shortname: datalineage name_pretty: Data Lineage product_documentation: https://cloud.google.com/data-catalog/docs/data-lineage/ @@ -815,7 +741,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/datacatalog/lineage/v1 - - api_shortname: datamanager name_pretty: Data Manager API product_documentation: https://developers.google.com/data-manager @@ -845,7 +770,6 @@ libraries: rpc_documentation: https://cloud.google.com/dataplex/docs/reference/rpc GAPICs: - proto_path: google/cloud/dataplex/v1 - - api_shortname: dataproc name_pretty: Dataproc product_documentation: https://cloud.google.com/dataproc @@ -858,7 +782,6 @@ libraries: rpc_documentation: https://cloud.google.com/dataproc/docs/reference/rpc GAPICs: - proto_path: google/cloud/dataproc/v1 - - api_shortname: metastore name_pretty: Dataproc Metastore product_documentation: https://cloud.google.com/dataproc-metastore/docs @@ -874,7 +797,29 @@ libraries: - proto_path: google/cloud/metastore/v1 - proto_path: google/cloud/metastore/v1alpha - proto_path: google/cloud/metastore/v1beta - +- api_shortname: datastore + name_pretty: Cloud Datastore + product_documentation: https://cloud.google.com/datastore + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-datastore/latest/history + issue_tracker: https://issuetracker.google.com/savedsearches/559768 + release_level: stable + language: java + distribution_name: com.google.cloud:google-cloud-datastore + codeowner_team: '@googleapis/cloud-native-db-dpes @googleapis/api-datastore-sdk + @googleapis/api-firestore-partners' + api_id: datastore.googleapis.com + library_type: GAPIC_COMBO + api_description: is a fully managed, schemaless database for\nstoring non-relational + data. Cloud Datastore automatically scales with\nyour users and supports ACID + transactions, high availability of reads and\nwrites, strong consistency for reads + and ancestor queries, and eventual\nconsistency for all other queries. + excluded_dependencies: grpc-google-cloud-datastore-v1 + extra_versioned_modules: datastore-v1-proto-client + excluded_poms: grpc-google-cloud-datastore-v1 + recommended_package: com.google.cloud.datastore + GAPICs: + - proto_path: google/datastore/v1 + - proto_path: google/datastore/admin/v1 - api_shortname: datastream name_pretty: Datastream product_documentation: https://cloud.google.com/datastream/docs @@ -886,7 +831,6 @@ libraries: GAPICs: - proto_path: google/cloud/datastream/v1 - proto_path: google/cloud/datastream/v1alpha1 - - api_shortname: clouddeploy name_pretty: Google Cloud Deploy product_documentation: https://cloud.google.com/deploy/docs @@ -897,13 +841,11 @@ libraries: codeowner_team: '@googleapis/aap-dpes' GAPICs: - proto_path: google/cloud/deploy/v1 - - api_shortname: developerconnect name_pretty: Developer Connect API product_documentation: https://cloud.google.com/developer-connect/docs/overview api_description: Connect third-party source code management to Google - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-developerconnect/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-developerconnect/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-developerconnect api_id: developerconnect.googleapis.com @@ -917,8 +859,7 @@ libraries: name_pretty: Device Streaming API product_documentation: https://cloud.google.com/device-streaming/docs api_description: The Cloud API for device streaming usage. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-devicestreaming/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-devicestreaming api_id: devicestreaming.googleapis.com @@ -943,7 +884,6 @@ libraries: GAPICs: - proto_path: google/cloud/dialogflow/v2 - proto_path: google/cloud/dialogflow/v2beta1 - - api_shortname: dialogflow-cx name_pretty: Dialogflow CX product_documentation: https://cloud.google.com/dialogflow/cx/docs @@ -955,7 +895,6 @@ libraries: GAPICs: - proto_path: google/cloud/dialogflow/cx/v3 - proto_path: google/cloud/dialogflow/cx/v3beta1 - - api_shortname: discoveryengine name_pretty: Discovery Engine API product_documentation: https://cloud.google.com/discovery-engine/media/docs @@ -966,7 +905,6 @@ libraries: - proto_path: google/cloud/discoveryengine/v1 - proto_path: google/cloud/discoveryengine/v1alpha - proto_path: google/cloud/discoveryengine/v1beta - - api_shortname: distributedcloudedge name_pretty: Google Distributed Cloud Edge product_documentation: https://cloud.google.com/distributed-cloud/edge/latest/ @@ -978,7 +916,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/edgecontainer/v1 - - api_shortname: dlp name_pretty: Cloud Data Loss Prevention product_documentation: https://cloud.google.com/dlp/docs/ @@ -991,7 +928,6 @@ libraries: rpc_documentation: https://cloud.google.com/dlp/docs/reference/rpc GAPICs: - proto_path: google/privacy/dlp/v2 - - api_shortname: datamigration name_pretty: Database Migration Service product_documentation: https://cloud.google.com/database-migration/docs @@ -1004,7 +940,6 @@ libraries: rest_documentation: https://cloud.google.com/database-migration/docs/reference/rest GAPICs: - proto_path: google/cloud/clouddms/v1 - - api_shortname: documentai name_pretty: Document AI product_documentation: https://cloud.google.com/compute/docs/documentai/ @@ -1016,7 +951,6 @@ libraries: GAPICs: - proto_path: google/cloud/documentai/v1 - proto_path: google/cloud/documentai/v1beta3 - - api_shortname: domains name_pretty: Cloud Domains product_documentation: https://cloud.google.com/domains @@ -1026,7 +960,6 @@ libraries: - proto_path: google/cloud/domains/v1 - proto_path: google/cloud/domains/v1alpha2 - proto_path: google/cloud/domains/v1beta1 - - api_shortname: edgenetwork name_pretty: Distributed Cloud Edge Network API product_documentation: https://cloud.google.com/distributed-cloud/edge/latest/docs/overview @@ -1034,7 +967,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/edgenetwork/v1 - - api_shortname: enterpriseknowledgegraph name_pretty: Enterprise Knowledge Graph product_documentation: https://cloud.google.com/enterprise-knowledge-graph/docs/overview @@ -1043,7 +975,6 @@ libraries: an efficient and useful way. GAPICs: - proto_path: google/cloud/enterpriseknowledgegraph/v1 - - api_shortname: clouderrorreporting name_pretty: Error Reporting product_documentation: https://cloud.google.com/error-reporting @@ -1058,7 +989,6 @@ libraries: requires_billing: false GAPICs: - proto_path: google/devtools/clouderrorreporting/v1beta1 - - api_shortname: essentialcontacts name_pretty: Essential Contacts API product_documentation: https://cloud.google.com/resource-manager/docs/managing-notification-contacts/ @@ -1068,7 +998,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/essentialcontacts/v1 - - api_shortname: eventarc name_pretty: Eventarc product_documentation: https://cloud.google.com/eventarc/docs @@ -1082,7 +1011,6 @@ libraries: rpc_documentation: https://cloud.google.com/eventarc/docs/reference/rpc GAPICs: - proto_path: google/cloud/eventarc/v1 - - api_shortname: eventarcpublishing name_pretty: Eventarc Publishing product_documentation: https://cloud.google.com/eventarc/docs @@ -1094,7 +1022,6 @@ libraries: rpc_documentation: https://cloud.google.com/eventarc/docs/reference/rpc GAPICs: - proto_path: google/cloud/eventarc/publishing/v1 - - api_shortname: file name_pretty: Cloud Filestore API product_documentation: https://cloud.google.com/filestore/docs @@ -1107,16 +1034,13 @@ libraries: GAPICs: - proto_path: google/cloud/filestore/v1 - proto_path: google/cloud/filestore/v1beta1 - - api_shortname: financialservices name_pretty: Financial Services API - product_documentation: - https://cloud.google.com/financial-services/anti-money-laundering/docs/concepts/overview + product_documentation: https://cloud.google.com/financial-services/anti-money-laundering/docs/concepts/overview api_description: Google Cloud's Anti Money Laundering AI (AML AI) product is an API that scores AML risk. Use it to identify more risk, more defensibly, with fewer false positives and reduced time per review. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-financialservices/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-financialservices/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-financialservices api_id: financialservices.googleapis.com @@ -1141,15 +1065,13 @@ libraries: - proto_path: google/cloud/functions/v2 - proto_path: google/cloud/functions/v2alpha - proto_path: google/cloud/functions/v2beta - - api_shortname: gdchardwaremanagement name_pretty: GDC Hardware Management API product_documentation: https://cloud.google.com/distributed-cloud/edge/latest/docs api_description: Google Distributed Cloud connected allows you to run Kubernetes clusters on dedicated hardware provided and maintained by Google that is separate from the Google Cloud data center. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-gdchardwaremanagement/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-gdchardwaremanagement/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-gdchardwaremanagement api_id: gdchardwaremanagement.googleapis.com @@ -1159,16 +1081,14 @@ libraries: GAPICs: - proto_path: google/cloud/gdchardwaremanagement/v1alpha requires_billing: true - rpc_documentation: - https://cloud.google.com/distributed-cloud/edge/latest/docs/reference/hardware/rpc + rpc_documentation: https://cloud.google.com/distributed-cloud/edge/latest/docs/reference/hardware/rpc - api_shortname: geminidataanalytics name_pretty: Data Analytics API with Gemini product_documentation: https://cloud.google.com/gemini/docs/conversational-analytics-api/overview api_description: Use Conversational Analytics API to build an artificial intelligence (AI)-powered chat interface, or data agent, that answers questions about structured data using natural language. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-geminidataanalytics/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-geminidataanalytics/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-geminidataanalytics api_id: geminidataanalytics.googleapis.com @@ -1187,7 +1107,6 @@ libraries: library_name: gke-backup GAPICs: - proto_path: google/cloud/gkebackup/v1 - - api_shortname: connectgateway name_pretty: Connect Gateway API product_documentation: https://cloud.google.com/anthos/multicluster-management/gateway/ @@ -1199,7 +1118,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/gkeconnect/gateway/v1beta1 - - api_shortname: gke-multi-cloud name_pretty: Anthos Multicloud product_documentation: https://cloud.google.com/anthos/clusters/docs/multi-cloud @@ -1208,7 +1126,6 @@ libraries: api_id: gkemulticloud.googleapis.com GAPICs: - proto_path: google/cloud/gkemulticloud/v1 - - api_shortname: gkehub name_pretty: GKE Hub API product_documentation: https://cloud.google.com/anthos/gke/docs/ @@ -1225,16 +1142,13 @@ libraries: - proto_path: google/cloud/gkehub/v1beta1 - proto_path: google/cloud/gkehub/policycontroller/v1beta - proto_path: google/cloud/gkehub/servicemesh/v1beta - - api_shortname: gkerecommender name_pretty: GKE Recommender API - product_documentation: - https://cloud.google.com/kubernetes-engine/docs/how-to/machine-learning/inference-quickstart + product_documentation: https://cloud.google.com/kubernetes-engine/docs/how-to/machine-learning/inference-quickstart api_description: lets you analyze the performance and cost-efficiency of your inference workloads, and make data-driven decisions about resource allocation and model deployment strategies. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-gkerecommender/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-gkerecommender/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-gkerecommender api_id: gkerecommender.googleapis.com @@ -1255,7 +1169,6 @@ libraries: library_name: grafeas GAPICs: - proto_path: grafeas/v1 - - api_shortname: gsuiteaddons name_pretty: Google Workspace Add-ons API product_documentation: https://developers.google.com/workspace/add-ons/overview @@ -1271,14 +1184,11 @@ libraries: - proto_path: google/apps/script/type/gmail - proto_path: google/apps/script/type/sheets - proto_path: google/apps/script/type/slides - - api_shortname: hypercomputecluster name_pretty: Cluster Director API - product_documentation: - https://cloud.google.com/blog/products/compute/managed-slurm-and-other-cluster-director-enhancements + product_documentation: https://cloud.google.com/blog/products/compute/managed-slurm-and-other-cluster-director-enhancements api_description: simplifies cluster management across compute, network, and storage - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-hypercomputecluster/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-hypercomputecluster/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-hypercomputecluster api_id: hypercomputecluster.googleapis.com @@ -1304,7 +1214,6 @@ libraries: - proto_path: google/iam/v2beta - proto_path: google/iam/v3 - proto_path: google/iam/v3beta - - api_shortname: iam-admin name_pretty: IAM Admin API product_documentation: https://cloud.google.com/iam/docs/apis @@ -1314,7 +1223,6 @@ libraries: api_id: iam.googleapis.com GAPICs: - proto_path: google/iam/admin/v1 - - api_shortname: iamcredentials name_pretty: IAM Service Account Credentials API product_documentation: https://cloud.google.com/iam/credentials/reference/rest/ @@ -1325,7 +1233,6 @@ libraries: issue_tracker: https://issuetracker.google.com/issues/new?component=187161&template=0 GAPICs: - proto_path: google/iam/credentials/v1 - - api_shortname: iap name_pretty: Cloud Identity-Aware Proxy API product_documentation: https://cloud.google.com/iap @@ -1348,7 +1255,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/ids/v1 - - api_shortname: infra-manager name_pretty: Infrastructure Manager API product_documentation: https://cloud.google.com/infrastructure-manager/docs/overview @@ -1357,7 +1263,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/config/v1 - - api_shortname: cloudiot name_pretty: Cloud Internet of Things (IoT) Core product_documentation: https://cloud.google.com/iot @@ -1374,8 +1279,7 @@ libraries: name_pretty: Merchant Issue Resolution API product_documentation: https://developers.google.com/merchant/api api_description: Programatically manage your Merchant Issues - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-issue-resolution/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-issue-resolution/latest/overview release_level: stable distribution_name: com.google.shopping:google-shopping-merchant-issue-resolution api_id: merchantapi.googleapis.com @@ -1387,13 +1291,11 @@ libraries: - proto_path: google/shopping/merchant/issueresolution/v1beta library_name: java-shopping-merchant-issue-resolution requires_billing: true - - api_shortname: merchantapi name_pretty: Merchant Order Tracking API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your Merchant Center Accounts - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-order-tracking/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-order-tracking/latest/overview release_level: stable distribution_name: com.google.shopping:google-shopping-merchant-order-tracking api_id: merchantapi.googleapis.com @@ -1405,7 +1307,6 @@ libraries: - proto_path: google/shopping/merchant/ordertracking/v1beta library_name: java-shopping-merchant-order-tracking requires_billing: true - - api_shortname: cloudkms name_pretty: Cloud Key Management Service product_documentation: https://cloud.google.com/kms @@ -1421,7 +1322,6 @@ libraries: issue_tracker: https://issuetracker.google.com/savedsearches/5264932 GAPICs: - proto_path: google/cloud/kms/v1 - - api_shortname: kmsinventory name_pretty: KMS Inventory API product_documentation: https://cloud.google.com/kms/docs/ @@ -1430,7 +1330,6 @@ libraries: rpc_documentation: https://cloud.google.com/kms/docs/reference/rpc GAPICs: - proto_path: google/cloud/kms/inventory/v1 - - api_shortname: language name_pretty: Natural Language product_documentation: https://cloud.google.com/natural-language/docs/ @@ -1446,14 +1345,12 @@ libraries: - proto_path: google/cloud/language/v1 - proto_path: google/cloud/language/v1beta2 - proto_path: google/cloud/language/v2 - - api_shortname: licensemanager name_pretty: License Manager API product_documentation: https://cloud.google.com/compute/docs/instances/windows/ms-licensing api_description: License Manager is a tool to manage and track third-party licenses on Google Cloud. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-licensemanager/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-licensemanager/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-licensemanager api_id: licensemanager.googleapis.com @@ -1473,15 +1370,13 @@ libraries: rpc_documentation: https://cloud.google.com/life-sciences/docs/reference/rpc GAPICs: - proto_path: google/cloud/lifesciences/v2beta - - api_shortname: locationfinder name_pretty: Cloud Location Finder API product_documentation: https://cloud.google.com/location-finder/docs/overview api_description: Cloud Location Finder is a public API that offers a repository of all Google Cloud and Google Distributed Cloud locations, as well as cloud locations for other cloud providers. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-locationfinder/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-locationfinder/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-locationfinder api_id: locationfinder.googleapis.com @@ -1512,8 +1407,7 @@ libraries: product_documentation: https://cloud.google.com/unified-maintenance/docs/overview api_description: The Maintenance API provides a centralized view of planned disruptive maintenance events across supported Google Cloud products. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-maintenance/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-maintenance/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-maintenance api_id: maintenance.googleapis.com @@ -1538,13 +1432,11 @@ libraries: GAPICs: - proto_path: google/cloud/managedidentities/v1 - proto_path: google/cloud/managedidentities/v1beta1 - - api_shortname: managedkafka name_pretty: Managed Service for Apache Kafka product_documentation: https://cloud.google.com/managed-kafka api_description: Manage Apache Kafka clusters and resources. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-managedkafka/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-managedkafka/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-managedkafka api_id: managedkafka.googleapis.com @@ -1566,13 +1458,11 @@ libraries: distribution_name: com.google.maps:google-maps-addressvalidation GAPICs: - proto_path: google/maps/addressvalidation/v1 - - api_shortname: maps-area-insights name_pretty: Places Insights API product_documentation: https://developers.google.com/maps/documentation/places-insights api_description: Places Insights API. - client_documentation: - https://cloud.google.com/java/docs/reference/google-maps-area-insights/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-maps-area-insights/latest/overview release_level: preview distribution_name: com.google.maps:google-maps-area-insights api_id: maps-area-insights.googleapis.com @@ -1584,14 +1474,12 @@ libraries: requires_billing: true - api_shortname: maps-fleetengine name_pretty: Local Rides and Deliveries API - product_documentation: - https://developers.google.com/maps/documentation/transportation-logistics/mobility + product_documentation: https://developers.google.com/maps/documentation/transportation-logistics/mobility api_description: Enables Fleet Engine for access to the On Demand Rides and Deliveries and Last Mile Fleet Solution APIs. Customer's use of Google Maps Content in the Cloud Logging Services is subject to the Google Maps Platform Terms of Service located at https://cloud.google.com/maps-platform/terms. - client_documentation: - https://cloud.google.com/java/docs/reference/google-maps-fleetengine/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-maps-fleetengine/latest/overview release_level: preview distribution_name: com.google.maps:google-maps-fleetengine api_id: maps-fleetengine.googleapis.com @@ -1603,14 +1491,12 @@ libraries: requires_billing: true - api_shortname: maps-fleetengine-delivery name_pretty: Last Mile Fleet Solution Delivery API - product_documentation: - https://developers.google.com/maps/documentation/transportation-logistics/mobility + product_documentation: https://developers.google.com/maps/documentation/transportation-logistics/mobility api_description: Enables Fleet Engine for access to the On Demand Rides and Deliveries and Last Mile Fleet Solution APIs. Customer's use of Google Maps Content in the Cloud Logging Services is subject to the Google Maps Platform Terms of Service located at https://cloud.google.com/maps-platform/terms. - client_documentation: - https://cloud.google.com/java/docs/reference/google-maps-fleetengine-delivery/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-maps-fleetengine-delivery/latest/overview release_level: preview distribution_name: com.google.maps:google-maps-fleetengine-delivery api_id: maps-fleetengine-delivery.googleapis.com @@ -1623,15 +1509,14 @@ libraries: - api_shortname: maps-mapsplatformdatasets name_pretty: Maps Platform Datasets API product_documentation: https://developers.google.com/maps/documentation - api_description: "The Maps Platform Datasets API enables developers to ingest geospatially-tied - datasets\n that they can use to enrich their experience of Maps Platform solutions - (e.g. styling, routing)." + api_description: "The Maps Platform Datasets API enables developers to ingest geospatially-tied\ + \ datasets\n that they can use to enrich their experience of Maps Platform\ + \ solutions (e.g. styling, routing)." api_id: mapsplatformdatasets.googleapis.com distribution_name: com.google.maps:google-maps-mapsplatformdatasets cloud_api: false GAPICs: - proto_path: google/maps/mapsplatformdatasets/v1 - - api_shortname: maps-places name_pretty: Places API (New) product_documentation: https://developers.google.com/maps/documentation/places/web-service/ @@ -1642,15 +1527,13 @@ libraries: cloud_api: false GAPICs: - proto_path: google/maps/places/v1 - - api_shortname: routeoptimization name_pretty: Route Optimization API product_documentation: https://developers.google.com/maps/documentation/route-optimization api_description: The Route Optimization API assigns tasks and routes to a vehicle fleet, optimizing against the objectives and constraints that you supply for your transportation goals. - client_documentation: - https://cloud.google.com/java/docs/reference/google-maps-routeoptimization/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-maps-routeoptimization/latest/overview release_level: preview distribution_name: com.google.maps:google-maps-routeoptimization api_id: routeoptimization.googleapis.com @@ -1661,10 +1544,8 @@ libraries: - proto_path: google/maps/routeoptimization/v1 library_name: maps-routeoptimization requires_billing: true - rest_documentation: - https://developers.google.com/maps/documentation/route-optimization/reference/rest/ - rpc_documentation: - https://developers.google.com/maps/documentation/route-optimization/reference/rpc + rest_documentation: https://developers.google.com/maps/documentation/route-optimization/reference/rest/ + rpc_documentation: https://developers.google.com/maps/documentation/route-optimization/reference/rpc - api_shortname: maps-routing name_pretty: Routes API product_documentation: https://developers.google.com/maps/documentation/routes @@ -1678,7 +1559,6 @@ libraries: cloud_api: false GAPICs: - proto_path: google/maps/routing/v2 - - api_shortname: maps-solar name_pretty: Solar API product_documentation: https://developers.google.com/maps/documentation/solar/overview @@ -1722,7 +1602,6 @@ libraries: requires_billing: false GAPICs: - proto_path: google/cloud/mediatranslation/v1beta1 - - api_shortname: meet name_pretty: Google Meet API product_documentation: https://developers.google.com/meet/api/guides/overview @@ -1731,7 +1610,6 @@ libraries: GAPICs: - proto_path: google/apps/meet/v2 - proto_path: google/apps/meet/v2beta - - api_shortname: memcache name_pretty: Cloud Memcache product_documentation: https://cloud.google.com/memorystore/ @@ -1741,7 +1619,6 @@ libraries: GAPICs: - proto_path: google/cloud/memcache/v1 - proto_path: google/cloud/memcache/v1beta2 - - api_shortname: migrationcenter name_pretty: Migration Center API product_documentation: https://cloud.google.com/migration-center/docs/migration-center-overview @@ -1750,15 +1627,13 @@ libraries: cloud environments to Google Cloud GAPICs: - proto_path: google/cloud/migrationcenter/v1 - - api_shortname: modelarmor name_pretty: Model Armor API product_documentation: https://cloud.google.com/security-command-center/docs/model-armor-overview api_description: Model Armor helps you protect against risks like prompt injection, harmful content, and data leakage in generative AI applications by letting you define policies that filter user prompts and model responses. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-modelarmor/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-modelarmor/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-modelarmor api_id: modelarmor.googleapis.com @@ -1782,7 +1657,6 @@ libraries: issue_tracker: https://issuetracker.google.com/savedsearches/559785 GAPICs: - proto_path: google/monitoring/v3 - - api_shortname: monitoring-dashboards name_pretty: Monitoring Dashboards product_documentation: https://cloud.google.com/monitoring/charts/dashboards @@ -1795,18 +1669,15 @@ libraries: api_id: monitoring.googleapis.com GAPICs: - proto_path: google/monitoring/dashboard/v1 - - api_shortname: monitoring-metricsscope name_pretty: Monitoring Metrics Scopes - product_documentation: - https://cloud.google.com/monitoring/api/ref_v3/rest/v1/locations.global.metricsScopes + product_documentation: https://cloud.google.com/monitoring/api/ref_v3/rest/v1/locations.global.metricsScopes api_description: The metrics scope defines the set of Google Cloud projects whose metrics the current Google Cloud project can access. api_id: monitoring.googleapis.com distribution_name: com.google.cloud:google-cloud-monitoring-metricsscope GAPICs: - proto_path: google/monitoring/metricsscope/v1 - - api_shortname: netapp name_pretty: NetApp API product_documentation: https://cloud.google.com/netapp/volumes/docs/discover/overview @@ -1815,11 +1686,9 @@ libraries: scalable performance with global availability. GAPICs: - proto_path: google/cloud/netapp/v1 - - api_shortname: networkmanagement name_pretty: Network Management API - product_documentation: - https://cloud.google.com/network-intelligence-center/docs/connectivity-tests/reference/networkmanagement/rest/ + product_documentation: https://cloud.google.com/network-intelligence-center/docs/connectivity-tests/reference/networkmanagement/rest/ api_description: provides a collection of network performance monitoring and diagnostic capabilities. library_name: network-management @@ -1827,7 +1696,6 @@ libraries: GAPICs: - proto_path: google/cloud/networkmanagement/v1 - proto_path: google/cloud/networkmanagement/v1beta1 - - api_shortname: networksecurity name_pretty: Network Security API product_documentation: https://cloud.google.com/traffic-director/docs/reference/network-security/rest @@ -1837,7 +1705,6 @@ libraries: GAPICs: - proto_path: google/cloud/networksecurity/v1 - proto_path: google/cloud/networksecurity/v1beta1 - - api_shortname: networkconnectivity name_pretty: Network Connectivity Center product_documentation: https://cloud.google.com/network-connectivity/docs @@ -1848,7 +1715,6 @@ libraries: GAPICs: - proto_path: google/cloud/networkconnectivity/v1 - proto_path: google/cloud/networkconnectivity/v1alpha1 - - api_shortname: networkservices name_pretty: Network Services API product_documentation: https://cloud.google.com/products/networking @@ -1856,8 +1722,7 @@ libraries: on top of planet-scale infrastructure that leverages automation, advanced AI, and programmability, enabling enterprises to connect, scale, secure, modernize and optimize their infrastructure. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-networkservices/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-networkservices/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-networkservices api_id: networkservices.googleapis.com @@ -1880,7 +1745,6 @@ libraries: - proto_path: google/cloud/notebooks/v1 - proto_path: google/cloud/notebooks/v1beta1 - proto_path: google/cloud/notebooks/v2 - - api_shortname: cloudoptimization name_pretty: Cloud Fleet Routing product_documentation: https://cloud.google.com/optimization/docs @@ -1893,14 +1757,12 @@ libraries: rpc_documentation: https://cloud.google.com/optimization/docs/reference/rpc GAPICs: - proto_path: google/cloud/optimization/v1 - - api_shortname: oracledatabase name_pretty: Oracle Database@Google Cloud API product_documentation: https://cloud.google.com/oracle/database/docs api_description: The Oracle Database@Google Cloud API provides a set of APIs to manage Oracle database services, such as Exadata and Autonomous Databases. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-oracledatabase/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-oracledatabase/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-oracledatabase api_id: oracledatabase.googleapis.com @@ -1925,18 +1787,15 @@ libraries: GAPICs: - proto_path: google/cloud/orchestration/airflow/service/v1 - proto_path: google/cloud/orchestration/airflow/service/v1beta1 - - api_shortname: orgpolicy name_pretty: Cloud Organization Policy product_documentation: n/a api_description: n/a release_level: stable - client_documentation: - https://cloud.google.com/java/docs/reference/proto-google-cloud-orgpolicy-v1/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/proto-google-cloud-orgpolicy-v1/latest/overview GAPICs: - proto_path: google/cloud/orgpolicy/v1 - proto_path: google/cloud/orgpolicy/v2 - - api_shortname: osconfig name_pretty: OS Config API product_documentation: https://cloud.google.com/compute/docs/os-patch-management @@ -1950,7 +1809,6 @@ libraries: - proto_path: google/cloud/osconfig/v1 - proto_path: google/cloud/osconfig/v1alpha - proto_path: google/cloud/osconfig/v1beta - - api_shortname: oslogin name_pretty: Cloud OS Login product_documentation: https://cloud.google.com/compute/docs/oslogin/ @@ -1961,14 +1819,12 @@ libraries: GAPICs: - proto_path: google/cloud/oslogin/v1 - proto_path: google/cloud/oslogin/v1beta - - api_shortname: parallelstore name_pretty: Parallelstore API product_documentation: https://cloud/parallelstore?hl=en api_description: 'Parallelstore is based on Intel DAOS and delivers up to 6.3x greater read throughput performance compared to competitive Lustre scratch offerings. ' - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-parallelstore/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-parallelstore/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-parallelstore api_id: parallelstore.googleapis.com @@ -1986,8 +1842,7 @@ libraries: to store, access and manage the lifecycle of your workload parameters. Parameter Manager aims to make management of sensitive application parameters effortless for customers without diminishing focus on security. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-parametermanager/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-parametermanager/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-parametermanager api_id: parametermanager.googleapis.com @@ -2009,7 +1864,6 @@ libraries: requires_billing: false GAPICs: - proto_path: google/cloud/phishingprotection/v1beta1 - - api_shortname: policytroubleshooter name_pretty: IAM Policy Troubleshooter API product_documentation: https://cloud.google.com/iam/docs/troubleshooting-access @@ -2025,7 +1879,6 @@ libraries: GAPICs: - proto_path: google/cloud/policytroubleshooter/v1 - proto_path: google/cloud/policytroubleshooter/iam/v3 - - api_shortname: policysimulator name_pretty: Policy Simulator API product_documentation: https://cloud.google.com/policysimulator/docs/overview @@ -2033,7 +1886,6 @@ libraries: and viewing a Replay. GAPICs: - proto_path: google/cloud/policysimulator/v1 - - api_shortname: cloudprivatecatalog name_pretty: Private Catalog product_documentation: https://cloud.google.com/private-catalog/docs @@ -2044,11 +1896,9 @@ libraries: api_id: privatecatalog.googleapis.com GAPICs: - proto_path: google/cloud/privatecatalog/v1beta1 - - api_shortname: privilegedaccessmanager name_pretty: Privileged Access Manager API - product_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-privilegedaccessmanager/latest/overview + product_documentation: https://cloud.google.com/java/docs/reference/google-cloud-privilegedaccessmanager/latest/overview api_description: Privileged Access Manager (PAM) helps you on your journey towards least privilege and helps mitigate risks tied to privileged access misuse orabuse. PAM allows you to shift from always-on standing privileges towards on-demand access @@ -2061,8 +1911,7 @@ libraries: access for developers for critical deployment or maintenance, temporary access for operators for data ingestion and audits, JIT access to service accounts for automated tasks, and more. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-privilegedaccessmanager/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-privilegedaccessmanager/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-privilegedaccessmanager api_id: privilegedaccessmanager.googleapis.com @@ -2086,7 +1935,6 @@ libraries: api_id: cloudprofiler.googleapis.com GAPICs: - proto_path: google/devtools/cloudprofiler/v2 - - api_shortname: publicca name_pretty: Public Certificate Authority API product_documentation: https://cloud.google.com/certificate-manager/docs/public-ca @@ -2098,14 +1946,12 @@ libraries: GAPICs: - proto_path: google/cloud/security/publicca/v1beta1 - proto_path: google/cloud/security/publicca/v1 - - api_shortname: rapidmigrationassessment name_pretty: Rapid Migration Assessment API product_documentation: https://cloud.google.com/migration-center/docs api_description: Rapid Migration Assessment API GAPICs: - proto_path: google/cloud/rapidmigrationassessment/v1 - - api_shortname: recaptchaenterprise name_pretty: reCAPTCHA Enterprise product_documentation: https://cloud.google.com/recaptcha-enterprise/docs/ @@ -2118,7 +1964,6 @@ libraries: GAPICs: - proto_path: google/cloud/recaptchaenterprise/v1 - proto_path: google/cloud/recaptchaenterprise/v1beta1 - - api_shortname: recommendationengine name_pretty: Recommendations AI product_documentation: https://cloud.google.com/recommendations-ai/ @@ -2126,7 +1971,6 @@ libraries: library_name: recommendations-ai GAPICs: - proto_path: google/cloud/recommendationengine/v1beta1 - - api_shortname: recommender name_pretty: Recommender product_documentation: https://cloud.google.com/recommendations/ @@ -2136,7 +1980,6 @@ libraries: GAPICs: - proto_path: google/cloud/recommender/v1 - proto_path: google/cloud/recommender/v1beta1 - - api_shortname: redis name_pretty: Cloud Redis product_documentation: https://cloud.google.com/memorystore/docs/redis/ @@ -2149,7 +1992,6 @@ libraries: GAPICs: - proto_path: google/cloud/redis/v1 - proto_path: google/cloud/redis/v1beta1 - - api_shortname: redis-cluster name_pretty: Google Cloud Memorystore for Redis API product_documentation: https://cloud.google.com/memorystore/docs/cluster @@ -2157,7 +1999,6 @@ libraries: GAPICs: - proto_path: google/cloud/redis/cluster/v1 - proto_path: google/cloud/redis/cluster/v1beta1 - - api_shortname: cloudresourcemanager name_pretty: Resource Manager API product_documentation: https://cloud.google.com/resource-manager @@ -2169,7 +2010,6 @@ libraries: issue_tracker: https://issuetracker.google.com/savedsearches/559757 GAPICs: - proto_path: google/cloud/resourcemanager/v3 - - api_shortname: retail name_pretty: Cloud Retail product_documentation: https://cloud.google.com/solutions/retail @@ -2179,7 +2019,6 @@ libraries: - proto_path: google/cloud/retail/v2 - proto_path: google/cloud/retail/v2alpha - proto_path: google/cloud/retail/v2beta - - api_shortname: run name_pretty: Cloud Run product_documentation: https://cloud.google.com/run/docs @@ -2189,13 +2028,11 @@ libraries: rpc_documentation: https://cloud.google.com/run/docs/reference/rpc GAPICs: - proto_path: google/cloud/run/v2 - - api_shortname: saasservicemgmt name_pretty: SaaS Runtime API product_documentation: https://cloud.google.com/saas-runtime/docs/overview api_description: "Model, deploy, and operate your SaaS at scale.\t" - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-saasservicemgmt/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-saasservicemgmt/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-saasservicemgmt api_id: saasservicemgmt.googleapis.com @@ -2223,7 +2060,6 @@ libraries: GAPICs: - proto_path: google/cloud/scheduler/v1 - proto_path: google/cloud/scheduler/v1beta1 - - api_shortname: secretmanager name_pretty: Secret Management product_documentation: https://cloud.google.com/solutions/secrets-management/ @@ -2234,18 +2070,15 @@ libraries: GAPICs: - proto_path: google/cloud/secretmanager/v1 - proto_path: google/cloud/secretmanager/v1beta2 - # v1beta1's version is in a different proto path from the rest - proto_path: google/cloud/secrets/v1beta1 - - api_shortname: securesourcemanager name_pretty: Secure Source Manager API product_documentation: https://cloud.google.com/secure-source-manager/docs/overview - api_description: "Regionally deployed, single-tenant managed source code repository - hosted on\n Google Cloud." + api_description: "Regionally deployed, single-tenant managed source code repository\ + \ hosted on\n Google Cloud." release_level: stable GAPICs: - proto_path: google/cloud/securesourcemanager/v1 - - api_shortname: privateca name_pretty: Certificate Authority Service product_documentation: https://cloud.google.com/certificate-authority-service/docs @@ -2259,8 +2092,6 @@ libraries: GAPICs: - proto_path: google/cloud/security/privateca/v1 - proto_path: google/cloud/security/privateca/v1beta1 - -# duplicated api_shortname - api_shortname: securitycenter name_pretty: Security Command Center product_documentation: https://cloud.google.com/security-command-center @@ -2280,7 +2111,6 @@ libraries: - proto_path: google/cloud/securitycenter/v1beta1 - proto_path: google/cloud/securitycenter/v1p1beta1 - proto_path: google/cloud/securitycenter/v2 - - api_shortname: securitycenter name_pretty: Security Command Center Settings API product_documentation: https://cloud.google.com/security-command-center/ @@ -2293,7 +2123,6 @@ libraries: rest_documentation: https://cloud.google.com/security-command-center/docs/reference/rest GAPICs: - proto_path: google/cloud/securitycenter/settings/v1beta1 - - api_shortname: securitycentermanagement name_pretty: Security Center Management API product_documentation: https://cloud.google.com/securitycentermanagement/docs/overview @@ -2301,7 +2130,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/securitycentermanagement/v1 - - api_shortname: securityposture name_pretty: Security Posture API product_documentation: https://cloud.google.com/security-command-center/docs/security-posture-overview @@ -2312,7 +2140,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/securityposture/v1 - - api_shortname: servicecontrol name_pretty: Service Control API product_documentation: https://cloud.google.com/service-infrastructure/docs/overview/ @@ -2324,7 +2151,6 @@ libraries: GAPICs: - proto_path: google/api/servicecontrol/v1 - proto_path: google/api/servicecontrol/v2 - - api_shortname: servicemanagement name_pretty: Service Management API product_documentation: https://cloud.google.com/service-infrastructure/docs/overview/ @@ -2338,7 +2164,6 @@ libraries: api_id: servicemanagement.googleapis.com GAPICs: - proto_path: google/api/servicemanagement/v1 - - api_shortname: serviceusage name_pretty: Service Usage product_documentation: https://cloud.google.com/service-usage/docs/overview @@ -2349,7 +2174,6 @@ libraries: GAPICs: - proto_path: google/api/serviceusage/v1 - proto_path: google/api/serviceusage/v1beta1 - - api_shortname: servicedirectory name_pretty: Service Directory product_documentation: https://cloud.google.com/service-directory/ @@ -2361,7 +2185,6 @@ libraries: GAPICs: - proto_path: google/cloud/servicedirectory/v1 - proto_path: google/cloud/servicedirectory/v1beta1 - - api_shortname: servicehealth name_pretty: Service Health API product_documentation: https://cloud.google.com/service-health/docs/overview @@ -2370,7 +2193,6 @@ libraries: rpc_documentation: https://cloud.google.com/service-health/docs/reference/rpc GAPICs: - proto_path: google/cloud/servicehealth/v1 - - api_shortname: cloudshell name_pretty: Cloud Shell product_documentation: https://cloud.google.com/shell/docs @@ -2384,7 +2206,6 @@ libraries: rpc_documentation: https://cloud.google.com/shell/docs/reference/rpc GAPICs: - proto_path: google/cloud/shell/v1 - - api_shortname: css name_pretty: CSS API product_documentation: https://developers.google.com/comparison-shopping-services/api @@ -2395,14 +2216,11 @@ libraries: distribution_name: com.google.shopping:google-shopping-css GAPICs: - proto_path: google/shopping/css/v1 - - # duplicated api_shortname - api_shortname: merchantapi name_pretty: Merchant API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your Merchant Center accounts. - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-accounts/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-accounts/latest/overview release_level: stable distribution_name: com.google.shopping:google-shopping-merchant-accounts api_id: merchantapi.googleapis.com @@ -2418,8 +2236,7 @@ libraries: name_pretty: Merchant Conversions API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your Merchant Center accounts. - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-conversions/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-conversions/latest/overview release_level: stable distribution_name: com.google.shopping:google-shopping-merchant-conversions api_id: shopping-merchant-conversions.googleapis.com @@ -2430,13 +2247,11 @@ libraries: - proto_path: google/shopping/merchant/conversions/v1 - proto_path: google/shopping/merchant/conversions/v1beta requires_billing: true - - api_shortname: merchantapi name_pretty: Merchant API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your Merchant Center accounts. - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-datasources/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-datasources/latest/overview release_level: stable distribution_name: com.google.shopping:google-shopping-merchant-datasources api_id: merchantapi.googleapis.com @@ -2463,8 +2278,7 @@ libraries: name_pretty: Merchant LFP API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your Merchant Center accounts. - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-lfp/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-lfp/latest/overview release_level: stable distribution_name: com.google.shopping:google-shopping-merchant-lfp api_id: shopping-merchant-lfp.googleapis.com @@ -2475,13 +2289,11 @@ libraries: - proto_path: google/shopping/merchant/lfp/v1 - proto_path: google/shopping/merchant/lfp/v1beta requires_billing: true - - api_shortname: shopping-merchant-notifications name_pretty: Merchant Notifications API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your Merchant Center accounts. - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-notifications/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-notifications/latest/overview release_level: stable distribution_name: com.google.shopping:google-shopping-merchant-notifications api_id: shopping-merchant-notifications.googleapis.com @@ -2496,8 +2308,7 @@ libraries: name_pretty: Merchant API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your products. - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-productstudio/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-productstudio/latest/overview release_level: preview distribution_name: com.google.shopping:google-shopping-merchant-productstudio api_id: merchantapi.googleapis.com @@ -2512,8 +2323,7 @@ libraries: name_pretty: Merchant API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your Merchant Center accounts. - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-products/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-products/latest/overview release_level: stable distribution_name: com.google.shopping:google-shopping-merchant-products api_id: merchantapi.googleapis.com @@ -2528,8 +2338,7 @@ libraries: name_pretty: Merchant API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your Merchant Center accounts. - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-promotions/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-promotions/latest/overview release_level: stable distribution_name: com.google.shopping:google-shopping-merchant-promotions api_id: merchantapi.googleapis.com @@ -2545,8 +2354,7 @@ libraries: name_pretty: Merchant Quota API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your Merchant Center accounts. - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-quota/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-quota/latest/overview release_level: stable distribution_name: com.google.shopping:google-shopping-merchant-quota api_id: shopping-merchant-quota.googleapis.com @@ -2557,7 +2365,6 @@ libraries: - proto_path: google/shopping/merchant/quota/v1 - proto_path: google/shopping/merchant/quota/v1beta requires_billing: true - - api_shortname: merchantapi name_pretty: Merchant API product_documentation: https://developers.google.com/merchant/api @@ -2570,13 +2377,11 @@ libraries: - proto_path: google/shopping/merchant/reports/v1 - proto_path: google/shopping/merchant/reports/v1beta - proto_path: google/shopping/merchant/reports/v1alpha - - api_shortname: merchantapi name_pretty: Merchant API product_documentation: https://developers.google.com/merchant/api api_description: Programmatically manage your Merchant Center Accounts. - client_documentation: - https://cloud.google.com/java/docs/reference/google-shopping-merchant-reviews/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-shopping-merchant-reviews/latest/overview release_level: preview distribution_name: com.google.shopping:google-shopping-merchant-reviews library_type: GAPIC_AUTO @@ -2586,16 +2391,13 @@ libraries: - proto_path: google/shopping/merchant/reviews/v1beta requires_billing: true library_name: shopping-merchant-reviews - - api_shortname: spanneradapter name_pretty: Cloud Spanner Adapter API - product_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-spanneradapter/latest/overview + product_documentation: https://cloud.google.com/java/docs/reference/google-cloud-spanneradapter/latest/overview api_description: The Cloud Spanner Adapter service allows native drivers of supported database dialects to interact directly with Cloud Spanner by wrapping the underlying wire protocol used by the driver in a gRPC stream. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-spanneradapter/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-spanneradapter/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-spanneradapter api_id: spanneradapter.googleapis.com @@ -2620,7 +2422,6 @@ libraries: - proto_path: google/cloud/speech/v1 - proto_path: google/cloud/speech/v1p1beta1 - proto_path: google/cloud/speech/v2 - - api_shortname: storagetransfer name_pretty: Storage Transfer Service product_documentation: https://cloud.google.com/storage-transfer-service @@ -2630,15 +2431,13 @@ libraries: release_level: stable GAPICs: - proto_path: google/storagetransfer/v1 - - api_shortname: storagebatchoperations name_pretty: Storage Batch Operations API product_documentation: https://cloud.google.com/storage/docs/batch-operations/overview api_description: Storage batch operations is a Cloud Storage management feature that performs operations on billions of Cloud Storage objects in a serverless manner. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-storagebatchoperations/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-storagebatchoperations/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-storagebatchoperations api_id: storagebatchoperations.googleapis.com @@ -2654,7 +2453,6 @@ libraries: api_description: Provides insights capability on Google Cloud Storage GAPICs: - proto_path: google/cloud/storageinsights/v1 - - api_shortname: jobs name_pretty: Talent Solution product_documentation: https://cloud.google.com/solutions/talent-solution/ @@ -2670,7 +2468,6 @@ libraries: GAPICs: - proto_path: google/cloud/talent/v4 - proto_path: google/cloud/talent/v4beta1 - - api_shortname: cloudtasks name_pretty: Cloud Tasks product_documentation: https://cloud.google.com/tasks/docs/ @@ -2688,7 +2485,6 @@ libraries: - proto_path: google/cloud/tasks/v2 - proto_path: google/cloud/tasks/v2beta2 - proto_path: google/cloud/tasks/v2beta3 - - api_shortname: telcoautomation name_pretty: Telco Automation API product_documentation: https://cloud.google.com/telecom-network-automation @@ -2698,7 +2494,6 @@ libraries: GAPICs: - proto_path: google/cloud/telcoautomation/v1 - proto_path: google/cloud/telcoautomation/v1alpha1 - - api_shortname: texttospeech name_pretty: Cloud Text-to-Speech product_documentation: https://cloud.google.com/text-to-speech @@ -2713,7 +2508,6 @@ libraries: GAPICs: - proto_path: google/cloud/texttospeech/v1 - proto_path: google/cloud/texttospeech/v1beta1 - - api_shortname: tpu name_pretty: Cloud TPU product_documentation: https://cloud.google.com/tpu/docs @@ -2725,7 +2519,6 @@ libraries: - proto_path: google/cloud/tpu/v1 - proto_path: google/cloud/tpu/v2 - proto_path: google/cloud/tpu/v2alpha1 - - api_shortname: cloudtrace name_pretty: Stackdriver Trace product_documentation: https://cloud.google.com/trace/docs/ @@ -2739,7 +2532,6 @@ libraries: GAPICs: - proto_path: google/devtools/cloudtrace/v1 - proto_path: google/devtools/cloudtrace/v2 - - api_shortname: translate name_pretty: Cloud Translation product_documentation: https://cloud.google.com/translate/docs/ @@ -2754,14 +2546,12 @@ libraries: GAPICs: - proto_path: google/cloud/translate/v3 - proto_path: google/cloud/translate/v3beta1 - - api_shortname: memorystore name_pretty: Memorystore API product_documentation: https://cloud.google.com/memorystore/docs/valkey api_description: Memorystore for Valkey is a fully managed Valkey Cluster service for Google Cloud. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-memorystore/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-memorystore/latest/overview release_level: stable api_id: memorystore.googleapis.com library_type: GAPIC_AUTO @@ -2784,8 +2574,7 @@ libraries: with associated metadata, automatically generate embeddings from your data, and perform fast approximate nearest neighbor (ANN) searches to find semantically similar items at scale. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-vectorsearch/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-vectorsearch/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-vectorsearch api_id: vectorsearch.googleapis.com @@ -2811,7 +2600,6 @@ libraries: - proto_path: google/cloud/videointelligence/v1p1beta1 - proto_path: google/cloud/videointelligence/v1p2beta1 - proto_path: google/cloud/videointelligence/v1p3beta1 - - api_shortname: livestream name_pretty: Live Stream API product_documentation: https://cloud.google.com/livestream/ @@ -2822,7 +2610,6 @@ libraries: distribution_name: com.google.cloud:google-cloud-live-stream GAPICs: - proto_path: google/cloud/video/livestream/v1 - - api_shortname: videostitcher name_pretty: Video Stitcher API product_documentation: https://cloud.google.com/video-stitcher/ @@ -2832,7 +2619,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/video/stitcher/v1 - - api_shortname: transcoder name_pretty: Video Transcoder product_documentation: https://cloud.google.com/transcoder/docs @@ -2846,7 +2632,6 @@ libraries: rpc_documentation: https://cloud.google.com/transcoder/docs/reference/rpc GAPICs: - proto_path: google/cloud/video/transcoder/v1 - - api_shortname: vision name_pretty: Cloud Vision product_documentation: https://cloud.google.com/vision/docs/ @@ -2863,14 +2648,12 @@ libraries: - proto_path: google/cloud/vision/v1p2beta1 - proto_path: google/cloud/vision/v1p3beta1 - proto_path: google/cloud/vision/v1p4beta1 - - api_shortname: visionai name_pretty: Vision AI API product_documentation: https://cloud.google.com/vision-ai/docs api_description: Vertex AI Vision is an AI-powered platform to ingest, analyze and store video data. - client_documentation: - https://cloud.google.com/java/docs/reference/google-cloud-visionai/latest/overview + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-visionai/latest/overview release_level: preview distribution_name: com.google.cloud:google-cloud-visionai api_id: visionai.googleapis.com @@ -2890,7 +2673,6 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/vmmigration/v1 - - api_shortname: vmwareengine name_pretty: Google Cloud VMware Engine product_documentation: https://cloud.google.com/vmware-engine/ @@ -2899,7 +2681,6 @@ libraries: rest_documentation: https://cloud.google.com/vmware-engine/docs/reference/rest GAPICs: - proto_path: google/cloud/vmwareengine/v1 - - api_shortname: vpcaccess name_pretty: Serverless VPC Access product_documentation: https://cloud.google.com/vpc/docs/serverless-vpc-access @@ -2910,18 +2691,17 @@ libraries: release_level: stable GAPICs: - proto_path: google/cloud/vpcaccess/v1 - - api_shortname: webrisk name_pretty: Web Risk product_documentation: https://cloud.google.com/web-risk/docs/ - api_description: is a Google Cloud service that lets client applications check URLs - against Google's constantly updated lists of unsafe web resources. Unsafe web - resources include social engineering sites—such as phishing and deceptive sites—and - sites that host malware or unwanted software. With the Web Risk API, you can quickly - identify known bad sites, warn users before they click infected links, and prevent - users from posting links to known infected pages from your site. The Web Risk - API includes data on more than a million unsafe URLs and stays up to date by examining - billions of URLs each day. + api_description: "is a Google Cloud service that lets client applications check\ + \ URLs against Google's constantly updated lists of unsafe web resources. Unsafe\ + \ web resources include social engineering sites\u2014such as phishing and deceptive\ + \ sites\u2014and sites that host malware or unwanted software. With the Web Risk\ + \ API, you can quickly identify known bad sites, warn users before they click\ + \ infected links, and prevent users from posting links to known infected pages\ + \ from your site. The Web Risk API includes data on more than a million unsafe\ + \ URLs and stays up to date by examining billions of URLs each day." release_level: stable requires_billing: false issue_tracker: '' @@ -2930,7 +2710,6 @@ libraries: GAPICs: - proto_path: google/cloud/webrisk/v1 - proto_path: google/cloud/webrisk/v1beta1 - - api_shortname: websecurityscanner name_pretty: Cloud Security Scanner product_documentation: https://cloud.google.com/security-scanner/docs/ @@ -2945,7 +2724,6 @@ libraries: - proto_path: google/cloud/websecurityscanner/v1 - proto_path: google/cloud/websecurityscanner/v1alpha - proto_path: google/cloud/websecurityscanner/v1beta - - api_shortname: workflowexecutions name_pretty: Cloud Workflow Executions product_documentation: https://cloud.google.com/workflows @@ -2958,7 +2736,6 @@ libraries: GAPICs: - proto_path: google/cloud/workflows/executions/v1 - proto_path: google/cloud/workflows/executions/v1beta - - api_shortname: workflows name_pretty: Cloud Workflows product_documentation: https://cloud.google.com/workflows @@ -2970,7 +2747,6 @@ libraries: GAPICs: - proto_path: google/cloud/workflows/v1 - proto_path: google/cloud/workflows/v1beta - - api_shortname: workspaceevents name_pretty: Google Workspace Events API product_documentation: https://developers.google.com/workspace/events @@ -2980,7 +2756,6 @@ libraries: GAPICs: - proto_path: google/apps/events/subscriptions/v1 - proto_path: google/apps/events/subscriptions/v1beta - - api_shortname: workstations name_pretty: Cloud Workstations product_documentation: https://cloud.google.com/workstations diff --git a/java-datastore/.OwlBot-hermetic.yaml b/java-datastore/.OwlBot-hermetic.yaml new file mode 100644 index 000000000000..c53f7529e9bf --- /dev/null +++ b/java-datastore/.OwlBot-hermetic.yaml @@ -0,0 +1,31 @@ +# 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. + +deep-remove-regex: +- /java-datastore/proto-google-.*/src +deep-preserve-regex: +- /java-datastore/google-.*/src/test/java/com/google/cloud/.*/v.*/it/IT.*Test.java +deep-copy-regex: +- source: /google/datastore/(v.*)/.*-java/proto-google-.*/src + dest: /owl-bot-staging/java-datastore/$1/proto-google-cloud-datastore-$1/src +- source: /google/datastore/admin/(v.*)/.*-java/proto-google-.*/src + dest: /owl-bot-staging/java-datastore/$1/proto-google-cloud-datastore-admin-$1/src +- source: /google/datastore/(v.*)/.*-java/grpc-google-.*/src + dest: /owl-bot-staging/java-datastore/$1/grpc-google-cloud-datastore-$1/src +- source: /google/datastore/admin/(v.*)/.*-java/grpc-google-.*/src + dest: /owl-bot-staging/java-datastore/$1/grpc-google-cloud-datastore-admin-$1/src +- source: /google/datastore/(v.*)/.*-java/gapic-google-.*/src + dest: /owl-bot-staging/java-datastore/$1/google-cloud-datastore/src +- source: /google/datastore/admin/(v.*)/.*-java/gapic-google-.*/src + dest: /owl-bot-staging/java-datastore/$1/google-cloud-datastore/src diff --git a/java-datastore/.cloudbuild/samples_build.yaml b/java-datastore/.cloudbuild/samples_build.yaml new file mode 100644 index 000000000000..3dd2ff94ced1 --- /dev/null +++ b/java-datastore/.cloudbuild/samples_build.yaml @@ -0,0 +1,32 @@ +steps: +- name: gcr.io/cloud-devrel-public-resources/java11 + entrypoint: ls + args: [ + '-alt', + ] +- name: gcr.io/cloud-devrel-public-resources/java11 + entrypoint: curl + args: [ + '--header', + 'Metadata-Flavor: Google', + 'http://metadata.google.internal/computeMetadata/v1/instance/service-accounts/default/email' + ] +- name: gcr.io/cloud-devrel-public-resources/java11 + entrypoint: pwd +- name: gcr.io/cloud-devrel-public-resources/java11 + entrypoint: bash + args: [ + '.kokoro/build.sh' + ] + env: + - 'JOB_TYPE=samples' + - 'GOOGLE_CLOUD_PROJECT=cloud-java-ci-sample' + - 'KOKORO_GITHUB_PULL_REQUEST_NUMBER=$_PR_NUMBER' +- name: gcr.io/cloud-devrel-public-resources/java11 + entrypoint: echo + args: [ + 'Sample job succeeded', + ] +timeout: 3600s +options: + defaultLogsBucketBehavior: REGIONAL_USER_OWNED_BUCKET diff --git a/java-datastore/.readme-partials.yaml b/java-datastore/.readme-partials.yaml new file mode 100644 index 000000000000..a6afbfd20dd5 --- /dev/null +++ b/java-datastore/.readme-partials.yaml @@ -0,0 +1,257 @@ +custom_content: | + See the [Google Cloud Datastore docs][cloud-datastore-activation] for more details on how to activate + Cloud Datastore for your project. + + See the [Datastore client library docs][datastore-client-lib-docs] to learn how to interact + with the Cloud Datastore using this Client Library. + + #### Creating an authorized service object + To make authenticated requests to Google Cloud Datastore, you must create a service object with credentials. You can then make API calls by calling methods on the Datastore service object. The simplest way to authenticate is to use [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials). These credentials are automatically inferred from your environment, so you only need the following code to create your service object: + + ```java + import com.google.cloud.datastore.Datastore; + import com.google.cloud.datastore.DatastoreOptions; + + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + ``` + + For other authentication options, see the [Authentication](https://github.com/googleapis/google-cloud-java#authentication) page. + + #### Storing data + Objects in Datastore are known as entities. Entities are grouped by "kind" and have keys for easy access. In this code snippet, we will create a new entity representing a person and store that data by the person's email. First, add the following imports at the top of your file: + + ```java + import com.google.cloud.datastore.Entity; + import com.google.cloud.datastore.Key; + import com.google.cloud.datastore.KeyFactory; + ``` + + Then add the following code to put an entity in Datastore. + + ```java + KeyFactory keyFactory = datastore.newKeyFactory().setKind("Person"); + Key key = keyFactory.newKey("john.doe@gmail.com"); + Entity entity = Entity.newBuilder(key) + .set("name", "John Doe") + .set("age", 51) + .set("favorite_food", "pizza") + .build(); + datastore.put(entity); + ``` + + Later, if you want to get this entity back, add the following to your code: + + ```java + Entity johnEntity = datastore.get(key); + ``` + + #### Running a query + In addition to retrieving entities by their keys, you can perform queries to retrieve entities by + the values of their properties. A typical query includes an entity kind, filters to select entities + with matching values, and sort orders to sequence the results. `google-cloud-datastore` supports two + types of queries: `StructuredQuery` (that allows you to construct query elements) and `GqlQuery` + (which operates using [GQL syntax](https://cloud.google.com/datastore/docs/apis/gql/gql_reference)) + in string format. In this tutorial, we will use a simple `StructuredQuery`. + + Suppose that you've added more people to Datastore, and now you want to find all people whose favorite food is pizza. Import the following: + + ```java + import com.google.cloud.datastore.Query; + import com.google.cloud.datastore.QueryResults; + import com.google.cloud.datastore.StructuredQuery; + import com.google.cloud.datastore.StructuredQuery.PropertyFilter; + ``` + + Then add the following code to your program: + + ```java + Query query = Query.newEntityQueryBuilder() + .setKind("Person") + .setFilter(PropertyFilter.eq("favorite_food", "pizza")) + .build(); + QueryResults results = datastore.run(query); + while (results.hasNext()) { + Entity currentEntity = results.next(); + System.out.println(currentEntity.getString("name") + ", you're invited to a pizza party!"); + } + ``` + + Cloud Datastore relies on indexing to run queries. Indexing is turned on by default for most types of properties. To read more about indexing, see the [Cloud Datastore Index Configuration documentation](https://cloud.google.com/datastore/docs/tools/indexconfig). + + #### Updating data + Another thing you'll probably want to do is update your data. The following snippet shows how to update a Datastore entity if it exists. + + ```java + KeyFactory keyFactory = datastore.newKeyFactory().setKind("keyKind"); + Key key = keyFactory.newKey("keyName"); + Entity entity = datastore.get(key); + if (entity != null) { + System.out.println("Updating access_time for " + entity.getString("name")); + entity = Entity.newBuilder(entity) + .set("access_time", DateTime.now()) + .build(); + datastore.update(entity); + } + ``` + + The complete source code can be found at + [UpdateEntity.java](https://github.com/googleapis/google-cloud-java/blob/2c1850d4f82f3fbd7b4a50582384c008085aa1a8/google-cloud-examples/src/main/java/com/google/cloud/examples/datastore/snippets/UpdateEntity.java). + + #### Complete source code + + In + [AddEntitiesAndRunQuery.java](https://github.com/googleapis/google-cloud-java/blob/2c1850d4f82f3fbd7b4a50582384c008085aa1a8/google-cloud-examples/src/main/java/com/google/cloud/examples/datastore/snippets/AddEntitiesAndRunQuery.java) + we put together all the code to store data and run queries into one program. The program assumes that you are + running on Compute Engine or from your own desktop. To run the example on App Engine, simply move + the code from the main method to your application's servlet class and change the print statements to + display on your webpage. + + gRPC Java Datastore Client User Guide + ------- + The [Java Datastore client](https://github.com/googleapis/java-datastore) now offers gRPC as a transport layer option with experimental support. Using [gRPC connection pooling](https://grpc.io/docs/guides/performance/) enables distributing RPCs over multiple connections which may improve performance. + + #### Installation Instructions + To use this feature, please upgrade your Java-datastore SDK to version v2.28.0 or a newer release. You can find the latest versions [here](https://github.com/googleapis/java-datastore/releases). + + #### How to Use + To opt-in to the gRPC transport behavior, simply add the below line of code (`setTransportOptions`) to your Datastore client instantiation. + + Example: + ```java + DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .build(); + ``` + Setting the transport options explicitly to `GrpcTransportOptions` will signal the client to use gRPC instead of HTTP when making calls to the server. + + To revert back to the existing stable behavior and transport, simply remove the transport options line or replace it with `HttpTransportOptions`. Please note this will require an application rebuild and restart. + Example: + ```java + // will default to existing HTTP transport behavior + DatastoreOptions datastoreOptions = DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .build(); + + // will also default to existing HTTP transport behavior + DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .setTransportOptions(HttpTransportOptions.newBuilder() + .setConnectTimeout(1000) + .build()).build(); + ``` + + Note: client instantiations that already use `setTransportOptions` with `HttpTransportOptions` will continue to have the same behavior. Only transports that are explicitly set to gRPC will change. + + #### Verify Datastore Transport Options Type + To verify which type of TransportOptions you have successfully configured, you can use the below lines of code to compare transport options type: + ```java + // checks if using gRPC transport options + boolean isGRPC = datastore.getOptions().getTransportOptions() instanceof GrpcTransportOptions; + + // checks if using HTTP transport options + boolean isHTTP = datastore.getOptions().getTransportOptions() instanceof HTTPTransportOptions; + ``` + + #### New Features + There are new gRPC specific features available to use in this update. + + ##### Connection Pool + A connection pool, also known as a channel pool, is a cache of database connections that are shared and reused to improve connection latency and performance. With this update, now you will be able to configure the channel pool to improve application performance. This section guides you in determining the optimal connection pool size and configuring it within the Java datastore client. + To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions. + ###### Determine the best connection pool size + The default connection pool size is right for most applications, and in most cases there's no need to change it. + + However sometimes you may want to change your connection pool size due to high throughput or buffered requests. Ideally, to leave room for traffic fluctuations, a connection pool has about twice the number of connections it takes for maximum saturation. Because a connection can handle a maximum of 100 concurrent requests, between 10 and 50 outstanding requests per connection is optimal. The limit of 100 concurrent streams per gRPC connection is enforced in Google's middleware layer, and you are not able to reconfigure this number. + + The following steps help you calculate the optimal number of connections in your channel pool using estimate per-client QPS and average latency numbers. + + To calculate the optimal connections, gather the following information: + + 1. The maximum number of queries per second (QPS) per client when your application is running a typical workload. + 2. The average latency (the response time for a single request) in ms. + 3. Determine the number of requests that you can send serially per second by dividing 1,000 by the average latency value. + 4. Divide the QPS in seconds by the number of serial requests per second. + 5. Divide the result by 50 requests per channel to determine the minimum optimal channel pool size. (If your calculation is less than 2, use at least 2 channels anyway, to ensure redundancy.) + 6. Divide the same result by 10 requests per channel to determine the maximum optimal channel pool size. + + These steps are expressed in the following equations: + ```java + (QPS ÷ (1,000 ÷ latency ms)) ÷ 50 streams = Minimum optimal number of connections + (QPS ÷ (1,000 ÷ latency ms)) ÷ 10 streams = Maximum optimal number of connections + ``` + + ###### Example + Your application typically sends 50,000 requests per second, and the average latency is 10 ms. Divide 1,000 by 10 ms to determine that you can send 100 requests serially per second. + Divide that number into 50,000 to get the parallelism needed to send 50,000 QPS: 500. Each channel can have at most 100 requests out concurrently, and your target channel utilization + is between 10 and 50 concurrent streams. Therefore, to calculate the minimum, divide 500 by 50 to get 10. To find the maximum, divide 500 by 10 to get 50. This means that your channel + pool size for this example should be between 10 and 50 connections. + + It is also important to monitor your traffic after making changes and adjust the number of connections in your pool if necessary. + + ###### Set the pool size + The following code sample demonstrates how to configure the channel pool in the client libraries using `DatastoreOptions`. + See [ChannelPoolSettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.ChannelPoolSettings) and [Performance Best Practices](https://grpc.io/docs/guides/performance/) for more information on channel pools and best practices for performance. + + Code Example + ```java + InstantiatingGrpcChannelProvider channelProvider = + DatastoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelPoolSettings( + ChannelPoolSettings.builder() + .setInitialChannelCount(MIN_VAL) + .setMaxChannelCount(MAX_VAL) + .build()) + .build(); + + DatastoreOptions options = DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setChannelProvider(channelProvider) + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .build(); + ``` + Testing + ------- + + This library has tools to help write tests for code that uses the Datastore. + + #### On your machine + + You can test against a temporary local Datastore by following these steps: + + 1. [Install Cloud SDK and start the emulator](https://cloud.google.com/datastore/docs/tools/datastore-emulator) + + To determine which host/port the emulator is running on: + + ``` + $ gcloud beta emulators datastore env-init + + # Sample output: + # export DATASTORE_EMULATOR_HOST=localhost:8759 + ``` + + 3. Point your client to the emulator + + ```java + DatastoreOptions options = DatastoreOptions.newBuilder() + .setProjectId(DatastoreOptions.getDefaultProjectId()) + .setHost(System.getenv("DATASTORE_EMULATOR_HOST")) + .setCredentials(NoCredentials.getInstance()) + .setRetrySettings(ServiceOptions.getNoRetrySettings()) + .build(); + Datastore datastore = options.getService(); + ``` + 4. Run your tests + + Example Applications + -------------------- + - [`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/main/bookshelf) - An App Engine app that manages a virtual bookshelf. + - This app uses `google-cloud` to interface with Cloud Datastore and Cloud Storage. It also uses Cloud SQL, another Google Cloud Platform service. + - [`Flexible Environment/Datastore example`](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/flexible/datastore) - A simple app that uses Cloud Datastore to list the last 10 IP addresses that visited your site. + - [`SparkDemo`](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/flexible/sparkjava) - An example of using `google-cloud-datastore` from within the SparkJava and App Engine Flexible Environment frameworks. + - Read about how it works on the example's [README page](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/flexible/sparkjava#how-does-it-work). diff --git a/java-datastore/.repo-metadata.json b/java-datastore/.repo-metadata.json new file mode 100644 index 000000000000..f15aa1b07777 --- /dev/null +++ b/java-datastore/.repo-metadata.json @@ -0,0 +1,22 @@ +{ + "api_shortname": "datastore", + "name_pretty": "Cloud Datastore", + "product_documentation": "https://cloud.google.com/datastore", + "api_description": "is a fully managed, schemaless database for\\nstoring non-relational data. Cloud Datastore automatically scales with\\nyour users and supports ACID transactions, high availability of reads and\\nwrites, strong consistency for reads and ancestor queries, and eventual\\nconsistency for all other queries.", + "client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-datastore/latest/history", + "release_level": "stable", + "transport": "both", + "language": "java", + "repo": "googleapis/google-cloud-java", + "repo_short": "java-datastore", + "distribution_name": "com.google.cloud:google-cloud-datastore", + "api_id": "datastore.googleapis.com", + "library_type": "GAPIC_COMBO", + "requires_billing": true, + "codeowner_team": "@googleapis/cloud-native-db-dpes @googleapis/api-datastore-sdk @googleapis/api-firestore-partners", + "excluded_dependencies": "grpc-google-cloud-datastore-v1", + "excluded_poms": "grpc-google-cloud-datastore-v1", + "issue_tracker": "https://issuetracker.google.com/savedsearches/559768", + "extra_versioned_modules": "datastore-v1-proto-client", + "recommended_package": "com.google.cloud.datastore" +} \ No newline at end of file diff --git a/java-datastore/CHANGELOG.md b/java-datastore/CHANGELOG.md new file mode 100644 index 000000000000..73068ed171cd --- /dev/null +++ b/java-datastore/CHANGELOG.md @@ -0,0 +1,1674 @@ +# Changelog + +## [2.33.2](https://github.com/googleapis/java-datastore/compare/v2.33.1...v2.33.2) (2026-01-15) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.65.0 ([4d7dd5a](https://github.com/googleapis/java-datastore/commit/4d7dd5a7e054bd552e5c5a81c8634dcaab4630f0)) +* **deps:** Update the Java code generator (gapic-generator-java) to 2.65.1 ([5d9bfd2](https://github.com/googleapis/java-datastore/commit/5d9bfd206ba9adc5ab9a9b16f5614ab7014cae92)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.55.1 ([#2027](https://github.com/googleapis/java-datastore/issues/2027)) ([6442e10](https://github.com/googleapis/java-datastore/commit/6442e1060e80b8476ba4635e1d7cf77f58f8f9eb)) +* Update googleapis/sdk-platform-java action to v2.65.1 ([#2029](https://github.com/googleapis/java-datastore/issues/2029)) ([de3236d](https://github.com/googleapis/java-datastore/commit/de3236d23abdafe9836310b097b1ff17642f16d8)) + +## [2.33.1](https://github.com/googleapis/java-datastore/compare/v2.33.0...v2.33.1) (2025-12-11) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.64.2 ([b5f1285](https://github.com/googleapis/java-datastore/commit/b5f1285bb783c004464b0f7e8b1fcea567ea22d5)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.54.2 ([#2011](https://github.com/googleapis/java-datastore/issues/2011)) ([c2062e7](https://github.com/googleapis/java-datastore/commit/c2062e77f0ae50981ff381bd82151720f31aa83a)) +* Update googleapis/sdk-platform-java action to v2.64.2 ([#2012](https://github.com/googleapis/java-datastore/issues/2012)) ([3ad3168](https://github.com/googleapis/java-datastore/commit/3ad31689197a97d3496ae10fa3338d15d9df022f)) + +## [2.33.0](https://github.com/googleapis/java-datastore/compare/v2.32.3...v2.33.0) (2025-11-13) + + +### Features + +* Enable flag for report generation ([#1991](https://github.com/googleapis/java-datastore/issues/1991)) ([767a558](https://github.com/googleapis/java-datastore/commit/767a558d7cd8b4ba791fe5d304757e660f7935ff)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.64.1 ([216e771](https://github.com/googleapis/java-datastore/commit/216e771f9181f03f4add7e35bf11c5f64f80b6a7)) + + +### Dependencies + +* Manage Opentelemetry version from Shared-Deps ([#1995](https://github.com/googleapis/java-datastore/issues/1995)) ([5f6c500](https://github.com/googleapis/java-datastore/commit/5f6c500d3fb092d87669550ff882782b10199a03)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.54.1 ([#1994](https://github.com/googleapis/java-datastore/issues/1994)) ([11265fd](https://github.com/googleapis/java-datastore/commit/11265fdee02b429803d2d2c7d1e7f5a735e11757)) + +## [2.32.3](https://github.com/googleapis/java-datastore/compare/v2.32.2...v2.32.3) (2025-10-20) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.63.0 ([b9b95cb](https://github.com/googleapis/java-datastore/commit/b9b95cb0b08ec393f714f885e511443c1e044a0e)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.53.0 ([#1980](https://github.com/googleapis/java-datastore/issues/1980)) ([1520b7c](https://github.com/googleapis/java-datastore/commit/1520b7c4ac51139c1c8809a4ead990d558f6c705)) + +## [2.32.2](https://github.com/googleapis/java-datastore/compare/v2.32.1...v2.32.2) (2025-10-04) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.52.3 ([#1973](https://github.com/googleapis/java-datastore/issues/1973)) ([141ec94](https://github.com/googleapis/java-datastore/commit/141ec943cd6e619a64a48e14053119aeb5238817)) + +## [2.32.1](https://github.com/googleapis/java-datastore/compare/v2.32.0...v2.32.1) (2025-09-26) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.52.2 ([#1969](https://github.com/googleapis/java-datastore/issues/1969)) ([2243471](https://github.com/googleapis/java-datastore/commit/22434714d50d9da1c6034bf9dbec745a62abc731)) + +## [2.32.0](https://github.com/googleapis/java-datastore/compare/v2.31.4...v2.32.0) (2025-09-12) + + +### Features + +* Add sample code for connection pooling ([#1947](https://github.com/googleapis/java-datastore/issues/1947)) ([57981db](https://github.com/googleapis/java-datastore/commit/57981db8fb73f35bf72a9c1c5d53bd06dedf0ebc)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.52.1 ([#1963](https://github.com/googleapis/java-datastore/issues/1963)) ([833a34a](https://github.com/googleapis/java-datastore/commit/833a34a7e5ab1194d2ac8ebf097d7c300d7e8d37)) + +## [2.31.4](https://github.com/googleapis/java-datastore/compare/v2.31.3...v2.31.4) (2025-08-22) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.62.0 ([90f5526](https://github.com/googleapis/java-datastore/commit/90f552624627b3ca6fde4b4241b66893019174dd)) + +## [2.31.3](https://github.com/googleapis/java-datastore/compare/v2.31.2...v2.31.3) (2025-08-20) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.52.0 ([#1944](https://github.com/googleapis/java-datastore/issues/1944)) ([30a6e28](https://github.com/googleapis/java-datastore/commit/30a6e2856ee87568f14bbe94fe5918a4ecea4612)) + +## [2.31.2](https://github.com/googleapis/java-datastore/compare/v2.31.1...v2.31.2) (2025-08-08) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.61.0 ([c7bd68d](https://github.com/googleapis/java-datastore/commit/c7bd68de82ec06f06c41cd12e87cc96a337dcd02)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.51.0 ([#1936](https://github.com/googleapis/java-datastore/issues/1936)) ([a25433f](https://github.com/googleapis/java-datastore/commit/a25433f805f957dc0beebaeef466aa20f14f8ccc)) + +## [2.31.1](https://github.com/googleapis/java-datastore/compare/v2.31.0...v2.31.1) (2025-07-28) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.60.2 ([06372cd](https://github.com/googleapis/java-datastore/commit/06372cd63a7ce35747d90c62cc1d57be0a6ffb37)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.50.2 ([#1926](https://github.com/googleapis/java-datastore/issues/1926)) ([1ecdf37](https://github.com/googleapis/java-datastore/commit/1ecdf377b2a6ccb2ffd231744726807b0493df79)) + +## [2.31.0](https://github.com/googleapis/java-datastore/compare/v2.30.0...v2.31.0) (2025-07-14) + + +### Features + +* Next release from main branch is 2.31.0 ([#1912](https://github.com/googleapis/java-datastore/issues/1912)) ([a74c46b](https://github.com/googleapis/java-datastore/commit/a74c46bfbac8eaf5c97fe653b740e26e7c79f4da)) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.61.0 ([#1901](https://github.com/googleapis/java-datastore/issues/1901)) ([beeb125](https://github.com/googleapis/java-datastore/commit/beeb125efc842776facfa67742bdf8b6c167e9f2)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.50.1 ([#1908](https://github.com/googleapis/java-datastore/issues/1908)) ([b10e0f0](https://github.com/googleapis/java-datastore/commit/b10e0f0748decf06574fc0eb7ddba33ee5ece1a7)) + +## [2.30.0](https://github.com/googleapis/java-datastore/compare/v2.29.2...v2.30.0) (2025-06-26) + + +### Features + +* Enable grpc configurator for client-side tracing ([#1886](https://github.com/googleapis/java-datastore/issues/1886)) ([97004c8](https://github.com/googleapis/java-datastore/commit/97004c85d73541ccfc26e0f4212e3a447d3e4ba6)) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.60.0 ([#1799](https://github.com/googleapis/java-datastore/issues/1799)) ([bf2a33c](https://github.com/googleapis/java-datastore/commit/bf2a33c32a04b978a19fd6dfbe845769c921fa4f)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.50.0 ([#1897](https://github.com/googleapis/java-datastore/issues/1897)) ([a8d99cd](https://github.com/googleapis/java-datastore/commit/a8d99cde26c38376b596f44379f4d069b25339b2)) +* Update googleapis/sdk-platform-java action to v2.59.1 ([#1880](https://github.com/googleapis/java-datastore/issues/1880)) ([4fb9929](https://github.com/googleapis/java-datastore/commit/4fb992943152bb4533e0bbd80e373de61f5ec864)) +* Update googleapis/sdk-platform-java action to v2.60.0 ([#1898](https://github.com/googleapis/java-datastore/issues/1898)) ([0921f86](https://github.com/googleapis/java-datastore/commit/0921f869ff4a19e7c0fe918aea0896922e9a18af)) + +## [2.29.2](https://github.com/googleapis/java-datastore/compare/v2.29.1...v2.29.2) (2025-06-13) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.59.0 ([910a6c2](https://github.com/googleapis/java-datastore/commit/910a6c20cb23f441ede5cd75972c65adbb8752e8)) + +## [2.29.1](https://github.com/googleapis/java-datastore/compare/v2.29.0...v2.29.1) (2025-06-07) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.49.0 ([#1860](https://github.com/googleapis/java-datastore/issues/1860)) ([0eff028](https://github.com/googleapis/java-datastore/commit/0eff0284bf78152341e1692ffc57930f62ec01dc)) + +## [2.29.0](https://github.com/googleapis/java-datastore/compare/v2.28.2...v2.29.0) (2025-06-06) + + +### Features + +* Add getNumber to AggregationResult (https://github.com/googleapis/java-datastore/issues/1851) ([#1861](https://github.com/googleapis/java-datastore/issues/1861)) ([b9c2c3f](https://github.com/googleapis/java-datastore/commit/b9c2c3ff775f7123d701ccacff9bd2ea3718243b)) + + +### Bug Fixes + +* Remove 500 char path name limit ([#1865](https://github.com/googleapis/java-datastore/issues/1865)) ([1097175](https://github.com/googleapis/java-datastore/commit/10971752310d8b1794c8e77041b582707142b328)) + + +### Dependencies + +* Update dependency org.easymock:easymock to v5.6.0 ([#1858](https://github.com/googleapis/java-datastore/issues/1858)) ([acc1513](https://github.com/googleapis/java-datastore/commit/acc1513ad90e8da6743e618322bae075bac4ac46)) + +## [2.28.2](https://github.com/googleapis/java-datastore/compare/v2.28.1...v2.28.2) (2025-05-16) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.48.0 ([#1847](https://github.com/googleapis/java-datastore/issues/1847)) ([7ed3232](https://github.com/googleapis/java-datastore/commit/7ed32321a5c84c4b2f61094e4c4adb5e36e5bc1b)) +* Update googleapis/sdk-platform-java action to v2.58.0 ([#1853](https://github.com/googleapis/java-datastore/issues/1853)) ([eef820d](https://github.com/googleapis/java-datastore/commit/eef820d017f5e00245924d551abe172a2a39e29f)) + +## [2.28.1](https://github.com/googleapis/java-datastore/compare/v2.28.0...v2.28.1) (2025-05-06) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.47.0 ([#1841](https://github.com/googleapis/java-datastore/issues/1841)) ([ac393e6](https://github.com/googleapis/java-datastore/commit/ac393e61e517d30b534be3e99070c210081c4f0b)) +* Update googleapis/sdk-platform-java action to v2.57.0 ([#1842](https://github.com/googleapis/java-datastore/issues/1842)) ([0745906](https://github.com/googleapis/java-datastore/commit/0745906bbdd8819ac2ccaafa301c8f4b4fd20be4)) + +## [2.28.0](https://github.com/googleapis/java-datastore/compare/v2.27.2...v2.28.0) (2025-04-29) + + +### Features + +* Java datastore gapic upgrade ([#1824](https://github.com/googleapis/java-datastore/issues/1824)) ([a296d43](https://github.com/googleapis/java-datastore/commit/a296d43724c57aba6a69ebed249261e3d367d625)) + +## [2.27.2](https://github.com/googleapis/java-datastore/compare/v2.27.1...v2.27.2) (2025-04-25) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.56.2 ([1210f32](https://github.com/googleapis/java-datastore/commit/1210f32662e7aafd2e170643bedbb851f40f3646)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.46.2 ([#1823](https://github.com/googleapis/java-datastore/issues/1823)) ([4d2026c](https://github.com/googleapis/java-datastore/commit/4d2026c330009becc201a95c42af365cc83b8ea5)) + +## [2.27.1](https://github.com/googleapis/java-datastore/compare/v2.27.0...v2.27.1) (2025-03-18) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.55.1 ([ba1ad98](https://github.com/googleapis/java-datastore/commit/ba1ad98cce4c0feae13a370ea0581d15674dd43c)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.45.1 ([#1791](https://github.com/googleapis/java-datastore/issues/1791)) ([ab5ac8e](https://github.com/googleapis/java-datastore/commit/ab5ac8e6407541520fabb4504fcce0d675347f63)) + +## [2.27.0](https://github.com/googleapis/java-datastore/compare/v2.26.4...v2.27.0) (2025-03-05) + + +### Features + +* Next release from main branch is 2.27.0 ([#1781](https://github.com/googleapis/java-datastore/issues/1781)) ([d29f47c](https://github.com/googleapis/java-datastore/commit/d29f47cbef9998acdc8b7b0f42d93574dab3cc7f)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.54.0 ([b9b302b](https://github.com/googleapis/java-datastore/commit/b9b302bb6c8bb1c8d8b175b776b2f65317511987)) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.53.0 ([#1779](https://github.com/googleapis/java-datastore/issues/1779)) ([8369118](https://github.com/googleapis/java-datastore/commit/8369118994e9a18b888a7779376fea7e22b219ed)) + +## [2.26.4](https://github.com/googleapis/java-datastore/compare/v2.26.3...v2.26.4) (2025-02-26) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.44.0 ([#1769](https://github.com/googleapis/java-datastore/issues/1769)) ([7a86509](https://github.com/googleapis/java-datastore/commit/7a8650939e652fc3b384053454d6ef5084bb1508)) + +## [2.26.3](https://github.com/googleapis/java-datastore/compare/v2.26.2...v2.26.3) (2025-02-21) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.52.0 ([#1747](https://github.com/googleapis/java-datastore/issues/1747)) ([592072b](https://github.com/googleapis/java-datastore/commit/592072b194706e63a7fd4a6f6230377e8f4b729d)) + +## [2.26.2](https://github.com/googleapis/java-datastore/compare/v2.26.1...v2.26.2) (2025-02-12) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.53.0 ([be0d0cd](https://github.com/googleapis/java-datastore/commit/be0d0cd960b9254d26404d9331b78dee1104cf0a)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.43.0 ([#1737](https://github.com/googleapis/java-datastore/issues/1737)) ([7272a41](https://github.com/googleapis/java-datastore/commit/7272a4197a0d7fb97ee039ccb88ac13a1ec037d1)) +* Update googleapis/sdk-platform-java action to v2.53.0 ([#1738](https://github.com/googleapis/java-datastore/issues/1738)) ([b8a7a5d](https://github.com/googleapis/java-datastore/commit/b8a7a5d5d8700ccccb643162843e3043396a9444)) + +## [2.26.1](https://github.com/googleapis/java-datastore/compare/v2.26.0...v2.26.1) (2025-02-05) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.52.0 ([9594024](https://github.com/googleapis/java-datastore/commit/95940241de9f324000d52dc80b3106aedefd481e)) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.51.0 ([#1726](https://github.com/googleapis/java-datastore/issues/1726)) ([89f31a8](https://github.com/googleapis/java-datastore/commit/89f31a88d346193c9a5533de3e38c9088db30043)) + +## [2.26.0](https://github.com/googleapis/java-datastore/compare/v2.25.4...v2.26.0) (2025-01-29) + + +### Features + +* Add firestoreInDatastoreMode for datastore emulator ([#1698](https://github.com/googleapis/java-datastore/issues/1698)) ([50f106d](https://github.com/googleapis/java-datastore/commit/50f106d4c50884ce471a66c00df322270fe4a91c)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.42.0 ([#1725](https://github.com/googleapis/java-datastore/issues/1725)) ([1cbaf22](https://github.com/googleapis/java-datastore/commit/1cbaf22cf557aec606dce7a5ca5d3ebe620a9339)) + +## [2.25.4](https://github.com/googleapis/java-datastore/compare/v2.25.3...v2.25.4) (2025-01-22) + + +### Dependencies + +* Update dependency org.easymock:easymock to v5.5.0 ([#1666](https://github.com/googleapis/java-datastore/issues/1666)) ([0333b07](https://github.com/googleapis/java-datastore/commit/0333b0744bab87afe78dad1c17f6811d3dec47e6)) + +## [2.25.3](https://github.com/googleapis/java-datastore/compare/v2.25.2...v2.25.3) (2025-01-15) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.50.0 ([#1708](https://github.com/googleapis/java-datastore/issues/1708)) ([b78660f](https://github.com/googleapis/java-datastore/commit/b78660f3866ce5c1198db4590b5e1f645170ecff)) + +## [2.25.2](https://github.com/googleapis/java-datastore/compare/v2.25.1...v2.25.2) (2025-01-09) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.51.1 ([90d8b30](https://github.com/googleapis/java-datastore/commit/90d8b3034d5a583d880a822d1e763035a2120f4a)) +* Fix emulator command arg data-dir ([#1695](https://github.com/googleapis/java-datastore/issues/1695)) ([9d53195](https://github.com/googleapis/java-datastore/commit/9d531957da3f017f0702a126601eaa8afe3113d6)) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.49.0 ([#1693](https://github.com/googleapis/java-datastore/issues/1693)) ([8160c28](https://github.com/googleapis/java-datastore/commit/8160c2895e947c118cea24e92d9a31a1fdf4653f)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.41.1 ([#1703](https://github.com/googleapis/java-datastore/issues/1703)) ([bf9537f](https://github.com/googleapis/java-datastore/commit/bf9537f81b6e7cc2252ad0183fb87db656b009d7)) +* Update dependency com.google.guava:guava-testlib to v33.4.0-jre ([#1694](https://github.com/googleapis/java-datastore/issues/1694)) ([b91a2af](https://github.com/googleapis/java-datastore/commit/b91a2af534eb7568ec86a0b27a80a6bd2943af7b)) + +## [2.25.1](https://github.com/googleapis/java-datastore/compare/v2.25.0...v2.25.1) (2024-12-13) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.51.0 ([106ee4d](https://github.com/googleapis/java-datastore/commit/106ee4dd7ca4dd9e59a5419f59b8625680e60f15)) + + +### Dependencies + +* Update sdk platform java dependencies ([#1685](https://github.com/googleapis/java-datastore/issues/1685)) ([4372350](https://github.com/googleapis/java-datastore/commit/4372350117ba57903f510512a383339b6a4ea47c)) + +## [2.25.0](https://github.com/googleapis/java-datastore/compare/v2.24.3...v2.25.0) (2024-12-11) + + +### Features + +* Introduce `java.time` methods and variables ([#1671](https://github.com/googleapis/java-datastore/issues/1671)) ([5a78a80](https://github.com/googleapis/java-datastore/commit/5a78a8075867f4b2fc598f0423bd2ab65b559856)) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.48.0 ([#1605](https://github.com/googleapis/java-datastore/issues/1605)) ([5c6a678](https://github.com/googleapis/java-datastore/commit/5c6a67844f7b5d4c7001cccd1bed3d0d56be6e90)) + + +### Documentation + +* Update gapic upgrade installation instructions ([#1677](https://github.com/googleapis/java-datastore/issues/1677)) ([b3fbfcc](https://github.com/googleapis/java-datastore/commit/b3fbfcc9654bc63bf0d8f3025641d8c50a24ef97)) + +## [2.24.3](https://github.com/googleapis/java-datastore/compare/v2.24.2...v2.24.3) (2024-11-18) + + +### Dependencies + +* Update sdk platform java dependencies ([#1662](https://github.com/googleapis/java-datastore/issues/1662)) ([b4d3ab9](https://github.com/googleapis/java-datastore/commit/b4d3ab9a72bb2a4dff59bf54abcc5d9536b2596b)) + +## [2.24.2](https://github.com/googleapis/java-datastore/compare/v2.24.1...v2.24.2) (2024-11-06) + + +### Bug Fixes + +* **doc:** Add discriptions for TransactionCallable interface ([#1644](https://github.com/googleapis/java-datastore/issues/1644)) ([173a883](https://github.com/googleapis/java-datastore/commit/173a88330cc5693f54504348cf39bf3191db2250)) +* **doc:** Fix return types for batch interface ([#1645](https://github.com/googleapis/java-datastore/issues/1645)) ([1189211](https://github.com/googleapis/java-datastore/commit/11892116f0fb8eacb711a8f48e780e48a232f987)) + +## [2.24.1](https://github.com/googleapis/java-datastore/compare/v2.24.0...v2.24.1) (2024-10-28) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.39.0 ([#1640](https://github.com/googleapis/java-datastore/issues/1640)) ([fe61f66](https://github.com/googleapis/java-datastore/commit/fe61f6691a5e3c8fbfc974b6fe613a69652241ca)) +* Update googleapis/sdk-platform-java action to v2.49.0 ([#1638](https://github.com/googleapis/java-datastore/issues/1638)) ([57598d7](https://github.com/googleapis/java-datastore/commit/57598d7d59cd6917f23a653403613e4edc160c64)) + +## [2.24.0](https://github.com/googleapis/java-datastore/compare/v2.23.0...v2.24.0) (2024-10-24) + + +### Features + +* Add FindNearest API to the stable branch ([3512ba2](https://github.com/googleapis/java-datastore/commit/3512ba2f1bcd358e3c39c36944e05873b3f25f51)) + + +### Bug Fixes + +* **sample:** Change update entity sample to use transaction ([#1633](https://github.com/googleapis/java-datastore/issues/1633)) ([c44f17a](https://github.com/googleapis/java-datastore/commit/c44f17a7bb93d688367611ee2533c59c940ae61f)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.38.0 ([#1632](https://github.com/googleapis/java-datastore/issues/1632)) ([6453f1e](https://github.com/googleapis/java-datastore/commit/6453f1e44f370a13434ef68295ae5638612032c8)) +* Update googleapis/sdk-platform-java action to v2.48.0 ([#1628](https://github.com/googleapis/java-datastore/issues/1628)) ([d3bce79](https://github.com/googleapis/java-datastore/commit/d3bce79467254b3128a8f16d5754e91d29ece525)) + +## [2.23.0](https://github.com/googleapis/java-datastore/compare/v2.22.0...v2.23.0) (2024-10-14) + + +### Features + +* Support for field update operators in the Datastore API and resolution strategies when there is a conflict at write time ([b299266](https://github.com/googleapis/java-datastore/commit/b299266e42037b731ee7bbba21dbded73a37323c)) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.46.1 ([678eee2](https://github.com/googleapis/java-datastore/commit/678eee2dfb6d447a852edd436137f8ebfbe50d74)) +* **deps:** Update the Java code generator (gapic-generator-java) to 2.47.0 ([b299266](https://github.com/googleapis/java-datastore/commit/b299266e42037b731ee7bbba21dbded73a37323c)) + + +### Dependencies + +* Update sdk platform java dependencies ([#1617](https://github.com/googleapis/java-datastore/issues/1617)) ([6eaff23](https://github.com/googleapis/java-datastore/commit/6eaff23f9de25ae6ad2a4fea67c0b65a243c08fd)) + +## [2.22.0](https://github.com/googleapis/java-datastore/compare/v2.21.3...v2.22.0) (2024-09-26) + + +### Features + +* Add sample code for multiple inequalities indexing consideration query ([#1579](https://github.com/googleapis/java-datastore/issues/1579)) ([1286792](https://github.com/googleapis/java-datastore/commit/1286792d7b49229d698df652cd117d229a5cd97e)) +* Introducing Tracing with OpenTelemetry API [#1537](https://github.com/googleapis/java-datastore/issues/1537) ([#1576](https://github.com/googleapis/java-datastore/issues/1576)) ([5440c22](https://github.com/googleapis/java-datastore/commit/5440c22364074c108450c3a748a6a17d5f1dddda)) + + +### Bug Fixes + +* Update opentelemetry-sdk dependency to be test-only ([#1595](https://github.com/googleapis/java-datastore/issues/1595)) ([9d719e8](https://github.com/googleapis/java-datastore/commit/9d719e809ea830d8602399b72e432580f14ae6bd)) +* Update opentelemetry.version to 1.42.1 to match the BOM version ([#1598](https://github.com/googleapis/java-datastore/issues/1598)) ([23c5c26](https://github.com/googleapis/java-datastore/commit/23c5c2662117370c66c611604c56b878d41f4738)) + + +### Dependencies + +* Update dependency com.google.cloud:gapic-libraries-bom to v1.43.0 ([#1584](https://github.com/googleapis/java-datastore/issues/1584)) ([fae3b74](https://github.com/googleapis/java-datastore/commit/fae3b74eaa3494a27fd43f56435c01e8fc09e5ee)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.36.0 ([#1590](https://github.com/googleapis/java-datastore/issues/1590)) ([2db9e43](https://github.com/googleapis/java-datastore/commit/2db9e439189baf8f97127f6cff1de5d47efb0073)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.36.1 ([#1602](https://github.com/googleapis/java-datastore/issues/1602)) ([e1b7d4b](https://github.com/googleapis/java-datastore/commit/e1b7d4b205312d7d4c2a285f3d1f61388da65c83)) +* Update dependency com.google.guava:guava-testlib to v33.3.1-jre ([#1592](https://github.com/googleapis/java-datastore/issues/1592)) ([5d078a4](https://github.com/googleapis/java-datastore/commit/5d078a4b294d071716f51f0d4b9baa5d65a0fe90)) +* Update dependency com.google.testparameterinjector:test-parameter-injector to v1.17 ([#1585](https://github.com/googleapis/java-datastore/issues/1585)) ([8f74a49](https://github.com/googleapis/java-datastore/commit/8f74a49c5982d00bd168e78671163683f7b41126)) + +## [2.21.3](https://github.com/googleapis/java-datastore/compare/v2.21.2...v2.21.3) (2024-09-11) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.35.0 ([#1561](https://github.com/googleapis/java-datastore/issues/1561)) ([5a79fd8](https://github.com/googleapis/java-datastore/commit/5a79fd8d1202e65c02423fe40402c41af6050efa)) +* Update dependency com.google.errorprone:error_prone_core to v2.31.0 ([#1523](https://github.com/googleapis/java-datastore/issues/1523)) ([8d3af32](https://github.com/googleapis/java-datastore/commit/8d3af322fb56032cd7a9d29e60fd93d1f3e7e632)) +* Update dependency com.google.guava:guava-testlib to v33.3.0-jre ([#1548](https://github.com/googleapis/java-datastore/issues/1548)) ([18ba37f](https://github.com/googleapis/java-datastore/commit/18ba37f60b5b3e69c95f6e55a28daf8c0de82ba9)) +* Update dependency org.easymock:easymock to v5.4.0 ([#1482](https://github.com/googleapis/java-datastore/issues/1482)) ([ee788a1](https://github.com/googleapis/java-datastore/commit/ee788a162841994e09a61bb81b94cbe93353a78e)) + +## [2.21.2](https://github.com/googleapis/java-datastore/compare/v2.21.1...v2.21.2) (2024-08-22) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.34.0 ([#1547](https://github.com/googleapis/java-datastore/issues/1547)) ([8c5f595](https://github.com/googleapis/java-datastore/commit/8c5f5954d88732ab929b4477a3f15b0052adc2ff)) + +## [2.21.1](https://github.com/googleapis/java-datastore/compare/v2.21.0...v2.21.1) (2024-08-06) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.33.0 ([#1531](https://github.com/googleapis/java-datastore/issues/1531)) ([9e52395](https://github.com/googleapis/java-datastore/commit/9e52395f7ee71315331790284d35e7aad2f387ed)) + +## [2.21.0](https://github.com/googleapis/java-datastore/compare/v2.20.2...v2.21.0) (2024-07-31) + + +### Features + +* Enable hermetic library generation ([#1462](https://github.com/googleapis/java-datastore/issues/1462)) ([d142d9c](https://github.com/googleapis/java-datastore/commit/d142d9c95d91c8cadaf696efc12d6136814938ff)) + +## [2.20.2](https://github.com/googleapis/java-datastore/compare/v2.20.1...v2.20.2) (2024-06-28) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.32.0 ([#1492](https://github.com/googleapis/java-datastore/issues/1492)) ([d940c93](https://github.com/googleapis/java-datastore/commit/d940c937959942d753f9215e7ce940ab6742be46)) + +## [2.20.1](https://github.com/googleapis/java-datastore/compare/v2.20.0...v2.20.1) (2024-06-04) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.31.0 ([#1471](https://github.com/googleapis/java-datastore/issues/1471)) ([42c643d](https://github.com/googleapis/java-datastore/commit/42c643d78562c5cbd6c17c29a0a124be8d05198a)) +* Update dependency com.google.errorprone:error_prone_core to v2.28.0 ([#1469](https://github.com/googleapis/java-datastore/issues/1469)) ([e3fac2b](https://github.com/googleapis/java-datastore/commit/e3fac2bf9992fcb2e91319df0520094865de2d49)) +* Update dependency com.google.guava:guava-testlib to v33.2.1-jre ([#1470](https://github.com/googleapis/java-datastore/issues/1470)) ([614e930](https://github.com/googleapis/java-datastore/commit/614e930f2bdccc517d4733e5fb7f3cefad696a20)) + +## [2.20.0](https://github.com/googleapis/java-datastore/compare/v2.19.3...v2.20.0) (2024-05-27) + + +### Features + +* New PropertyMask field which allows partial commits, lookups, and query results ([#1455](https://github.com/googleapis/java-datastore/issues/1455)) ([ff5e397](https://github.com/googleapis/java-datastore/commit/ff5e39775446216b4806f55f14dacb7fc8e8854b)) + + +### Bug Fixes + +* Migrate off TextPrinter's deprecated methods ([#1452](https://github.com/googleapis/java-datastore/issues/1452)) ([c3c1317](https://github.com/googleapis/java-datastore/commit/c3c131735863d71971110e2ac7ac0244ce16ee92)) +* Set the correct database id on the key parent when calling Key#getParent ([#1457](https://github.com/googleapis/java-datastore/issues/1457)) ([992815d](https://github.com/googleapis/java-datastore/commit/992815d9989d04f7b371dfa320ed17894626a07f)) + +## [2.19.3](https://github.com/googleapis/java-datastore/compare/v2.19.2...v2.19.3) (2024-05-16) + + +### Dependencies + +* Update actions/checkout action to v4 ([#1390](https://github.com/googleapis/java-datastore/issues/1390)) ([80dbca1](https://github.com/googleapis/java-datastore/commit/80dbca1246facf21b08d33e5c6a09b9708b6ce63)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.30.1 ([#1443](https://github.com/googleapis/java-datastore/issues/1443)) ([79f6c46](https://github.com/googleapis/java-datastore/commit/79f6c46bdbabc66082f23e9562ee9541e0fdeac9)) + +## [2.19.2](https://github.com/googleapis/java-datastore/compare/v2.19.1...v2.19.2) (2024-05-03) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.39.0 ([#1406](https://github.com/googleapis/java-datastore/issues/1406)) ([b265fb3](https://github.com/googleapis/java-datastore/commit/b265fb3c3b8ebc972edbe5a7beae816379846dac)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.30.0 ([#1426](https://github.com/googleapis/java-datastore/issues/1426)) ([ac3a1c1](https://github.com/googleapis/java-datastore/commit/ac3a1c10f64c8338346f8fb39f4857f47e8fc639)) +* Update dependency com.google.errorprone:error_prone_core to v2.27.0 ([#1411](https://github.com/googleapis/java-datastore/issues/1411)) ([a3f5a2c](https://github.com/googleapis/java-datastore/commit/a3f5a2c24bff408479541e08278e888cf3166727)) +* Update dependency com.google.errorprone:error_prone_core to v2.27.1 ([#1421](https://github.com/googleapis/java-datastore/issues/1421)) ([48d7daf](https://github.com/googleapis/java-datastore/commit/48d7dafc0c7a49e95bf41d29865ac872b0de0faf)) +* Update dependency com.google.guava:guava-testlib to v33.2.0-jre ([#1422](https://github.com/googleapis/java-datastore/issues/1422)) ([5a5dfdf](https://github.com/googleapis/java-datastore/commit/5a5dfdfb0855cf485b875ab071b79979d24f98dd)) + +## [2.19.1](https://github.com/googleapis/java-datastore/compare/v2.19.0...v2.19.1) (2024-04-19) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.29.0 ([#1403](https://github.com/googleapis/java-datastore/issues/1403)) ([d23dc4c](https://github.com/googleapis/java-datastore/commit/d23dc4c26a95f2c323ade4db9a88d5435a173be8)) + +## [2.19.0](https://github.com/googleapis/java-datastore/compare/v2.18.6...v2.19.0) (2024-03-25) + + +### Features + +* Implement query profile ([#1365](https://github.com/googleapis/java-datastore/issues/1365)) ([2515ed6](https://github.com/googleapis/java-datastore/commit/2515ed6cf733df84069309a3055a21cdd65c9c90)) + +## [2.18.6](https://github.com/googleapis/java-datastore/compare/v2.18.5...v2.18.6) (2024-03-18) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.37.0 ([#1355](https://github.com/googleapis/java-datastore/issues/1355)) ([bcc5668](https://github.com/googleapis/java-datastore/commit/bcc5668039d4dd2055e9666a65fcda3984fc33b5)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.28.0 ([#1372](https://github.com/googleapis/java-datastore/issues/1372)) ([09db2a7](https://github.com/googleapis/java-datastore/commit/09db2a75fa714a909bc6fa9b43a9213ae6467c84)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.28.1 ([#1373](https://github.com/googleapis/java-datastore/issues/1373)) ([c6e63e5](https://github.com/googleapis/java-datastore/commit/c6e63e5f876fdda953935d09f0536a90a98a812c)) +* Update dependency com.google.errorprone:error_prone_core to v2.26.0 ([#1361](https://github.com/googleapis/java-datastore/issues/1361)) ([9442766](https://github.com/googleapis/java-datastore/commit/9442766ad61b0c1001d36ecfc0668308838b4a83)) +* Update dependency com.google.errorprone:error_prone_core to v2.26.1 ([#1363](https://github.com/googleapis/java-datastore/issues/1363)) ([05fe5bc](https://github.com/googleapis/java-datastore/commit/05fe5bccf97dae92c00f2eead98424771cb321fd)) +* Update dependency com.google.guava:guava-testlib to v33.1.0-jre ([#1368](https://github.com/googleapis/java-datastore/issues/1368)) ([0195345](https://github.com/googleapis/java-datastore/commit/0195345630f404bbcaf1601ded8a8e2011fc3e6e)) + +## [2.18.5](https://github.com/googleapis/java-datastore/compare/v2.18.4...v2.18.5) (2024-03-04) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.27.0 ([#1352](https://github.com/googleapis/java-datastore/issues/1352)) ([124d7ca](https://github.com/googleapis/java-datastore/commit/124d7cab46e2fa1ba654369887fb10ffb3f8eaef)) +* Update dependency com.google.errorprone:error_prone_core to v2.25.0 ([#1339](https://github.com/googleapis/java-datastore/issues/1339)) ([0c6702e](https://github.com/googleapis/java-datastore/commit/0c6702e27917b976c76a0d44d3f5d550418310be)) + +## [2.18.4](https://github.com/googleapis/java-datastore/compare/v2.18.3...v2.18.4) (2024-02-14) + + +### Dependencies + +* **autogen:** Set packed = false on field_behavior extension ([#1320](https://github.com/googleapis/java-datastore/issues/1320)) ([9cfa1c3](https://github.com/googleapis/java-datastore/commit/9cfa1c37a8a86fcb09ec896dc9219e4416ff2fef)) +* Update dependency com.google.cloud:sdk-platform-java-config to v3.25.0 ([#1333](https://github.com/googleapis/java-datastore/issues/1333)) ([0e64a7d](https://github.com/googleapis/java-datastore/commit/0e64a7da73a3b6d40d5952bf09372d631a7d247b)) + +## [2.18.3](https://github.com/googleapis/java-datastore/compare/v2.18.2...v2.18.3) (2024-02-01) + + +### Bug Fixes + +* Remove QueryMode field from RunAggregationQueryRequest ([c1e7c62](https://github.com/googleapis/java-datastore/commit/c1e7c6201e0e35469df1492a4ce61bf6a095f8be)) +* Remove QueryMode field from RunQueryRequest ([c1e7c62](https://github.com/googleapis/java-datastore/commit/c1e7c6201e0e35469df1492a4ce61bf6a095f8be)) +* Remove ResultSetStats field from RunAggregationQueryResponse ([c1e7c62](https://github.com/googleapis/java-datastore/commit/c1e7c6201e0e35469df1492a4ce61bf6a095f8be)) +* Remove ResultSetStats field from RunQueryResponse ([c1e7c62](https://github.com/googleapis/java-datastore/commit/c1e7c6201e0e35469df1492a4ce61bf6a095f8be)) +* Remove types QueryMode, QueryPlan, ResultSetStats ([#1304](https://github.com/googleapis/java-datastore/issues/1304)) ([c1e7c62](https://github.com/googleapis/java-datastore/commit/c1e7c6201e0e35469df1492a4ce61bf6a095f8be)) + + +### Dependencies + +* Update dependency com.google.cloud:sdk-platform-java-config to v3.24.0 ([#1310](https://github.com/googleapis/java-datastore/issues/1310)) ([26e5f98](https://github.com/googleapis/java-datastore/commit/26e5f9873c4df1815406020a6c22e4a20638f959)) +* Update protobuf to 25.2 in WORKSPACE ([#1311](https://github.com/googleapis/java-datastore/issues/1311)) ([3f4ae83](https://github.com/googleapis/java-datastore/commit/3f4ae83b20f160eaccd9de17582d54d8222dd015)) + +## [2.18.2](https://github.com/googleapis/java-datastore/compare/v2.18.1...v2.18.2) (2024-01-25) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.23.0 ([#1301](https://github.com/googleapis/java-datastore/issues/1301)) ([ac947a5](https://github.com/googleapis/java-datastore/commit/ac947a545235fa41f0ffb52c4e3a0ffc498991e1)) + +## [2.18.1](https://github.com/googleapis/java-datastore/compare/v2.18.0...v2.18.1) (2024-01-22) + + +### Bug Fixes + +* **deps:** Update the Java code generator (gapic-generator-java) to 2.31.0 ([#1278](https://github.com/googleapis/java-datastore/issues/1278)) ([01cced6](https://github.com/googleapis/java-datastore/commit/01cced66613bc10ba71cc80166119e321915ec34)) +* **deps:** Update the Java code generator (gapic-generator-java) to 2.32.0 ([#1293](https://github.com/googleapis/java-datastore/issues/1293)) ([f4ee0cb](https://github.com/googleapis/java-datastore/commit/f4ee0cb4668077f9fb6b0ede1ea69b9033748fe9)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.22.0 ([#1291](https://github.com/googleapis/java-datastore/issues/1291)) ([5a5c78e](https://github.com/googleapis/java-datastore/commit/5a5c78e01a765d3ebce547b54d7d6d16c0894fb2)) + +## [2.18.0](https://github.com/googleapis/java-datastore/compare/v2.17.6...v2.18.0) (2024-01-08) + + +### Features + +* Remove `@BetaApi` annotations from get/setDatabaseId methods ([#1272](https://github.com/googleapis/java-datastore/issues/1272)) ([2bd9a51](https://github.com/googleapis/java-datastore/commit/2bd9a51122248ee242bbcd4914e219d9d5e435bb)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.21.0 ([#1280](https://github.com/googleapis/java-datastore/issues/1280)) ([ac253dc](https://github.com/googleapis/java-datastore/commit/ac253dca1add844124ca03039a996196e09a1759)) +* Update dependency com.google.errorprone:error_prone_core to v2.24.1 ([#1274](https://github.com/googleapis/java-datastore/issues/1274)) ([86cd785](https://github.com/googleapis/java-datastore/commit/86cd7856463c5039601afc10fecc1b28727d4906)) + +## [2.17.6](https://github.com/googleapis/java-datastore/compare/v2.17.5...v2.17.6) (2023-11-30) + + +### Bug Fixes + +* Remove deprecated `databaseId` field in DatastoreOptions ([#1237](https://github.com/googleapis/java-datastore/issues/1237)) ([05e25e5](https://github.com/googleapis/java-datastore/commit/05e25e5d31f72f9cdedbb5efa85c64b55ccbc405)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.20.0 ([#1247](https://github.com/googleapis/java-datastore/issues/1247)) ([c4e3533](https://github.com/googleapis/java-datastore/commit/c4e3533fe357827cc25d0f029e5a83ced31db12a)) +* Update dependency org.junit.vintage:junit-vintage-engine to v5.10.1 ([#1230](https://github.com/googleapis/java-datastore/issues/1230)) ([05c7fc6](https://github.com/googleapis/java-datastore/commit/05c7fc69d52f5a9026a6529f638fe6164860e8f9)) + +## [2.17.5](https://github.com/googleapis/java-datastore/compare/v2.17.4...v2.17.5) (2023-11-02) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.19.0 ([#1226](https://github.com/googleapis/java-datastore/issues/1226)) ([970ac96](https://github.com/googleapis/java-datastore/commit/970ac9652ad16848ccfb26ce248e66956693be9e)) + +## [2.17.4](https://github.com/googleapis/java-datastore/compare/v2.17.3...v2.17.4) (2023-10-23) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.18.0 ([#1215](https://github.com/googleapis/java-datastore/issues/1215)) ([aa82f01](https://github.com/googleapis/java-datastore/commit/aa82f019bcf90f99e6d3d2c96a52d8f2b9a8d27a)) +* Update dependency com.google.errorprone:error_prone_core to v2.23.0 ([#1213](https://github.com/googleapis/java-datastore/issues/1213)) ([c57db43](https://github.com/googleapis/java-datastore/commit/c57db43c783ba6ec16a55d470664990e932971ef)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.28 ([#1216](https://github.com/googleapis/java-datastore/issues/1216)) ([ce4eff2](https://github.com/googleapis/java-datastore/commit/ce4eff24aae8d1e6e02558e627c033dc138891e6)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.28 ([#1217](https://github.com/googleapis/java-datastore/issues/1217)) ([7d56b3c](https://github.com/googleapis/java-datastore/commit/7d56b3cee53e0852873896f7fd22a0414d4b7d83)) + +## [2.17.3](https://github.com/googleapis/java-datastore/compare/v2.17.2...v2.17.3) (2023-10-10) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.17.0 ([#1206](https://github.com/googleapis/java-datastore/issues/1206)) ([2ad068b](https://github.com/googleapis/java-datastore/commit/2ad068b115c6ff7c59394fdba5e0e445028a3fee)) + +## [2.17.2](https://github.com/googleapis/java-datastore/compare/v2.17.1...v2.17.2) (2023-09-26) + + +### Bug Fixes + +* Checksum format ([#1178](https://github.com/googleapis/java-datastore/issues/1178)) ([410b939](https://github.com/googleapis/java-datastore/commit/410b9397bb9ba480dff6217c0c4c27364e58db49)) +* Deprecate `databaseId` on datastore-v1-proto-client DatastoreOptions ([#1190](https://github.com/googleapis/java-datastore/issues/1190)) ([12a3d27](https://github.com/googleapis/java-datastore/commit/12a3d27ebc7ca87338ee896fd6ba3e804edd95ce)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.16.0 ([#1195](https://github.com/googleapis/java-datastore/issues/1195)) ([6f0cad7](https://github.com/googleapis/java-datastore/commit/6f0cad7268cee6347d34125c14c1133b80c840d7)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.16.1 ([#1198](https://github.com/googleapis/java-datastore/issues/1198)) ([8062be9](https://github.com/googleapis/java-datastore/commit/8062be94b00fe2967e592f3d0a35751f0d11a013)) +* Update dependency com.google.errorprone:error_prone_core to v2.22.0 ([#1194](https://github.com/googleapis/java-datastore/issues/1194)) ([b8f108a](https://github.com/googleapis/java-datastore/commit/b8f108a3d013b5b54c519db24b40dd63e4855240)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.26 ([#1176](https://github.com/googleapis/java-datastore/issues/1176)) ([76e3a71](https://github.com/googleapis/java-datastore/commit/76e3a71560222894513a485cb91cec7161276e3c)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.27 ([#1192](https://github.com/googleapis/java-datastore/issues/1192)) ([aa3bca1](https://github.com/googleapis/java-datastore/commit/aa3bca10de19350cabc244426ebc284c64cb7344)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.26 ([#1177](https://github.com/googleapis/java-datastore/issues/1177)) ([7733004](https://github.com/googleapis/java-datastore/commit/7733004aff34bb8b4b8addccc68e75080f0f33a5)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.27 ([#1193](https://github.com/googleapis/java-datastore/issues/1193)) ([a628255](https://github.com/googleapis/java-datastore/commit/a628255dffc2e8f871df699ebe7a94e4b75eb4b9)) +* Update gapic-generator-java to 2.26.0 ([#1197](https://github.com/googleapis/java-datastore/issues/1197)) ([2540282](https://github.com/googleapis/java-datastore/commit/2540282653d8f8f06a71568c81eca8d3cb70f00f)) + +## [2.17.1](https://github.com/googleapis/java-datastore/compare/v2.17.0...v2.17.1) (2023-09-11) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.15.0 ([#1184](https://github.com/googleapis/java-datastore/issues/1184)) ([6cbb795](https://github.com/googleapis/java-datastore/commit/6cbb79589e7eb8648c734bd02579a93423aa4e13)) +* Update dependency org.easymock:easymock to v5.2.0 ([#1180](https://github.com/googleapis/java-datastore/issues/1180)) ([3e62380](https://github.com/googleapis/java-datastore/commit/3e62380ae2793437aa9c4d21fa4484a8896cb49e)) + + +### Documentation + +* Marking AggregationResult#get as Obsolete ([#1185](https://github.com/googleapis/java-datastore/issues/1185)) ([252f854](https://github.com/googleapis/java-datastore/commit/252f8549895250ced3aecf5c082cb0b41ea12472)) + +## [2.17.0](https://github.com/googleapis/java-datastore/compare/v2.16.3...v2.17.0) (2023-08-22) + + +### Features + +* Publish proto definitions for SUM/AVG in Datastore ([#1157](https://github.com/googleapis/java-datastore/issues/1157)) ([954320a](https://github.com/googleapis/java-datastore/commit/954320aaefec249c77c757a1610727519a4029bd)) +* Sum and Avg aggregation feature ([#1067](https://github.com/googleapis/java-datastore/issues/1067)) ([56d1001](https://github.com/googleapis/java-datastore/commit/56d1001005cf7d52f8ba3e5258d6401be729bdbf)) + + +### Dependencies + +* Update dependency com.google.errorprone:error_prone_core to v2.21.1 ([#1163](https://github.com/googleapis/java-datastore/issues/1163)) ([83158b6](https://github.com/googleapis/java-datastore/commit/83158b6172a4a61b3e2a86dea6271ff7f9f84f6b)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.24 ([#1165](https://github.com/googleapis/java-datastore/issues/1165)) ([4094c70](https://github.com/googleapis/java-datastore/commit/4094c702982e4a005a36324892daee451bd16062)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.24 ([#1166](https://github.com/googleapis/java-datastore/issues/1166)) ([70cc371](https://github.com/googleapis/java-datastore/commit/70cc371babd674000fe6f8d78a0f42e75deb5d99)) + + +### Documentation + +* Update property requirement specifications ([#1169](https://github.com/googleapis/java-datastore/issues/1169)) ([c908837](https://github.com/googleapis/java-datastore/commit/c908837ea953a5fdc87f9c83937646d309806e03)) + +## [2.16.3](https://github.com/googleapis/java-datastore/compare/v2.16.2...v2.16.3) (2023-08-02) + + +### Documentation + +* Specify limit for `properties` in `Index` message in Datastore Admin API ([#1149](https://github.com/googleapis/java-datastore/issues/1149)) ([00a696d](https://github.com/googleapis/java-datastore/commit/00a696d5e0fe2ffe6c9e02abd902d1b533265310)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.14.0 ([#1159](https://github.com/googleapis/java-datastore/issues/1159)) ([fcf07d4](https://github.com/googleapis/java-datastore/commit/fcf07d4b5b1f949f1d6b46861406cef88a9a052b)) +* Update dependency com.google.errorprone:error_prone_core to v2.21.0 ([#1158](https://github.com/googleapis/java-datastore/issues/1158)) ([08dbb3a](https://github.com/googleapis/java-datastore/commit/08dbb3ab98870f74b78caa7d160271fccc134ae9)) + +## [2.16.2](https://github.com/googleapis/java-datastore/compare/v2.16.1...v2.16.2) (2023-07-25) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.13.1 ([#1136](https://github.com/googleapis/java-datastore/issues/1136)) ([f4d66af](https://github.com/googleapis/java-datastore/commit/f4d66aff3b86c656998443d12ff1eec301194cfd)) +* Update dependency org.junit.vintage:junit-vintage-engine to v5.10.0 ([#1139](https://github.com/googleapis/java-datastore/issues/1139)) ([a170611](https://github.com/googleapis/java-datastore/commit/a170611e824d6ca6ea14c0ee57c35e3a4ab1eab0)) + +## [2.16.1](https://github.com/googleapis/java-datastore/compare/v2.16.0...v2.16.1) (2023-07-10) + + +### Documentation + +* Fix javadoc errors ([#1126](https://github.com/googleapis/java-datastore/issues/1126)) ([d4b11bb](https://github.com/googleapis/java-datastore/commit/d4b11bbf9198b446365b25617614434865d7e285)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.13.0 ([#1130](https://github.com/googleapis/java-datastore/issues/1130)) ([2181847](https://github.com/googleapis/java-datastore/commit/2181847666bce403743677b06f90b34e5ae180a3)) + +## [2.16.0](https://github.com/googleapis/java-datastore/compare/v2.15.0...v2.16.0) (2023-06-22) + + +### Features + +* Remove BetaApi annotation from OR query API ([#1118](https://github.com/googleapis/java-datastore/issues/1118)) ([b08dc9a](https://github.com/googleapis/java-datastore/commit/b08dc9ac796bf066e447633644c4380aa2c26753)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.12.0 ([#1121](https://github.com/googleapis/java-datastore/issues/1121)) ([65dd46d](https://github.com/googleapis/java-datastore/commit/65dd46d501de1360701146f4a9d7231dccd1e3c2)) +* Update dependency com.google.errorprone:error_prone_core to v2.20.0 ([#1115](https://github.com/googleapis/java-datastore/issues/1115)) ([381d76e](https://github.com/googleapis/java-datastore/commit/381d76e3e079752f9f02d488603e3b89979018ea)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.23 ([#1114](https://github.com/googleapis/java-datastore/issues/1114)) ([7f58868](https://github.com/googleapis/java-datastore/commit/7f588682212e1a8f7e27d4cacb5995c0c129c090)) + +## [2.15.0](https://github.com/googleapis/java-datastore/compare/v2.14.7...v2.15.0) (2023-06-09) + + +### Features + +* Multiple dbs support ([#1102](https://github.com/googleapis/java-datastore/issues/1102)) ([7887f32](https://github.com/googleapis/java-datastore/commit/7887f3255cba4dedd7b4f369d77a3279d903127f)) + + +### Bug Fixes + +* Add some missing annotations and fix equals/hashcode for DatastoreOptions ([#1106](https://github.com/googleapis/java-datastore/issues/1106)) ([c4a79ef](https://github.com/googleapis/java-datastore/commit/c4a79effa83c5fdb7ad8db15ae52e2c70db238bc)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.11.0 ([#1104](https://github.com/googleapis/java-datastore/issues/1104)) ([fc9b091](https://github.com/googleapis/java-datastore/commit/fc9b09103a1bfbb238b22102dcf2b889292658ce)) + +## [2.14.7](https://github.com/googleapis/java-datastore/compare/v2.14.6...v2.14.7) (2023-05-29) + + +### Documentation + +* Marking Transaction, Batch and DatastoreBatchWriter class with 'NotThreadSafe' annotation ([#1082](https://github.com/googleapis/java-datastore/issues/1082)) ([9e96650](https://github.com/googleapis/java-datastore/commit/9e966506c1e860f10e82d34bd6a705c1cae71764)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.10.0 ([#1085](https://github.com/googleapis/java-datastore/issues/1085)) ([47df1b8](https://github.com/googleapis/java-datastore/commit/47df1b8a4b54eae0bb42e261e02d64aee7b95e7a)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.10.1 ([#1086](https://github.com/googleapis/java-datastore/issues/1086)) ([e3ad866](https://github.com/googleapis/java-datastore/commit/e3ad86614a2462054bfb800613f2456f6f98102d)) +* Update dependency com.google.errorprone:error_prone_core to v2.19.1 ([#1069](https://github.com/googleapis/java-datastore/issues/1069)) ([2390016](https://github.com/googleapis/java-datastore/commit/239001682bd1284be39d4646ce0594274070c143)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.22 ([#1074](https://github.com/googleapis/java-datastore/issues/1074)) ([c0cc456](https://github.com/googleapis/java-datastore/commit/c0cc4565cc0e34098f5bc97c031ae671af44fcf3)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.22 ([#1075](https://github.com/googleapis/java-datastore/issues/1075)) ([a4db895](https://github.com/googleapis/java-datastore/commit/a4db89502e9611bf5f9760bfceb1025cc99a9830)) + +## [2.14.6](https://github.com/googleapis/java-datastore/compare/v2.14.5...v2.14.6) (2023-05-09) + + +### Documentation + +* Minor comment update for Entity message ([#1063](https://github.com/googleapis/java-datastore/issues/1063)) ([52f8c27](https://github.com/googleapis/java-datastore/commit/52f8c274b9972fd0e672ee05bebd5b17543fca85)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.9.0 ([#1071](https://github.com/googleapis/java-datastore/issues/1071)) ([6bd4dfe](https://github.com/googleapis/java-datastore/commit/6bd4dfeeecfa0ce9ee9e705f4390c7686e233bd8)) + +## [2.14.5](https://github.com/googleapis/java-datastore/compare/v2.14.4...v2.14.5) (2023-04-27) + + +### Bug Fixes + +* Using namespace from DatastoreOptions if aggregation query is not configured with one. ([#1055](https://github.com/googleapis/java-datastore/issues/1055)) ([ac21ef6](https://github.com/googleapis/java-datastore/commit/ac21ef6cff5308fb17990a768100d1b2ee4c3654)), closes [#1054](https://github.com/googleapis/java-datastore/issues/1054) + +## [2.14.4](https://github.com/googleapis/java-datastore/compare/v2.14.3...v2.14.4) (2023-04-26) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.8.0 ([#1052](https://github.com/googleapis/java-datastore/issues/1052)) ([412be61](https://github.com/googleapis/java-datastore/commit/412be617db28a97d38883bd6e26ddbc7d1c434fa)) +* Update dependency org.junit.vintage:junit-vintage-engine to v5.9.3 ([#1056](https://github.com/googleapis/java-datastore/issues/1056)) ([2a871e2](https://github.com/googleapis/java-datastore/commit/2a871e25436a8812bc2f691c6462675b88976afc)) + + +### Documentation + +* Remove `@BetaApi` annotations for count aggregations ([#1051](https://github.com/googleapis/java-datastore/issues/1051)) ([b8bdaa2](https://github.com/googleapis/java-datastore/commit/b8bdaa23f165f6bcb5a891ef2437ffdd7ce8aa4c)) + +## [2.14.3](https://github.com/googleapis/java-datastore/compare/v2.14.2...v2.14.3) (2023-04-13) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.7.0 ([#1044](https://github.com/googleapis/java-datastore/issues/1044)) ([3ecd20a](https://github.com/googleapis/java-datastore/commit/3ecd20a1c8575855dfb6c7b70d9f4a98a8e92591)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.21 ([#1045](https://github.com/googleapis/java-datastore/issues/1045)) ([d18ff7c](https://github.com/googleapis/java-datastore/commit/d18ff7c4738efe3cc7d43966fb1f3ec8733af3b6)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.21 ([#1046](https://github.com/googleapis/java-datastore/issues/1046)) ([0d3f78e](https://github.com/googleapis/java-datastore/commit/0d3f78ec05f8a4a6f6d3a89917e1d417740bb883)) + +## [2.14.2](https://github.com/googleapis/java-datastore/compare/v2.14.1...v2.14.2) (2023-03-29) + + +### Documentation + +* Adds OR filter sample ([#1032](https://github.com/googleapis/java-datastore/issues/1032)) ([e319efa](https://github.com/googleapis/java-datastore/commit/e319efa402539f0297179d270aa8c8f50e6e3e93)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.6.0 ([#1035](https://github.com/googleapis/java-datastore/issues/1035)) ([b2f4cb3](https://github.com/googleapis/java-datastore/commit/b2f4cb361afb1398b10edc0fcfe744b414926e07)) +* Update gapic-generator-java to 2.16.0 ([8c96c55](https://github.com/googleapis/java-datastore/commit/8c96c555159d48f1dc6d53616f0412f60e3095d7)) + +## [2.14.1](https://github.com/googleapis/java-datastore/compare/v2.14.0...v2.14.1) (2023-03-20) + + +### Documentation + +* Fix broken link to UpdateEntity snippet ([#1022](https://github.com/googleapis/java-datastore/issues/1022)) ([6880604](https://github.com/googleapis/java-datastore/commit/6880604b6b88caf8e03449349d0815d388cfb1a3)), closes [#1010](https://github.com/googleapis/java-datastore/issues/1010) +* Fix broken README links ([#1011](https://github.com/googleapis/java-datastore/issues/1011)) ([276174e](https://github.com/googleapis/java-datastore/commit/276174e26ff92be2bdeb24f733278d2042519cfd)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.5.0 ([#1024](https://github.com/googleapis/java-datastore/issues/1024)) ([4a57e95](https://github.com/googleapis/java-datastore/commit/4a57e959dbac14d395ff202fd479f776c84b25e5)) +* Upgrade gapic-generator-java to 2.15.3 ([091d197](https://github.com/googleapis/java-datastore/commit/091d1976c24c1bec7a7974bcffb246d2a16d790c)) + +## [2.14.0](https://github.com/googleapis/java-datastore/compare/v2.13.6...v2.14.0) (2023-03-08) + + +### Features + +* OR query support ([#993](https://github.com/googleapis/java-datastore/issues/993)) ([99b7843](https://github.com/googleapis/java-datastore/commit/99b784332919ccc813a94ba17beaaa11b02b1c8e)) + +## [2.13.6](https://github.com/googleapis/java-datastore/compare/v2.13.5...v2.13.6) (2023-03-02) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.4.0 ([#1001](https://github.com/googleapis/java-datastore/issues/1001)) ([a230e03](https://github.com/googleapis/java-datastore/commit/a230e030fadc11c72f6ced51e566d59439bc1c6e)) + +## [2.13.5](https://github.com/googleapis/java-datastore/compare/v2.13.4...v2.13.5) (2023-02-17) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.3.0 ([#994](https://github.com/googleapis/java-datastore/issues/994)) ([ce8df48](https://github.com/googleapis/java-datastore/commit/ce8df48ca03e561642e996f9a022b5edd5cb76d9)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.20 ([#989](https://github.com/googleapis/java-datastore/issues/989)) ([f71ccd9](https://github.com/googleapis/java-datastore/commit/f71ccd94c5ed7c01f388d31dda17387d13496547)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.20 ([#990](https://github.com/googleapis/java-datastore/issues/990)) ([5e984c8](https://github.com/googleapis/java-datastore/commit/5e984c87fc95e18fb9a43ebd8d5dbafe7090c1cf)) + +## [2.13.4](https://github.com/googleapis/java-datastore/compare/v2.13.3...v2.13.4) (2023-02-06) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.2.0 ([#975](https://github.com/googleapis/java-datastore/issues/975)) ([f94bd37](https://github.com/googleapis/java-datastore/commit/f94bd3784686fc98fe90af4e74ea0afd040c7db4)) + +## [2.13.3](https://github.com/googleapis/java-datastore/compare/v2.13.2...v2.13.3) (2023-01-23) + + +### Bug Fixes + +* **java:** Skip fixing poms for special modules ([#1744](https://github.com/googleapis/java-datastore/issues/1744)) ([#964](https://github.com/googleapis/java-datastore/issues/964)) ([c89b27a](https://github.com/googleapis/java-datastore/commit/c89b27ac6a7791312f61558515d89baffde40bdf)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.1.2 ([#966](https://github.com/googleapis/java-datastore/issues/966)) ([78e9e8e](https://github.com/googleapis/java-datastore/commit/78e9e8e74163f4c8bd7e1d42540e609a86a99769)) + +## [2.13.2](https://github.com/googleapis/java-datastore/compare/v2.13.1...v2.13.2) (2023-01-10) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.1.1 ([#953](https://github.com/googleapis/java-datastore/issues/953)) ([fdffe1e](https://github.com/googleapis/java-datastore/commit/fdffe1e6b84fa58d7bf4210016d814642cbd45a2)) +* Update dependency com.google.errorprone:error_prone_core to v2.18.0 ([#951](https://github.com/googleapis/java-datastore/issues/951)) ([ac5c83e](https://github.com/googleapis/java-datastore/commit/ac5c83e03f3ea1ef6a66373b80858cd68dda0c80)) +* Update dependency org.junit.vintage:junit-vintage-engine to v5.9.2 ([#954](https://github.com/googleapis/java-datastore/issues/954)) ([b0b72bb](https://github.com/googleapis/java-datastore/commit/b0b72bb8ba3c6382f3d5883cd302a0d0756ccb71)) + +## [2.13.1](https://github.com/googleapis/java-datastore/compare/v2.13.0...v2.13.1) (2023-01-03) + + +### Dependencies + +* Update dependency com.google.errorprone:error_prone_core to v2.17.0 ([#944](https://github.com/googleapis/java-datastore/issues/944)) ([b0fd082](https://github.com/googleapis/java-datastore/commit/b0fd082f34d642f450d51e0c732daa3023fc57a4)) +* Update dependency org.easymock:easymock to v5.1.0 ([#945](https://github.com/googleapis/java-datastore/issues/945)) ([7774aac](https://github.com/googleapis/java-datastore/commit/7774aaca4bb99bd5114002a511981dc6992b00f4)) + +## [2.13.0](https://github.com/googleapis/java-datastore/compare/v2.12.5...v2.13.0) (2022-12-06) + + +### Features + +* Next release from main branch is 2.13.0 ([#917](https://github.com/googleapis/java-datastore/issues/917)) ([1f12435](https://github.com/googleapis/java-datastore/commit/1f1243577cbdc206b6a0bfcde818411eb1b806ad)) + + +### Bug Fixes + +* [#355](https://github.com/googleapis/java-datastore/issues/355) Explicitly passing --project argument when starting emulator ([#923](https://github.com/googleapis/java-datastore/issues/923)) ([ef4065d](https://github.com/googleapis/java-datastore/commit/ef4065d233b968f58a34673aa53d39f60a013e2d)) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.1.0 ([#932](https://github.com/googleapis/java-datastore/issues/932)) ([1dbcea7](https://github.com/googleapis/java-datastore/commit/1dbcea73827961148800c1ec8e87065dbceb6c88)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.18 ([#924](https://github.com/googleapis/java-datastore/issues/924)) ([625e896](https://github.com/googleapis/java-datastore/commit/625e89685172ae546a813f5f7184223d01fbb0ac)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.19 ([#930](https://github.com/googleapis/java-datastore/issues/930)) ([77285be](https://github.com/googleapis/java-datastore/commit/77285be97fbd6bca1ada35202842238e306dd8dc)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.18 ([#925](https://github.com/googleapis/java-datastore/issues/925)) ([0c7539d](https://github.com/googleapis/java-datastore/commit/0c7539d736ec993d7bb0531d7cd4dab1b08487a0)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.19 ([#931](https://github.com/googleapis/java-datastore/issues/931)) ([40b4011](https://github.com/googleapis/java-datastore/commit/40b4011e3a826a91e33541efdecb05f0e129f87c)) + +## [2.12.5](https://github.com/googleapis/java-datastore/compare/v2.12.4...v2.12.5) (2022-11-08) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.6 ([#912](https://github.com/googleapis/java-datastore/issues/912)) ([360c790](https://github.com/googleapis/java-datastore/commit/360c7909a673bbd180e69e31ad830376be11ecf4)) + +## [2.12.4](https://github.com/googleapis/java-datastore/compare/v2.12.3...v2.12.4) (2022-11-07) + + +### Dependencies + +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.17 ([#906](https://github.com/googleapis/java-datastore/issues/906)) ([294e6a8](https://github.com/googleapis/java-datastore/commit/294e6a86ff653d6f3f77369f408c970c4a236f96)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.17 ([#907](https://github.com/googleapis/java-datastore/issues/907)) ([6f8a518](https://github.com/googleapis/java-datastore/commit/6f8a5184c04e9499c02e5589d73fc492bc980213)) + +## [2.12.3](https://github.com/googleapis/java-datastore/compare/v2.12.2...v2.12.3) (2022-10-24) + + +### Dependencies + +* Update dependency org.easymock:easymock to v5.0.1 ([#896](https://github.com/googleapis/java-datastore/issues/896)) ([0382c3d](https://github.com/googleapis/java-datastore/commit/0382c3ddfcf13192e483e371ab470f2dd83607aa)) + +## [2.12.2](https://github.com/googleapis/java-datastore/compare/v2.12.1...v2.12.2) (2022-10-21) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.5 ([#891](https://github.com/googleapis/java-datastore/issues/891)) ([1f32176](https://github.com/googleapis/java-datastore/commit/1f3217607b491db594cde2e7e767c8e50aa26eb1)) + +## [2.12.1](https://github.com/googleapis/java-datastore/compare/v2.12.0...v2.12.1) (2022-10-19) + + +### Dependencies + +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.16 ([#885](https://github.com/googleapis/java-datastore/issues/885)) ([c8b7559](https://github.com/googleapis/java-datastore/commit/c8b75595e74a33d29d972af8c463cf33c41ac02b)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.16 ([#886](https://github.com/googleapis/java-datastore/issues/886)) ([76df7ea](https://github.com/googleapis/java-datastore/commit/76df7eaadf1d27e1669a557039ac790a11c110b3)) + +## [2.12.0](https://github.com/googleapis/java-datastore/compare/v2.11.5...v2.12.0) (2022-10-17) + + +### Features + +* Count API ([#823](https://github.com/googleapis/java-datastore/issues/823)) ([8c22e61](https://github.com/googleapis/java-datastore/commit/8c22e61f8a0307a59301259f83a16c8324fa1b6f)) + + +### Dependencies + +* Update dependency com.google.errorprone:error_prone_core to v2.16 ([#872](https://github.com/googleapis/java-datastore/issues/872)) ([b2a72ca](https://github.com/googleapis/java-datastore/commit/b2a72ca407b1fa168c18b136e73932c8716fbdf6)) +* Update dependency org.easymock:easymock to v5 ([#877](https://github.com/googleapis/java-datastore/issues/877)) ([ed816e2](https://github.com/googleapis/java-datastore/commit/ed816e20b605882a9cf2c637145597fdcd95f324)) +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.15 ([#878](https://github.com/googleapis/java-datastore/issues/878)) ([831a92b](https://github.com/googleapis/java-datastore/commit/831a92bdc1d3f81fb44ae8d17cad236a50234ea5)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.15 ([#879](https://github.com/googleapis/java-datastore/issues/879)) ([76a187a](https://github.com/googleapis/java-datastore/commit/76a187a48cdc8d40fa233123894a36e11c590ca9)) + +## [2.11.5](https://github.com/googleapis/java-datastore/compare/v2.11.4...v2.11.5) (2022-10-03) + + +### Dependencies + +* Convert from `JacksonFactory` to `GsonFactory` ([#780](https://github.com/googleapis/java-datastore/issues/780)) ([d24cae2](https://github.com/googleapis/java-datastore/commit/d24cae20c2c69327b8f097cc56fcb48b5f61c358)) +* Update dependency cachetools to v5 ([#863](https://github.com/googleapis/java-datastore/issues/863)) ([74320c1](https://github.com/googleapis/java-datastore/commit/74320c18bc9ad95fd366a1be5fc2d95105944833)) +* Update dependency certifi to v2022.9.24 ([#842](https://github.com/googleapis/java-datastore/issues/842)) ([1631a67](https://github.com/googleapis/java-datastore/commit/1631a67d037f1b1e09a6653a4867d51a6412f6bb)) +* Update dependency charset-normalizer to v2.1.1 ([#854](https://github.com/googleapis/java-datastore/issues/854)) ([8814084](https://github.com/googleapis/java-datastore/commit/881408421e7c9cea5712e9c7c315ab4671c15d49)) +* Update dependency click to v8.1.3 ([#855](https://github.com/googleapis/java-datastore/issues/855)) ([5935e6e](https://github.com/googleapis/java-datastore/commit/5935e6e871724965f05817a6739369e40b59809b)) +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.4 ([#866](https://github.com/googleapis/java-datastore/issues/866)) ([af1d1eb](https://github.com/googleapis/java-datastore/commit/af1d1eb3bc3dbbb6637ad6bc686ed9fc7c5b9bd5)) +* Update dependency gcp-releasetool to v1.8.8 ([#843](https://github.com/googleapis/java-datastore/issues/843)) ([10b4e44](https://github.com/googleapis/java-datastore/commit/10b4e449ebdf238ad882842ca75ef5477a0d0292)) +* Update dependency google-api-core to v2.10.1 ([#856](https://github.com/googleapis/java-datastore/issues/856)) ([874166e](https://github.com/googleapis/java-datastore/commit/874166e9d2bff6c61f280494fc6b82845e66257b)) +* Update dependency google-auth to v2.12.0 ([#857](https://github.com/googleapis/java-datastore/issues/857)) ([d832df6](https://github.com/googleapis/java-datastore/commit/d832df63ebbc259a9d86818d6dfdcbfe29dd27ce)) +* Update dependency google-cloud-core to v2.3.2 ([#852](https://github.com/googleapis/java-datastore/issues/852)) ([14aad83](https://github.com/googleapis/java-datastore/commit/14aad838b7edd572ca1df6f67cc1988722c3dee5)) +* Update dependency google-cloud-storage to v2.5.0 ([#858](https://github.com/googleapis/java-datastore/issues/858)) ([17f47bc](https://github.com/googleapis/java-datastore/commit/17f47bcb368887291c41ac863743c46feae3c2cf)) +* Update dependency google-crc32c to v1.5.0 ([#859](https://github.com/googleapis/java-datastore/issues/859)) ([dd58916](https://github.com/googleapis/java-datastore/commit/dd58916e895c6b9e5449a562a53ddca0c33cf530)) +* Update dependency googleapis-common-protos to v1.56.4 ([#853](https://github.com/googleapis/java-datastore/issues/853)) ([416e157](https://github.com/googleapis/java-datastore/commit/416e157a51caaa11b21b0d43ac94a2bd76e4de14)) +* Update dependency importlib-metadata to v4.12.0 ([#860](https://github.com/googleapis/java-datastore/issues/860)) ([0a15a3f](https://github.com/googleapis/java-datastore/commit/0a15a3fc5294b5e8d7b0b86fcd6f65739eb700ca)) +* Update dependency jinja2 to v3.1.2 ([#861](https://github.com/googleapis/java-datastore/issues/861)) ([9fc4af5](https://github.com/googleapis/java-datastore/commit/9fc4af50bc7f69d080a29d4e772026f990e02fe8)) +* Update dependency keyring to v23.9.3 ([#862](https://github.com/googleapis/java-datastore/issues/862)) ([620e5f2](https://github.com/googleapis/java-datastore/commit/620e5f2ebc33a14ebf106bdc8e3731e1ce1bd449)) +* Update dependency markupsafe to v2.1.1 ([#844](https://github.com/googleapis/java-datastore/issues/844)) ([8d64f16](https://github.com/googleapis/java-datastore/commit/8d64f16e20fa8c3e15d48fb44657b412bb55bdc1)) +* Update dependency protobuf to v3.20.2 ([#845](https://github.com/googleapis/java-datastore/issues/845)) ([7b46721](https://github.com/googleapis/java-datastore/commit/7b46721d8db483348decb27818de67feb19851c5)) +* Update dependency protobuf to v4 ([#864](https://github.com/googleapis/java-datastore/issues/864)) ([0bf85e9](https://github.com/googleapis/java-datastore/commit/0bf85e9355dff9321bd84038c1bad249b5a92531)) +* Update dependency pyjwt to v2.5.0 ([#846](https://github.com/googleapis/java-datastore/issues/846)) ([e4edcd1](https://github.com/googleapis/java-datastore/commit/e4edcd1e4c3079ab579d15c7b47e110fb99b6674)) +* Update dependency requests to v2.28.1 ([#847](https://github.com/googleapis/java-datastore/issues/847)) ([08ca8e5](https://github.com/googleapis/java-datastore/commit/08ca8e5af44a4b2b1cfae8996b2f7edfe7109204)) +* Update dependency typing-extensions to v4.3.0 ([#848](https://github.com/googleapis/java-datastore/issues/848)) ([2197874](https://github.com/googleapis/java-datastore/commit/219787455d34a2667587f9577368c36811c0c58b)) +* Update dependency zipp to v3.8.1 ([#849](https://github.com/googleapis/java-datastore/issues/849)) ([18db303](https://github.com/googleapis/java-datastore/commit/18db3030ad51ae0db6465717ee432460b67f696a)) + +## [2.11.4](https://github.com/googleapis/java-datastore/compare/v2.11.3...v2.11.4) (2022-09-22) + + +### Dependencies + +* Update dependency org.graalvm.buildtools:junit-platform-native to v0.9.14 ([#833](https://github.com/googleapis/java-datastore/issues/833)) ([4463f89](https://github.com/googleapis/java-datastore/commit/4463f89567613ac2aa3f0fd572e973b45b6b9e97)) +* Update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.14 ([#834](https://github.com/googleapis/java-datastore/issues/834)) ([6e6b609](https://github.com/googleapis/java-datastore/commit/6e6b6094acc860036b864680bc8a625e6e4113e8)) + +## [2.11.3](https://github.com/googleapis/java-datastore/compare/v2.11.2...v2.11.3) (2022-09-21) + + +### Dependencies + +* Update dependency org.junit.vintage:junit-vintage-engine to v5.9.1 ([#829](https://github.com/googleapis/java-datastore/issues/829)) ([2ab161e](https://github.com/googleapis/java-datastore/commit/2ab161e1b44475f46adc2fe0e7d9bfcfb813f50f)) + +## [2.11.2](https://github.com/googleapis/java-datastore/compare/v2.11.1...v2.11.2) (2022-09-15) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.3 ([#824](https://github.com/googleapis/java-datastore/issues/824)) ([819f79f](https://github.com/googleapis/java-datastore/commit/819f79ff16389f75dc4fb8b439ab32aa0c61a4cd)) + +## [2.11.1](https://github.com/googleapis/java-datastore/compare/v2.11.0...v2.11.1) (2022-09-10) + + +### Dependencies + +* Update dependency com.google.cloud:google-cloud-shared-dependencies to v3.0.2 ([#818](https://github.com/googleapis/java-datastore/issues/818)) ([47780d6](https://github.com/googleapis/java-datastore/commit/47780d652e5ac0977278059374aa3865548ec798)) + +## [2.11.0](https://github.com/googleapis/java-datastore/compare/v2.10.1...v2.11.0) (2022-08-04) + + +### Features + +* add database_id field ([#802](https://github.com/googleapis/java-datastore/issues/802)) ([6ed09dd](https://github.com/googleapis/java-datastore/commit/6ed09dd44865639922156c85a441b7c6bb751df9)) + + +### Documentation + +* **sample:** Add a top-level Datastore samples README ([#790](https://github.com/googleapis/java-datastore/issues/790)) ([d3884dc](https://github.com/googleapis/java-datastore/commit/d3884dce1b04f3143190e8cfbb084dd22fa6df15)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v3 ([#805](https://github.com/googleapis/java-datastore/issues/805)) ([ad467ef](https://github.com/googleapis/java-datastore/commit/ad467ef55696dcb9bb2b340916216000aff6bcc8)) +* update dependency com.google.errorprone:error_prone_core to v2.15.0 ([#810](https://github.com/googleapis/java-datastore/issues/810)) ([fc8cd15](https://github.com/googleapis/java-datastore/commit/fc8cd15a72a80109a519b0dcc1236a2606b41264)) +* update dependency org.junit.vintage:junit-vintage-engine to v5.9.0 ([#804](https://github.com/googleapis/java-datastore/issues/804)) ([6caafd8](https://github.com/googleapis/java-datastore/commit/6caafd854278953de937a4a07c8ef163850ab9b0)) + +## [2.10.1](https://github.com/googleapis/java-datastore/compare/v2.10.0...v2.10.1) (2022-07-13) + + +### Dependencies + +* update dependency org.graalvm.buildtools:junit-platform-native to v0.9.13 ([#793](https://github.com/googleapis/java-datastore/issues/793)) ([0bd0199](https://github.com/googleapis/java-datastore/commit/0bd0199f22a4bc5b0b93e3bbeca5d2e990dde83f)) +* update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.13 ([#794](https://github.com/googleapis/java-datastore/issues/794)) ([fa3979a](https://github.com/googleapis/java-datastore/commit/fa3979a32dfb3cb84a593948f38ed27549355a55)) + +## [2.10.0](https://github.com/googleapis/java-datastore/compare/v2.9.1...v2.10.0) (2022-06-30) + + +### Features + +* Enable REST transport for admin client ([#778](https://github.com/googleapis/java-datastore/issues/778)) ([c3290e3](https://github.com/googleapis/java-datastore/commit/c3290e3e32a5309abc8e456bfd584c929d23628c)) + + +### Bug Fixes + +* update gapic-generator-java with mock service generation fixes ([#785](https://github.com/googleapis/java-datastore/issues/785)) ([8a12f25](https://github.com/googleapis/java-datastore/commit/8a12f25ece95429a10c1bcae220a678a7c2e3ff1)) + +## [2.9.1](https://github.com/googleapis/java-datastore/compare/v2.9.0...v2.9.1) (2022-06-23) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#777](https://github.com/googleapis/java-datastore/issues/777)) ([58136d6](https://github.com/googleapis/java-datastore/commit/58136d64ca717c20c6b8058a07fc25fbac9a9125)) + +## [2.9.0](https://github.com/googleapis/java-datastore/compare/v2.8.0...v2.9.0) (2022-06-22) + + +### Features + +* support readTime in Datastore query splitter. ([#763](https://github.com/googleapis/java-datastore/issues/763)) ([61758e0](https://github.com/googleapis/java-datastore/commit/61758e02c30c8410dd397d0cc77c987332c4f11c)) + + +### Documentation + +* **sample:** clean up README for native image sample ([#771](https://github.com/googleapis/java-datastore/issues/771)) ([7358aa3](https://github.com/googleapis/java-datastore/commit/7358aa34ec9d3d52aae3195fea718ef748ab22b1)) + + +### Dependencies + +* update dependency org.graalvm.buildtools:junit-platform-native to v0.9.12 ([#773](https://github.com/googleapis/java-datastore/issues/773)) ([cab7e54](https://github.com/googleapis/java-datastore/commit/cab7e54359a4fad5fca23b89a9cf52f95e53e19e)) +* update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.12 ([#774](https://github.com/googleapis/java-datastore/issues/774)) ([496c1bc](https://github.com/googleapis/java-datastore/commit/496c1bcb4c7343fd8330629f82ca9f96fb1a9acc)) + +## [2.8.0](https://github.com/googleapis/java-datastore/compare/v2.7.0...v2.8.0) (2022-06-09) + + +### Features + +* support IN/NOT_IN/NOT_EQUAL operators ([#688](https://github.com/googleapis/java-datastore/issues/688)) ([f8a84ff](https://github.com/googleapis/java-datastore/commit/f8a84ffa6d743501f5cfb71ac271d8a9b764705c)) + +## [2.7.0](https://github.com/googleapis/java-datastore/compare/v2.6.0...v2.7.0) (2022-06-02) + + +### Features + +* new enum value `OPTIMISTIC_WITH_ENTITY_GROUPS` for `ConcurrencyMode` ([df6b793](https://github.com/googleapis/java-datastore/commit/df6b793cb66424ad470fe871f9a3868ae482e1a4)) + + +### Documentation + +* clarifications for `DatastoreFirestoreMigraitonMetadata` ([df6b793](https://github.com/googleapis/java-datastore/commit/df6b793cb66424ad470fe871f9a3868ae482e1a4)) + +## [2.6.0](https://github.com/googleapis/java-datastore/compare/v2.5.1...v2.6.0) (2022-05-31) + + +### Features + +* Expose Datastore Admin generated client ([#748](https://github.com/googleapis/java-datastore/issues/748)) ([3dd882a](https://github.com/googleapis/java-datastore/commit/3dd882a9ffe2a8828cdedcdc2e562c9354aebfbc)) + +### [2.5.1](https://github.com/googleapis/java-datastore/compare/v2.5.0...v2.5.1) (2022-05-25) + + +### Dependencies + +* update dependency com.google.errorprone:error_prone_core to v2.14.0 ([#744](https://github.com/googleapis/java-datastore/issues/744)) ([51d9244](https://github.com/googleapis/java-datastore/commit/51d9244b10f5bb754785e8267a51fddd9cdb6cb5)) + +## [2.5.0](https://github.com/googleapis/java-datastore/compare/v2.4.0...v2.5.0) (2022-05-23) + + +### Features + +* add build scripts for native image testing in Java 17 ([#1440](https://github.com/googleapis/java-datastore/issues/1440)) ([#739](https://github.com/googleapis/java-datastore/issues/739)) ([252a174](https://github.com/googleapis/java-datastore/commit/252a17490337dfef213e6296aadbaf592c0d1e9e)) +* add ReadOption.ReadTime to support timestamp reads. ([#712](https://github.com/googleapis/java-datastore/issues/712)) ([06bb08f](https://github.com/googleapis/java-datastore/commit/06bb08f6929c8e2b539a5c296d9c500d46c857af)) + + +### Bug Fixes + +* **java:** rename test to be picked up by native profile ([#723](https://github.com/googleapis/java-datastore/issues/723)) ([3a30e75](https://github.com/googleapis/java-datastore/commit/3a30e7520927a50b8457dd5ceea9700407a17e69)) + + +### Documentation + +* **samples:** remove unused dependency ([#730](https://github.com/googleapis/java-datastore/issues/730)) ([5185691](https://github.com/googleapis/java-datastore/commit/51856917a2ca59b889460f962e9f90d7a1c02f2f)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.11.0 ([#737](https://github.com/googleapis/java-datastore/issues/737)) ([8eb0c5f](https://github.com/googleapis/java-datastore/commit/8eb0c5f6f2cdb0b681fad012a45bad253be6cb8a)) +* update shared deps to 2.12.0 ([#740](https://github.com/googleapis/java-datastore/issues/740)) ([5c3676e](https://github.com/googleapis/java-datastore/commit/5c3676e871264b552b579ea5d492c02ab54d501e)) + +## [2.4.0](https://github.com/googleapis/java-datastore/compare/v2.3.1...v2.4.0) (2022-04-21) + + +### Features + +* expose new read_time API fields, currently only available in private preview ([#706](https://github.com/googleapis/java-datastore/issues/706)) ([e11bd20](https://github.com/googleapis/java-datastore/commit/e11bd20fb99a3d671b09e1b46247fdfd11927fbe)) +* next release from main branch is 2.4.0 ([#715](https://github.com/googleapis/java-datastore/issues/715)) ([9cc80c9](https://github.com/googleapis/java-datastore/commit/9cc80c999d08d5ccfd667e765f94181904e17645)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.10.0 ([#710](https://github.com/googleapis/java-datastore/issues/710)) ([ed8de9c](https://github.com/googleapis/java-datastore/commit/ed8de9cc519d5817b8af2c9705b9f335b909b78a)) +* update dependency com.google.cloud:native-image-support to v0.13.1 ([#709](https://github.com/googleapis/java-datastore/issues/709)) ([354ad90](https://github.com/googleapis/java-datastore/commit/354ad90aa075b203329b9ebde88f2b668351c37e)) +* update dependency com.google.errorprone:error_prone_core to v2.13.0 ([#708](https://github.com/googleapis/java-datastore/issues/708)) ([f22a1bc](https://github.com/googleapis/java-datastore/commit/f22a1bce83c850e34f27984a4d57347d860f436b)) +* update dependency com.google.errorprone:error_prone_core to v2.13.1 ([#711](https://github.com/googleapis/java-datastore/issues/711)) ([a9f565d](https://github.com/googleapis/java-datastore/commit/a9f565d2d4251f36cf9868420c9ce6efb2b71be3)) + +### [2.3.1](https://github.com/googleapis/java-datastore/compare/v2.3.0...v2.3.1) (2022-04-07) + + +### Dependencies + +* update dependency com.google.errorprone:error_prone_core to v2.12.1 ([#701](https://github.com/googleapis/java-datastore/issues/701)) ([b2803ea](https://github.com/googleapis/java-datastore/commit/b2803ea19beab451a52c88dea0779ac463f29d44)) + +## [2.3.0](https://github.com/googleapis/java-datastore/compare/v2.2.9...v2.3.0) (2022-03-29) + + +### Features + +* fix next release version ([#689](https://github.com/googleapis/java-datastore/issues/689)) ([3ccbc75](https://github.com/googleapis/java-datastore/commit/3ccbc7557476dedd531b82035251d2a98354c718)) + + +### Documentation + +* update doc link ([#685](https://github.com/googleapis/java-datastore/issues/685)) ([91807b9](https://github.com/googleapis/java-datastore/commit/91807b92fa1f410cec6184f2b2dd1c300666878c)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.9.0 ([#695](https://github.com/googleapis/java-datastore/issues/695)) ([875b661](https://github.com/googleapis/java-datastore/commit/875b6615dc7c09a8e0db83d9ccf18b881a39bad2)) +* update dependency com.google.cloud:native-image-support to v0.12.11 ([#694](https://github.com/googleapis/java-datastore/issues/694)) ([5e98681](https://github.com/googleapis/java-datastore/commit/5e986815471cb3350673f7a5e669d3cd09bf1a8a)) +* update dependency org.graalvm.buildtools:junit-platform-native to v0.9.11 ([#691](https://github.com/googleapis/java-datastore/issues/691)) ([17d9bcb](https://github.com/googleapis/java-datastore/commit/17d9bcb4ba4df865aef45153ec29de1de40875ab)) +* update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.11 ([#692](https://github.com/googleapis/java-datastore/issues/692)) ([4c49614](https://github.com/googleapis/java-datastore/commit/4c4961404aabba6cc183e6a133f112449db2bb77)) + +### [2.2.9](https://github.com/googleapis/java-datastore/compare/v2.2.8...v2.2.9) (2022-03-14) + + +### Dependencies + +* update dependency com.google.cloud:native-image-support to v0.12.10 ([#679](https://github.com/googleapis/java-datastore/issues/679)) ([0f8afd7](https://github.com/googleapis/java-datastore/commit/0f8afd7409955efb89b481218861fa9ee531de89)) + +### [2.2.8](https://github.com/googleapis/java-datastore/compare/v2.2.7...v2.2.8) (2022-03-10) + + +### Dependencies + +* update dependency com.google.cloud:native-image-support to v0.12.9 ([#671](https://github.com/googleapis/java-datastore/issues/671)) ([4338c40](https://github.com/googleapis/java-datastore/commit/4338c4008c5e5bf7522713b45d13950f1a881ee7)) +* update dependency com.google.errorprone:error_prone_core to v2.11.0 ([#673](https://github.com/googleapis/java-datastore/issues/673)) ([0888bac](https://github.com/googleapis/java-datastore/commit/0888bac22704f5b2befd170267be28454f5ee059)) + +### [2.2.7](https://github.com/googleapis/java-datastore/compare/v2.2.6...v2.2.7) (2022-03-09) + + +### Dependencies + +* update dependency com.google.cloud:native-image-support to v0.12.8 ([#668](https://github.com/googleapis/java-datastore/issues/668)) ([917a3fe](https://github.com/googleapis/java-datastore/commit/917a3fe427a697816790be131a113d6962667458)) + +### [2.2.6](https://github.com/googleapis/java-datastore/compare/v2.2.5...v2.2.6) (2022-03-08) + + +### Dependencies + +* update dependency com.google.cloud:native-image-support to v0.12.7 ([#661](https://github.com/googleapis/java-datastore/issues/661)) ([11634df](https://github.com/googleapis/java-datastore/commit/11634dfd6e536cb0e37ef5bb91435cc54614c8f6)) + +### [2.2.5](https://github.com/googleapis/java-datastore/compare/v2.2.4...v2.2.5) (2022-03-02) + + +### Bug Fixes + +* Use ImmutableMap.Bulder.buildOrThrow() instead of build(). ([#632](https://github.com/googleapis/java-datastore/issues/632)) ([5d0f484](https://github.com/googleapis/java-datastore/commit/5d0f48403f6746bb7901b13aa223e4de31c3c5a4)) + + +### Documentation + +* **sample:** Add sample for native image support in Datastore ([#640](https://github.com/googleapis/java-datastore/issues/640)) ([f728901](https://github.com/googleapis/java-datastore/commit/f728901b4984f1cc79a02ecc2ff631322974d761)) +* **sample:** Use Java 8 for Native Image sample ([#656](https://github.com/googleapis/java-datastore/issues/656)) ([b95ee96](https://github.com/googleapis/java-datastore/commit/b95ee9635173617cd13605928b306974c70423e8)) + + +### Dependencies + +* update actions/setup-java action to v3 ([#648](https://github.com/googleapis/java-datastore/issues/648)) ([8d85b64](https://github.com/googleapis/java-datastore/commit/8d85b64faa72265851e92562f5381ace1088c066)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.8.0 ([#653](https://github.com/googleapis/java-datastore/issues/653)) ([03162a6](https://github.com/googleapis/java-datastore/commit/03162a69c01c5cddc524b99325900196aa26cd0d)) +* update dependency com.google.cloud:native-image-support to v0.12.5 ([#650](https://github.com/googleapis/java-datastore/issues/650)) ([b449554](https://github.com/googleapis/java-datastore/commit/b4495542bb086e7e169fea10795342e78aac2e1e)) +* update dependency com.google.cloud:native-image-support to v0.12.6 ([#654](https://github.com/googleapis/java-datastore/issues/654)) ([5e69833](https://github.com/googleapis/java-datastore/commit/5e69833713421d7deee2f4cf2f50a725270c36e0)) +* update dependency org.graalvm.buildtools:junit-platform-native to v0.9.10 ([#646](https://github.com/googleapis/java-datastore/issues/646)) ([c62a390](https://github.com/googleapis/java-datastore/commit/c62a39074a44e58222115b05f14e3ffdd52273c0)) +* update dependency org.graalvm.buildtools:native-maven-plugin to v0.9.10 ([#647](https://github.com/googleapis/java-datastore/issues/647)) ([d6e2a16](https://github.com/googleapis/java-datastore/commit/d6e2a16fe2e6dfd07892ff6928118a4a031de9f2)) + +### [2.2.4](https://github.com/googleapis/java-datastore/compare/v2.2.3...v2.2.4) (2022-02-03) + + +### Dependencies + +* **java:** update actions/github-script action to v5 ([#626](https://github.com/googleapis/java-datastore/issues/626)) ([7ddb377](https://github.com/googleapis/java-datastore/commit/7ddb3779271338b9ff01df91ac446450eba45ba8)) + +### [2.2.3](https://github.com/googleapis/java-datastore/compare/v2.2.2...v2.2.3) (2022-02-01) + + +### Dependencies + +* update dependency org.easymock:easymock to v4 ([#614](https://github.com/googleapis/java-datastore/issues/614)) ([a24215c](https://github.com/googleapis/java-datastore/commit/a24215c650c8cb2eb20bbc99f0ccc4c2fd91ac9a)) +* update shared dependencies to 2.7.0 and remove google-oauth-client from dependency management ([#629](https://github.com/googleapis/java-datastore/issues/629)) ([298e0b0](https://github.com/googleapis/java-datastore/commit/298e0b0651355649629888dcbacafc2970df4167)) + +### [2.2.2](https://www.github.com/googleapis/java-datastore/compare/v2.2.1...v2.2.2) (2022-01-07) + + +### Bug Fixes + +* **java:** add -ntp flag to native image testing command ([#593](https://www.github.com/googleapis/java-datastore/issues/593)) ([9b6496e](https://www.github.com/googleapis/java-datastore/commit/9b6496e92cb48ca1bfc0b1a733d564466f28deca)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.6.0 ([#607](https://www.github.com/googleapis/java-datastore/issues/607)) ([095fd5d](https://www.github.com/googleapis/java-datastore/commit/095fd5dbe470083d37b561b615952e39f46544c3)) + +### [2.2.1](https://www.github.com/googleapis/java-datastore/compare/v2.2.0...v2.2.1) (2021-12-03) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.5.1 ([#586](https://www.github.com/googleapis/java-datastore/issues/586)) ([c1d1b91](https://www.github.com/googleapis/java-datastore/commit/c1d1b91e0a74e97177ab0874ede975da9bad4368)) + +## [2.2.0](https://www.github.com/googleapis/java-datastore/compare/v2.1.3...v2.2.0) (2021-11-15) + + +### Features + +* next release to 2.2.0 ([#567](https://www.github.com/googleapis/java-datastore/issues/567)) ([a23066f](https://www.github.com/googleapis/java-datastore/commit/a23066fcd13f4ad373ab16f13df014a23f639390)) + + +### Bug Fixes + +* **java:** java 17 dependency arguments ([#569](https://www.github.com/googleapis/java-datastore/issues/569)) ([19dd87f](https://www.github.com/googleapis/java-datastore/commit/19dd87fc0c929be278256d8fc25e0bf1fde29769)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.5.0 ([#577](https://www.github.com/googleapis/java-datastore/issues/577)) ([931e6ec](https://www.github.com/googleapis/java-datastore/commit/931e6ec846b446c369b5394c5284f6f26bb299ee)) + +### [2.1.3](https://www.github.com/googleapis/java-datastore/compare/v2.1.2...v2.1.3) (2021-10-20) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.4.0 ([#559](https://www.github.com/googleapis/java-datastore/issues/559)) ([9d9afee](https://www.github.com/googleapis/java-datastore/commit/9d9afee9a6242c4670326ff1d091af48da26c459)) + +### [2.1.2](https://www.github.com/googleapis/java-datastore/compare/v2.1.1...v2.1.2) (2021-09-22) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.3.0 ([#543](https://www.github.com/googleapis/java-datastore/issues/543)) ([3d1a18a](https://www.github.com/googleapis/java-datastore/commit/3d1a18a984ec9c0610c0d10e720ea06fe2369695)) + +### [2.1.1](https://www.github.com/googleapis/java-datastore/compare/v2.1.0...v2.1.1) (2021-09-14) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.2.1 ([#536](https://www.github.com/googleapis/java-datastore/issues/536)) ([b9b0e79](https://www.github.com/googleapis/java-datastore/commit/b9b0e79f6510311666b1ba442cab124d9c6c547f)) + +## [2.1.0](https://www.github.com/googleapis/java-datastore/compare/v2.0.3...v2.1.0) (2021-08-31) + + +### Features + +* support overriding the emulator download URL in LocalDatastoreHelper ([#492](https://www.github.com/googleapis/java-datastore/issues/492)) ([76397bf](https://www.github.com/googleapis/java-datastore/commit/76397bf7ce27804101a1622e82f436cac0dcd605)), closes [#376](https://www.github.com/googleapis/java-datastore/issues/376) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.2.0 ([#524](https://www.github.com/googleapis/java-datastore/issues/524)) ([81b9de5](https://www.github.com/googleapis/java-datastore/commit/81b9de5b8bc6e788618b2530a9f47ca97aa30d98)) + +### [2.0.3](https://www.github.com/googleapis/java-datastore/compare/v2.0.2...v2.0.3) (2021-08-24) + + +### Dependencies + +* update dependency com.google.oauth-client:google-oauth-client to v1.32.1 ([#511](https://www.github.com/googleapis/java-datastore/issues/511)) ([51fb68f](https://www.github.com/googleapis/java-datastore/commit/51fb68f0f3a791c28f9b3d73fb6fc4fd7dfe2d3c)) + +### [2.0.2](https://www.github.com/googleapis/java-datastore/compare/v2.0.1...v2.0.2) (2021-08-23) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.1.0 ([#507](https://www.github.com/googleapis/java-datastore/issues/507)) ([231a87f](https://www.github.com/googleapis/java-datastore/commit/231a87fabd2450bb3169a4098ab6196baeeb05c8)) + +### [2.0.1](https://www.github.com/googleapis/java-datastore/compare/v2.0.0...v2.0.1) (2021-08-12) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.0.1 ([#496](https://www.github.com/googleapis/java-datastore/issues/496)) ([a8dde5d](https://www.github.com/googleapis/java-datastore/commit/a8dde5dcb5575f391db0d300ac7cf56c029a51f7)) + +## [2.0.0](https://www.github.com/googleapis/java-datastore/compare/v1.107.1...v2.0.0) (2021-08-06) + + +### ⚠ BREAKING CHANGES + +* update compile level to Java 1.8 ([#486](https://github.com/googleapis/java-datastore/pull/486)) +* upgrade shared dependencies to 2.0.0 (#490) + +### Features + +* update compile level to Java 1.8 ([#486](https://github.com/googleapis/java-datastore/pull/486)) +* upgrade shared dependencies to 2.0.0 ([#490](https://www.github.com/googleapis/java-datastore/issues/490)) ([d3e1af5](https://www.github.com/googleapis/java-datastore/commit/d3e1af5091ca864f6495a1440d475ecbabe465d4)) + +### [1.107.1](https://www.github.com/googleapis/java-datastore/compare/v1.107.0...v1.107.1) (2021-06-30) + + +### Bug Fixes + +* Add `shopt -s nullglob` to dependencies script ([#461](https://www.github.com/googleapis/java-datastore/issues/461)) ([147a3e5](https://www.github.com/googleapis/java-datastore/commit/147a3e5a80b2597258c4b78ae54d4be5d45b4df1)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.4.0 ([#465](https://www.github.com/googleapis/java-datastore/issues/465)) ([9a83695](https://www.github.com/googleapis/java-datastore/commit/9a83695cd5913096dc3d810c385d62c579bd7ace)) + +## [1.107.0](https://www.github.com/googleapis/java-datastore/compare/v1.106.5...v1.107.0) (2021-06-16) + + +### Features + +* add `gcf-owl-bot[bot]` to `ignoreAuthors` ([#433](https://www.github.com/googleapis/java-datastore/issues/433)) ([a8bc795](https://www.github.com/googleapis/java-datastore/commit/a8bc7957719c10a323eba17a68137476de068c5d)) + + +### Bug Fixes + +* Update dependencies.sh to not break on mac ([#456](https://www.github.com/googleapis/java-datastore/issues/456)) ([1e514c0](https://www.github.com/googleapis/java-datastore/commit/1e514c00c4f0f3735295330b255c52eb61af72aa)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.3.0 ([#451](https://www.github.com/googleapis/java-datastore/issues/451)) ([00ca1a6](https://www.github.com/googleapis/java-datastore/commit/00ca1a680f744ea3c5855136b79ba6de384583ed)) + +### [1.106.5](https://www.github.com/googleapis/java-datastore/compare/v1.106.4...v1.106.5) (2021-05-19) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.2.0 ([#430](https://www.github.com/googleapis/java-datastore/issues/430)) ([86c4dfe](https://www.github.com/googleapis/java-datastore/commit/86c4dfe1a9ae4fdcf1b788281be0f57d14c6d353)) + +### [1.106.4](https://www.github.com/googleapis/java-datastore/compare/v1.106.3...v1.106.4) (2021-05-11) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1.1.0 ([#417](https://www.github.com/googleapis/java-datastore/issues/417)) ([0ecddb2](https://www.github.com/googleapis/java-datastore/commit/0ecddb25c43569e3b50e96ceec102bec52bad7d6)) + +### [1.106.3](https://www.github.com/googleapis/java-datastore/compare/v1.106.2...v1.106.3) (2021-04-23) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v1 ([#404](https://www.github.com/googleapis/java-datastore/issues/404)) ([c168760](https://www.github.com/googleapis/java-datastore/commit/c168760909dbfb5d2d6ad176a4822e9a7dcc1d47)) + +### [1.106.2](https://www.github.com/googleapis/java-datastore/compare/v1.106.1...v1.106.2) (2021-04-20) + + +### Bug Fixes + +* release scripts from issuing overlapping phases ([#394](https://www.github.com/googleapis/java-datastore/issues/394)) ([397ae6c](https://www.github.com/googleapis/java-datastore/commit/397ae6cdbf2effa926d0a4503148970ee7e5d8cf)) +* typo ([#389](https://www.github.com/googleapis/java-datastore/issues/389)) ([10b0336](https://www.github.com/googleapis/java-datastore/commit/10b03365c227d7b6f15ba60eb946079a3f70b729)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.21.1 ([#397](https://www.github.com/googleapis/java-datastore/issues/397)) ([947befe](https://www.github.com/googleapis/java-datastore/commit/947befed8e074c244cb68099ed5e9a6ad0721caf)) + +### [1.106.1](https://www.github.com/googleapis/java-datastore/compare/v1.106.0...v1.106.1) (2021-04-12) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.21.0 ([#380](https://www.github.com/googleapis/java-datastore/issues/380)) ([7577e1b](https://www.github.com/googleapis/java-datastore/commit/7577e1b1cb1af0539fc931059fbb48ee5e934447)) +* update dependency com.google.oauth-client:google-oauth-client to v1.31.5 ([#379](https://www.github.com/googleapis/java-datastore/issues/379)) ([917719c](https://www.github.com/googleapis/java-datastore/commit/917719cb36d4d55b586b6fde7a0e0950a26cd233)) + +## [1.106.0](https://www.github.com/googleapis/java-datastore/compare/v1.105.9...v1.106.0) (2021-03-11) + + +### Features + +* **generator:** update protoc to v3.15.3 ([#354](https://www.github.com/googleapis/java-datastore/issues/354)) ([3b1f67a](https://www.github.com/googleapis/java-datastore/commit/3b1f67af118b188e57a7dda77d2c265672765a6a)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.20.1 ([#365](https://www.github.com/googleapis/java-datastore/issues/365)) ([ccc4a01](https://www.github.com/googleapis/java-datastore/commit/ccc4a015bc30b5b7bf43eb6af697a44b7be2e041)) + +### [1.105.9](https://www.github.com/googleapis/java-datastore/compare/v1.105.8...v1.105.9) (2021-02-25) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.20.0 ([#350](https://www.github.com/googleapis/java-datastore/issues/350)) ([13336fb](https://www.github.com/googleapis/java-datastore/commit/13336fbe4dc5ea54ea0b50f2dce4c7534e8203ce)) + +### [1.105.8](https://www.github.com/googleapis/java-datastore/compare/v1.105.7...v1.105.8) (2021-02-22) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.19.0 ([#339](https://www.github.com/googleapis/java-datastore/issues/339)) ([393bd29](https://www.github.com/googleapis/java-datastore/commit/393bd29b15d818b6f7ab34542dcd3ca6b956f61d)) + +### [1.105.7](https://www.github.com/googleapis/java-datastore/compare/v1.105.6...v1.105.7) (2021-01-21) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.18.0 ([#309](https://www.github.com/googleapis/java-datastore/issues/309)) ([211ac20](https://www.github.com/googleapis/java-datastore/commit/211ac202d4fd9b5b7b07bc0b21e56d98e8bc18e5)) + +### [1.105.6](https://www.github.com/googleapis/java-datastore/compare/v1.105.5...v1.105.6) (2021-01-11) + + +### Dependencies + +* update dependency com.google.oauth-client:google-oauth-client to v1.31.4 ([#301](https://www.github.com/googleapis/java-datastore/issues/301)) ([f03b4ce](https://www.github.com/googleapis/java-datastore/commit/f03b4ceae059a6be93b48776cfcf51dbd53c8c1d)) + +### [1.105.5](https://www.github.com/googleapis/java-datastore/compare/v1.105.4...v1.105.5) (2020-12-15) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.17.0 ([#288](https://www.github.com/googleapis/java-datastore/issues/288)) ([30f11d2](https://www.github.com/googleapis/java-datastore/commit/30f11d234e63723b0f8afe57f6d3390cb54ad9fe)) + +### [1.105.4](https://www.github.com/googleapis/java-datastore/compare/v1.105.3...v1.105.4) (2020-12-14) + + +### Bug Fixes + +* broken links ([#276](https://www.github.com/googleapis/java-datastore/issues/276)) ([7203098](https://www.github.com/googleapis/java-datastore/commit/7203098e4ab09bb73c3b66ff4c6100aac02d20c4)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.16.1 ([b323187](https://www.github.com/googleapis/java-datastore/commit/b323187011d66bb12410a2f762c13bb8e21ad227)) + +### [1.105.3](https://www.github.com/googleapis/java-datastore/compare/v1.105.2...v1.105.3) (2020-12-02) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.16.0 ([#277](https://www.github.com/googleapis/java-datastore/issues/277)) ([fbfa25b](https://www.github.com/googleapis/java-datastore/commit/fbfa25bf7ef717ec12364ccd76e7f5b35d51234e)) + +### [1.105.2](https://www.github.com/googleapis/java-datastore/compare/v1.105.1...v1.105.2) (2020-11-20) + + +### Dependencies + +* update dependency com.google.oauth-client:google-oauth-client to v1.31.2 ([#265](https://www.github.com/googleapis/java-datastore/issues/265)) ([3f165c7](https://www.github.com/googleapis/java-datastore/commit/3f165c7843b7241340eae8e9ad391357e36df237)) + +### [1.105.1](https://www.github.com/googleapis/java-datastore/compare/v1.105.0...v1.105.1) (2020-11-16) + + +### Documentation + +* update google cloud libraries-bom ([#236](https://www.github.com/googleapis/java-datastore/issues/236)) ([7325fa0](https://www.github.com/googleapis/java-datastore/commit/7325fa0ba489efe31a58f64c2d3e2b55cd156822)) +* update libraries-bom ([#220](https://www.github.com/googleapis/java-datastore/issues/220)) ([593fc66](https://www.github.com/googleapis/java-datastore/commit/593fc662e11ea446cd3fc7864cfa9a1b75480fba)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.13.0 ([#243](https://www.github.com/googleapis/java-datastore/issues/243)) ([d275db8](https://www.github.com/googleapis/java-datastore/commit/d275db8e3f14783acfebb9dff7347a871dcd9727)) +* update dependency com.google.oauth-client:google-oauth-client to v1.31.1 ([#244](https://www.github.com/googleapis/java-datastore/issues/244)) ([b984e36](https://www.github.com/googleapis/java-datastore/commit/b984e360ccaf30f55b239f831430256f3231036f)) +* update google-cloud-shared-dependencies to 0.15.0 ([#259](https://www.github.com/googleapis/java-datastore/issues/259)) ([d6c68e7](https://www.github.com/googleapis/java-datastore/commit/d6c68e7e09f5e5728f2f082d5e95503df04a2ec2)) + +## [1.105.0](https://www.github.com/googleapis/java-datastore/compare/v1.104.0...v1.105.0) (2020-09-01) + + +### Features + +* **deps:** adopt flatten plugin and google-cloud-shared-dependencies ([#174](https://www.github.com/googleapis/java-datastore/issues/174)) ([8618c18](https://www.github.com/googleapis/java-datastore/commit/8618c1848e71424fa164fee9d8b7b53641b6b823)) + + +### Bug Fixes + +* query result start with startCursor if specified ([#207](https://www.github.com/googleapis/java-datastore/issues/207)) ([023229a](https://www.github.com/googleapis/java-datastore/commit/023229a15edbbe773bd03410ed0784aba248ad6e)) + + +### Dependencies + +* remove direct declaration of google-auth-library-oauth2-http ([#184](https://www.github.com/googleapis/java-datastore/issues/184)) ([4fa4df4](https://www.github.com/googleapis/java-datastore/commit/4fa4df40d63d7fbce023d6231830dcc296c29dd1)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.2 ([#187](https://www.github.com/googleapis/java-datastore/issues/187)) ([941bea0](https://www.github.com/googleapis/java-datastore/commit/941bea016f1ce4e1c1fd027b1671f950e9c52160)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.3 ([#191](https://www.github.com/googleapis/java-datastore/issues/191)) ([a89eb08](https://www.github.com/googleapis/java-datastore/commit/a89eb08be1cd9689d38b8b67c472cc928e3549c1)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.4 ([#196](https://www.github.com/googleapis/java-datastore/issues/196)) ([7214e0a](https://www.github.com/googleapis/java-datastore/commit/7214e0ae224633e2effc023d10494e0164a8f9dc)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.6 ([#199](https://www.github.com/googleapis/java-datastore/issues/199)) ([6a959d3](https://www.github.com/googleapis/java-datastore/commit/6a959d3f7ca75ba5da1d1c4cb509593d3be39e98)) +* update dependency com.google.oauth-client:google-oauth-client to v1.31.0 ([#186](https://www.github.com/googleapis/java-datastore/issues/186)) ([16bfb9a](https://www.github.com/googleapis/java-datastore/commit/16bfb9a0127f4969a796ad95cc11cf2b8b92d0f3)) + + +### Documentation + +* libraries-bom 8.1.0 ([#200](https://www.github.com/googleapis/java-datastore/issues/200)) ([9425972](https://www.github.com/googleapis/java-datastore/commit/9425972905d1e370192eeb3bbfe837f5a7fb25cf)) +* update libraries-bom ([#211](https://www.github.com/googleapis/java-datastore/issues/211)) ([9407c4a](https://www.github.com/googleapis/java-datastore/commit/9407c4afec3de6e18c96c24872269e61c8ad40fb)) + +## [1.104.0](https://www.github.com/googleapis/java-datastore/compare/v1.103.0...v1.104.0) (2020-06-17) + + +### Features + +* add opencensus tracing/stats support for Datastore RPC operations ([#130](https://www.github.com/googleapis/java-datastore/issues/130)) ([5aee52f](https://www.github.com/googleapis/java-datastore/commit/5aee52f5013d6780e523e0c6d7d00a1826b83b9b)) +* add support to customize gcloud command of LocalDatastoreHelper ([#137](https://www.github.com/googleapis/java-datastore/issues/137)) ([976d979](https://www.github.com/googleapis/java-datastore/commit/976d9791572117dc703d8d7d6963bdd6603ecd63)) + + +### Bug Fixes + +* fix version number in changelog to correctly reflect what was released to maven central ([#145](https://www.github.com/googleapis/java-datastore/issues/145)) ([c509a2a](https://www.github.com/googleapis/java-datastore/commit/c509a2a4229f864edef8681677d73f3c7be1101f)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.0 ([#161](https://www.github.com/googleapis/java-datastore/issues/161)) ([39c8d72](https://www.github.com/googleapis/java-datastore/commit/39c8d723b318d08ca494b71167eaa80b1df6423d)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.8.1 ([#163](https://www.github.com/googleapis/java-datastore/issues/163)) ([7bfa07e](https://www.github.com/googleapis/java-datastore/commit/7bfa07eb3a7cf84fcf3e19f6a33914162fa28499)) + +## [1.103.0](https://www.github.com/googleapis/java-datastore/compare/v1.102.4...v1.103.0) (2020-06-02) + + +### Features + +* add flatten plugin to client and proto modules ([#108](https://www.github.com/googleapis/java-datastore/issues/108)) ([fb3566d](https://www.github.com/googleapis/java-datastore/commit/fb3566d31600b9ed629a2daa46c5202a894181b2)) +* Create CODEOWNERS ([#122](https://www.github.com/googleapis/java-datastore/issues/122)) ([8082369](https://www.github.com/googleapis/java-datastore/commit/80823698416bbe08e2d22fbc81ec3709ad2552c8)) +* implement google-cloud-shared-dependencies BOM ([#135](https://www.github.com/googleapis/java-datastore/issues/135)) ([72e29ff](https://www.github.com/googleapis/java-datastore/commit/72e29ff3460b12436e76d445aad7b8ae0e4ee82d)) + + +### Bug Fixes + +* update retry logic for operations that can be associated with a transaction ([#144](https://www.github.com/googleapis/java-datastore/issues/144)) ([82ee74e](https://www.github.com/googleapis/java-datastore/commit/82ee74ed4487f90f97856bc766edb53b66474378)) + + +### Dependencies + +* bump shared-deps version and add back certain test deps ([#139](https://www.github.com/googleapis/java-datastore/issues/139)) ([660f216](https://www.github.com/googleapis/java-datastore/commit/660f216302fedaf2f5fe0f4c76cdab8fca65cbd1)) +* update core transport dependencies to v1.35.0 ([#114](https://www.github.com/googleapis/java-datastore/issues/114)) ([cad3bfb](https://www.github.com/googleapis/java-datastore/commit/cad3bfbbe739ab3ed5ebea89bee620ef8bbefd95)) +* update dependency com.google.api.grpc:proto-google-common-protos to v1.18.0 ([#117](https://www.github.com/googleapis/java-datastore/issues/117)) ([b484256](https://www.github.com/googleapis/java-datastore/commit/b484256c30ac9117eb82688c801966b6ace856df)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.6.0 ([#140](https://www.github.com/googleapis/java-datastore/issues/140)) ([712779c](https://www.github.com/googleapis/java-datastore/commit/712779c4a25bd5f74b9557931a84bd4a812279c7)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v0.7.0 ([#142](https://www.github.com/googleapis/java-datastore/issues/142)) ([e1a5a65](https://www.github.com/googleapis/java-datastore/commit/e1a5a65d2ae2d45c4871e3e7b2e9089ad5cdc542)) +* update dependency com.google.guava:guava-bom to v29 ([#95](https://www.github.com/googleapis/java-datastore/issues/95)) ([32d5e37](https://www.github.com/googleapis/java-datastore/commit/32d5e37f244969ba980cd94a8eaa8165b368ebc6)) +* update dependency com.google.protobuf:protobuf-java to v3.12.0 ([#127](https://www.github.com/googleapis/java-datastore/issues/127)) ([8a310f3](https://www.github.com/googleapis/java-datastore/commit/8a310f313e53fac802ca75ea539fc4656337c6ee)) +* update dependency io.grpc:grpc-bom to v1.29.0 ([#110](https://www.github.com/googleapis/java-datastore/issues/110)) ([ad6b880](https://www.github.com/googleapis/java-datastore/commit/ad6b8803d4cd55fa37ba57fd3edafad256c41aed)) +* update dependency org.threeten:threetenbp to v1.4.4 ([#112](https://www.github.com/googleapis/java-datastore/issues/112)) ([41d571d](https://www.github.com/googleapis/java-datastore/commit/41d571d1e18f1400f7975a6e82646417ed39ee84)) + + +### Documentation + +* fix java doc link of LocalDatastoreHelper#stop ([#126](https://www.github.com/googleapis/java-datastore/issues/126)) ([ed9b895](https://www.github.com/googleapis/java-datastore/commit/ed9b895d57db302a731e38bc6708310baa69cd67)) +* update CONTRIBUTING.md to include code formatting ([#534](https://www.github.com/googleapis/java-datastore/issues/534)) ([#124](https://www.github.com/googleapis/java-datastore/issues/124)) ([147197d](https://www.github.com/googleapis/java-datastore/commit/147197d0655a509a11f906e95d5f81d57193c562)) + +### [1.101.4](https://www.github.com/googleapis/java-datastore/compare/v1.101.3...v1.101.4) (2020-04-08) + + +### Dependencies + +* update core dependencies ([#64](https://www.github.com/googleapis/java-datastore/issues/64)) ([ce0fd11](https://www.github.com/googleapis/java-datastore/commit/ce0fd116dbc5de69ae4526d95cd8014eaf2da1a0)) +* update core dependencies ([#86](https://www.github.com/googleapis/java-datastore/issues/86)) ([8394595](https://www.github.com/googleapis/java-datastore/commit/83945955b6bc6f915d321d190a2b6349fa52b597)) +* update core dependencies to v1.93.3 ([#67](https://www.github.com/googleapis/java-datastore/issues/67)) ([3286a38](https://www.github.com/googleapis/java-datastore/commit/3286a38b3f4176f0b83a9a4230fba2c431c86047)) +* update core dependencies to v1.93.4 ([#90](https://www.github.com/googleapis/java-datastore/issues/90)) ([9707cd4](https://www.github.com/googleapis/java-datastore/commit/9707cd41ac0b43bee048bb2386ab2484ced0e57b)) +* update dependency com.google.api:api-common to v1.9.0 ([#80](https://www.github.com/googleapis/java-datastore/issues/80)) ([ce0726b](https://www.github.com/googleapis/java-datastore/commit/ce0726ba9ded67f48c4c11403f4f59b0dc30a5b7)) +* update dependency com.google.api:gax-bom to v1.55.0 ([#83](https://www.github.com/googleapis/java-datastore/issues/83)) ([b67b962](https://www.github.com/googleapis/java-datastore/commit/b67b962d0883433ae9aea909886aa5b5d988e78c)) +* update dependency com.google.cloud.samples:shared-configuration to v1.0.13 ([#76](https://www.github.com/googleapis/java-datastore/issues/76)) ([1ecf942](https://www.github.com/googleapis/java-datastore/commit/1ecf942228f963b947732381e44b0a25a4d24d6b)) +* update dependency com.google.oauth-client:google-oauth-client to v1.30.6 ([#60](https://www.github.com/googleapis/java-datastore/issues/60)) ([e355d0f](https://www.github.com/googleapis/java-datastore/commit/e355d0f8ac86601099d8d3570f786d5a3880b968)) +* update dependency org.threeten:threetenbp to v1.4.2 ([#73](https://www.github.com/googleapis/java-datastore/issues/73)) ([13c867a](https://www.github.com/googleapis/java-datastore/commit/13c867a4135ae024d0eb6af602ee50daf8ad30ff)) +* update dependency org.threeten:threetenbp to v1.4.3 ([#88](https://www.github.com/googleapis/java-datastore/issues/88)) ([75a7254](https://www.github.com/googleapis/java-datastore/commit/75a7254a65e1d97a7bc8fae0f812ffebea060b60)) + +### [1.101.3](https://www.github.com/googleapis/java-datastore/compare/v1.101.2...v1.101.3) (2020-02-28) + + +### Bug Fixes + +* flakey ITDatastoreTest#testSkippedResults ([#46](https://www.github.com/googleapis/java-datastore/issues/46)) ([3035ef2](https://www.github.com/googleapis/java-datastore/commit/3035ef2b6bf659bc847c4cf0a963a1f3badd68c7)), closes [#18](https://www.github.com/googleapis/java-datastore/issues/18) + + +### Dependencies + +* update core dependencies ([#57](https://www.github.com/googleapis/java-datastore/issues/57)) ([34e94b1](https://www.github.com/googleapis/java-datastore/commit/34e94b15c670aea011503e8b6835301959ac0152)) +* update core transport dependencies to v1.34.2 ([#44](https://www.github.com/googleapis/java-datastore/issues/44)) ([42e7e63](https://www.github.com/googleapis/java-datastore/commit/42e7e6349ac9a6ae9134f2bd1149a50f498a917e)) +* update dependency com.google.protobuf:protobuf-java to v3.11.4 ([#48](https://www.github.com/googleapis/java-datastore/issues/48)) ([f78d0bd](https://www.github.com/googleapis/java-datastore/commit/f78d0bda15cce4e9639c582beab45a58d19d2a38)) +* update dependency io.grpc:grpc-bom to v1.27.1 ([#45](https://www.github.com/googleapis/java-datastore/issues/45)) ([ef6ca5b](https://www.github.com/googleapis/java-datastore/commit/ef6ca5bb0dc7311253980d5bbef2d88a510d85cc)) +* update dependency io.grpc:grpc-bom to v1.27.2 ([#55](https://www.github.com/googleapis/java-datastore/issues/55)) ([dea7ec2](https://www.github.com/googleapis/java-datastore/commit/dea7ec20c603be9890f06a78fa17396299232a20)) +* update truth 1.0 -> 1.0.1 ([#58](https://www.github.com/googleapis/java-datastore/issues/58)) ([2af29c5](https://www.github.com/googleapis/java-datastore/commit/2af29c5c5fb13921f79e6b8b68fff0c82be29402)) + +### [1.101.2](https://www.github.com/googleapis/java-datastore/compare/v1.101.1...v1.101.2) (2020-02-13) + + +### Bug Fixes + +* bom version tag miss configured ([#42](https://www.github.com/googleapis/java-datastore/issues/42)) ([6af084f](https://www.github.com/googleapis/java-datastore/commit/6af084face9afa7ee1fa8dec2a96419e7f4db706)) + +### [1.101.1](https://www.github.com/googleapis/java-datastore/compare/1.101.0...v1.101.1) (2020-02-11) + + +### Bug Fixes + +* remove error_prone_annotations exclusion rules from poms ([#31](https://www.github.com/googleapis/java-datastore/issues/31)) ([b659cfa](https://www.github.com/googleapis/java-datastore/commit/b659cfa6992f6327b4b0d9f0414d51c4a70d8557)) +* remove temporary added animal-sniffer-annotations exclusion rule from pom ([#16](https://www.github.com/googleapis/java-datastore/issues/16)) ([fde0a9f](https://www.github.com/googleapis/java-datastore/commit/fde0a9fcf38c74143b896a6e6b282047d7dadb6f)), closes [#3](https://www.github.com/googleapis/java-datastore/issues/3) + + +### Dependencies + +* update core dependencies ([4481c27](https://www.github.com/googleapis/java-datastore/commit/4481c27e941b6ba17b69bc84ab4ae700d57ac92f)) +* update core dependencies to v1.92.5 ([#36](https://www.github.com/googleapis/java-datastore/issues/36)) ([028b669](https://www.github.com/googleapis/java-datastore/commit/028b6690ba4b75aa0691f7b999792f333fea1d8d)) +* update dependency com.google.cloud:google-cloud-shared-config to v0.4.0 ([#25](https://www.github.com/googleapis/java-datastore/issues/25)) ([657c69b](https://www.github.com/googleapis/java-datastore/commit/657c69bab7296c57575c24e96b208427e6791d1f)) +* update dependency com.google.protobuf:protobuf-java to v3.11.3 ([#32](https://www.github.com/googleapis/java-datastore/issues/32)) ([6b3a930](https://www.github.com/googleapis/java-datastore/commit/6b3a930e0ed9c389ce5bedbf33dcd7a0a40227d3)) +* update dependency junit:junit to v4.13 ([#13](https://www.github.com/googleapis/java-datastore/issues/13)) ([174158b](https://www.github.com/googleapis/java-datastore/commit/174158bac4fad21563fdd209b39e377c48bd8efe)) +* update dependency org.threeten:threetenbp to v1.4.1 ([#28](https://www.github.com/googleapis/java-datastore/issues/28)) ([d6d74a1](https://www.github.com/googleapis/java-datastore/commit/d6d74a19e735e55ccf84dc5f0961f44cd71fc183)) diff --git a/java-datastore/README.md b/java-datastore/README.md new file mode 100644 index 000000000000..be8b583d1b5d --- /dev/null +++ b/java-datastore/README.md @@ -0,0 +1,498 @@ +# Google Cloud Datastore Client for Java + +Java idiomatic client for [Cloud Datastore][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.62.0 + pom + import + + + + + + + com.google.cloud + google-cloud-datastore + + +``` + +If you are using Maven without the BOM, add this to your dependencies: + + +```xml + + com.google.cloud + google-cloud-datastore + 2.31.2 + + +``` + +If you are using Gradle 5.x or later, add this to your dependencies: + +```Groovy +implementation platform('com.google.cloud:libraries-bom:26.73.0') + +implementation 'com.google.cloud:google-cloud-datastore' +``` +If you are using Gradle without BOM, add this to your dependencies: + +```Groovy +implementation 'com.google.cloud:google-cloud-datastore:2.33.2' +``` + +If you are using SBT, add this to your dependencies: + +```Scala +libraryDependencies += "com.google.cloud" % "google-cloud-datastore" % "2.33.2" +``` + +## 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 Datastore APIs, and the authenticated principal must have the [IAM role(s)][predefined-iam-roles] required to access GCP resources using the Cloud Datastore API calls. + +## Getting Started + +### Prerequisites + +You will need a [Google Cloud Platform Console][developer-console] project with the Cloud Datastore [API enabled][enable-api]. +You will need to [enable billing][enable-billing] to use Google Cloud Datastore. +[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-datastore` library. See the [Quickstart](#quickstart) section +to add `google-cloud-datastore` as a dependency in your code. + +## About Cloud Datastore + + +[Cloud Datastore][product-docs] is a fully managed, schemaless database for\nstoring non-relational data. Cloud Datastore automatically scales with\nyour users and supports ACID transactions, high availability of reads and\nwrites, strong consistency for reads and ancestor queries, and eventual\nconsistency for all other queries. + +See the [Cloud Datastore client library docs][javadocs] to learn how to +use this Cloud Datastore Client Library. + + +See the [Google Cloud Datastore docs][cloud-datastore-activation] for more details on how to activate +Cloud Datastore for your project. + +See the [Datastore client library docs][datastore-client-lib-docs] to learn how to interact +with the Cloud Datastore using this Client Library. + +#### Creating an authorized service object +To make authenticated requests to Google Cloud Datastore, you must create a service object with credentials. You can then make API calls by calling methods on the Datastore service object. The simplest way to authenticate is to use [Application Default Credentials](https://developers.google.com/identity/protocols/application-default-credentials). These credentials are automatically inferred from your environment, so you only need the following code to create your service object: + +```java +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; + +Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); +``` + +For other authentication options, see the [Authentication](https://github.com/googleapis/google-cloud-java#authentication) page. + +#### Storing data +Objects in Datastore are known as entities. Entities are grouped by "kind" and have keys for easy access. In this code snippet, we will create a new entity representing a person and store that data by the person's email. First, add the following imports at the top of your file: + +```java +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +``` + +Then add the following code to put an entity in Datastore. + +```java +KeyFactory keyFactory = datastore.newKeyFactory().setKind("Person"); +Key key = keyFactory.newKey("john.doe@gmail.com"); +Entity entity = Entity.newBuilder(key) + .set("name", "John Doe") + .set("age", 51) + .set("favorite_food", "pizza") + .build(); +datastore.put(entity); +``` + +Later, if you want to get this entity back, add the following to your code: + +```java +Entity johnEntity = datastore.get(key); +``` + +#### Running a query +In addition to retrieving entities by their keys, you can perform queries to retrieve entities by +the values of their properties. A typical query includes an entity kind, filters to select entities +with matching values, and sort orders to sequence the results. `google-cloud-datastore` supports two +types of queries: `StructuredQuery` (that allows you to construct query elements) and `GqlQuery` +(which operates using [GQL syntax](https://cloud.google.com/datastore/docs/apis/gql/gql_reference)) +in string format. In this tutorial, we will use a simple `StructuredQuery`. + +Suppose that you've added more people to Datastore, and now you want to find all people whose favorite food is pizza. Import the following: + +```java +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +``` + +Then add the following code to your program: + +```java +Query query = Query.newEntityQueryBuilder() + .setKind("Person") + .setFilter(PropertyFilter.eq("favorite_food", "pizza")) + .build(); +QueryResults results = datastore.run(query); +while (results.hasNext()) { + Entity currentEntity = results.next(); + System.out.println(currentEntity.getString("name") + ", you're invited to a pizza party!"); +} +``` + +Cloud Datastore relies on indexing to run queries. Indexing is turned on by default for most types of properties. To read more about indexing, see the [Cloud Datastore Index Configuration documentation](https://cloud.google.com/datastore/docs/tools/indexconfig). + +#### Updating data +Another thing you'll probably want to do is update your data. The following snippet shows how to update a Datastore entity if it exists. + +```java +KeyFactory keyFactory = datastore.newKeyFactory().setKind("keyKind"); +Key key = keyFactory.newKey("keyName"); +Entity entity = datastore.get(key); +if (entity != null) { + System.out.println("Updating access_time for " + entity.getString("name")); + entity = Entity.newBuilder(entity) + .set("access_time", DateTime.now()) + .build(); + datastore.update(entity); +} +``` + +The complete source code can be found at +[UpdateEntity.java](https://github.com/googleapis/google-cloud-java/blob/2c1850d4f82f3fbd7b4a50582384c008085aa1a8/google-cloud-examples/src/main/java/com/google/cloud/examples/datastore/snippets/UpdateEntity.java). + +#### Complete source code + +In +[AddEntitiesAndRunQuery.java](https://github.com/googleapis/google-cloud-java/blob/2c1850d4f82f3fbd7b4a50582384c008085aa1a8/google-cloud-examples/src/main/java/com/google/cloud/examples/datastore/snippets/AddEntitiesAndRunQuery.java) +we put together all the code to store data and run queries into one program. The program assumes that you are +running on Compute Engine or from your own desktop. To run the example on App Engine, simply move +the code from the main method to your application's servlet class and change the print statements to +display on your webpage. + +gRPC Java Datastore Client User Guide +------- +The [Java Datastore client](https://github.com/googleapis/java-datastore) now offers gRPC as a transport layer option with experimental support. Using [gRPC connection pooling](https://grpc.io/docs/guides/performance/) enables distributing RPCs over multiple connections which may improve performance. + +#### Installation Instructions +To use this feature, please upgrade your Java-datastore SDK to version v2.28.0 or a newer release. You can find the latest versions [here](https://github.com/googleapis/java-datastore/releases). + +#### How to Use +To opt-in to the gRPC transport behavior, simply add the below line of code (`setTransportOptions`) to your Datastore client instantiation. + +Example: +```java +DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .build(); +``` +Setting the transport options explicitly to `GrpcTransportOptions` will signal the client to use gRPC instead of HTTP when making calls to the server. + +To revert back to the existing stable behavior and transport, simply remove the transport options line or replace it with `HttpTransportOptions`. Please note this will require an application rebuild and restart. +Example: +```java +// will default to existing HTTP transport behavior +DatastoreOptions datastoreOptions = DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .build(); + +// will also default to existing HTTP transport behavior +DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setDatabaseId("my-database") + .setTransportOptions(HttpTransportOptions.newBuilder() + .setConnectTimeout(1000) + .build()).build(); +``` + +Note: client instantiations that already use `setTransportOptions` with `HttpTransportOptions` will continue to have the same behavior. Only transports that are explicitly set to gRPC will change. + +#### Verify Datastore Transport Options Type +To verify which type of TransportOptions you have successfully configured, you can use the below lines of code to compare transport options type: +```java +// checks if using gRPC transport options +boolean isGRPC = datastore.getOptions().getTransportOptions() instanceof GrpcTransportOptions; + +// checks if using HTTP transport options +boolean isHTTP = datastore.getOptions().getTransportOptions() instanceof HTTPTransportOptions; +``` + +#### New Features +There are new gRPC specific features available to use in this update. + +##### Connection Pool +A connection pool, also known as a channel pool, is a cache of database connections that are shared and reused to improve connection latency and performance. With this update, now you will be able to configure the channel pool to improve application performance. This section guides you in determining the optimal connection pool size and configuring it within the Java datastore client. +To customize the number of channels your client uses, you can update the channel provider in the DatastoreOptions. +###### Determine the best connection pool size +The default connection pool size is right for most applications, and in most cases there's no need to change it. + +However sometimes you may want to change your connection pool size due to high throughput or buffered requests. Ideally, to leave room for traffic fluctuations, a connection pool has about twice the number of connections it takes for maximum saturation. Because a connection can handle a maximum of 100 concurrent requests, between 10 and 50 outstanding requests per connection is optimal. The limit of 100 concurrent streams per gRPC connection is enforced in Google's middleware layer, and you are not able to reconfigure this number. + +The following steps help you calculate the optimal number of connections in your channel pool using estimate per-client QPS and average latency numbers. + +To calculate the optimal connections, gather the following information: + +1. The maximum number of queries per second (QPS) per client when your application is running a typical workload. +2. The average latency (the response time for a single request) in ms. +3. Determine the number of requests that you can send serially per second by dividing 1,000 by the average latency value. +4. Divide the QPS in seconds by the number of serial requests per second. +5. Divide the result by 50 requests per channel to determine the minimum optimal channel pool size. (If your calculation is less than 2, use at least 2 channels anyway, to ensure redundancy.) +6. Divide the same result by 10 requests per channel to determine the maximum optimal channel pool size. + +These steps are expressed in the following equations: +```java +(QPS ÷ (1,000 ÷ latency ms)) ÷ 50 streams = Minimum optimal number of connections +(QPS ÷ (1,000 ÷ latency ms)) ÷ 10 streams = Maximum optimal number of connections +``` + +###### Example +Your application typically sends 50,000 requests per second, and the average latency is 10 ms. Divide 1,000 by 10 ms to determine that you can send 100 requests serially per second. +Divide that number into 50,000 to get the parallelism needed to send 50,000 QPS: 500. Each channel can have at most 100 requests out concurrently, and your target channel utilization +is between 10 and 50 concurrent streams. Therefore, to calculate the minimum, divide 500 by 50 to get 10. To find the maximum, divide 500 by 10 to get 50. This means that your channel +pool size for this example should be between 10 and 50 connections. + +It is also important to monitor your traffic after making changes and adjust the number of connections in your pool if necessary. + +###### Set the pool size +The following code sample demonstrates how to configure the channel pool in the client libraries using `DatastoreOptions`. +See [ChannelPoolSettings](https://cloud.google.com/java/docs/reference/gax/latest/com.google.api.gax.grpc.ChannelPoolSettings) and [Performance Best Practices](https://grpc.io/docs/guides/performance/) for more information on channel pools and best practices for performance. + +Code Example +```java +InstantiatingGrpcChannelProvider channelProvider = + DatastoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelPoolSettings( + ChannelPoolSettings.builder() + .setInitialChannelCount(MIN_VAL) + .setMaxChannelCount(MAX_VAL) + .build()) + .build(); + +DatastoreOptions options = DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setChannelProvider(channelProvider) + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .build(); +``` +Testing +------- + +This library has tools to help write tests for code that uses the Datastore. + +#### On your machine + +You can test against a temporary local Datastore by following these steps: + +1. [Install Cloud SDK and start the emulator](https://cloud.google.com/datastore/docs/tools/datastore-emulator) + +To determine which host/port the emulator is running on: + +``` +$ gcloud beta emulators datastore env-init + +# Sample output: +# export DATASTORE_EMULATOR_HOST=localhost:8759 +``` + +3. Point your client to the emulator + +```java +DatastoreOptions options = DatastoreOptions.newBuilder() +.setProjectId(DatastoreOptions.getDefaultProjectId()) +.setHost(System.getenv("DATASTORE_EMULATOR_HOST")) +.setCredentials(NoCredentials.getInstance()) +.setRetrySettings(ServiceOptions.getNoRetrySettings()) +.build(); +Datastore datastore = options.getService(); +``` +4. Run your tests + +Example Applications +-------------------- +- [`Bookshelf`](https://github.com/GoogleCloudPlatform/getting-started-java/tree/main/bookshelf) - An App Engine app that manages a virtual bookshelf. + - This app uses `google-cloud` to interface with Cloud Datastore and Cloud Storage. It also uses Cloud SQL, another Google Cloud Platform service. +- [`Flexible Environment/Datastore example`](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/flexible/datastore) - A simple app that uses Cloud Datastore to list the last 10 IP addresses that visited your site. +- [`SparkDemo`](https://github.com/GoogleCloudPlatform/java-docs-samples/blob/main/flexible/sparkjava) - An example of using `google-cloud-datastore` from within the SparkJava and App Engine Flexible Environment frameworks. + - Read about how it works on the example's [README page](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/flexible/sparkjava#how-does-it-work). + + + + +## Samples + +Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-java/tree/main/samples) directory. + +| Sample | Source Code | Try it | +| --------------------------- | --------------------------------- | ------ | +| Configure Connection Pool | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/ConfigureConnectionPool.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/datastore/ConfigureConnectionPool.java) | +| Quickstart Sample | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/QuickstartSample.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/datastore/QuickstartSample.java) | +| Avg Aggregation On Kind | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationOnKind.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/datastore/aggregation/AvgAggregationOnKind.java) | +| Avg Aggregation With Limit | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithLimit.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/datastore/aggregation/AvgAggregationWithLimit.java) | +| Avg Aggregation With Order By | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithOrderBy.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/datastore/aggregation/AvgAggregationWithOrderBy.java) | +| Avg Aggregation With Property Filter | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithPropertyFilter.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/datastore/aggregation/AvgAggregationWithPropertyFilter.java) | +| Count Aggregation In Transaction | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationInTransaction.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/datastore/aggregation/CountAggregationInTransaction.java) | +| Count Aggregation On Kind | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationOnKind.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/datastore/aggregation/CountAggregationOnKind.java) | +| Count Aggregation With Gql Query | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithGqlQuery.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/datastore/aggregation/CountAggregationWithGqlQuery.java) | +| Count Aggregation With Limit | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithLimit.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/datastore/aggregation/CountAggregationWithLimit.java) | +| Count Aggregation With Order By | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithOrderBy.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/datastore/aggregation/CountAggregationWithOrderBy.java) | +| Count Aggregation With Property Filter | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithPropertyFilter.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/datastore/aggregation/CountAggregationWithPropertyFilter.java) | +| Count Aggregation With Stale Read | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithStaleRead.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/datastore/aggregation/CountAggregationWithStaleRead.java) | +| Multiple Aggregations In Gql Query | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/MultipleAggregationsInGqlQuery.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/datastore/aggregation/MultipleAggregationsInGqlQuery.java) | +| Multiple Aggregations In Structured Query | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/MultipleAggregationsInStructuredQuery.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/datastore/aggregation/MultipleAggregationsInStructuredQuery.java) | +| Sum Aggregation On Kind | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationOnKind.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/datastore/aggregation/SumAggregationOnKind.java) | +| Sum Aggregation With Limit | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithLimit.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/datastore/aggregation/SumAggregationWithLimit.java) | +| Sum Aggregation With Order By | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithOrderBy.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/datastore/aggregation/SumAggregationWithOrderBy.java) | +| Sum Aggregation With Property Filter | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithPropertyFilter.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/datastore/aggregation/SumAggregationWithPropertyFilter.java) | +| Indexing Consideration Query | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.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/datastore/filters/IndexingConsiderationQuery.java) | +| Create a union between two filters | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/filters/OrFilterQuery.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/datastore/filters/OrFilterQuery.java) | +| Order Fields Query | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.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/datastore/filters/OrderFieldsQuery.java) | +| Query Profile Explain | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplain.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/datastore/queryprofile/QueryProfileExplain.java) | +| Query Profile Explain Aggregation | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAggregation.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/datastore/queryprofile/QueryProfileExplainAggregation.java) | +| Query Profile Explain Analyze | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyze.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/datastore/queryprofile/QueryProfileExplainAnalyze.java) | +| Query Profile Explain Analyze Aggregation | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyzeAggregation.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/datastore/queryprofile/QueryProfileExplainAnalyzeAggregation.java) | +| Task List | [source code](https://github.com/googleapis/google-cloud-java/blob/main/samples/snippets/src/main/java/com/google/datastore/snippets/TaskList.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/google/datastore/snippets/TaskList.java) | + + + +## Troubleshooting + +To get help, follow the instructions in the [shared Troubleshooting document][troubleshooting]. + +## Transport + +Cloud Datastore uses both gRPC and HTTP/JSON 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/datastore +[javadocs]: https://cloud.google.com/java/docs/reference/google-cloud-datastore/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-datastore.svg +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-datastore/2.33.2 +[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=datastore.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-datastore/datastore-v1-proto-client/clirr-ignored-differences.xml b/java-datastore/datastore-v1-proto-client/clirr-ignored-differences.xml new file mode 100644 index 000000000000..7df1765da288 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/clirr-ignored-differences.xml @@ -0,0 +1,20 @@ + + + + + com/google/datastore/v1/client/QuerySplitter + java.util.List getSplits(com.google.datastore.v1.Query, com.google.datastore.v1.PartitionId, int, com.google.datastore.v1.client.Datastore, com.google.protobuf.Timestamp) + 7012 + + + + com/google/datastore/v1/client/DatastoreOptions + java.lang.String getDatabaseId() + 7002 + + + com/google/datastore/v1/client/DatastoreOptions$Builder + com.google.datastore.v1.client.DatastoreOptions$Builder databaseId(java.lang.String) + 7002 + + diff --git a/java-datastore/datastore-v1-proto-client/pom.xml b/java-datastore/datastore-v1-proto-client/pom.xml new file mode 100644 index 000000000000..51144a08a434 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/pom.xml @@ -0,0 +1,177 @@ + + + + 4.0.0 + com.google.cloud.datastore + datastore-v1-proto-client + 2.33.2 + + + com.google.cloud + google-cloud-datastore-parent + 2.33.2 + + + jar + datastore-v1-proto-client + + Low level client for accessing Google Cloud Datastore v1. + + + + + com.google.api.grpc + proto-google-cloud-datastore-v1 + + + + com.google.http-client + google-http-client + + + + com.google.http-client + google-http-client-protobuf + + + + com.google.http-client + google-http-client-gson + + + + com.google.oauth-client + google-oauth-client + + + + com.google.api-client + google-api-client + + + + com.google.guava + guava + + + + com.google.code.findbugs + jsr305 + + + + com.google.api.grpc + proto-google-common-protos + + + + com.google.protobuf + protobuf-java + + + + com.google.api + api-common + + + + + junit + junit + test + + + + com.google.truth + truth + 1.4.4 + test + + + org.checkerframework + checker-qual + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + -Xmx2048m + + + + + + + + native + + + true + + + + java17 + + [17,) + + + + + org.apache.maven.plugins + maven-compiler-plugin + + UTF-8 + true + + -XDcompilePolicy=simple + --should-stop=ifError=FLOW + -Xplugin:ErrorProne -XepExcludedPaths:.*/generated-sources/.* + + -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED + + + + + com.google.errorprone + error_prone_core + ${error-prone.version} + + + + + + + + + + diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/ChecksumEnforcingInputStream.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/ChecksumEnforcingInputStream.java new file mode 100644 index 000000000000..fc525bd4f28e --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/ChecksumEnforcingInputStream.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 + * + * 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.datastore.v1.client; + +import com.google.api.client.http.HttpResponse; +import com.google.common.annotations.VisibleForTesting; +import java.io.IOException; +import java.io.InputStream; + +/** This class provides End-to-End Checksum API for http protocol. */ +class ChecksumEnforcingInputStream extends InputStream { + private final InputStream delegate; + private final EndToEndChecksumHandler endToEndChecksumHandler; + private final String expectedChecksum; + + ChecksumEnforcingInputStream(InputStream originalInputStream, HttpResponse response) { + this(originalInputStream, EndToEndChecksumHandler.getChecksumHeader(response)); + } + + @VisibleForTesting + ChecksumEnforcingInputStream(InputStream originalInputStream, String checksum) { + delegate = originalInputStream; + expectedChecksum = checksum; + endToEndChecksumHandler = new EndToEndChecksumHandler(); + } + + @Override + public int available() throws IOException { + return delegate.available(); + } + + @Override + public void close() throws IOException { + delegate.close(); + } + + @Override + public void mark(int readlimit) { + throw new RuntimeException("mark(int) Not Supported"); + } + + @Override + public boolean markSupported() { + // This class doesn't support mark, reset methods! + return false; + } + + @Override + public int read() throws IOException { + throw new RuntimeException("read() Not Supported"); + } + + @Override + public int read(byte[] b) throws IOException { + throw new RuntimeException("read(byte[]) Not Supported"); + } + + @Override + public int read(byte[] b, int off, int len) throws IOException { + if (len <= 0) return 0; + int i = delegate.read(b, off, len); + if (i > 0) { + endToEndChecksumHandler.update(b, off, i); + } else { + // no more payload to read. compute checksum and verify + if (!expectedChecksum.equals(endToEndChecksumHandler.hash())) { + throw new IOException("possible memory corruption on payload detected"); + } + } + return i; + } + + @Override + public void reset() throws IOException { + throw new RuntimeException("reset() Not Supported"); + } + + @Override + public long skip(long n) throws IOException { + if (n <= 0) return 0; + // TODO: handle the case of n > Integer.MAX_VALUE ( that is, n > (2GB - 1). It is highly + // unlikely that callers will want to skip that many bytes. That is the entire payload + if (n > Integer.MAX_VALUE) { + throw new IOException("can't skip more than Integer.MAX bytes"); + } + int intSkip = (int) n; + byte[] b = new byte[intSkip]; + return read(b, 0, intSkip); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/Datastore.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/Datastore.java new file mode 100644 index 000000000000..4a980baa344e --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/Datastore.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 + * + * 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.datastore.v1.client; + +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.rpc.Code; +import java.io.IOException; +import java.io.InputStream; + +/** + * Provides access to Cloud Datastore. + * + *

This class is thread-safe. + */ +public class Datastore { + + final RemoteRpc remoteRpc; + + Datastore(RemoteRpc remoteRpc) { + this.remoteRpc = remoteRpc; + } + + /** Reset the RPC count. */ + public void resetRpcCount() { + remoteRpc.resetRpcCount(); + } + + /** + * Returns the number of RPC calls made since the client was created or {@link #resetRpcCount} was + * called. + */ + public int getRpcCount() { + return remoteRpc.getRpcCount(); + } + + private DatastoreException invalidResponseException(String method, IOException exception) { + return RemoteRpc.makeException( + remoteRpc.getUrl(), method, Code.UNAVAILABLE, "Invalid response", exception); + } + + public AllocateIdsResponse allocateIds(AllocateIdsRequest request) throws DatastoreException { + try (InputStream is = + remoteRpc.call("allocateIds", request, request.getProjectId(), request.getDatabaseId())) { + return AllocateIdsResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("allocateIds", exception); + } + } + + public BeginTransactionResponse beginTransaction(BeginTransactionRequest request) + throws DatastoreException { + try (InputStream is = + remoteRpc.call( + "beginTransaction", request, request.getProjectId(), request.getDatabaseId())) { + return BeginTransactionResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("beginTransaction", exception); + } + } + + public CommitResponse commit(CommitRequest request) throws DatastoreException { + try (InputStream is = + remoteRpc.call("commit", request, request.getProjectId(), request.getDatabaseId())) { + return CommitResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("commit", exception); + } + } + + public LookupResponse lookup(LookupRequest request) throws DatastoreException { + try (InputStream is = + remoteRpc.call("lookup", request, request.getProjectId(), request.getDatabaseId())) { + return LookupResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("lookup", exception); + } + } + + public ReserveIdsResponse reserveIds(ReserveIdsRequest request) throws DatastoreException { + try (InputStream is = + remoteRpc.call("reserveIds", request, request.getProjectId(), request.getDatabaseId())) { + return ReserveIdsResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("reserveIds", exception); + } + } + + public RollbackResponse rollback(RollbackRequest request) throws DatastoreException { + try (InputStream is = + remoteRpc.call("rollback", request, request.getProjectId(), request.getDatabaseId())) { + return RollbackResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("rollback", exception); + } + } + + public RunQueryResponse runQuery(RunQueryRequest request) throws DatastoreException { + try (InputStream is = + remoteRpc.call("runQuery", request, request.getProjectId(), request.getDatabaseId())) { + return RunQueryResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("runQuery", exception); + } + } + + public RunAggregationQueryResponse runAggregationQuery(RunAggregationQueryRequest request) + throws DatastoreException { + try (InputStream is = + remoteRpc.call( + "runAggregationQuery", request, request.getProjectId(), request.getDatabaseId())) { + return RunAggregationQueryResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("runAggregationQuery", exception); + } + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulator.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulator.java new file mode 100644 index 000000000000..e4720c2e8eb4 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulator.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 + * + * 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.datastore.v1.client; + +import static com.google.api.client.util.Preconditions.checkNotNull; +import static com.google.api.client.util.Preconditions.checkState; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.HttpURLConnection; +import java.net.URL; +import java.nio.file.Files; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.TimeUnit; + +/** + * An extension to {@link Datastore} that provides lifecycle management for a datastore emulator. + * + *

In order to use the emulator for a JUnit 4 test you might do something like this: + * + *

+ * public class MyTest {
+ *
+ *   static DatastoreEmulator datastore;
+ *
+ *   {@literal @}BeforeClass
+ *   public static void startEmulator() throws DatastoreEmulatorException {
+ *     DatastoreOptions options = new DatastoreOptions.Builder()
+ *         .localHost("localhost:8080")
+ *         .projectId("my-project-id")
+ *         .build();
+ *     datastore = DatastoreEmulatorFactory.get().create(options);
+ *     datastore.start("/usr/local/cloud-datastore-emulator", "my-project-id");
+ *   }
+ *
+ *   {@literal @}Before
+ *   public void setUp() throws DatastoreEmulatorException {
+ *     datastore.clear();
+ *   }
+ *
+ *   {@literal @}AfterClass
+ *   public static void stopEmulator() throws DatastoreEmulatorException {
+ *     datastore.stop();
+ *   }
+ *
+ *   {@literal @}Test
+ *   public void testFoo1() { }
+ *
+ *   {@literal @}Test
+ *   public void testFoo2() { }
+ *
+ * }
+ * 
+ */ +public class DatastoreEmulator extends Datastore { + private static final int STARTUP_TIMEOUT_SECS = 30; + + private final String host; + private final DatastoreEmulatorOptions options; + + /** Internal state lifecycle management. */ + enum State { + NEW, + STARTED, + STOPPED + } + + private volatile State state = State.NEW; + + private File projectDirectory; + + DatastoreEmulator(RemoteRpc rpc, String localHost, DatastoreEmulatorOptions options) { + super(rpc); + this.host = "http://" + localHost; + this.options = options; + } + + /** + * Clears all data in the emulator. + * + * @throws DatastoreEmulatorException if the clear fails + */ + public void clear() throws DatastoreEmulatorException { + sendEmptyRequest("/reset", "POST"); + } + + /** + * Starts the emulator. It is the caller's responsibility to call {@link #stop}. Note that + * receiving an exception does not indicate that the server did not start. We recommend calling + * {@link #stop} to ensure the server is not running regardless of the result of this method. + * + * @param emulatorDir The path to the emulator directory, e.g. /usr/local/cloud-datastore-emulator + * @param projectId The project ID + * @param commandLineOptions Command line options to pass to the emulator on startup + * @throws DatastoreEmulatorException If {@link #start} has already been called or the server does + * not start successfully. + * @deprecated prefer setting options in the emulator options and calling {#start()}. + */ + @Deprecated + public synchronized void start(String emulatorDir, String projectId, String... commandLineOptions) + throws DatastoreEmulatorException { + checkNotNull(emulatorDir, "emulatorDir cannot be null"); + checkNotNull(projectId, "projectId cannot be null"); + checkState(state == State.NEW, "Cannot call start() more than once."); + try { + startEmulatorInternal( + emulatorDir + "/cloud_datastore_emulator", projectId, Arrays.asList(commandLineOptions)); + state = State.STARTED; + } finally { + if (state != State.STARTED) { + // If we're not able to start the server we don't want people trying again. Just move it + // straight to the STOPPED state. + state = State.STOPPED; + } + } + } + + public synchronized void start() throws DatastoreEmulatorException { + checkState(state == State.NEW, "Cannot call start() more than once."); + try { + startEmulatorInternal(options.getCmd(), options.getProjectId(), options.getCmdLineOptions()); + state = State.STARTED; + } finally { + if (state != State.STARTED) { + // If we're not able to start the server we don't want people trying again. Just move it + // straight to the STOPPED state. + state = State.STOPPED; + } + } + } + + void startEmulatorInternal(String emulatorCmd, String projectId, List commandLineOptions) + throws DatastoreEmulatorException { + projectDirectory = createProjectDirectory(emulatorCmd, projectId); + List cmd = new ArrayList<>(Arrays.asList(emulatorCmd, "start", "--testing")); + cmd.addAll(commandLineOptions); + cmd.add(projectDirectory.getPath()); + final Process emulatorStartProcess; + try { + emulatorStartProcess = newEmulatorProcess(cmd).start(); + } catch (IOException e) { + throw new DatastoreEmulatorException("Could not start emulator", e); + } + // Ensure we don't leak the emulator instance if tests end prematurely. + Runtime.getRuntime() + .addShutdownHook( + new Thread() { + @Override + public void run() { + emulatorStartProcess.destroy(); + } + }); + StartupMonitor monitor = new StartupMonitor(emulatorStartProcess.getInputStream()); + try { + monitor.start(); + if (!monitor.startupCompleteLatch.await(STARTUP_TIMEOUT_SECS, TimeUnit.SECONDS)) { + throw new DatastoreEmulatorException("Emulator did not start within 30 seconds"); + } + if (!monitor.success) { + throw new DatastoreEmulatorException("Emulator did not start normally"); + } + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new DatastoreEmulatorException("Received an interrupt", e); + } + } + + private File createProjectDirectory(String emulatorCmd, String projectId) + throws DatastoreEmulatorException { + File projectDirectory; + try { + projectDirectory = Files.createTempDirectory("datastore-emulator").toFile(); + } catch (IOException e) { + throw new DatastoreEmulatorException("Could not create temporary project directory", e); + } + List cmd = + Arrays.asList( + emulatorCmd, "create", "--project_id=" + projectId, projectDirectory.getPath()); + try { + int retCode = newEmulatorProcess(cmd).start().waitFor(); + if (retCode != 0) { + throw new DatastoreEmulatorException( + String.format("Could not create project (retcode=%d)", retCode)); + } + } catch (IOException e) { + throw new DatastoreEmulatorException("Could not create project", e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new DatastoreEmulatorException("Received an interrupt", e); + } + return projectDirectory; + } + + private ProcessBuilder newEmulatorProcess(List cmd) { + ProcessBuilder builder = new ProcessBuilder(cmd); + builder.redirectErrorStream(true); + builder.environment().putAll(options.getEnvVars()); + return builder; + } + + /** + * Stops the emulator. Multiple calls are allowed. + * + * @throws DatastoreEmulatorException if the emulator cannot be stopped + */ + public synchronized void stop() throws DatastoreEmulatorException { + // We intentionally don't check the internal state. If people want to try and stop the server + // multiple times that's fine. + stopEmulatorInternal(); + if (state != State.STOPPED) { + state = State.STOPPED; + if (projectDirectory != null) { + try { + Process process = + new ProcessBuilder("rm", "-r", projectDirectory.getAbsolutePath()).start(); + if (process.waitFor() != 0) { + throw new IOException( + "Temporary project directory deletion exited with " + process.exitValue()); + } + } catch (IOException e) { + throw new IllegalStateException("Could not delete temporary project directory", e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new IllegalStateException("Could not delete temporary project directory", e); + } + } + } + } + + protected void stopEmulatorInternal() throws DatastoreEmulatorException { + sendEmptyRequest("/shutdown", "POST"); + } + + public synchronized File getProjectDirectory() { + checkState(state == State.STARTED); + return projectDirectory; + } + + /** + * Monitors the provided input stream for evidence that the emulator has started successfully and + * redirects the output of the emulator process to sysout for this process. + */ + static class StartupMonitor extends Thread { + private final InputStream inputStream; + private volatile boolean success = false; + + /** This latch will reach 0 once server startup has completed. */ + private final CountDownLatch startupCompleteLatch = new CountDownLatch(1); + + StartupMonitor(InputStream inputStream) { + this.inputStream = inputStream; + setDaemon(true); + } + + @Override + public void run() { + try { + BufferedReader br = new BufferedReader(new InputStreamReader(inputStream)); + String line; + while ((line = br.readLine()) != null) { + // Redirect to sysout for our process. + System.out.println(line); + // TODO(pcostello): Just make a request to "/" and look for an HTTP 200. + if (!success && line.contains("Dev App Server is now running")) { + success = true; + startupCompleteLatch.countDown(); + } + } + } catch (IOException ioe) { + if (!success) { + System.err.println( + "Received an IOException before emulator startup completed. " + + "Emulator is in an unknown state."); + } else { + // We got an exception after the server started successfully. We'll lose the ability + // to log the output of the emulator but there's no need to shut anything down. + System.err.println( + "Received an exception handling output from the emulator. " + + "Logging will stop but the emulator is probably ok."); + } + ioe.printStackTrace(); + } finally { + if (!success) { + // Either the stream is closed (indicates server shut down) or we received an Exception + // while processing the stream contents. Either way we can tell the calling thread to stop + // waiting. + startupCompleteLatch.countDown(); + } + } + } + } + + /** Send an empty request using a standard HTTP connection. */ + private void sendEmptyRequest(String path, String method) throws DatastoreEmulatorException { + HttpURLConnection connection = null; + try { + URL url = new URL(this.host + path); + connection = (HttpURLConnection) url.openConnection(); + connection.setDoOutput(true); + connection.setRequestMethod(method); + connection.getOutputStream().close(); + if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { + throw new DatastoreEmulatorException( + String.format( + "%s request to %s returned HTTP status %s", + method, path, connection.getResponseCode())); + } + } catch (IOException e) { + throw new DatastoreEmulatorException( + String.format("Exception connecting to emulator on %s request to %s", method, path), e); + } finally { + if (connection != null) { + connection.disconnect(); + } + } + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulatorException.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulatorException.java new file mode 100644 index 000000000000..fb84ea1fe015 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulatorException.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 + * + * 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.datastore.v1.client; + +/** An exception related to the {@link DatastoreEmulator}. */ +public class DatastoreEmulatorException extends Exception { + public DatastoreEmulatorException(String message) { + super(message); + } + + public DatastoreEmulatorException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulatorFactory.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulatorFactory.java new file mode 100644 index 000000000000..901edcdaabb8 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulatorFactory.java @@ -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. + */ +package com.google.datastore.v1.client; + +/** Factory for {@link DatastoreEmulator}. */ +public class DatastoreEmulatorFactory extends DatastoreFactory { + + /** Singleton factory instance. */ + private static final DatastoreEmulatorFactory INSTANCE = new DatastoreEmulatorFactory(); + + public static DatastoreEmulatorFactory get() { + return INSTANCE; + } + + DatastoreEmulatorFactory() {} + + @Override + public DatastoreEmulator create(DatastoreOptions options) throws IllegalArgumentException { + return create(options, new DatastoreEmulatorOptions.Builder().build()); + } + + public DatastoreEmulator create( + DatastoreOptions options, DatastoreEmulatorOptions localDevelopmentOptions) { + RemoteRpc rpc = newRemoteRpc(options); + return new DatastoreEmulator(rpc, options.getLocalHost(), localDevelopmentOptions); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulatorOptions.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulatorOptions.java new file mode 100644 index 000000000000..04b90cc23e5c --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreEmulatorOptions.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 + * + * 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.datastore.v1.client; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.Nullable; + +/** An immutable object containing settings for a {@link DatastoreEmulator}. */ +public class DatastoreEmulatorOptions { + private final Map envVars; + private final String cmd; + private final List cmdLineOptions; + private final String projectId; + + DatastoreEmulatorOptions( + Map envVars, String cmd, List cmdLineOptions, String projectId) { + this.envVars = envVars; + this.cmd = cmd; + this.cmdLineOptions = cmdLineOptions; + this.projectId = projectId; + } + + /** Builder for {@link DatastoreEmulatorOptions}. */ + public static class Builder { + private final Map envVars = new HashMap<>(); + private final List cmdLineOptions = new ArrayList<>(); + private String cmd = "./cloud_datastore_emulator"; + private String projectId; + + public DatastoreEmulatorOptions build() { + return new DatastoreEmulatorOptions(envVars, cmd, cmdLineOptions, projectId); + } + + /** Adds an environment variable to pass to the emulator. */ + public Builder addEnvVar(String var, String value) { + envVars.put(var, value); + return this; + } + + public Builder addCmdLineOption(String option) { + cmdLineOptions.add(option); + return this; + } + + public Builder addCmdLineOptions(Collection options) { + cmdLineOptions.addAll(options); + return this; + } + + public Builder setCommand(String cmd) { + this.cmd = cmd; + return this; + } + + public Builder setProjectId(String projectId) { + this.projectId = projectId; + return this; + } + } + + public Map getEnvVars() { + return envVars; + } + + public List getCmdLineOptions() { + return cmdLineOptions; + } + + public String getCmd() { + return cmd; + } + + @Nullable + public String getProjectId() { + return projectId; + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreException.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreException.java new file mode 100644 index 000000000000..08a085a48a68 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreException.java @@ -0,0 +1,49 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client; + +import com.google.rpc.Code; + +/** Indicates an error in a {@link Datastore} call. */ +public class DatastoreException extends Exception { + private final String methodName; + private final Code code; + + public DatastoreException(String methodName, Code code, String message, Throwable cause) { + super(message, cause); + this.methodName = methodName; + this.code = code; + } + + /** + * @return the canonical error code + */ + public Code getCode() { + return code; + } + + /** + * @return the datastore method name + */ + public String getMethodName() { + return methodName; + } + + @Override + public String toString() { + return String.format("%s, code=%s", super.toString(), code); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreFactory.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreFactory.java new file mode 100644 index 000000000000..c7e7ceff87a5 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreFactory.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 + * + * 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.datastore.v1.client; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.http.HttpRequestFactory; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.javanet.NetHttpTransport; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.logging.ConsoleHandler; +import java.util.logging.Formatter; +import java.util.logging.Level; +import java.util.logging.LogRecord; +import java.util.logging.Logger; +import java.util.logging.StreamHandler; + +/** Client factory for {@link Datastore}. */ +public class DatastoreFactory { + + // Lazy load this because we might be running inside App Engine and this + // class isn't on the whitelist. + private static ConsoleHandler methodHandler; + + /** API version. */ + public static final String VERSION = "v1"; + + public static final String DEFAULT_HOST = "https://datastore.googleapis.com"; + + /** Singleton factory instance. */ + private static final DatastoreFactory INSTANCE = new DatastoreFactory(); + + public static DatastoreFactory get() { + return INSTANCE; + } + + /** + * Provides access to a datastore using the provided options. Logs into the application using the + * credentials available via these options. + * + * @throws IllegalArgumentException if the server or credentials weren't provided. + */ + public Datastore create(DatastoreOptions options) { + return new Datastore(newRemoteRpc(options)); + } + + /** Constructs a Google APIs HTTP client with the associated credentials. */ + public HttpRequestFactory makeClient(DatastoreOptions options) { + Credential credential = options.getCredential(); + HttpTransport transport = options.getTransport(); + if (transport == null) { + transport = credential == null ? new NetHttpTransport() : credential.getTransport(); + transport = transport == null ? new NetHttpTransport() : transport; + } + return transport.createRequestFactory(credential); + } + + /** Starts logging datastore method calls to the console. (Useful within tests.) */ + public static void logMethodCalls() { + Logger logger = Logger.getLogger(Datastore.class.getName()); + logger.setLevel(Level.FINE); + if (!Arrays.asList(logger.getHandlers()).contains(getStreamHandler())) { + logger.addHandler(getStreamHandler()); + } + } + + /** Build a valid datastore URL. */ + String buildProjectEndpoint(DatastoreOptions options) { + if (options.getProjectEndpoint() != null) { + return options.getProjectEndpoint(); + } + // DatastoreOptions ensures either project endpoint or project ID is set. + String projectId = checkNotNull(options.getProjectId()); + if (options.getHost() != null) { + return validateUrl( + String.format("https://%s/%s/projects/%s", options.getHost(), VERSION, projectId)); + } else if (options.getLocalHost() != null) { + return validateUrl( + String.format("http://%s/%s/projects/%s", options.getLocalHost(), VERSION, projectId)); + } + return validateUrl(String.format("%s/%s/projects/%s", DEFAULT_HOST, VERSION, projectId)); + } + + protected RemoteRpc newRemoteRpc(DatastoreOptions options) { + checkNotNull(options); + HttpRequestFactory client = makeClient(options); + return new RemoteRpc(client, options.getInitializer(), buildProjectEndpoint(options)); + } + + private static String validateUrl(String url) { + try { + return new URI(url).toString(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + } + + // TODO: Support something other than console handler for when we're + // running in App Engine + private static synchronized StreamHandler getStreamHandler() { + if (methodHandler == null) { + methodHandler = new ConsoleHandler(); + methodHandler.setFormatter( + new Formatter() { + @Override + public String format(LogRecord record) { + return record.getMessage() + "\n"; + } + }); + methodHandler.setLevel(Level.FINE); + } + return methodHandler; + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreHelper.java new file mode 100644 index 000000000000..de364a307c36 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreHelper.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 + * + * 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.datastore.v1.client; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; +import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; +import com.google.api.client.http.GenericUrl; +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.gson.GsonFactory; +import com.google.datastore.v1.ArrayValue; +import com.google.datastore.v1.CompositeFilter; +import com.google.datastore.v1.Entity; +import com.google.datastore.v1.Filter; +import com.google.datastore.v1.Key; +import com.google.datastore.v1.Key.PathElement; +import com.google.datastore.v1.Key.PathElement.IdTypeCase; +import com.google.datastore.v1.Mutation; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.PropertyFilter; +import com.google.datastore.v1.PropertyOrder; +import com.google.datastore.v1.PropertyReference; +import com.google.datastore.v1.Value; +import com.google.datastore.v1.Value.ValueTypeCase; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import com.google.protobuf.TimestampOrBuilder; +import com.google.type.LatLng; +import java.io.File; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.security.PrivateKey; +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Nullable; + +/** Helper methods for {@link Datastore}. */ +// TODO: Accept OrBuilders when possible. +public final class DatastoreHelper { + private static final Logger logger = Logger.getLogger(DatastoreHelper.class.getName()); + + private static final int MICROSECONDS_PER_SECOND = 1000 * 1000; + private static final int NANOSECONDS_PER_MICROSECOND = 1000; + + /** The property used in the Datastore to give us a random distribution. * */ + public static final String SCATTER_PROPERTY_NAME = "__scatter__"; + + /** The property used in the Datastore to get the key of the entity. * */ + public static final String KEY_PROPERTY_NAME = "__key__"; + + /** Name of the environment variable used to set the project ID. */ + public static final String PROJECT_ID_ENV_VAR = "DATASTORE_PROJECT_ID"; + + /** Name of the environment variable used to set the local host. */ + public static final String LOCAL_HOST_ENV_VAR = "DATASTORE_EMULATOR_HOST"; + + /** Name of the environment variable used to set the service account. */ + public static final String SERVICE_ACCOUNT_ENV_VAR = "DATASTORE_SERVICE_ACCOUNT"; + + /** Name of the environment variable used to set the private key file. */ + public static final String PRIVATE_KEY_FILE_ENV_VAR = "DATASTORE_PRIVATE_KEY_FILE"; + + private static final String URL_OVERRIDE_ENV_VAR = "__DATASTORE_URL_OVERRIDE"; + + private static final AtomicReference projectIdFromComputeEngine = new AtomicReference<>(); + + /** Comparator for Keys */ + private static final class KeyComparator implements Comparator { + + static final KeyComparator INSTANCE = new KeyComparator(); + + private int comparePathElement(PathElement thisElement, PathElement otherElement) { + int result = thisElement.getKind().compareTo(otherElement.getKind()); + if (result != 0) { + return result; + } + if (thisElement.getIdTypeCase() == IdTypeCase.ID) { + if (otherElement.getIdTypeCase() != IdTypeCase.ID) { + return -1; + } + return Long.valueOf(thisElement.getId()).compareTo(otherElement.getId()); + } + if (otherElement.getIdTypeCase() == IdTypeCase.ID) { + return 1; + } + + return thisElement.getName().compareTo(otherElement.getName()); + } + + @Override + public int compare(Key thisKey, Key otherKey) { + if (!thisKey.getPartitionId().equals(otherKey.getPartitionId())) { + throw new IllegalArgumentException("Cannot compare keys with different partition ids."); + } + + Iterator thisPath = thisKey.getPathList().iterator(); + Iterator otherPath = otherKey.getPathList().iterator(); + while (thisPath.hasNext()) { + if (!otherPath.hasNext()) { + return 1; + } + int result = comparePathElement(thisPath.next(), otherPath.next()); + if (result != 0) { + return result; + } + } + + return otherPath.hasNext() ? -1 : 0; + } + } + + private DatastoreHelper() {} + + private static HttpTransport newTransport() throws GeneralSecurityException, IOException { + return GoogleNetHttpTransport.newTrustedTransport(); + } + + static JsonFactory newJsonFactory() { + return new GsonFactory(); + } + + /** + * Constructs credentials for the given account and key. + * + * @param serviceAccountId service account ID (typically an e-mail address). + * @param privateKeyFile the file name from which to get the private key. + * @return valid credentials or {@code null} + */ + public static Credential getServiceAccountCredential( + String serviceAccountId, String privateKeyFile) throws GeneralSecurityException, IOException { + return getServiceAccountCredential(serviceAccountId, privateKeyFile, DatastoreOptions.SCOPES); + } + + /** + * Constructs credentials for the given account and key file. + * + * @param serviceAccountId service account ID (typically an e-mail address). + * @param privateKeyFile the file name from which to get the private key. + * @param serviceAccountScopes Collection of OAuth scopes to use with the the service account flow + * or {@code null} if not. + * @return valid credentials or {@code null} + */ + public static Credential getServiceAccountCredential( + String serviceAccountId, String privateKeyFile, Collection serviceAccountScopes) + throws GeneralSecurityException, IOException { + return getCredentialBuilderWithoutPrivateKey(serviceAccountId, serviceAccountScopes) + .setServiceAccountPrivateKeyFromP12File(new File(privateKeyFile)) + .build(); + } + + /** + * Constructs credentials for the given account and key. + * + * @param serviceAccountId service account ID (typically an e-mail address). + * @param privateKey the private key for the given account. + * @param serviceAccountScopes Collection of OAuth scopes to use with the the service account flow + * or {@code null} if not. + * @return valid credentials or {@code null} + */ + public static Credential getServiceAccountCredential( + String serviceAccountId, PrivateKey privateKey, Collection serviceAccountScopes) + throws GeneralSecurityException, IOException { + return getCredentialBuilderWithoutPrivateKey(serviceAccountId, serviceAccountScopes) + .setServiceAccountPrivateKey(privateKey) + .build(); + } + + private static GoogleCredential.Builder getCredentialBuilderWithoutPrivateKey( + String serviceAccountId, Collection serviceAccountScopes) + throws GeneralSecurityException, IOException { + HttpTransport transport = newTransport(); + JsonFactory jsonFactory = newJsonFactory(); + return new GoogleCredential.Builder() + .setTransport(transport) + .setJsonFactory(jsonFactory) + .setServiceAccountId(serviceAccountId) + .setServiceAccountScopes(serviceAccountScopes); + } + + /** + * Constructs a {@link Datastore} from environment variables and/or the Compute Engine metadata + * server. + * + *

The project ID is determined from, in order of preference: + * + *

    + *
  • DATASTORE_PROJECT_ID environment variable + *
  • Compute Engine + *
+ * + *

Credentials are taken from, in order of preference: + * + *

    + *
  1. No credentials (if the DATASTORE_EMULATOR_HOST environment variable is set) + *
  2. Service Account specified by the DATASTORE_SERVICE_ACCOUNT and DATASTORE_PRIVATE_KEY_FILE + * environment variables + *
  3. Google Application Default as described here. + *
+ */ + public static DatastoreOptions.Builder getOptionsFromEnv() + throws GeneralSecurityException, IOException { + DatastoreOptions.Builder options = new DatastoreOptions.Builder(); + setProjectEndpointFromEnv(options); + options.credential(getCredentialFromEnv()); + return options; + } + + private static Credential getCredentialFromEnv() throws GeneralSecurityException, IOException { + if (System.getenv(LOCAL_HOST_ENV_VAR) != null) { + logger.log( + Level.INFO, + "{0} environment variable was set. Not using credentials.", + new Object[] {LOCAL_HOST_ENV_VAR}); + return null; + } + String serviceAccount = System.getenv(SERVICE_ACCOUNT_ENV_VAR); + String privateKeyFile = System.getenv(PRIVATE_KEY_FILE_ENV_VAR); + if (serviceAccount != null && privateKeyFile != null) { + logger.log( + Level.INFO, + "{0} and {1} environment variables were set. " + "Using service account credential.", + new Object[] {SERVICE_ACCOUNT_ENV_VAR, PRIVATE_KEY_FILE_ENV_VAR}); + return getServiceAccountCredential(serviceAccount, privateKeyFile); + } + return GoogleCredential.getApplicationDefault().createScoped(DatastoreOptions.SCOPES); + } + + /** + * Determines the project id from the environment. Uses the following sources in order of + * preference: + * + *
    + *
  1. Value of the DATASTORE_PROJECT_ID environment variable + *
  2. Compute Engine + *
+ * + * @throws IllegalStateException if the project ID cannot be determined + */ + private static String getProjectIdFromEnv() { + if (System.getenv(PROJECT_ID_ENV_VAR) != null) { + return System.getenv(PROJECT_ID_ENV_VAR); + } + String projectIdFromComputeEngine = getProjectIdFromComputeEngine(); + if (projectIdFromComputeEngine != null) { + return projectIdFromComputeEngine; + } + throw new IllegalStateException( + String.format( + "Could not determine project ID." + + " If you are not running on Compute Engine, set the" + + " %s environment variable.", + PROJECT_ID_ENV_VAR)); + } + + /** + * Gets the project ID from the Compute Engine metadata server. Returns {@code null} if the + * project ID cannot be determined (because, for instance, the code is not running on Compute + * Engine). + */ + @Nullable + public static String getProjectIdFromComputeEngine() { + String cachedProjectId = projectIdFromComputeEngine.get(); + return cachedProjectId != null ? cachedProjectId : queryProjectIdFromComputeEngine(); + } + + @Nullable + private static String queryProjectIdFromComputeEngine() { + HttpTransport transport; + + try { + transport = newTransport(); + } catch (GeneralSecurityException | IOException e) { + logger.log(Level.WARNING, "Failed to create HttpTransport.", e); + return null; + } + + try { + GenericUrl projectIdUrl = + new GenericUrl("http://metadata/computeMetadata/v1/project/project-id"); + HttpRequest request = transport.createRequestFactory().buildGetRequest(projectIdUrl); + request.getHeaders().set("Metadata-Flavor", "Google"); + String result = request.execute().parseAsString(); + projectIdFromComputeEngine.set(result); + return result; + } catch (IOException e) { + logger.log(Level.INFO, "Could not determine project ID from Compute Engine.", e); + return null; + } + } + + private static void setProjectEndpointFromEnv(DatastoreOptions.Builder options) { + // DATASTORE_HOST is deprecated. + if (System.getenv("DATASTORE_HOST") != null) { + logger.warning( + String.format( + "Ignoring value of environment variable DATASTORE_HOST. " + + "To point datastore to a host running locally, use " + + "the environment variable %s.", + LOCAL_HOST_ENV_VAR)); + } + String projectId = getProjectIdFromEnv(); + if (System.getenv(URL_OVERRIDE_ENV_VAR) != null) { + options.projectEndpoint( + String.format("%s/projects/%s", System.getenv(URL_OVERRIDE_ENV_VAR), projectId)); + return; + } + if (System.getenv(LOCAL_HOST_ENV_VAR) != null) { + options.projectId(projectId); + options.localHost(System.getenv(LOCAL_HOST_ENV_VAR)); + return; + } + options.projectId(projectId); + return; + } + + /** + * @see #getOptionsFromEnv() + */ + public static Datastore getDatastoreFromEnv() throws GeneralSecurityException, IOException { + return DatastoreFactory.get().create(getOptionsFromEnv().build()); + } + + /** + * Gets a {@link QuerySplitter}. + * + *

The returned {@link QuerySplitter#getSplits} cannot accept a query that contains inequality + * filters, a sort filter, or a missing kind. + */ + public static QuerySplitter getQuerySplitter() { + return QuerySplitterImpl.INSTANCE; + } + + public static Comparator getKeyComparator() { + return KeyComparator.INSTANCE; + } + + /** Make a sort order for use in a query. */ + public static PropertyOrder.Builder makeOrder( + String property, PropertyOrder.Direction direction) { + return PropertyOrder.newBuilder() + .setProperty(makePropertyReference(property)) + .setDirection(direction); + } + + /** Makes an ancestor filter. */ + public static Filter.Builder makeAncestorFilter(Key ancestor) { + return makeFilter( + DatastoreHelper.KEY_PROPERTY_NAME, + PropertyFilter.Operator.HAS_ANCESTOR, + makeValue(ancestor)); + } + + /** Make a filter on a property for use in a query. */ + public static Filter.Builder makeFilter( + String property, PropertyFilter.Operator operator, Value value) { + return Filter.newBuilder() + .setPropertyFilter( + PropertyFilter.newBuilder() + .setProperty(makePropertyReference(property)) + .setOp(operator) + .setValue(value)); + } + + /** Make a filter on a property for use in a query. */ + public static Filter.Builder makeFilter( + String property, PropertyFilter.Operator operator, Value.Builder value) { + return makeFilter(property, operator, value.build()); + } + + /** Make a composite filter from the given sub-filters using AND to combine filters. */ + public static Filter.Builder makeAndFilter(Filter... subfilters) { + return makeAndFilter(Arrays.asList(subfilters)); + } + + /** Make a composite filter from the given sub-filters using AND to combine filters. */ + public static Filter.Builder makeAndFilter(Iterable subfilters) { + return Filter.newBuilder() + .setCompositeFilter( + CompositeFilter.newBuilder() + .addAllFilters(subfilters) + .setOp(CompositeFilter.Operator.AND)); + } + + /** Make a property reference for use in a query. */ + public static PropertyReference.Builder makePropertyReference(String propertyName) { + return PropertyReference.newBuilder().setName(propertyName); + } + + /** Make an array value containing the specified values. */ + public static Value.Builder makeValue(Iterable values) { + return Value.newBuilder().setArrayValue(ArrayValue.newBuilder().addAllValues(values)); + } + + /** Make a list value containing the specified values. */ + public static Value.Builder makeValue(Value value1, Value value2, Value... rest) { + ArrayValue.Builder arrayValue = ArrayValue.newBuilder(); + arrayValue.addValues(value1); + arrayValue.addValues(value2); + arrayValue.addAllValues(Arrays.asList(rest)); + return Value.newBuilder().setArrayValue(arrayValue); + } + + /** Make an array value containing the specified values. */ + public static Value.Builder makeValue( + Value.Builder value1, Value.Builder value2, Value.Builder... rest) { + ArrayValue.Builder arrayValue = ArrayValue.newBuilder(); + arrayValue.addValues(value1); + arrayValue.addValues(value2); + for (Value.Builder builder : rest) { + arrayValue.addValues(builder); + } + return Value.newBuilder().setArrayValue(arrayValue); + } + + /** Make a key value. */ + public static Value.Builder makeValue(Key key) { + return Value.newBuilder().setKeyValue(key); + } + + /** Make a key value. */ + public static Value.Builder makeValue(Key.Builder key) { + return makeValue(key.build()); + } + + /** Make an integer value. */ + public static Value.Builder makeValue(long key) { + return Value.newBuilder().setIntegerValue(key); + } + + /** Make a floating point value. */ + public static Value.Builder makeValue(double value) { + return Value.newBuilder().setDoubleValue(value); + } + + /** Make a boolean value. */ + public static Value.Builder makeValue(boolean value) { + return Value.newBuilder().setBooleanValue(value); + } + + /** Make a string value. */ + public static Value.Builder makeValue(String value) { + return Value.newBuilder().setStringValue(value); + } + + /** Make an entity value. */ + public static Value.Builder makeValue(Entity entity) { + return Value.newBuilder().setEntityValue(entity); + } + + /** Make a entity value. */ + public static Value.Builder makeValue(Entity.Builder entity) { + return makeValue(entity.build()); + } + + /** Make a ByteString value. */ + public static Value.Builder makeValue(ByteString blob) { + return Value.newBuilder().setBlobValue(blob); + } + + /** Make a timestamp value given a date. */ + public static Value.Builder makeValue(Date date) { + return Value.newBuilder().setTimestampValue(toTimestamp(date.getTime() * 1000L)); + } + + /** Makes a GeoPoint value. */ + public static Value.Builder makeValue(LatLng value) { + return Value.newBuilder().setGeoPointValue(value); + } + + /** Makes a GeoPoint value. */ + public static Value.Builder makeValue(LatLng.Builder value) { + return makeValue(value.build()); + } + + private static Timestamp.Builder toTimestamp(long microseconds) { + long seconds = microseconds / MICROSECONDS_PER_SECOND; + long microsecondsRemainder = microseconds % MICROSECONDS_PER_SECOND; + if (microsecondsRemainder < 0) { + // Nanos must be positive even if microseconds is negative. + // Java modulus doesn't take care of this for us. + microsecondsRemainder += MICROSECONDS_PER_SECOND; + seconds -= 1; + } + return Timestamp.newBuilder() + .setSeconds(seconds) + .setNanos((int) microsecondsRemainder * NANOSECONDS_PER_MICROSECOND); + } + + /** + * Make a key from the specified path of kind/id-or-name pairs and/or Keys. + * + *

The id-or-name values must be either String, Long, Integer or Short. + * + *

The last id-or-name value may be omitted, in which case an entity without an id is created + * (for use with automatic id allocation). + * + *

The PartitionIds of all Keys in the path must be equal. The returned Key.Builder will use + * this PartitionId. + */ + public static Key.Builder makeKey(Object... elements) { + Key.Builder key = Key.newBuilder(); + PartitionId partitionId = null; + for (int pathIndex = 0; pathIndex < elements.length; pathIndex += 2) { + PathElement.Builder pathElement = PathElement.newBuilder(); + Object element = elements[pathIndex]; + if (element instanceof Key) { + Key subKey = (Key) element; + if (partitionId == null) { + partitionId = subKey.getPartitionId(); + } else if (!partitionId.equals(subKey.getPartitionId())) { + throw new IllegalArgumentException( + "Partition IDs did not match, found: " + + partitionId + + " and " + + subKey.getPartitionId()); + } + key.addAllPath(((Key) element).getPathList()); + // We increment by 2, but since we got a Key argument we're only consuming 1 element in this + // iteration of the loop. Decrement the index so that when we jump by 2 we end up in the + // right spot. + pathIndex--; + } else { + String kind; + try { + kind = (String) element; + } catch (ClassCastException e) { + throw new IllegalArgumentException( + "Expected string or Key, got: " + element.getClass(), e); + } + pathElement.setKind(kind); + if (pathIndex + 1 < elements.length) { + Object value = elements[pathIndex + 1]; + if (value instanceof String) { + pathElement.setName((String) value); + } else if (value instanceof Long) { + pathElement.setId((Long) value); + } else if (value instanceof Integer) { + pathElement.setId((Integer) value); + } else if (value instanceof Short) { + pathElement.setId((Short) value); + } else { + throw new IllegalArgumentException( + "Expected string or integer, got: " + value.getClass()); + } + } + key.addPath(pathElement); + } + } + if (partitionId != null && !partitionId.equals(PartitionId.getDefaultInstance())) { + key.setPartitionId(partitionId); + } + return key; + } + + /** + * @return the double contained in value + * @throws IllegalArgumentException if the value does not contain a double. + */ + public static double getDouble(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.DOUBLE_VALUE) { + throw new IllegalArgumentException("Value does not contain a double."); + } + return value.getDoubleValue(); + } + + /** + * @return the key contained in value + * @throws IllegalArgumentException if the value does not contain a key. + */ + public static Key getKey(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.KEY_VALUE) { + throw new IllegalArgumentException("Value does not contain a key."); + } + return value.getKeyValue(); + } + + /** + * @return the blob contained in value + * @throws IllegalArgumentException if the value does not contain a blob. + */ + public static ByteString getByteString(Value value) { + if (value.getMeaning() == 18 && value.getValueTypeCase() == ValueTypeCase.STRING_VALUE) { + return value.getStringValueBytes(); + } else if (value.getValueTypeCase() == ValueTypeCase.BLOB_VALUE) { + return value.getBlobValue(); + } + throw new IllegalArgumentException("Value does not contain a blob."); + } + + /** + * @return the entity contained in value + * @throws IllegalArgumentException if the value does not contain an entity. + */ + public static Entity getEntity(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.ENTITY_VALUE) { + throw new IllegalArgumentException("Value does not contain an Entity."); + } + return value.getEntityValue(); + } + + /** + * @return the string contained in value + * @throws IllegalArgumentException if the value does not contain a string. + */ + public static String getString(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.STRING_VALUE) { + throw new IllegalArgumentException("Value does not contain a string."); + } + return value.getStringValue(); + } + + /** + * @return the boolean contained in value + * @throws IllegalArgumentException if the value does not contain a boolean. + */ + public static boolean getBoolean(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.BOOLEAN_VALUE) { + throw new IllegalArgumentException("Value does not contain a boolean."); + } + return value.getBooleanValue(); + } + + /** + * @return the long contained in value + * @throws IllegalArgumentException if the value does not contain a long. + */ + public static long getLong(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.INTEGER_VALUE) { + throw new IllegalArgumentException("Value does not contain an integer."); + } + return value.getIntegerValue(); + } + + /** + * @return the timestamp in microseconds contained in value + * @throws IllegalArgumentException if the value does not contain a timestamp. + */ + public static long getTimestamp(Value value) { + if (value.getMeaning() == 18 && value.getValueTypeCase() == ValueTypeCase.INTEGER_VALUE) { + return value.getIntegerValue(); + } else if (value.getValueTypeCase() == ValueTypeCase.TIMESTAMP_VALUE) { + return toMicroseconds(value.getTimestampValue()); + } + throw new IllegalArgumentException("Value does not contain a timestamp."); + } + + private static long toMicroseconds(TimestampOrBuilder timestamp) { + // Nanosecond precision is lost. + return timestamp.getSeconds() * MICROSECONDS_PER_SECOND + + timestamp.getNanos() / NANOSECONDS_PER_MICROSECOND; + } + + /** + * @return the array contained in value as a list. + * @throws IllegalArgumentException if the value does not contain an array. + */ + public static List getList(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.ARRAY_VALUE) { + throw new IllegalArgumentException("Value does not contain an array."); + } + return value.getArrayValue().getValuesList(); + } + + /** + * Convert a timestamp value into a {@link Date} clipping off the microseconds. + * + * @param value a timestamp value to convert + * @return the resulting {@link Date} + * @throws IllegalArgumentException if the value does not contain a timestamp. + */ + public static Date toDate(Value value) { + return new Date(getTimestamp(value) / 1000); + } + + /** + * @param entity the entity to insert + * @return a mutation that will insert an entity + */ + public static Mutation.Builder makeInsert(Entity entity) { + return Mutation.newBuilder().setInsert(entity); + } + + /** + * @param entity the entity to update + * @return a mutation that will update an entity + */ + public static Mutation.Builder makeUpdate(Entity entity) { + return Mutation.newBuilder().setUpdate(entity); + } + + /** + * @param entity the entity to upsert + * @return a mutation that will upsert an entity + */ + public static Mutation.Builder makeUpsert(Entity entity) { + return Mutation.newBuilder().setUpsert(entity); + } + + /** + * @param key the key of the entity to delete + * @return a mutation that will delete an entity + */ + public static Mutation.Builder makeDelete(Key key) { + return Mutation.newBuilder().setDelete(key); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreOptions.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreOptions.java new file mode 100644 index 000000000000..780a3c940184 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/DatastoreOptions.java @@ -0,0 +1,204 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.http.HttpRequestInitializer; +import com.google.api.client.http.HttpTransport; +import java.util.Arrays; +import java.util.List; + +/** + * An immutable object containing settings for the datastore. + * + *

Example for connecting to a datastore: + * + *

+ * DatastoreOptions options = new DatastoreOptions.Builder()
+ *     .projectId("my-project-id")
+ *     .credential(DatastoreHelper.getComputeEngineCredential())
+ *     .build();
+ * DatastoreFactory.get().create(options);
+ * 
+ * + *

The options should be passed to {@link DatastoreFactory#create}. + */ +public class DatastoreOptions { + private final String projectId; + + private final String projectEndpoint; + private final String host; + private final String localHost; + + private final HttpRequestInitializer initializer; + + private final Credential credential; + private final HttpTransport transport; + public static final List SCOPES = + Arrays.asList("https://www.googleapis.com/auth/datastore"); + + DatastoreOptions(Builder b) { + checkArgument( + b.projectId != null || b.projectEndpoint != null, + "Either project ID or project endpoint must be provided."); + this.projectId = b.projectId; + this.projectEndpoint = b.projectEndpoint; + this.host = b.host; + this.localHost = b.localHost; + this.initializer = b.initializer; + this.credential = b.credential; + this.transport = b.transport; + } + + /** Builder for {@link DatastoreOptions}. */ + public static class Builder { + private static final String PROJECT_ENDPOINT_AND_PROJECT_ID_ERROR = + "Cannot set both project endpoint and project ID."; + private static final String PROJECT_ENDPOINT_AND_HOST_ERROR = + "Can set at most one of project endpoint, host, and local host."; + + private String projectId; + + private String projectEndpoint; + private String host; + private String localHost; + private HttpRequestInitializer initializer; + private Credential credential; + private HttpTransport transport; + + public Builder() {} + + public Builder(DatastoreOptions options) { + this.projectId = options.projectId; + this.projectEndpoint = options.projectEndpoint; + this.host = options.host; + this.localHost = options.localHost; + this.initializer = options.initializer; + this.credential = options.credential; + this.transport = options.transport; + } + + public DatastoreOptions build() { + return new DatastoreOptions(this); + } + + /** Sets the project ID used to access Cloud Datastore. */ + public Builder projectId(String projectId) { + checkArgument(projectEndpoint == null, PROJECT_ENDPOINT_AND_PROJECT_ID_ERROR); + this.projectId = projectId; + return this; + } + + /** + * Sets the host used to access Cloud Datastore. To connect to the Cloud Datastore Emulator, use + * {@link #localHost} instead. + */ + public Builder host(String host) { + checkArgument(projectEndpoint == null && localHost == null, PROJECT_ENDPOINT_AND_HOST_ERROR); + if (includesScheme(host)) { + throw new IllegalArgumentException( + String.format("Host \"%s\" must not include scheme.", host)); + } + this.host = host; + return this; + } + + /** + * Configures the client to access Cloud Datastore on a local host (typically a Cloud Datastore + * Emulator instance). Call this method also configures the client not to attach credentials to + * requests. + */ + public Builder localHost(String localHost) { + checkArgument(projectEndpoint == null && host == null, PROJECT_ENDPOINT_AND_HOST_ERROR); + if (includesScheme(localHost)) { + throw new IllegalArgumentException( + String.format("Local host \"%s\" must not include scheme.", localHost)); + } + this.localHost = localHost; + return this; + } + + /** + * Sets the project endpoint used to access Cloud Datastore. Prefer using {@link #projectId} + * and/or {@link #host}/{@link #localHost} when possible. + * + * @deprecated Use {@link #projectId} and/or {@link #host}/{@link #localHost} instead. + */ + @Deprecated + public Builder projectEndpoint(String projectEndpoint) { + checkArgument(projectId == null, PROJECT_ENDPOINT_AND_PROJECT_ID_ERROR); + checkArgument(localHost == null && host == null, PROJECT_ENDPOINT_AND_HOST_ERROR); + if (!includesScheme(projectEndpoint)) { + throw new IllegalArgumentException( + String.format("Project endpoint \"%s\" must include scheme.", projectEndpoint)); + } + this.projectEndpoint = projectEndpoint; + return this; + } + + /** Sets the (optional) initializer to run on HTTP requests to Cloud Datastore. */ + public Builder initializer(HttpRequestInitializer initializer) { + this.initializer = initializer; + return this; + } + + /** Sets the Google APIs {@link Credential} used to access Cloud Datastore. */ + public Builder credential(Credential credential) { + this.credential = credential; + return this; + } + + /** Sets the transport used to access Cloud Datastore. */ + public Builder transport(HttpTransport transport) { + this.transport = transport; + return this; + } + + private static boolean includesScheme(String url) { + return url.startsWith("http://") || url.startsWith("https://"); + } + } + + public String getProjectId() { + return projectId; + } + + public String getProjectEndpoint() { + return projectEndpoint; + } + + public String getHost() { + return host; + } + + public String getLocalHost() { + return localHost; + } + + public HttpRequestInitializer getInitializer() { + return initializer; + } + + public Credential getCredential() { + return credential; + } + + public HttpTransport getTransport() { + return transport; + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/EndToEndChecksumHandler.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/EndToEndChecksumHandler.java new file mode 100644 index 000000000000..507625a47cc7 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/EndToEndChecksumHandler.java @@ -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. + */ +package com.google.datastore.v1.client; + +import com.google.api.client.http.HttpResponse; +import com.google.common.hash.HashCode; +import com.google.common.hash.Hasher; +import com.google.common.hash.Hashing; + +/** This class provides End-to-End Checksum API for http protocol. */ +class EndToEndChecksumHandler { + /** The checksum http header on http requests */ + static final String HTTP_REQUEST_CHECKSUM_HEADER = "x-request-checksum-348659783"; + + /** The checksum http header on http responses */ + static final String HTTP_RESPONSE_CHECKSUM_HEADER = "x-response-checksum-348659783"; + + final Hasher hasher = EndToEndChecksumHandler.getNewCrc32cHasher(); + + /** + * Create and return checksum as a string value for the input 'bytes'. + * + * @param bytes raw message for which the checksum is being computed + * @return computed checksum as a hex string + */ + static String computeChecksum(byte[] bytes) { + if (bytes == null || (bytes.length == 0)) { + return null; + } + HashCode hc = getNewCrc32cHasher().putBytes(bytes).hash(); + return hashToString(hc); + } + + private static String hashToString(HashCode hc) { + return String.valueOf(Integer.toUnsignedLong(hc.asInt())); + } + + private static Hasher getNewCrc32cHasher() { + return Hashing.crc32c().newHasher(); + } + + /** + * Validates the checksum for the given input 'bytes' and returns true if valid, false otherwise. + * + * @param checksum the checksum as a hex string + * @param bytes the raw message for which the checksum was sent + * @return {@code true} if input checksum is valid for the input bytes; {@code false} otherwise + */ + static boolean validateChecksum(String checksum, byte[] bytes) { + return checksum != null + && !checksum.isEmpty() + && bytes != null + && bytes.length > 0 + && checksum.equals(computeChecksum(bytes)); + } + + static boolean hasChecksumHeader(HttpResponse response) { + String checksum = getChecksumHeader(response); + return checksum != null && !checksum.isEmpty(); + } + + static String getChecksumHeader(HttpResponse response) { + return response.getHeaders().getFirstHeaderStringValue(HTTP_RESPONSE_CHECKSUM_HEADER); + } + + void update(byte[] bytes, int off, int len) { + hasher.putBytes(bytes, off, len); + } + + String hash() { + return hashToString(hasher.hash()); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/QuerySplitter.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/QuerySplitter.java new file mode 100644 index 000000000000..e704f4c932ad --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/QuerySplitter.java @@ -0,0 +1,56 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client; + +import com.google.api.core.BetaApi; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.Query; +import com.google.protobuf.Timestamp; +import java.util.List; + +/** Provides the ability to split a query into multiple shards. */ +public interface QuerySplitter { + + /** + * Returns a list of sharded {@link Query}s for the given query. + * + *

This will create up to the desired number of splits, however it may return less splits if + * the desired number of splits is unavailable. This will happen if the number of split points + * provided by the underlying Datastore is less than the desired number, which will occur if the + * number of results for the query is too small. + * + * @param query the query to split. + * @param partition the partition the query is running in. + * @param numSplits the desired number of splits. + * @param datastore the datastore to run on. + * @throws DatastoreException if there was a datastore error while generating query splits. + * @throws IllegalArgumentException if the given query or numSplits was invalid. + */ + List getSplits(Query query, PartitionId partition, int numSplits, Datastore datastore) + throws DatastoreException; + + /** + * Same as {@link #getSplits(Query, PartitionId, int, Datastore)} but the splits are based on + * {@code readTime}, and the returned sharded {@link Query}s should also be executed with {@code + * readTime}. Reading from a timestamp is currently a private preview feature in Datastore. + */ + @BetaApi + default List getSplits( + Query query, PartitionId partition, int numSplits, Datastore datastore, Timestamp readTime) + throws DatastoreException { + throw new UnsupportedOperationException("Not implemented."); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java new file mode 100644 index 000000000000..3eac40fa111c --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/QuerySplitterImpl.java @@ -0,0 +1,308 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client; + +import static com.google.datastore.v1.client.DatastoreHelper.makeAndFilter; + +import com.google.api.core.BetaApi; +import com.google.datastore.v1.EntityResult; +import com.google.datastore.v1.Filter; +import com.google.datastore.v1.Key; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.Projection; +import com.google.datastore.v1.PropertyFilter; +import com.google.datastore.v1.PropertyFilter.Operator; +import com.google.datastore.v1.PropertyOrder.Direction; +import com.google.datastore.v1.PropertyReference; +import com.google.datastore.v1.Query; +import com.google.datastore.v1.QueryResultBatch; +import com.google.datastore.v1.QueryResultBatch.MoreResultsType; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.RunQueryRequest; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; +import java.util.Collections; +import java.util.EnumSet; +import java.util.List; +import javax.annotation.Nullable; + +/** + * Provides the ability to split a query into multiple shards using Cloud Datastore. + * + *

This implementation of the QuerySplitter uses the __scatter__ property to gather random split + * points for a query. + */ +final class QuerySplitterImpl implements QuerySplitter { + + /** The number of keys to sample for each split. * */ + private static final int KEYS_PER_SPLIT = 32; + + private static final EnumSet UNSUPPORTED_OPERATORS = + EnumSet.of( + Operator.LESS_THAN, + Operator.LESS_THAN_OR_EQUAL, + Operator.GREATER_THAN, + Operator.GREATER_THAN_OR_EQUAL); + + static final QuerySplitter INSTANCE = new QuerySplitterImpl(); + + private QuerySplitterImpl() { + // No initialization required. + } + + @Override + public List getSplits( + Query query, PartitionId partition, int numSplits, Datastore datastore) + throws DatastoreException, IllegalArgumentException { + return getSplitsInternal(query, partition, numSplits, datastore, null); + } + + @BetaApi + @Override + public List getSplits( + Query query, PartitionId partition, int numSplits, Datastore datastore, Timestamp readTime) + throws DatastoreException, IllegalArgumentException { + return getSplitsInternal(query, partition, numSplits, datastore, readTime); + } + + private List getSplitsInternal( + Query query, + PartitionId partition, + int numSplits, + Datastore datastore, + @Nullable Timestamp readTime) + throws DatastoreException, IllegalArgumentException { + List splits = new ArrayList(numSplits); + if (numSplits == 1) { + splits.add(query); + return splits; + } + validateQuery(query); + validateSplitSize(numSplits); + + List scatterKeys = getScatterKeys(numSplits, query, partition, datastore, readTime); + Key lastKey = null; + for (Key nextKey : getSplitKey(scatterKeys, numSplits)) { + splits.add(createSplit(lastKey, nextKey, query)); + lastKey = nextKey; + } + splits.add(createSplit(lastKey, null, query)); + return splits; + } + + /** + * Verify that the given number of splits is not out of bounds. + * + * @param numSplits the number of splits. + * @throws IllegalArgumentException if the split size is invalid. + */ + private void validateSplitSize(int numSplits) throws IllegalArgumentException { + if (numSplits < 1) { + throw new IllegalArgumentException("The number of splits must be greater than 0."); + } + } + + /** + * Validates that we only have allowable filters. + * + *

Note that equality and ancestor filters are allowed, however they may result in inefficient + * sharding. + */ + private void validateFilter(Filter filter) throws IllegalArgumentException { + switch (filter.getFilterTypeCase()) { + case COMPOSITE_FILTER: + for (Filter subFilter : filter.getCompositeFilter().getFiltersList()) { + validateFilter(subFilter); + } + break; + case PROPERTY_FILTER: + if (UNSUPPORTED_OPERATORS.contains(filter.getPropertyFilter().getOp())) { + throw new IllegalArgumentException("Query cannot have any inequality filters."); + } + break; + default: + throw new IllegalArgumentException( + "Unsupported filter type: " + filter.getFilterTypeCase()); + } + } + + /** + * Verifies that the given query can be properly scattered. + * + * @param query the query to verify + * @throws IllegalArgumentException if the query is invalid. + */ + private void validateQuery(Query query) throws IllegalArgumentException { + if (query.getKindCount() != 1) { + throw new IllegalArgumentException("Query must have exactly one kind."); + } + if (query.getOrderCount() != 0) { + throw new IllegalArgumentException("Query cannot have any sort orders."); + } + if (query.hasFilter()) { + validateFilter(query.getFilter()); + } + } + + /** + * Create a new {@link Query} given the query and range. + * + * @param lastKey the previous key. If null then assumed to be the beginning. + * @param nextKey the next key. If null then assumed to be the end. + * @param query the desired query. + */ + private Query createSplit(Key lastKey, Key nextKey, Query query) { + if (lastKey == null && nextKey == null) { + return query; + } + List keyFilters = new ArrayList(); + if (query.hasFilter()) { + keyFilters.add(query.getFilter()); + } + if (lastKey != null) { + Filter lowerBound = + DatastoreHelper.makeFilter( + DatastoreHelper.KEY_PROPERTY_NAME, + PropertyFilter.Operator.GREATER_THAN_OR_EQUAL, + DatastoreHelper.makeValue(lastKey)) + .build(); + keyFilters.add(lowerBound); + } + if (nextKey != null) { + Filter upperBound = + DatastoreHelper.makeFilter( + DatastoreHelper.KEY_PROPERTY_NAME, + PropertyFilter.Operator.LESS_THAN, + DatastoreHelper.makeValue(nextKey)) + .build(); + keyFilters.add(upperBound); + } + return Query.newBuilder(query).setFilter(makeAndFilter(keyFilters)).build(); + } + + /** + * Gets a list of split keys given a desired number of splits. + * + *

This list will contain multiple split keys for each split. Only a single split key will be + * chosen as the split point, however providing multiple keys allows for more uniform sharding. + * + * @param numSplits the number of desired splits. + * @param query the user query. + * @param partition the partition to run the query in. + * @param datastore the datastore containing the data. + * @param readTime read time at which to get the split keys from the datastore. + * @throws DatastoreException if there was an error when executing the datastore query. + */ + private List getScatterKeys( + int numSplits, + Query query, + PartitionId partition, + Datastore datastore, + @Nullable Timestamp readTime) + throws DatastoreException { + Query.Builder scatterPointQuery = createScatterQuery(query, numSplits); + + List keySplits = new ArrayList(); + + QueryResultBatch batch; + do { + RunQueryRequest.Builder scatterRequest = + RunQueryRequest.newBuilder().setPartitionId(partition).setQuery(scatterPointQuery); + scatterRequest.setProjectId(partition.getProjectId()); + scatterRequest.setDatabaseId(partition.getDatabaseId()); + if (readTime != null) { + scatterRequest.setReadOptions(ReadOptions.newBuilder().setReadTime(readTime).build()); + } + batch = datastore.runQuery(scatterRequest.build()).getBatch(); + for (EntityResult result : batch.getEntityResultsList()) { + keySplits.add(result.getEntity().getKey()); + } + scatterPointQuery.setStartCursor(batch.getEndCursor()); + scatterPointQuery + .getLimitBuilder() + .setValue(scatterPointQuery.getLimit().getValue() - batch.getEntityResultsCount()); + } while (batch.getMoreResults() == MoreResultsType.NOT_FINISHED); + Collections.sort(keySplits, DatastoreHelper.getKeyComparator()); + return keySplits; + } + + /** + * Creates a scatter query from the given user query + * + * @param query the user's query. + * @param numSplits the number of splits to create. + */ + private Query.Builder createScatterQuery(Query query, int numSplits) { + // TODO(pcostello): We can potentially support better splits with equality filters in our query + // if there exists a composite index on property, __scatter__, __key__. Until an API for + // metadata exists, this isn't possible. Note that ancestor and inequality queries fall into + // the same category. + Query.Builder scatterPointQuery = Query.newBuilder(); + scatterPointQuery.addAllKind(query.getKindList()); + scatterPointQuery.addOrder( + DatastoreHelper.makeOrder(DatastoreHelper.SCATTER_PROPERTY_NAME, Direction.ASCENDING)); + // There is a split containing entities before and after each scatter entity: + // ||---*------*------*------*------*------*------*---|| = scatter entity + // If we represent each split as a region before a scatter entity, there is an extra region + // following the last scatter point. Thus, we do not need the scatter entities for the last + // region. + scatterPointQuery.getLimitBuilder().setValue((numSplits - 1) * KEYS_PER_SPLIT); + scatterPointQuery.addProjection( + Projection.newBuilder().setProperty(PropertyReference.newBuilder().setName("__key__"))); + return scatterPointQuery; + } + + /** + * Given a list of keys and a number of splits find the keys to split on. + * + * @param keys the list of keys. + * @param numSplits the number of splits. + */ + private Iterable getSplitKey(List keys, int numSplits) { + // If the number of keys is less than the number of splits, we are limited in the number of + // splits we can make. + if (keys.size() < numSplits - 1) { + return keys; + } + + // Calculate the number of keys per split. This should be KEYS_PER_SPLIT, but may + // be less if there are not KEYS_PER_SPLIT * (numSplits - 1) scatter entities. + // + // Consider the following dataset, where - represents an entity and * represents an entity + // that is returned as a scatter entity: + // ||---*-----*----*-----*-----*------*----*----|| + // If we want 4 splits in this data, the optimal split would look like: + // ||---*-----*----*-----*-----*------*----*----|| + // | | | + // The scatter keys in the last region are not useful to us, so we never request them: + // ||---*-----*----*-----*-----*------*---------|| + // | | | + // With 6 scatter keys we want to set scatter points at indexes: 1, 3, 5. + // + // We keep this as a double so that any "fractional" keys per split get distributed throughout + // the splits and don't make the last split significantly larger than the rest. + double numKeysPerSplit = Math.max(1.0, ((double) keys.size()) / (numSplits - 1)); + + List keysList = new ArrayList(numSplits - 1); + // Grab the last sample for each split, otherwise the first split will be too small. + for (int i = 1; i < numSplits; i++) { + int splitIndex = (int) Math.round(i * numKeysPerSplit) - 1; + keysList.add(keys.get(splitIndex)); + } + + return keysList; + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/RemoteRpc.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/RemoteRpc.java new file mode 100644 index 000000000000..75fc84d62e28 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/RemoteRpc.java @@ -0,0 +1,254 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client; + +import com.google.api.client.http.GenericUrl; +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpRequestFactory; +import com.google.api.client.http.HttpRequestInitializer; +import com.google.api.client.http.HttpResponse; +import com.google.api.client.http.HttpStatusCodes; +import com.google.api.client.http.protobuf.ProtoHttpContent; +import com.google.api.client.util.IOUtils; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Strings; +import com.google.protobuf.MessageLite; +import com.google.rpc.Code; +import com.google.rpc.Status; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.SocketTimeoutException; +import java.nio.charset.Charset; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Logger; + +/** + * An RPC transport that sends protocol buffers over HTTP. + * + *

This class is thread-safe. + */ +class RemoteRpc { + private static final Logger logger = Logger.getLogger(RemoteRpc.class.getName()); + + @VisibleForTesting static final String API_FORMAT_VERSION_HEADER = "X-Goog-Api-Format-Version"; + private static final String API_FORMAT_VERSION = "2"; + + @VisibleForTesting static final String X_GOOG_REQUEST_PARAMS_HEADER = "x-goog-request-params"; + + private final HttpRequestFactory client; + private final HttpRequestInitializer initializer; + private final String url; + private final AtomicInteger rpcCount = new AtomicInteger(0); + // Not final - so it can be set/reset in Unittests + private static boolean enableE2EChecksum = + Boolean.parseBoolean(System.getenv("GOOGLE_CLOUD_DATASTORE_HTTP_ENABLE_E2E_CHECKSUM")); + + RemoteRpc(HttpRequestFactory client, HttpRequestInitializer initializer, String url) { + this.client = client; + this.initializer = initializer; + this.url = url; + try { + resolveURL("dummyRpc"); + } catch (Exception e) { + throw new IllegalArgumentException( + "Unable to construct RemoteRpc due to unsupported url: <" + url + ">", e); + } + } + + /** + * Makes an RPC call using the client. Logs how long it took and any exceptions. + * + *

NOTE: The request could be an InputStream too, but the http client will need to find its + * length, which will require buffering it anyways. + * + * @throws DatastoreException if the RPC fails. + */ + public InputStream call( + String methodName, MessageLite request, String projectId, String databaseId) + throws DatastoreException { + logger.fine("remote datastore call " + methodName); + + long startTime = System.currentTimeMillis(); + try { + HttpResponse httpResponse; + try { + rpcCount.incrementAndGet(); + ProtoHttpContent payload = new ProtoHttpContent(request); + HttpRequest httpRequest = client.buildPostRequest(resolveURL(methodName), payload); + setHeaders(request, httpRequest, projectId, databaseId); + // Don't throw an HTTPResponseException on error. It converts the response to a String and + // throws away the original, whereas we need the raw bytes to parse it as a proto. + httpRequest.setThrowExceptionOnExecuteError(false); + // Datastore requests typically time out after 60s; set the read timeout to slightly longer + // than that by default (can be overridden via the HttpRequestInitializer). + httpRequest.setReadTimeout(65 * 1000); + if (initializer != null) { + initializer.initialize(httpRequest); + } + httpResponse = httpRequest.execute(); + if (!httpResponse.isSuccessStatusCode()) { + try (InputStream content = httpResponse.getContent()) { + throw makeException( + url, + methodName, + content, + httpResponse.getContentType(), + httpResponse.getContentCharset(), + null, + httpResponse.getStatusCode()); + } + } + InputStream inputStream = httpResponse.getContent(); + return enableE2EChecksum && EndToEndChecksumHandler.hasChecksumHeader(httpResponse) + ? new ChecksumEnforcingInputStream(inputStream, httpResponse) + : inputStream; + } catch (SocketTimeoutException e) { + throw makeException(url, methodName, Code.DEADLINE_EXCEEDED, "Deadline exceeded", e); + } catch (IOException e) { + throw makeException(url, methodName, Code.UNAVAILABLE, "I/O error", e); + } + } finally { + long elapsedTime = System.currentTimeMillis() - startTime; + logger.fine("remote datastore call " + methodName + " took " + elapsedTime + " ms"); + } + } + + @VisibleForTesting + void setHeaders( + MessageLite request, HttpRequest httpRequest, String projectId, String databaseId) { + httpRequest.getHeaders().put(API_FORMAT_VERSION_HEADER, API_FORMAT_VERSION); + StringBuilder builder = new StringBuilder("project_id="); + builder.append(projectId); + if (!Strings.isNullOrEmpty(databaseId)) { + builder.append("&database_id="); + builder.append(databaseId); + } + httpRequest.getHeaders().put(X_GOOG_REQUEST_PARAMS_HEADER, builder.toString()); + if (enableE2EChecksum && request != null) { + String checksum = EndToEndChecksumHandler.computeChecksum(request.toByteArray()); + if (checksum != null) { + httpRequest + .getHeaders() + .put(EndToEndChecksumHandler.HTTP_REQUEST_CHECKSUM_HEADER, checksum); + } + } + } + + @VisibleForTesting + HttpRequestFactory getClient() { + return client; + } + + @VisibleForTesting + static void setSystemEnvE2EChecksum(boolean enableE2EChecksum) { + RemoteRpc.enableE2EChecksum = enableE2EChecksum; + } + + void resetRpcCount() { + rpcCount.set(0); + } + + int getRpcCount() { + return rpcCount.get(); + } + + public String getUrl() { + return url; + } + + GenericUrl resolveURL(String path) { + return new GenericUrl(url + ":" + path); + } + + HttpRequestFactory getHttpRequestFactory() { + return client; + } + + public static DatastoreException makeException( + String url, String methodName, Code code, String message, Throwable cause) { + logger.fine("remote datastore call " + methodName + " against " + url + " failed: " + message); + return new DatastoreException(methodName, code, message, cause); + } + + static DatastoreException makeException( + String url, + String methodName, + InputStream content, + String contentType, + Charset contentCharset, + Throwable cause, + int httpStatusCode) { + if (!contentType.equals("application/x-protobuf")) { + String responseContent; + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + IOUtils.copy(content, out, false); + responseContent = out.toString(contentCharset.name()); + } catch (IOException e) { + responseContent = ""; + } + return makeException( + url, + methodName, + Code.INTERNAL, + String.format( + "Non-protobuf error: %s. HTTP status code was %d.", responseContent, httpStatusCode), + cause); + } + + Status rpcStatus; + try { + rpcStatus = Status.parseFrom(content); + } catch (IOException e) { + return makeException( + url, + methodName, + Code.INTERNAL, + String.format( + "Unable to parse Status protocol buffer: HTTP status code was %s.", httpStatusCode), + e); + } + + Code code = Code.forNumber(rpcStatus.getCode()); + if (code == null) { + return makeException( + url, + methodName, + Code.INTERNAL, + String.format( + "Invalid error code: %d. Message: %s.", rpcStatus.getCode(), rpcStatus.getMessage()), + cause); + } else if (code == Code.OK) { + // We can end up here because there was no response body (and we successfully parsed an + // empty Status message). This may happen for 401s in particular due to special handling + // in low-level HTTP libraries. + if (httpStatusCode == HttpStatusCodes.STATUS_CODE_UNAUTHORIZED) { + return makeException(url, methodName, Code.UNAUTHENTICATED, "Unauthenticated.", cause); + } + return makeException( + url, + methodName, + Code.INTERNAL, + String.format( + "Unexpected OK error code with HTTP status code of %d. Message: %s.", + httpStatusCode, rpcStatus.getMessage()), + cause); + } + + return makeException(url, methodName, code, rpcStatus.getMessage(), cause); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/testing/MockCredential.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/testing/MockCredential.java new file mode 100644 index 000000000000..7831d2a03f6d --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/testing/MockCredential.java @@ -0,0 +1,36 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client.testing; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.http.HttpRequest; +import java.io.IOException; + +/** Fake credential used for testing purpose. */ +public class MockCredential extends Credential { + public MockCredential() { + super( + new AccessMethod() { + @Override + public void intercept(HttpRequest request, String accessToken) throws IOException {} + + @Override + public String getAccessTokenFromRequest(HttpRequest request) { + return "MockAccessToken"; + } + }); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/testing/MockDatastoreFactory.java b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/testing/MockDatastoreFactory.java new file mode 100644 index 000000000000..bbe8468258a9 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/java/com/google/datastore/v1/client/testing/MockDatastoreFactory.java @@ -0,0 +1,137 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client.testing; + +import static com.google.common.base.Preconditions.checkState; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.http.GenericUrl; +import com.google.api.client.http.HttpRequestFactory; +import com.google.api.client.http.HttpStatusCodes; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.LowLevelHttpRequest; +import com.google.api.client.http.LowLevelHttpResponse; +import com.google.api.client.testing.http.MockHttpTransport; +import com.google.api.client.testing.http.MockLowLevelHttpRequest; +import com.google.api.client.testing.http.MockLowLevelHttpResponse; +import com.google.api.client.testing.util.TestableByteArrayInputStream; +import com.google.common.collect.Iterables; +import com.google.datastore.v1.client.DatastoreFactory; +import com.google.datastore.v1.client.DatastoreOptions; +import com.google.protobuf.Message; +import com.google.rpc.Code; +import com.google.rpc.Status; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; + +/** Fake Datastore factory used for testing purposes when a true Datastore service is not needed. */ +public class MockDatastoreFactory extends DatastoreFactory { + private int nextStatus; + private Message nextResponse; + private Status nextError; + private IOException nextException; + + private String lastPath; + private String lastMimeType; + private byte[] lastBody; + private List lastCookies; + private String lastApiFormatHeaderValue; + + public void setNextResponse(Message response) { + nextStatus = HttpStatusCodes.STATUS_CODE_OK; + nextResponse = response; + nextError = null; + nextException = null; + } + + public void setNextError(int status, Code code, String message) { + nextStatus = status; + nextResponse = null; + nextError = makeErrorContent(message, code); + nextException = null; + } + + public void setNextException(IOException exception) { + nextStatus = 0; + nextResponse = null; + nextError = null; + nextException = exception; + } + + @Override + public HttpRequestFactory makeClient(DatastoreOptions options) { + HttpTransport transport = + new MockHttpTransport() { + @Override + public LowLevelHttpRequest buildRequest(String method, String url) { + return new MockLowLevelHttpRequest(url) { + @Override + public LowLevelHttpResponse execute() throws IOException { + lastPath = new GenericUrl(getUrl()).getRawPath(); + lastMimeType = getContentType(); + lastCookies = getHeaderValues("Cookie"); + lastApiFormatHeaderValue = + Iterables.getOnlyElement(getHeaderValues("X-Goog-Api-Format-Version")); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + getStreamingContent().writeTo(out); + lastBody = out.toByteArray(); + if (nextException != null) { + throw nextException; + } + MockLowLevelHttpResponse response = + new MockLowLevelHttpResponse() + .setStatusCode(nextStatus) + .setContentType("application/x-protobuf"); + if (nextError != null) { + checkState(nextResponse == null); + response.setContent(new TestableByteArrayInputStream(nextError.toByteArray())); + } else { + response.setContent(new TestableByteArrayInputStream(nextResponse.toByteArray())); + } + return response; + } + }; + } + }; + Credential credential = options.getCredential(); + return transport.createRequestFactory(credential); + } + + public String getLastPath() { + return lastPath; + } + + public String getLastMimeType() { + return lastMimeType; + } + + public String getLastApiFormatHeaderValue() { + return lastApiFormatHeaderValue; + } + + public byte[] getLastBody() { + return lastBody; + } + + public List getLastCookies() { + return lastCookies; + } + + private static Status makeErrorContent(String message, Code code) { + return Status.newBuilder().setCode(code.getNumber()).setMessage(message).build(); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/main/resources/META-INF/native-image/native-image.properties b/java-datastore/datastore-v1-proto-client/src/main/resources/META-INF/native-image/native-image.properties new file mode 100644 index 000000000000..0b5b2e18cb09 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/resources/META-INF/native-image/native-image.properties @@ -0,0 +1 @@ +Args = --enable-url-protocols=https,http \ No newline at end of file diff --git a/java-datastore/datastore-v1-proto-client/src/main/resources/META-INF/native-image/reflect-config.json b/java-datastore/datastore-v1-proto-client/src/main/resources/META-INF/native-image/reflect-config.json new file mode 100644 index 000000000000..17876ff433eb --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/main/resources/META-INF/native-image/reflect-config.json @@ -0,0 +1,33 @@ +[ + { + "name":"com.google.datastore.v1.client.Datastore", + "methods":[ + {"name":"allocateIds","parameterTypes":["com.google.datastore.v1.AllocateIdsRequest"] }, + {"name":"beginTransaction","parameterTypes":["com.google.datastore.v1.BeginTransactionRequest"] }, + {"name":"commit","parameterTypes":["com.google.datastore.v1.CommitRequest"] }, + {"name":"lookup","parameterTypes":["com.google.datastore.v1.LookupRequest"] }, + {"name":"reserveIds","parameterTypes":["com.google.datastore.v1.ReserveIdsRequest"] }, + {"name":"rollback","parameterTypes":["com.google.datastore.v1.RollbackRequest"] }, + {"name":"runQuery","parameterTypes":["com.google.datastore.v1.RunQueryRequest"] }, + {"name":"runAggregationQuery","parameterTypes":["com.google.datastore.v1.RunAggregationQueryRequest"] } + ] + }, + { + "name":"com.google.api.client.http.HttpRequest", + "allDeclaredFields":true, + "allPublicFields":true, + "allDeclaredMethods":true, + "allPublicMethods":true, + "allDeclaredConstructors" : true, + "allPublicConstructors" : true + }, + { + "name":"com.google.api.client.http.HttpHeaders", + "allDeclaredFields":true, + "allPublicFields":true, + "allDeclaredMethods":true, + "allPublicMethods":true, + "allDeclaredConstructors" : true, + "allPublicConstructors" : true + } +] \ No newline at end of file diff --git a/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/ChecksumEnforcingInputStreamTest.java b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/ChecksumEnforcingInputStreamTest.java new file mode 100644 index 000000000000..74ab41de0d5f --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/ChecksumEnforcingInputStreamTest.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 + * + * 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.datastore.v1.client; + +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Test for {@link ChecksumEnforcingInputStream}. */ +@RunWith(JUnit4.class) +public class ChecksumEnforcingInputStreamTest { + public void test(int payloadSize) throws Exception { + // read 1000 bytes at a time + // Since checksum should be correct, do not expect IOException + try (ChecksumEnforcingInputStream testInstance = setUpData(payloadSize)) { + byte[] buf = new byte[1000]; + while (testInstance.read(buf, 0, 1000) != -1) { + // do nothing with the bytes read + } + } catch (IOException e) { + fail("checksum verification failed! " + e.getMessage()); + } + } + + @Test + public void read_withValidChecksum_differentPayloadSizes() throws Exception { + // test with various payload sizes (1, 2, 2**2, 2**3 etc upto 2**28 = 256MB) + for (int i = 0, payloadSize = 1; i < 29; i++) { + long start = System.currentTimeMillis(); + test(payloadSize); + payloadSize *= 2; + long duration = System.currentTimeMillis() - start; + // log test duration times for bigger payloads + if (i > 20) { + System.out.println("Test duration for payloadsize = 2** " + i + " is: " + duration + "ms"); + } + } + } + + @Test + public void read_withInvalidChecksum() { + // build a test instance with invalidchecksum + // read 1000 bytes at a time + // Since checksum should be correct, do not expect IOException + try (ChecksumEnforcingInputStream instance = + new ChecksumEnforcingInputStream( + new ByteArrayInputStream("hello there".getBytes(UTF_8)), "this checksum is invalid")) { + byte[] buf = new byte[1000]; + while (instance.read(buf, 0, 1000) != -1) { + // do nothing with the bytes read + } + } catch (IOException e) { + // this is expected + return; + } + fail("should have failed"); + } + + @Test + public void markNotSupported() throws Exception { + try (ChecksumEnforcingInputStream testInstance = setUpData(1)) { + assertFalse(testInstance.markSupported()); + } + } + + private ChecksumEnforcingInputStream setUpData(int payloadSize) throws Exception { + // setup a String of size = input param: payloadSize + String str = "This is a repeating string."; + String payload; + if (payloadSize > str.length()) { + int num = payloadSize / str.length(); + StringBuilder buf = new StringBuilder(); + for (int i = 0; i < num; i++) { + buf.append(str); + } + payload = buf.toString(); + } else { + payload = str.substring(0, payloadSize); + } + byte[] bytes = payload.getBytes(UTF_8); + String expectedChecksum = EndToEndChecksumHandler.computeChecksum(bytes); + return new ChecksumEnforcingInputStream(new ByteArrayInputStream(bytes), expectedChecksum); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreClientTest.java b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreClientTest.java new file mode 100644 index 000000000000..b2fe1ee90afa --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreClientTest.java @@ -0,0 +1,407 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client; + +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.fail; + +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpRequestInitializer; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.EntityResult; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.QueryResultBatch; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.datastore.v1.client.testing.MockCredential; +import com.google.datastore.v1.client.testing.MockDatastoreFactory; +import com.google.protobuf.ByteString; +import com.google.protobuf.Message; +import com.google.rpc.Code; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.SocketTimeoutException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link DatastoreFactory} and {@link Datastore}. */ +@RunWith(JUnit4.class) +public class DatastoreClientTest { + private static final String PROJECT_ID = "project-id"; + + private DatastoreFactory factory = new MockDatastoreFactory(); + private DatastoreOptions.Builder options = + new DatastoreOptions.Builder().projectId(PROJECT_ID).credential(new MockCredential()); + + @Test + public void options_NoProjectIdOrProjectEndpoint() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> factory.create(new DatastoreOptions.Builder().build())); + assertThat(exception) + .hasMessageThat() + .contains("Either project ID or project endpoint must be provided"); + factory.create(options.build()); + } + + @Test + public void options_ProjectIdAndProjectEndpoint() throws Exception { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .projectEndpoint( + "http://localhost:1234/datastore/v1beta42/projects/project-id")); + assertThat(exception) + .hasMessageThat() + .contains("Cannot set both project endpoint and project ID"); + } + + @Test + public void options_LocalHostAndProjectEndpoint() throws Exception { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + new DatastoreOptions.Builder() + .localHost("localhost:8080") + .projectEndpoint( + "http://localhost:1234/datastore/v1beta42/projects/project-id")); + assertThat(exception) + .hasMessageThat() + .contains("Can set at most one of project endpoint, host, and local host"); + } + + @Test + public void options_HostAndProjectEndpoint() throws Exception { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + new DatastoreOptions.Builder() + .host("foo-datastore.googleapis.com") + .projectEndpoint( + "http://localhost:1234/datastore/v1beta42/projects/project-id")); + assertThat(exception) + .hasMessageThat() + .contains("Can set at most one of project endpoint, host, and local host"); + } + + @Test + public void options_HostAndLocalHost() throws Exception { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + new DatastoreOptions.Builder() + .host("foo-datastore.googleapis.com") + .localHost("localhost:8080")); + assertThat(exception) + .hasMessageThat() + .contains("Can set at most one of project endpoint, host, and local host"); + } + + @Test + public void options_InvalidLocalHost() throws Exception { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + factory.create( + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .localHost("!not a valid url!") + .build())); + assertThat(exception).hasMessageThat().contains("Illegal character"); + } + + @Test + public void options_SchemeInLocalHost() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> new DatastoreOptions.Builder().localHost("http://localhost:8080")); + assertThat(exception) + .hasMessageThat() + .contains("Local host \"http://localhost:8080\" must not include scheme"); + } + + @Test + public void options_InvalidHost() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + factory.create( + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .host("!not a valid url!") + .build())); + assertThat(exception).hasMessageThat().contains("Illegal character"); + } + + @Test + public void options_SchemeInHost() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> new DatastoreOptions.Builder().host("http://foo-datastore.googleapis.com")); + + assertThat(exception) + .hasMessageThat() + .contains("Host \"http://foo-datastore.googleapis.com\" must not include scheme."); + } + + @Test + public void create_NullOptions() throws Exception { + assertThrows(NullPointerException.class, () -> factory.create(null)); + } + + @Test + public void create_Host() { + Datastore datastore = + factory.create( + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .host("foo-datastore.googleapis.com") + .build()); + assertThat(datastore.remoteRpc.getUrl()) + .isEqualTo("https://foo-datastore.googleapis.com/v1/projects/project-id"); + } + + @Test + public void create_LocalHost() { + Datastore datastore = + factory.create( + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .localHost("localhost:8080") + .build()); + assertThat(datastore.remoteRpc.getUrl()) + .isEqualTo("http://localhost:8080/v1/projects/project-id"); + } + + @Test + public void create_LocalHostIp() { + Datastore datastore = + factory.create( + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .localHost("127.0.0.1:8080") + .build()); + assertThat(datastore.remoteRpc.getUrl()) + .isEqualTo("http://127.0.0.1:8080/v1/projects/project-id"); + } + + @Test + public void create_DefaultHost() { + Datastore datastore = + factory.create(new DatastoreOptions.Builder().projectId(PROJECT_ID).build()); + assertThat(datastore.remoteRpc.getUrl()) + .isEqualTo("https://datastore.googleapis.com/v1/projects/project-id"); + } + + @Test + public void create_ProjectEndpoint() { + Datastore datastore = + factory.create( + new DatastoreOptions.Builder() + .projectEndpoint("http://prom-qa/datastore/v1beta42/projects/project-id") + .build()); + assertThat(datastore.remoteRpc.getUrl()) + .isEqualTo("http://prom-qa/datastore/v1beta42/projects/project-id"); + } + + @Test + public void create_ProjectEndpointNoScheme() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + factory.create( + new DatastoreOptions.Builder() + .projectEndpoint("localhost:1234/datastore/v1beta42/projects/project-id") + .build())); + assertThat(exception) + .hasMessageThat() + .contains( + "Project endpoint \"localhost:1234/datastore/v1beta42/projects/project-id\" must" + + " include scheme."); + } + + @Test + public void initializer() throws Exception { + options.initializer( + new HttpRequestInitializer() { + @Override + public void initialize(HttpRequest request) { + request.getHeaders().setCookie("magic"); + } + }); + Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + AllocateIdsRequest request = AllocateIdsRequest.newBuilder().build(); + AllocateIdsResponse response = AllocateIdsResponse.newBuilder().build(); + mockClient.setNextResponse(response); + assertEquals(response, datastore.allocateIds(request)); + assertEquals("magic", mockClient.getLastCookies().get(0)); + } + + @Test + public void allocateIds() throws Exception { + AllocateIdsRequest.Builder request = AllocateIdsRequest.newBuilder(); + AllocateIdsResponse.Builder response = AllocateIdsResponse.newBuilder(); + expectRpc("allocateIds", request.build(), response.build()); + } + + @Test + public void lookup() throws Exception { + LookupRequest.Builder request = LookupRequest.newBuilder(); + LookupResponse.Builder response = LookupResponse.newBuilder(); + expectRpc("lookup", request.build(), response.build()); + } + + @Test + public void beginTransaction() throws Exception { + BeginTransactionRequest.Builder request = BeginTransactionRequest.newBuilder(); + BeginTransactionResponse.Builder response = BeginTransactionResponse.newBuilder(); + response.setTransaction(ByteString.copyFromUtf8("project-id")); + expectRpc("beginTransaction", request.build(), response.build()); + } + + @Test + public void commit() throws Exception { + CommitRequest.Builder request = CommitRequest.newBuilder(); + request.setTransaction(ByteString.copyFromUtf8("project-id")); + CommitResponse.Builder response = CommitResponse.newBuilder(); + expectRpc("commit", request.build(), response.build()); + } + + @Test + public void reserveIds() throws Exception { + ReserveIdsRequest.Builder request = ReserveIdsRequest.newBuilder(); + ReserveIdsResponse.Builder response = ReserveIdsResponse.newBuilder(); + expectRpc("reserveIds", request.build(), response.build()); + } + + @Test + public void rollback() throws Exception { + RollbackRequest.Builder request = RollbackRequest.newBuilder(); + request.setTransaction(ByteString.copyFromUtf8("project-id")); + RollbackResponse.Builder response = RollbackResponse.newBuilder(); + expectRpc("rollback", request.build(), response.build()); + } + + @Test + public void runQuery() throws Exception { + RunQueryRequest.Builder request = RunQueryRequest.newBuilder(); + request.getQueryBuilder(); + RunQueryResponse.Builder response = RunQueryResponse.newBuilder(); + response + .getBatchBuilder() + .setEntityResultType(EntityResult.ResultType.FULL) + .setMoreResults(QueryResultBatch.MoreResultsType.NOT_FINISHED); + expectRpc("runQuery", request.build(), response.build()); + } + + @Test + public void runAggregationQuery() throws Exception { + RunAggregationQueryRequest.Builder request = RunAggregationQueryRequest.newBuilder(); + RunAggregationQueryResponse.Builder response = RunAggregationQueryResponse.newBuilder(); + expectRpc("runAggregationQuery", request.build(), response.build()); + } + + private void expectRpc(String methodName, Message request, Message response) throws Exception { + Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + + mockClient.setNextResponse(response); + @SuppressWarnings("rawtypes") + Class[] methodArgs = {request.getClass()}; + Method call = Datastore.class.getMethod(methodName, methodArgs); + Object[] callArgs = {request}; + assertEquals(response, call.invoke(datastore, callArgs)); + + assertEquals("/v1/projects/project-id:" + methodName, mockClient.getLastPath()); + assertEquals("application/x-protobuf", mockClient.getLastMimeType()); + assertEquals("2", mockClient.getLastApiFormatHeaderValue()); + assertArrayEquals(request.toByteArray(), mockClient.getLastBody()); + assertEquals(1, datastore.getRpcCount()); + + datastore.resetRpcCount(); + assertEquals(0, datastore.getRpcCount()); + + mockClient.setNextError(400, Code.INVALID_ARGUMENT, "oops"); + try { + call.invoke(datastore, callArgs); + fail(); + } catch (InvocationTargetException targetException) { + DatastoreException exception = (DatastoreException) targetException.getCause(); + assertEquals(Code.INVALID_ARGUMENT, exception.getCode()); + assertEquals(methodName, exception.getMethodName()); + assertEquals("oops", exception.getMessage()); + } + + SocketTimeoutException socketTimeoutException = new SocketTimeoutException("ste"); + mockClient.setNextException(socketTimeoutException); + try { + call.invoke(datastore, callArgs); + fail(); + } catch (InvocationTargetException targetException) { + DatastoreException exception = (DatastoreException) targetException.getCause(); + assertEquals(Code.DEADLINE_EXCEEDED, exception.getCode()); + assertEquals(methodName, exception.getMethodName()); + assertEquals("Deadline exceeded", exception.getMessage()); + assertSame(socketTimeoutException, exception.getCause()); + } + + IOException ioException = new IOException("ioe"); + mockClient.setNextException(ioException); + try { + call.invoke(datastore, callArgs); + fail(); + } catch (InvocationTargetException targetException) { + DatastoreException exception = (DatastoreException) targetException.getCause(); + assertEquals(Code.UNAVAILABLE, exception.getCode()); + assertEquals(methodName, exception.getMethodName()); + assertEquals("I/O error", exception.getMessage()); + assertSame(ioException, exception.getCause()); + } + + assertEquals(3, datastore.getRpcCount()); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreEmulatorTest.java b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreEmulatorTest.java new file mode 100644 index 000000000000..d03cfa867fab --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreEmulatorTest.java @@ -0,0 +1,99 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client; + +import static org.junit.Assert.fail; + +import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link DatastoreEmulator}. */ +@RunWith(JUnit4.class) +public class DatastoreEmulatorTest { + + private static final DatastoreEmulatorOptions options = + new DatastoreEmulatorOptions.Builder().build(); + + @Test + public void testArgs() throws DatastoreEmulatorException { + DatastoreEmulator datastore = + new DatastoreEmulator(null, "blar", options) { + @Override + void startEmulatorInternal( + String emulatorDir, String projectId, List cmdLineOpts) { + // no-op for testing + } + }; + + try { + datastore.start(null, "projectId"); + fail("expected exception"); + } catch (NullPointerException npe) { + // good + } + + try { + datastore.start("path/to/emulator", null); + fail("expected exception"); + } catch (NullPointerException npe) { + // good + } + + datastore.start("path/to/emulator", "projectId"); + } + + @Test + public void testLifecycle() throws DatastoreEmulatorException { + DatastoreEmulator datastore = + new DatastoreEmulator(null, "blar", options) { + @Override + void startEmulatorInternal( + String emulatorDir, String projectId, List cmdLineOpts) { + // no-op for testing + } + + @Override + protected void stopEmulatorInternal() { + // no-op for testing + } + }; + + String emulatorDir = "/yar"; + String myProject = "myproject"; + + datastore.start(emulatorDir, myProject); + try { + datastore.start(emulatorDir, myProject); + fail("expected exception"); + } catch (IllegalStateException e) { + // good + } + + datastore.stop(); + // It's ok to stop if we've already stopped. + datastore.stop(); + + // Once we've stopped we can't start again. + try { + datastore.start(emulatorDir, myProject); + fail("expected exception"); + } catch (IllegalStateException e) { + // good + } + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreFactoryTest.java b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreFactoryTest.java new file mode 100644 index 000000000000..bc28342c092f --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreFactoryTest.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 + * + * 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.datastore.v1.client; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; + +import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; +import com.google.api.client.http.HttpRequestFactory; +import com.google.api.client.http.javanet.NetHttpTransport; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Test for {@link DatastoreFactory}. */ +@RunWith(JUnit4.class) +public class DatastoreFactoryTest { + private static final String PROJECT_ID = "project-id"; + + private DatastoreFactory factory = DatastoreFactory.get(); + + /** + * Without specifying a credential or transport, the factory will create a default transport on + * its own. + */ + @Test + public void makeClient_Default() { + DatastoreOptions options = new DatastoreOptions.Builder().projectId(PROJECT_ID).build(); + HttpRequestFactory f = factory.makeClient(options); + assertNotNull(f.getTransport()); + assertTrue(f.getTransport() instanceof NetHttpTransport); + } + + /** + * Specifying a credential, but not a transport, the factory will use the transport from the + * credential. + */ + @Test + public void makeClient_WithCredential() { + NetHttpTransport transport = new NetHttpTransport(); + GoogleCredential credential = new GoogleCredential.Builder().setTransport(transport).build(); + DatastoreOptions options = + new DatastoreOptions.Builder().projectId(PROJECT_ID).credential(credential).build(); + HttpRequestFactory f = factory.makeClient(options); + assertEquals(transport, f.getTransport()); + } + + /** Specifying a transport, but not a credential, the factory will use the transport specified. */ + @Test + public void makeClient_WithTransport() { + NetHttpTransport transport = new NetHttpTransport(); + DatastoreOptions options = + new DatastoreOptions.Builder().projectId(PROJECT_ID).transport(transport).build(); + HttpRequestFactory f = factory.makeClient(options); + assertEquals(transport, f.getTransport()); + } + + /** + * Specifying both credential and transport, the factory will use the transport specified and not + * the one in the credential. + */ + @Test + public void makeClient_WithCredentialTransport() { + NetHttpTransport credTransport = new NetHttpTransport(); + NetHttpTransport transport = new NetHttpTransport(); + GoogleCredential credential = + new GoogleCredential.Builder().setTransport(credTransport).build(); + DatastoreOptions options = + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .credential(credential) + .transport(transport) + .build(); + HttpRequestFactory f = factory.makeClient(options); + assertNotSame(credTransport, f.getTransport()); + assertEquals(transport, f.getTransport()); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreHelperTest.java b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreHelperTest.java new file mode 100644 index 000000000000..d9f5979c317d --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/DatastoreHelperTest.java @@ -0,0 +1,320 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client; + +import static com.google.datastore.v1.client.DatastoreHelper.getByteString; +import static com.google.datastore.v1.client.DatastoreHelper.makeKey; +import static com.google.datastore.v1.client.DatastoreHelper.makeValue; +import static com.google.datastore.v1.client.DatastoreHelper.toDate; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import com.google.datastore.v1.Key; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.Value; +import com.google.datastore.v1.Value.ValueTypeCase; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import java.util.Date; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link DatastoreHelper}. */ +@RunWith(JUnit4.class) +public class DatastoreHelperTest { + + private static final Key PARENT = + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Parent").setId(23L)).build(); + private static final Key GRANDPARENT = + Key.newBuilder() + .addPath(Key.PathElement.newBuilder().setKind("Grandparent").setId(24L)) + .build(); + private static final Key CHILD = + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Child").setId(26L)).build(); + + @Test + public void testMakeKey_BadTypeForKind() { + try { + DatastoreHelper.makeKey(new Object()); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + } + + @Test + public void testMakeKey_BadTypeForNameId() { + try { + DatastoreHelper.makeKey("kind", new Object()); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + } + + @Test + public void testMakeKey_Empty() { + assertEquals(Key.newBuilder().build(), DatastoreHelper.makeKey().build()); + } + + @Test + public void testMakeKey_Incomplete() { + assertEquals( + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Foo")).build(), + makeKey("Foo").build()); + } + + @Test + public void testMakeKey_IdInt() { + assertEquals( + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Foo").setId(1)).build(), + makeKey("Foo", 1).build()); + } + + @Test + public void testMakeKey_IdLong() { + assertEquals( + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Foo").setId(1)).build(), + makeKey("Foo", 1L).build()); + } + + @Test + public void testMakeKey_IdShort() { + assertEquals( + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Foo").setId(1)).build(), + makeKey("Foo", (short) 1).build()); + } + + @Test + public void testMakeKey_Name() { + assertEquals( + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Foo").setName("hi")).build(), + makeKey("Foo", "hi").build()); + } + + @Test + public void testMakeKey_KindNameKind() { + assertEquals( + Key.newBuilder() + .addPath(Key.PathElement.newBuilder().setKind("Foo").setName("hi")) + .addPath(Key.PathElement.newBuilder().setKind("Bar")) + .build(), + makeKey("Foo", "hi", "Bar").build()); + } + + @Test + public void testMakeKey_KeyKind() { + // 1 key at the beginning of the series + assertEquals( + Key.newBuilder() + .addPath(PARENT.getPath(0)) + .addPath(Key.PathElement.newBuilder().setKind("Child")) + .build(), + makeKey(PARENT, "Child").build()); + } + + @Test + public void testMakeKey_KindIdKeyKind() { + // 1 key in the middle of the series + assertEquals( + Key.newBuilder() + .addPath(Key.PathElement.newBuilder().setKind("Grandparent").setId(24L)) + .addPath(PARENT.getPath(0)) + .addPath(Key.PathElement.newBuilder().setKind("Child")) + .build(), + makeKey("Grandparent", 24L, PARENT, "Child").build()); + } + + @Test + public void testMakeKey_KindIdKey() { + // 1 key at the end of the series + assertEquals( + Key.newBuilder() + .addPath(Key.PathElement.newBuilder().setKind("Grandparent").setId(24L)) + .addPath(PARENT.getPath(0)) + .build(), + makeKey("Grandparent", 24L, PARENT).build()); + } + + @Test + public void testMakeKey_KeyKindIdKey() { + // 1 key at the beginning and 1 key at the end of the series + assertEquals( + Key.newBuilder() + .addPath(GRANDPARENT.getPath(0)) + .addPath(Key.PathElement.newBuilder().setKind("Parent").setId(23L)) + .addPath(CHILD.getPath(0)) + .build(), + makeKey(GRANDPARENT, "Parent", 23, CHILD).build()); + } + + @Test + public void testMakeKey_Key() { + // Just 1 key + assertEquals(Key.newBuilder().addPath(CHILD.getPath(0)).build(), makeKey(CHILD).build()); + } + + @Test + public void testMakeKey_KeyKey() { + // Just 2 keys + assertEquals( + Key.newBuilder().addPath(PARENT.getPath(0)).addPath(CHILD.getPath(0)).build(), + makeKey(PARENT, CHILD).build()); + } + + @Test + public void testMakeKey_KeyKeyKey() { + // Just 3 keys + assertEquals( + Key.newBuilder() + .addPath(GRANDPARENT.getPath(0)) + .addPath(PARENT.getPath(0)) + .addPath(CHILD.getPath(0)) + .build(), + makeKey(GRANDPARENT, PARENT, CHILD).build()); + } + + @Test + public void testMakeKey_KeyMultiLevelKey() { + // 1 key with 2 elements + assertEquals( + Key.newBuilder() + .addPath(GRANDPARENT.getPath(0)) + .addPath(PARENT.getPath(0)) + .addPath(CHILD.getPath(0)) + .build(), + makeKey(GRANDPARENT, makeKey(PARENT, CHILD).build()).build()); + } + + @Test + public void testMakeKey_MultiLevelKeyKey() { + // 1 key with 2 elements + assertEquals( + Key.newBuilder() + .addPath(GRANDPARENT.getPath(0)) + .addPath(PARENT.getPath(0)) + .addPath(CHILD.getPath(0)) + .build(), + makeKey(makeKey(GRANDPARENT, PARENT).build(), CHILD).build()); + } + + @Test + public void testMakeKey_MultiLevelKey() { + // 1 key with 3 elements + assertEquals( + Key.newBuilder() + .addPath(GRANDPARENT.getPath(0)) + .addPath(PARENT.getPath(0)) + .addPath(CHILD.getPath(0)) + .build(), + makeKey(makeKey(GRANDPARENT, PARENT, CHILD).build()).build()); + } + + @Test + public void testMakeKey_PartitionId() { + PartitionId partitionId = PartitionId.newBuilder().setNamespaceId("namespace-id").build(); + Key parent = PARENT.toBuilder().setPartitionId(partitionId).build(); + assertEquals( + Key.newBuilder() + .setPartitionId(partitionId) + .addPath(PARENT.getPath(0)) + .addPath(Key.PathElement.newBuilder().setKind("Child")) + .build(), + makeKey(parent, "Child").build()); + } + + @Test + public void testMakeKey_NonMatchingPartitionId2() { + PartitionId partitionId1 = PartitionId.newBuilder().setNamespaceId("namespace-id").build(); + PartitionId partitionId2 = + PartitionId.newBuilder().setNamespaceId("another-namespace-id").build(); + try { + makeKey( + PARENT.toBuilder().setPartitionId(partitionId1).build(), + CHILD.toBuilder().setPartitionId(partitionId2).build()); + fail("expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + } + + @Test + public void testMakeTimestampValue() throws Exception { + // Test cases with nanos == 0. + assertConversion(-50_000, -50, 0); + assertConversion(-1_000, -1, 0); + assertConversion(0, 0, 0); + assertConversion(1_000, 1, 0); + assertConversion(2_000, 2, 0); + assertConversion(100_000, 100, 0); + + // Test cases with nanos % 1_000_000 == 0 (no loss of precision). + assertConversion(2, 0, 2_000_000); + assertConversion(1_003, 1, 3_000_000); + assertConversion(2_005, 2, 5_000_000); + + // Timestamp specification requires that nanos >= 0 even if the timestamp + // is before the epoch. + assertConversion(0, 0, 0); + assertConversion(-250, -1, 750_000_000); // 1/4 second before epoch + assertConversion(-500, -1, 500_000_000); // 1/2 second before epoch + assertConversion(-750, -1, 250_000_000); // 3/4 second before epoch + + // If nanos % 1_000_000 != 0, precision is lost (via truncation) when + // converting to milliseconds. + assertTimestampToMilliseconds(3_100, 3, 100_000_999); + assertMillisecondsToTimestamp(3_100, 3, 100_000_000); + assertTimestampToMilliseconds(5_999, 5, 999_999_999); + assertMillisecondsToTimestamp(5_999, 5, 999_000_000); + assertTimestampToMilliseconds(7_100, 7, 100_000_001); + assertMillisecondsToTimestamp(7_100, 7, 100_000_000); + } + + private void assertConversion(long millis, long seconds, int nanos) { + assertMillisecondsToTimestamp(millis, seconds, nanos); + assertTimestampToMilliseconds(millis, seconds, nanos); + } + + private void assertMillisecondsToTimestamp(long millis, long seconds, long nanos) { + Value timestampValue = makeValue(new Date(millis)).build(); + assertEquals(ValueTypeCase.TIMESTAMP_VALUE, timestampValue.getValueTypeCase()); + assertEquals(seconds, timestampValue.getTimestampValue().getSeconds()); + assertEquals(nanos, timestampValue.getTimestampValue().getNanos()); + } + + private void assertTimestampToMilliseconds(long millis, long seconds, int nanos) { + Value.Builder value = + Value.newBuilder() + .setTimestampValue(Timestamp.newBuilder().setSeconds(seconds).setNanos(nanos)); + assertEquals(millis, DatastoreHelper.toDate(value.build()).getTime()); + } + + @Test + public void testProjectionHandling() { + assertEquals( + ByteString.copyFromUtf8("hi"), getByteString(makeValue("hi").setMeaning(18).build())); + try { + getByteString(makeValue("hi").build()); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + + assertEquals(new Date(1), toDate(makeValue(1000).setMeaning(18).build())); + try { + toDate(makeValue(1000).build()); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/EndToEndChecksumHandlerTest.java b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/EndToEndChecksumHandlerTest.java new file mode 100644 index 000000000000..09176678e18a --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/EndToEndChecksumHandlerTest.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 + * + * 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.datastore.v1.client; + +import static java.nio.charset.StandardCharsets.UTF_8; +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 org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Test for {@link EndToEndChecksumHandler}. */ +@RunWith(JUnit4.class) +public class EndToEndChecksumHandlerTest { + private final byte[] payloadBytes = + "This is a long string with numbers 1234, 134.56 ".getBytes(UTF_8); + private final byte[] payloadForUnsignedLongChecksum = "aaa".getBytes(UTF_8); + private final String unsignedLongChecksum = "3818383321"; + + @Test + public void validateChecksum_correctChecksum() { + String computed = EndToEndChecksumHandler.computeChecksum(payloadBytes); + assertTrue(EndToEndChecksumHandler.validateChecksum(computed, payloadBytes)); + } + + @Test + public void computeChecksum_returnsUnsignedLongAsStringValue() { + String computed = EndToEndChecksumHandler.computeChecksum(payloadForUnsignedLongChecksum); + assertEquals("computeChecksum return value", unsignedLongChecksum, computed); + } + + @Test + public void validateChecksum_incorrectChecksum() { + String computed = EndToEndChecksumHandler.computeChecksum("random string".getBytes(UTF_8)); + assertFalse(EndToEndChecksumHandler.validateChecksum(computed, payloadBytes)); + } + + @Test + public void validateChecksum_nullChecksum() { + assertFalse(EndToEndChecksumHandler.validateChecksum(null, payloadBytes)); + } + + @Test + public void validateChecksum_emptyChecksum() { + assertFalse(EndToEndChecksumHandler.validateChecksum("", payloadBytes)); + } + + @Test + public void validateChecksum_nullPayload() { + assertFalse(EndToEndChecksumHandler.validateChecksum("foo", null)); + } + + @Test + public void validateChecksum_emptyPayload() { + assertFalse(EndToEndChecksumHandler.validateChecksum("foo", new byte[0])); + } + + @Test + public void computeChecksum_nullInputBytes() { + assertNull(EndToEndChecksumHandler.computeChecksum(null)); + } + + @Test + public void computeChecksum_emptyArrayForInputBytes() { + assertNull(EndToEndChecksumHandler.computeChecksum(new byte[0])); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/QuerySplitterTest.java b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/QuerySplitterTest.java new file mode 100644 index 000000000000..027029a768af --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/QuerySplitterTest.java @@ -0,0 +1,369 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.v1.client; + +import static com.google.common.truth.Truth.assertThat; +import static com.google.datastore.v1.client.DatastoreHelper.makeAndFilter; +import static com.google.datastore.v1.client.DatastoreHelper.makeFilter; +import static com.google.datastore.v1.client.DatastoreHelper.makeKey; +import static com.google.datastore.v1.client.DatastoreHelper.makeOrder; +import static com.google.datastore.v1.client.DatastoreHelper.makePropertyReference; +import static com.google.datastore.v1.client.DatastoreHelper.makeValue; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertThrows; + +import com.google.datastore.v1.Entity; +import com.google.datastore.v1.EntityResult; +import com.google.datastore.v1.EntityResult.ResultType; +import com.google.datastore.v1.Filter; +import com.google.datastore.v1.Key; +import com.google.datastore.v1.KindExpression; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.Projection; +import com.google.datastore.v1.PropertyFilter.Operator; +import com.google.datastore.v1.PropertyOrder.Direction; +import com.google.datastore.v1.Query; +import com.google.datastore.v1.QueryResultBatch; +import com.google.datastore.v1.QueryResultBatch.MoreResultsType; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.datastore.v1.client.testing.MockCredential; +import com.google.datastore.v1.client.testing.MockDatastoreFactory; +import com.google.protobuf.Int32Value; +import com.google.protobuf.Timestamp; +import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link QuerySplitterImpl}. */ +@RunWith(JUnit4.class) +public class QuerySplitterTest { + private static final String PROJECT_ID = "project-id"; + private static final PartitionId PARTITION = + PartitionId.newBuilder().setProjectId(PROJECT_ID).build(); + private static final String KIND = "test-kind"; + + private DatastoreFactory factory = new MockDatastoreFactory(); + private DatastoreOptions.Builder options = + new DatastoreOptions.Builder().projectId(PROJECT_ID).credential(new MockCredential()); + + private Filter propertyFilter = makeFilter("foo", Operator.EQUAL, makeValue("value")).build(); + + private Query query = + Query.newBuilder() + .addKind(KindExpression.newBuilder().setName(KIND).build()) + .setFilter(propertyFilter) + .build(); + + private Query splitQuery = + Query.newBuilder() + .addKind(KindExpression.newBuilder().setName(KIND).build()) + .addOrder(makeOrder("__scatter__", Direction.ASCENDING)) + .addProjection(Projection.newBuilder().setProperty(makePropertyReference("__key__"))) + .build(); + + private Key splitKey0 = makeKey(KIND, String.format("%05d", 1)).setPartitionId(PARTITION).build(); + private Key splitKey1 = + makeKey(KIND, String.format("%05d", 101)).setPartitionId(PARTITION).build(); + private Key splitKey2 = + makeKey(KIND, String.format("%05d", 201)).setPartitionId(PARTITION).build(); + private Key splitKey3 = + makeKey(KIND, String.format("%05d", 301)).setPartitionId(PARTITION).build(); + + @Test + public void disallowsSortOrder() { + Datastore datastore = factory.create(options.build()); + Query queryWithOrder = + query.toBuilder().addOrder(makeOrder("bar", Direction.ASCENDING)).build(); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> QuerySplitterImpl.INSTANCE.getSplits(queryWithOrder, PARTITION, 2, datastore)); + assertThat(exception).hasMessageThat().contains("Query cannot have any sort orders."); + } + + @Test + public void disallowsMultipleKinds() { + Datastore datastore = factory.create(options.build()); + Query queryWithMultipleKinds = + query.toBuilder() + .addKind(KindExpression.newBuilder().setName("another-kind").build()) + .build(); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + QuerySplitterImpl.INSTANCE.getSplits( + queryWithMultipleKinds, PARTITION, 2, datastore)); + assertThat(exception).hasMessageThat().contains("Query must have exactly one kind."); + } + + @Test + public void disallowsKindlessQuery() { + Datastore datastore = factory.create(options.build()); + Query kindlessQuery = query.toBuilder().clearKind().build(); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> QuerySplitterImpl.INSTANCE.getSplits(kindlessQuery, PARTITION, 2, datastore)); + assertThat(exception).hasMessageThat().contains("Query must have exactly one kind."); + } + + @Test + public void disallowsInequalityFilter() { + Datastore datastore = factory.create(options.build()); + Query queryWithInequality = + query.toBuilder() + .setFilter(makeFilter("foo", Operator.GREATER_THAN, makeValue("value"))) + .build(); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + QuerySplitterImpl.INSTANCE.getSplits(queryWithInequality, PARTITION, 2, datastore)); + assertThat(exception).hasMessageThat().contains("Query cannot have any inequality filters."); + } + + @Test + public void splitsMustBePositive() { + Datastore datastore = factory.create(options.build()); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> QuerySplitterImpl.INSTANCE.getSplits(query, PARTITION, 0, datastore)); + assertThat(exception).hasMessageThat().contains("The number of splits must be greater than 0."); + } + + @Test + public void getSplits() throws Exception { + Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + + RunQueryResponse splitQueryResponse = + RunQueryResponse.newBuilder() + .setQuery(splitQuery) + .setBatch( + QueryResultBatch.newBuilder() + .setEntityResultType(ResultType.KEY_ONLY) + .setMoreResults(MoreResultsType.NO_MORE_RESULTS) + .addEntityResults(makeKeyOnlyEntity(splitKey0)) + .addEntityResults(makeKeyOnlyEntity(splitKey1)) + .addEntityResults(makeKeyOnlyEntity(splitKey2)) + .addEntityResults(makeKeyOnlyEntity(splitKey3)) + .build()) + .build(); + + mockClient.setNextResponse(splitQueryResponse); + + List splittedQueries = + QuerySplitterImpl.INSTANCE.getSplits(query, PARTITION, 3, datastore); + + assertThat(splittedQueries) + .containsExactly( + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, null, splitKey1)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey1, splitKey3)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey3, null)) + .build()); + + RunQueryRequest expectedSplitQueryRequest = + RunQueryRequest.newBuilder() + .setPartitionId(PARTITION) + .setProjectId(PROJECT_ID) + .setQuery( + splitQuery.toBuilder().setLimit(Int32Value.newBuilder().setValue(2 * 32).build())) + .build(); + + assertArrayEquals(expectedSplitQueryRequest.toByteArray(), mockClient.getLastBody()); + } + + @Test + public void getSplitsWithDatabaseId() throws Exception { + Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + + PartitionId partition = + PartitionId.newBuilder().setProjectId(PROJECT_ID).setDatabaseId("test-database").build(); + + RunQueryResponse splitQueryResponse = + RunQueryResponse.newBuilder() + .setQuery(splitQuery) + .setBatch( + QueryResultBatch.newBuilder() + .setEntityResultType(ResultType.KEY_ONLY) + .setMoreResults(MoreResultsType.NO_MORE_RESULTS) + .addEntityResults(makeKeyOnlyEntity(splitKey0)) + .addEntityResults(makeKeyOnlyEntity(splitKey1)) + .addEntityResults(makeKeyOnlyEntity(splitKey2)) + .addEntityResults(makeKeyOnlyEntity(splitKey3)) + .build()) + .build(); + + mockClient.setNextResponse(splitQueryResponse); + + List splitQueries = QuerySplitterImpl.INSTANCE.getSplits(query, partition, 3, datastore); + + assertThat(splitQueries) + .containsExactly( + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, null, splitKey1)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey1, splitKey3)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey3, null)) + .build()); + + RunQueryRequest expectedSplitQueryRequest = + RunQueryRequest.newBuilder() + .setPartitionId(partition) + .setProjectId(PROJECT_ID) + .setDatabaseId("test-database") + .setQuery( + splitQuery.toBuilder().setLimit(Int32Value.newBuilder().setValue(2 * 32).build())) + .build(); + + assertArrayEquals(expectedSplitQueryRequest.toByteArray(), mockClient.getLastBody()); + } + + @Test + public void notEnoughSplits() throws Exception { + Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + + RunQueryResponse splitQueryResponse = + RunQueryResponse.newBuilder() + .setQuery(splitQuery) + .setBatch( + QueryResultBatch.newBuilder() + .setEntityResultType(ResultType.KEY_ONLY) + .setMoreResults(MoreResultsType.NO_MORE_RESULTS) + .addEntityResults(makeKeyOnlyEntity(splitKey0)) + .build()) + .build(); + + mockClient.setNextResponse(splitQueryResponse); + + List splittedQueries = + QuerySplitterImpl.INSTANCE.getSplits(query, PARTITION, 100, datastore); + + assertThat(splittedQueries) + .containsExactly( + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, null, splitKey0)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey0, null)) + .build()); + + RunQueryRequest expectedSplitQueryRequest = + RunQueryRequest.newBuilder() + .setPartitionId(PARTITION) + .setProjectId(PROJECT_ID) + .setQuery( + splitQuery.toBuilder().setLimit(Int32Value.newBuilder().setValue(99 * 32).build())) + .build(); + + assertArrayEquals(expectedSplitQueryRequest.toByteArray(), mockClient.getLastBody()); + } + + @Test + public void getSplits_withReadTime() throws Exception { + Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + + RunQueryResponse splitQueryResponse = + RunQueryResponse.newBuilder() + .setQuery(splitQuery) + .setBatch( + QueryResultBatch.newBuilder() + .setEntityResultType(ResultType.KEY_ONLY) + .setMoreResults(MoreResultsType.NO_MORE_RESULTS) + .addEntityResults(makeKeyOnlyEntity(splitKey0)) + .addEntityResults(makeKeyOnlyEntity(splitKey1)) + .addEntityResults(makeKeyOnlyEntity(splitKey2)) + .addEntityResults(makeKeyOnlyEntity(splitKey3)) + .build()) + .build(); + + mockClient.setNextResponse(splitQueryResponse); + + Timestamp readTime = Timestamp.newBuilder().setSeconds(1654651341L).build(); + + List splittedQueries = + QuerySplitterImpl.INSTANCE.getSplits(query, PARTITION, 3, datastore, readTime); + + assertThat(splittedQueries) + .containsExactly( + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, null, splitKey1)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey1, splitKey3)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey3, null)) + .build()); + + RunQueryRequest expectedSplitQueryRequest = + RunQueryRequest.newBuilder() + .setPartitionId(PARTITION) + .setProjectId(PROJECT_ID) + .setQuery( + splitQuery.toBuilder().setLimit(Int32Value.newBuilder().setValue(2 * 32).build())) + .setReadOptions(ReadOptions.newBuilder().setReadTime(readTime)) + .build(); + + assertArrayEquals(expectedSplitQueryRequest.toByteArray(), mockClient.getLastBody()); + } + + private static EntityResult makeKeyOnlyEntity(Key key) { + return EntityResult.newBuilder().setEntity(Entity.newBuilder().setKey(key).build()).build(); + } + + private static Filter makeFilterWithKeyRange(Filter originalFilter, Key startKey, Key endKey) { + Filter startKeyFilter = + startKey == null + ? null + : makeFilter("__key__", Operator.GREATER_THAN_OR_EQUAL, makeValue(startKey)).build(); + + Filter endKeyFilter = + endKey == null + ? null + : makeFilter("__key__", Operator.LESS_THAN, makeValue(endKey)).build(); + + if (startKeyFilter == null && endKeyFilter == null) { + throw new IllegalArgumentException(); + } + + if (startKeyFilter != null && endKeyFilter == null) { + return makeAndFilter(originalFilter, startKeyFilter).build(); + } + + if (startKeyFilter == null && endKeyFilter != null) { + return makeAndFilter(originalFilter, endKeyFilter).build(); + } + + return makeAndFilter(originalFilter, startKeyFilter, endKeyFilter).build(); + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/RemoteRpcTest.java b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/RemoteRpcTest.java new file mode 100644 index 000000000000..4fad87d26a85 --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/RemoteRpcTest.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 + * + * 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.datastore.v1.client; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.LowLevelHttpRequest; +import com.google.api.client.http.LowLevelHttpResponse; +import com.google.api.client.http.protobuf.ProtoHttpContent; +import com.google.api.client.util.Charsets; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.protobuf.ByteString; +import com.google.protobuf.MessageLite; +import com.google.rpc.Code; +import com.google.rpc.Status; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.GZIPOutputStream; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Test for {@link RemoteRpc}. */ +@RunWith(JUnit4.class) +public class RemoteRpcTest { + + private static final String METHOD_NAME = "methodName"; + + @Test + public void testException() { + Status statusProto = + Status.newBuilder() + .setCode(Code.UNAUTHENTICATED_VALUE) + .setMessage("The request does not have valid authentication credentials.") + .build(); + DatastoreException exception = + RemoteRpc.makeException( + "url", + METHOD_NAME, + new ByteArrayInputStream(statusProto.toByteArray()), + "application/x-protobuf", + Charsets.UTF_8, + new RuntimeException(), + 401); + assertEquals(Code.UNAUTHENTICATED, exception.getCode()); + assertEquals( + "The request does not have valid authentication credentials.", exception.getMessage()); + assertEquals(METHOD_NAME, exception.getMethodName()); + } + + @Test + public void testInvalidProtoException() { + DatastoreException exception = + RemoteRpc.makeException( + "url", + METHOD_NAME, + new ByteArrayInputStream("".getBytes()), + "application/x-protobuf", + Charsets.UTF_8, + new RuntimeException(), + 401); + assertEquals(Code.INTERNAL, exception.getCode()); + assertEquals( + "Unable to parse Status protocol buffer: HTTP status code was 401.", + exception.getMessage()); + assertEquals(METHOD_NAME, exception.getMethodName()); + } + + @Test + public void testEmptyProtoException() { + Status statusProto = Status.newBuilder().build(); + DatastoreException exception = + RemoteRpc.makeException( + "url", + METHOD_NAME, + new ByteArrayInputStream(statusProto.toByteArray()), + "application/x-protobuf", + Charsets.UTF_8, + new RuntimeException(), + 404); + assertEquals(Code.INTERNAL, exception.getCode()); + assertEquals( + "Unexpected OK error code with HTTP status code of 404. Message: .", + exception.getMessage()); + assertEquals(METHOD_NAME, exception.getMethodName()); + } + + @Test + public void testEmptyProtoExceptionUnauthenticated() { + Status statusProto = Status.newBuilder().build(); + DatastoreException exception = + RemoteRpc.makeException( + "url", + METHOD_NAME, + new ByteArrayInputStream(statusProto.toByteArray()), + "application/x-protobuf", + Charsets.UTF_8, + new RuntimeException(), + 401); + assertEquals(Code.UNAUTHENTICATED, exception.getCode()); + assertEquals("Unauthenticated.", exception.getMessage()); + assertEquals(METHOD_NAME, exception.getMethodName()); + } + + @Test + public void testPlainTextException() { + DatastoreException exception = + RemoteRpc.makeException( + "url", + METHOD_NAME, + new ByteArrayInputStream("Text Error".getBytes()), + "text/plain", + Charsets.UTF_8, + new RuntimeException(), + 401); + assertEquals(Code.INTERNAL, exception.getCode()); + assertEquals( + "Non-protobuf error: Text Error. HTTP status code was 401.", exception.getMessage()); + assertEquals(METHOD_NAME, exception.getMethodName()); + } + + @Test + public void testGzip() throws IOException, DatastoreException { + BeginTransactionResponse response = newBeginTransactionResponse(); + InjectedTestValues injectedTestValues = + new InjectedTestValues(gzip(response), new byte[1], true); + RemoteRpc rpc = newRemoteRpc(injectedTestValues); + + InputStream is = + rpc.call("beginTransaction", BeginTransactionResponse.getDefaultInstance(), "", ""); + BeginTransactionResponse parsedResponse = BeginTransactionResponse.parseFrom(is); + is.close(); + + assertEquals(response, parsedResponse); + // Check that the underlying stream is exhausted. + assertEquals(-1, injectedTestValues.inputStream.read()); + } + + @Test + public void testHttpHeaders_expectE2eChecksumHeader() throws IOException { + // Enable E2E-Checksum system env variable + RemoteRpc.setSystemEnvE2EChecksum(true); + String projectId = "project-id"; + MessageLite request = + RollbackRequest.newBuilder().setTransaction(ByteString.copyFromUtf8(projectId)).build(); + RemoteRpc rpc = + newRemoteRpc( + new InjectedTestValues(gzip(newBeginTransactionResponse()), new byte[1], true)); + HttpRequest httpRequest = + rpc.getClient().buildPostRequest(rpc.resolveURL("blah"), new ProtoHttpContent(request)); + rpc.setHeaders(request, httpRequest, projectId, ""); + assertNotNull( + httpRequest.getHeaders().getFirstHeaderStringValue(RemoteRpc.API_FORMAT_VERSION_HEADER)); + // Expect to find e2e-checksum header + String header = + httpRequest + .getHeaders() + .getFirstHeaderStringValue(EndToEndChecksumHandler.HTTP_REQUEST_CHECKSUM_HEADER); + assertEquals(9, header.length()); + } + + @Test + public void testHttpHeaders_doNotExpectE2eChecksumHeader() throws IOException { + // disable E2E-Checksum system env variable + RemoteRpc.setSystemEnvE2EChecksum(false); + String projectId = "project-id"; + MessageLite request = + RollbackRequest.newBuilder().setTransaction(ByteString.copyFromUtf8(projectId)).build(); + RemoteRpc rpc = + newRemoteRpc( + new InjectedTestValues(gzip(newBeginTransactionResponse()), new byte[1], true)); + HttpRequest httpRequest = + rpc.getClient().buildPostRequest(rpc.resolveURL("blah"), new ProtoHttpContent(request)); + rpc.setHeaders(request, httpRequest, projectId, ""); + assertNotNull( + httpRequest.getHeaders().getFirstHeaderStringValue(RemoteRpc.API_FORMAT_VERSION_HEADER)); + // Do not expect to find e2e-checksum header + assertNull( + httpRequest + .getHeaders() + .getFirstHeaderStringValue(EndToEndChecksumHandler.HTTP_REQUEST_CHECKSUM_HEADER)); + } + + @Test + public void testHttpHeaders_prefixHeader() throws IOException { + String projectId = "my-project"; + String databaseId = "my-db"; + MessageLite request = + RollbackRequest.newBuilder() + .setTransaction(ByteString.copyFromUtf8(projectId)) + .setDatabaseId(databaseId) + .build(); + RemoteRpc rpc = + newRemoteRpc( + new InjectedTestValues(gzip(newBeginTransactionResponse()), new byte[1], true)); + HttpRequest httpRequest = + rpc.getClient().buildPostRequest(rpc.resolveURL("blah"), new ProtoHttpContent(request)); + rpc.setHeaders(request, httpRequest, projectId, databaseId); + assertEquals( + "project_id=my-project&database_id=my-db", + httpRequest.getHeaders().get(RemoteRpc.X_GOOG_REQUEST_PARAMS_HEADER)); + + MessageLite request2 = + RollbackRequest.newBuilder().setTransaction(ByteString.copyFromUtf8(projectId)).build(); + RemoteRpc rpc2 = + newRemoteRpc( + new InjectedTestValues(gzip(newBeginTransactionResponse()), new byte[1], true)); + HttpRequest httpRequest2 = + rpc2.getClient().buildPostRequest(rpc2.resolveURL("blah"), new ProtoHttpContent(request2)); + rpc2.setHeaders(request, httpRequest2, projectId, ""); + assertEquals( + "project_id=my-project", + httpRequest2.getHeaders().get(RemoteRpc.X_GOOG_REQUEST_PARAMS_HEADER)); + } + + private static BeginTransactionResponse newBeginTransactionResponse() { + return BeginTransactionResponse.newBuilder() + .setTransaction(ByteString.copyFromUtf8("blah-blah-blah")) + .build(); + } + + private static RemoteRpc newRemoteRpc(InjectedTestValues injectedTestValues) { + return new RemoteRpc( + new MyHttpTransport(injectedTestValues).createRequestFactory(), + null, + "https://www.example.com/v1/projects/p"); + } + + private byte[] gzip(BeginTransactionResponse response) throws IOException { + ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); + try (GZIPOutputStream gzipOut = new GZIPOutputStream(bytesOut)) { + response.writeTo(gzipOut); + } + return bytesOut.toByteArray(); + } + + private static class InjectedTestValues { + private final InputStream inputStream; + private final int contentLength; + private final boolean isGzip; + + public InjectedTestValues(byte[] messageBytes, byte[] additionalBytes, boolean isGzip) { + byte[] allBytes = concat(messageBytes, additionalBytes); + this.inputStream = new ByteArrayInputStream(allBytes); + this.contentLength = allBytes.length; + this.isGzip = isGzip; + } + + private static byte[] concat(byte[] a, byte[] b) { + byte[] c = new byte[a.length + b.length]; + System.arraycopy(a, 0, c, 0, a.length); + System.arraycopy(b, 0, c, a.length, b.length); + return c; + } + } + + /** {@link HttpTransport} that allows injection of the returned {@link LowLevelHttpRequest}. */ + private static class MyHttpTransport extends HttpTransport { + + private final InjectedTestValues injectedTestValues; + + public MyHttpTransport(InjectedTestValues injectedTestValues) { + this.injectedTestValues = injectedTestValues; + } + + @Override + protected LowLevelHttpRequest buildRequest(String method, String url) throws IOException { + return new MyLowLevelHttpRequest(injectedTestValues); + } + } + + /** + * {@link LowLevelHttpRequest} that allows injection of the returned {@link LowLevelHttpResponse}. + */ + private static class MyLowLevelHttpRequest extends LowLevelHttpRequest { + + private final InjectedTestValues injectedTestValues; + + public MyLowLevelHttpRequest(InjectedTestValues injectedTestValues) { + this.injectedTestValues = injectedTestValues; + } + + @Override + public void addHeader(String name, String value) throws IOException { + // Do nothing. + } + + @Override + public LowLevelHttpResponse execute() throws IOException { + return new MyLowLevelHttpResponse(injectedTestValues); + } + } + + /** {@link LowLevelHttpResponse} that allows injected properties. */ + private static class MyLowLevelHttpResponse extends LowLevelHttpResponse { + + private final InjectedTestValues injectedTestValues; + + public MyLowLevelHttpResponse(InjectedTestValues injectedTestValues) { + this.injectedTestValues = injectedTestValues; + } + + @Override + public InputStream getContent() throws IOException { + return injectedTestValues.inputStream; + } + + @Override + public String getContentEncoding() throws IOException { + return injectedTestValues.isGzip ? "gzip" : ""; + } + + @Override + public long getContentLength() throws IOException { + return injectedTestValues.contentLength; + } + + @Override + public String getContentType() throws IOException { + return "application/x-protobuf"; + } + + @Override + public String getStatusLine() throws IOException { + return null; + } + + @Override + public int getStatusCode() throws IOException { + return 200; + } + + @Override + public String getReasonPhrase() throws IOException { + return null; + } + + @Override + public int getHeaderCount() throws IOException { + return 0; + } + + @Override + public String getHeaderName(int index) throws IOException { + return null; + } + + @Override + public String getHeaderValue(int index) throws IOException { + return null; + } + } +} diff --git a/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/it/ITDatastoreProtoClientTest.java b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/it/ITDatastoreProtoClientTest.java new file mode 100644 index 000000000000..c6df61ce762d --- /dev/null +++ b/java-datastore/datastore-v1-proto-client/src/test/java/com/google/datastore/v1/client/it/ITDatastoreProtoClientTest.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 + * + * 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.datastore.v1.client.it; + +import static com.google.datastore.v1.client.DatastoreHelper.makeFilter; +import static com.google.datastore.v1.client.DatastoreHelper.makeValue; + +import com.google.common.truth.Truth; +import com.google.datastore.v1.Filter; +import com.google.datastore.v1.KindExpression; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.PropertyFilter; +import com.google.datastore.v1.Query; +import com.google.datastore.v1.client.Datastore; +import com.google.datastore.v1.client.DatastoreException; +import com.google.datastore.v1.client.DatastoreHelper; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.util.List; +import org.junit.Before; +import org.junit.Test; + +public class ITDatastoreProtoClientTest { + + private static Datastore DATASTORE; + + private static PartitionId PARTITION; + + private static final String KIND = "test-kind"; + private static final String PROJECT_ID = System.getenv(DatastoreHelper.PROJECT_ID_ENV_VAR); + + @Before + public void setUp() throws GeneralSecurityException, IOException { + DATASTORE = DatastoreHelper.getDatastoreFromEnv(); + } + + @Test + public void testQuerySplitterWithDefaultDb() throws DatastoreException { + Filter propertyFilter = + makeFilter("foo", PropertyFilter.Operator.EQUAL, makeValue("value")).build(); + Query query = + Query.newBuilder() + .addKind(KindExpression.newBuilder().setName(KIND).build()) + .setFilter(propertyFilter) + .build(); + + PARTITION = PartitionId.newBuilder().setProjectId(PROJECT_ID).build(); + + List splits = + DatastoreHelper.getQuerySplitter().getSplits(query, PARTITION, 2, DATASTORE); + Truth.assertThat(splits).isNotEmpty(); + splits.forEach( + split -> { + Truth.assertThat(split.getKind(0).getName()).isEqualTo(KIND); + Truth.assertThat(split.getFilter()).isEqualTo(propertyFilter); + }); + } + + @Test + public void testQuerySplitterWithDb() throws DatastoreException { + Filter propertyFilter = + makeFilter("foo", PropertyFilter.Operator.EQUAL, makeValue("value")).build(); + Query query = + Query.newBuilder() + .addKind(KindExpression.newBuilder().setName(KIND).build()) + .setFilter(propertyFilter) + .build(); + + PARTITION = PartitionId.newBuilder().setProjectId(PROJECT_ID).setDatabaseId("test-db").build(); + + List splits = + DatastoreHelper.getQuerySplitter().getSplits(query, PARTITION, 2, DATASTORE); + + Truth.assertThat(splits).isNotEmpty(); + splits.forEach( + split -> { + Truth.assertThat(split.getKind(0).getName()).isEqualTo(KIND); + Truth.assertThat(split.getFilter()).isEqualTo(propertyFilter); + }); + } +} diff --git a/java-datastore/google-cloud-datastore-bom/pom.xml b/java-datastore/google-cloud-datastore-bom/pom.xml new file mode 100644 index 000000000000..be45f940c304 --- /dev/null +++ b/java-datastore/google-cloud-datastore-bom/pom.xml @@ -0,0 +1,87 @@ + + + 4.0.0 + com.google.cloud + google-cloud-datastore-bom + 2.33.2 + pom + + com.google.cloud + google-cloud-pom-parent + 1.77.0-SNAPSHOT + ../../google-cloud-pom-parent/pom.xml + + + Google Cloud datastore BOM + https://github.com/googleapis/google-cloud-java + + BOM for Google Cloud datastore + + + + 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-datastore + 2.33.2 + + + com.google.api.grpc + grpc-google-cloud-datastore-admin-v1 + 2.33.2 + + + com.google.api.grpc + proto-google-cloud-datastore-v1 + 0.124.2 + + + com.google.api.grpc + proto-google-cloud-datastore-admin-v1 + 2.33.2 + + + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + true + + + + + diff --git a/java-datastore/google-cloud-datastore-utils/pom.xml b/java-datastore/google-cloud-datastore-utils/pom.xml new file mode 100644 index 000000000000..3d5e26875790 --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/pom.xml @@ -0,0 +1,153 @@ + + + 4.0.0 + com.google.cloud + google-cloud-datastore-utils + 2.33.2 + jar + Google Cloud Datastore Utilities + https://github.com/googleapis/java-datastore + + Java datastore client utility library. + + + com.google.cloud + google-cloud-datastore-parent + 2.33.2 + + + google-cloud-datastore-utils + + + + com.google.api-client + google-api-client + + + com.google.http-client + google-http-client-protobuf + + + com.google.http-client + google-http-client-gson + + + com.google.api.grpc + proto-google-cloud-datastore-v1 + + + com.google.api + api-common + + + com.google.protobuf + protobuf-java + + + com.google.guava + guava + + + com.google.api.grpc + proto-google-common-protos + + + com.google.http-client + google-http-client + + + com.google.http-client + google-http-client-jackson2 + + + com.google.oauth-client + google-oauth-client + + + com.google.code.findbugs + jsr305 + + + + junit + junit + test + + + com.google.truth + truth + 1.4.2 + test + + + org.checkerframework + checker-qual + + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + -Xmx2048m + + + + + + + + native + + + true + + + + java17 + + [17,) + + + + + org.apache.maven.plugins + maven-compiler-plugin + + UTF-8 + true + + -XDcompilePolicy=simple + --should-stop=ifError=FLOW + -Xplugin:ErrorProne -XepExcludedPaths:.*/generated-sources/.* + + -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED + + + + + com.google.errorprone + error_prone_core + ${error-prone.version} + + + + + + + + + diff --git a/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/Datastore.java b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/Datastore.java new file mode 100644 index 000000000000..92e2e0a6d00f --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/Datastore.java @@ -0,0 +1,136 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import com.google.datastore.v1.*; +import com.google.rpc.Code; +import java.io.IOException; +import java.io.InputStream; + +/** + * Provides access to Cloud Datastore. + * + *

This class is thread-safe. + */ +public class Datastore { + + final RemoteRpc remoteRpc; + + Datastore(RemoteRpc remoteRpc) { + this.remoteRpc = remoteRpc; + } + + /** Reset the RPC count. */ + public void resetRpcCount() { + remoteRpc.resetRpcCount(); + } + + /** + * Returns the number of RPC calls made since the client was created or {@link #resetRpcCount} was + * called. + */ + public int getRpcCount() { + return remoteRpc.getRpcCount(); + } + + private com.google.datastore.utils.DatastoreException invalidResponseException( + String method, IOException exception) { + return RemoteRpc.makeException( + remoteRpc.getUrl(), method, Code.UNAVAILABLE, "Invalid response", exception); + } + + public AllocateIdsResponse allocateIds(AllocateIdsRequest request) + throws com.google.datastore.utils.DatastoreException { + try (InputStream is = + remoteRpc.call("allocateIds", request, request.getProjectId(), request.getDatabaseId())) { + return AllocateIdsResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("allocateIds", exception); + } + } + + public BeginTransactionResponse beginTransaction(BeginTransactionRequest request) + throws com.google.datastore.utils.DatastoreException { + try (InputStream is = + remoteRpc.call( + "beginTransaction", request, request.getProjectId(), request.getDatabaseId())) { + return BeginTransactionResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("beginTransaction", exception); + } + } + + public CommitResponse commit(CommitRequest request) + throws com.google.datastore.utils.DatastoreException { + try (InputStream is = + remoteRpc.call("commit", request, request.getProjectId(), request.getDatabaseId())) { + return CommitResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("commit", exception); + } + } + + public LookupResponse lookup(LookupRequest request) + throws com.google.datastore.utils.DatastoreException { + try (InputStream is = + remoteRpc.call("lookup", request, request.getProjectId(), request.getDatabaseId())) { + return LookupResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("lookup", exception); + } + } + + public ReserveIdsResponse reserveIds(ReserveIdsRequest request) + throws com.google.datastore.utils.DatastoreException { + try (InputStream is = + remoteRpc.call("reserveIds", request, request.getProjectId(), request.getDatabaseId())) { + return ReserveIdsResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("reserveIds", exception); + } + } + + public RollbackResponse rollback(RollbackRequest request) + throws com.google.datastore.utils.DatastoreException { + try (InputStream is = + remoteRpc.call("rollback", request, request.getProjectId(), request.getDatabaseId())) { + return RollbackResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("rollback", exception); + } + } + + public RunQueryResponse runQuery(RunQueryRequest request) + throws com.google.datastore.utils.DatastoreException { + try (InputStream is = + remoteRpc.call("runQuery", request, request.getProjectId(), request.getDatabaseId())) { + return RunQueryResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("runQuery", exception); + } + } + + public RunAggregationQueryResponse runAggregationQuery(RunAggregationQueryRequest request) + throws DatastoreException { + try (InputStream is = + remoteRpc.call( + "runAggregationQuery", request, request.getProjectId(), request.getDatabaseId())) { + return RunAggregationQueryResponse.parseFrom(is); + } catch (IOException exception) { + throw invalidResponseException("runAggregationQuery", exception); + } + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreException.java b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreException.java new file mode 100644 index 000000000000..20913b5e12e5 --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreException.java @@ -0,0 +1,49 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import com.google.rpc.Code; + +/** Indicates an error in a {@link Datastore} call. */ +public class DatastoreException extends Exception { + private final String methodName; + private final Code code; + + public DatastoreException(String methodName, Code code, String message, Throwable cause) { + super(message, cause); + this.methodName = methodName; + this.code = code; + } + + /** + * @return the canonical error code + */ + public Code getCode() { + return code; + } + + /** + * @return the datastore method name + */ + public String getMethodName() { + return methodName; + } + + @Override + public String toString() { + return String.format("%s, code=%s", super.toString(), code); + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreFactory.java b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreFactory.java new file mode 100644 index 000000000000..cdd1698d5c28 --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreFactory.java @@ -0,0 +1,127 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.http.HttpRequestFactory; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.javanet.NetHttpTransport; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.logging.*; + +/** Client factory for {@link com.google.datastore.utils.Datastore}. */ +public class DatastoreFactory { + + // Lazy load this because we might be running inside App Engine and this + // class isn't on the whitelist. + private static ConsoleHandler methodHandler; + + /** API version. */ + public static final String VERSION = "v1"; + + public static final String DEFAULT_HOST = "https://datastore.googleapis.com"; + + /** Singleton factory instance. */ + private static final DatastoreFactory INSTANCE = new DatastoreFactory(); + + public static DatastoreFactory get() { + return INSTANCE; + } + + /** + * Provides access to a datastore using the provided options. Logs into the application using the + * credentials available via these options. + * + * @throws IllegalArgumentException if the server or credentials weren't provided. + */ + public com.google.datastore.utils.Datastore create( + com.google.datastore.utils.DatastoreOptions options) { + return new com.google.datastore.utils.Datastore(newRemoteRpc(options)); + } + + /** Constructs a Google APIs HTTP client with the associated credentials. */ + public HttpRequestFactory makeClient(com.google.datastore.utils.DatastoreOptions options) { + Credential credential = options.getCredential(); + HttpTransport transport = options.getTransport(); + if (transport == null) { + transport = credential == null ? new NetHttpTransport() : credential.getTransport(); + transport = transport == null ? new NetHttpTransport() : transport; + } + return transport.createRequestFactory(credential); + } + + /** Starts logging datastore method calls to the console. (Useful within tests.) */ + public static void logMethodCalls() { + Logger logger = Logger.getLogger(Datastore.class.getName()); + logger.setLevel(Level.FINE); + if (!Arrays.asList(logger.getHandlers()).contains(getStreamHandler())) { + logger.addHandler(getStreamHandler()); + } + } + + /** Build a valid datastore URL. */ + String buildProjectEndpoint(com.google.datastore.utils.DatastoreOptions options) { + if (options.getProjectEndpoint() != null) { + return options.getProjectEndpoint(); + } + // DatastoreOptions ensures either project endpoint or project ID is set. + String projectId = checkNotNull(options.getProjectId()); + if (options.getHost() != null) { + return validateUrl( + String.format("https://%s/%s/projects/%s", options.getHost(), VERSION, projectId)); + } else if (options.getLocalHost() != null) { + return validateUrl( + String.format("http://%s/%s/projects/%s", options.getLocalHost(), VERSION, projectId)); + } + return validateUrl(String.format("%s/%s/projects/%s", DEFAULT_HOST, VERSION, projectId)); + } + + protected com.google.datastore.utils.RemoteRpc newRemoteRpc(DatastoreOptions options) { + checkNotNull(options); + HttpRequestFactory client = makeClient(options); + return new com.google.datastore.utils.RemoteRpc( + client, options.getInitializer(), buildProjectEndpoint(options)); + } + + private static String validateUrl(String url) { + try { + return new URI(url).toString(); + } catch (URISyntaxException e) { + throw new IllegalArgumentException(e); + } + } + + // TODO: Support something other than console handler for when we're + // running in App Engine + private static synchronized StreamHandler getStreamHandler() { + if (methodHandler == null) { + methodHandler = new ConsoleHandler(); + methodHandler.setFormatter( + new Formatter() { + @Override + public String format(LogRecord record) { + return record.getMessage() + "\n"; + } + }); + methodHandler.setLevel(Level.FINE); + } + return methodHandler; + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreHelper.java b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreHelper.java new file mode 100644 index 000000000000..0001cfb09dff --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreHelper.java @@ -0,0 +1,731 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; +import com.google.api.client.googleapis.javanet.GoogleNetHttpTransport; +import com.google.api.client.http.GenericUrl; +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.json.JsonFactory; +import com.google.api.client.json.gson.GsonFactory; +import com.google.datastore.v1.ArrayValue; +import com.google.datastore.v1.CompositeFilter; +import com.google.datastore.v1.Entity; +import com.google.datastore.v1.Filter; +import com.google.datastore.v1.Key; +import com.google.datastore.v1.Key.PathElement; +import com.google.datastore.v1.Key.PathElement.IdTypeCase; +import com.google.datastore.v1.Mutation; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.PropertyFilter; +import com.google.datastore.v1.PropertyOrder; +import com.google.datastore.v1.PropertyReference; +import com.google.datastore.v1.Value; +import com.google.datastore.v1.Value.ValueTypeCase; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import com.google.protobuf.TimestampOrBuilder; +import com.google.type.LatLng; +import java.io.File; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.security.PrivateKey; +import java.util.Arrays; +import java.util.Collection; +import java.util.Comparator; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.concurrent.atomic.AtomicReference; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Nullable; + +/** Helper methods for {@link Datastore}. */ +// TODO: Accept OrBuilders when possible. +public final class DatastoreHelper { + private static final Logger logger = + Logger.getLogger(com.google.datastore.utils.DatastoreHelper.class.getName()); + + private static final int MICROSECONDS_PER_SECOND = 1000 * 1000; + private static final int NANOSECONDS_PER_MICROSECOND = 1000; + + /** The property used in the Datastore to give us a random distribution. * */ + public static final String SCATTER_PROPERTY_NAME = "__scatter__"; + + /** The property used in the Datastore to get the key of the entity. * */ + public static final String KEY_PROPERTY_NAME = "__key__"; + + /** Name of the environment variable used to set the project ID. */ + public static final String PROJECT_ID_ENV_VAR = "DATASTORE_PROJECT_ID"; + + /** Name of the environment variable used to set the local host. */ + public static final String LOCAL_HOST_ENV_VAR = "DATASTORE_EMULATOR_HOST"; + + /** Name of the environment variable used to set the service account. */ + public static final String SERVICE_ACCOUNT_ENV_VAR = "DATASTORE_SERVICE_ACCOUNT"; + + /** Name of the environment variable used to set the private key file. */ + public static final String PRIVATE_KEY_FILE_ENV_VAR = "DATASTORE_PRIVATE_KEY_FILE"; + + private static final String URL_OVERRIDE_ENV_VAR = "__DATASTORE_URL_OVERRIDE"; + + private static final AtomicReference projectIdFromComputeEngine = new AtomicReference<>(); + + /** Comparator for Keys */ + private static final class KeyComparator implements Comparator { + + static final com.google.datastore.utils.DatastoreHelper.KeyComparator INSTANCE = + new com.google.datastore.utils.DatastoreHelper.KeyComparator(); + + private int comparePathElement(PathElement thisElement, PathElement otherElement) { + int result = thisElement.getKind().compareTo(otherElement.getKind()); + if (result != 0) { + return result; + } + if (thisElement.getIdTypeCase() == IdTypeCase.ID) { + if (otherElement.getIdTypeCase() != IdTypeCase.ID) { + return -1; + } + return Long.valueOf(thisElement.getId()).compareTo(otherElement.getId()); + } + if (otherElement.getIdTypeCase() == IdTypeCase.ID) { + return 1; + } + + return thisElement.getName().compareTo(otherElement.getName()); + } + + @Override + public int compare(Key thisKey, Key otherKey) { + if (!thisKey.getPartitionId().equals(otherKey.getPartitionId())) { + throw new IllegalArgumentException("Cannot compare keys with different partition ids."); + } + + Iterator thisPath = thisKey.getPathList().iterator(); + Iterator otherPath = otherKey.getPathList().iterator(); + while (thisPath.hasNext()) { + if (!otherPath.hasNext()) { + return 1; + } + int result = comparePathElement(thisPath.next(), otherPath.next()); + if (result != 0) { + return result; + } + } + + return otherPath.hasNext() ? -1 : 0; + } + } + + private DatastoreHelper() {} + + private static HttpTransport newTransport() throws GeneralSecurityException, IOException { + return GoogleNetHttpTransport.newTrustedTransport(); + } + + static JsonFactory newJsonFactory() { + return new GsonFactory(); + } + + /** + * Constructs credentials for the given account and key. + * + * @param serviceAccountId service account ID (typically an e-mail address). + * @param privateKeyFile the file name from which to get the private key. + * @return valid credentials or {@code null} + */ + public static Credential getServiceAccountCredential( + String serviceAccountId, String privateKeyFile) throws GeneralSecurityException, IOException { + return getServiceAccountCredential(serviceAccountId, privateKeyFile, DatastoreOptions.SCOPES); + } + + /** + * Constructs credentials for the given account and key file. + * + * @param serviceAccountId service account ID (typically an e-mail address). + * @param privateKeyFile the file name from which to get the private key. + * @param serviceAccountScopes Collection of OAuth scopes to use with the the service account flow + * or {@code null} if not. + * @return valid credentials or {@code null} + */ + public static Credential getServiceAccountCredential( + String serviceAccountId, String privateKeyFile, Collection serviceAccountScopes) + throws GeneralSecurityException, IOException { + return getCredentialBuilderWithoutPrivateKey(serviceAccountId, serviceAccountScopes) + .setServiceAccountPrivateKeyFromP12File(new File(privateKeyFile)) + .build(); + } + + /** + * Constructs credentials for the given account and key. + * + * @param serviceAccountId service account ID (typically an e-mail address). + * @param privateKey the private key for the given account. + * @param serviceAccountScopes Collection of OAuth scopes to use with the the service account flow + * or {@code null} if not. + * @return valid credentials or {@code null} + */ + public static Credential getServiceAccountCredential( + String serviceAccountId, PrivateKey privateKey, Collection serviceAccountScopes) + throws GeneralSecurityException, IOException { + return getCredentialBuilderWithoutPrivateKey(serviceAccountId, serviceAccountScopes) + .setServiceAccountPrivateKey(privateKey) + .build(); + } + + private static GoogleCredential.Builder getCredentialBuilderWithoutPrivateKey( + String serviceAccountId, Collection serviceAccountScopes) + throws GeneralSecurityException, IOException { + HttpTransport transport = newTransport(); + JsonFactory jsonFactory = newJsonFactory(); + return new GoogleCredential.Builder() + .setTransport(transport) + .setJsonFactory(jsonFactory) + .setServiceAccountId(serviceAccountId) + .setServiceAccountScopes(serviceAccountScopes); + } + + /** + * Constructs a {@link Datastore} from environment variables and/or the Compute Engine metadata + * server. + * + *

The project ID is determined from, in order of preference: + * + *

    + *
  • DATASTORE_PROJECT_ID environment variable + *
  • Compute Engine + *
+ * + *

Credentials are taken from, in order of preference: + * + *

    + *
  1. No credentials (if the DATASTORE_EMULATOR_HOST environment variable is set) + *
  2. Service Account specified by the DATASTORE_SERVICE_ACCOUNT and DATASTORE_PRIVATE_KEY_FILE + * environment variables + *
  3. Google Application Default as described here. + *
+ */ + public static DatastoreOptions.Builder getOptionsFromEnv() + throws GeneralSecurityException, IOException { + DatastoreOptions.Builder options = new DatastoreOptions.Builder(); + setProjectEndpointFromEnv(options); + options.credential(getCredentialFromEnv()); + return options; + } + + private static Credential getCredentialFromEnv() throws GeneralSecurityException, IOException { + if (System.getenv(LOCAL_HOST_ENV_VAR) != null) { + logger.log( + Level.INFO, + "{0} environment variable was set. Not using credentials.", + new Object[] {LOCAL_HOST_ENV_VAR}); + return null; + } + String serviceAccount = System.getenv(SERVICE_ACCOUNT_ENV_VAR); + String privateKeyFile = System.getenv(PRIVATE_KEY_FILE_ENV_VAR); + if (serviceAccount != null && privateKeyFile != null) { + logger.log( + Level.INFO, + "{0} and {1} environment variables were set. " + "Using service account credential.", + new Object[] {SERVICE_ACCOUNT_ENV_VAR, PRIVATE_KEY_FILE_ENV_VAR}); + return getServiceAccountCredential(serviceAccount, privateKeyFile); + } + return GoogleCredential.getApplicationDefault().createScoped(DatastoreOptions.SCOPES); + } + + /** + * Determines the project id from the environment. Uses the following sources in order of + * preference: + * + *
    + *
  1. Value of the DATASTORE_PROJECT_ID environment variable + *
  2. Compute Engine + *
+ * + * @throws IllegalStateException if the project ID cannot be determined + */ + private static String getProjectIdFromEnv() { + if (System.getenv(PROJECT_ID_ENV_VAR) != null) { + return System.getenv(PROJECT_ID_ENV_VAR); + } + String projectIdFromComputeEngine = getProjectIdFromComputeEngine(); + if (projectIdFromComputeEngine != null) { + return projectIdFromComputeEngine; + } + throw new IllegalStateException( + String.format( + "Could not determine project ID." + + " If you are not running on Compute Engine, set the" + + " %s environment variable.", + PROJECT_ID_ENV_VAR)); + } + + /** + * Gets the project ID from the Compute Engine metadata server. Returns {@code null} if the + * project ID cannot be determined (because, for instance, the code is not running on Compute + * Engine). + */ + @Nullable + public static String getProjectIdFromComputeEngine() { + String cachedProjectId = projectIdFromComputeEngine.get(); + return cachedProjectId != null ? cachedProjectId : queryProjectIdFromComputeEngine(); + } + + @Nullable + private static String queryProjectIdFromComputeEngine() { + HttpTransport transport; + + try { + transport = newTransport(); + } catch (GeneralSecurityException | IOException e) { + logger.log(Level.WARNING, "Failed to create HttpTransport.", e); + return null; + } + + try { + GenericUrl projectIdUrl = + new GenericUrl("http://metadata/computeMetadata/v1/project/project-id"); + HttpRequest request = transport.createRequestFactory().buildGetRequest(projectIdUrl); + request.getHeaders().set("Metadata-Flavor", "Google"); + String result = request.execute().parseAsString(); + projectIdFromComputeEngine.set(result); + return result; + } catch (IOException e) { + logger.log(Level.INFO, "Could not determine project ID from Compute Engine.", e); + return null; + } + } + + private static void setProjectEndpointFromEnv(DatastoreOptions.Builder options) { + // DATASTORE_HOST is deprecated. + if (System.getenv("DATASTORE_HOST") != null) { + logger.warning( + String.format( + "Ignoring value of environment variable DATASTORE_HOST. " + + "To point datastore to a host running locally, use " + + "the environment variable %s.", + LOCAL_HOST_ENV_VAR)); + } + String projectId = getProjectIdFromEnv(); + if (System.getenv(URL_OVERRIDE_ENV_VAR) != null) { + options.projectEndpoint( + String.format("%s/projects/%s", System.getenv(URL_OVERRIDE_ENV_VAR), projectId)); + return; + } + if (System.getenv(LOCAL_HOST_ENV_VAR) != null) { + options.projectId(projectId); + options.localHost(System.getenv(LOCAL_HOST_ENV_VAR)); + return; + } + options.projectId(projectId); + return; + } + + /** + * @see #getOptionsFromEnv() + */ + public static Datastore getDatastoreFromEnv() throws GeneralSecurityException, IOException { + return DatastoreFactory.get().create(getOptionsFromEnv().build()); + } + + /** + * Gets a {@link com.google.datastore.utils.QuerySplitter}. + * + *

The returned {@link com.google.datastore.utils.QuerySplitter#getSplits} cannot accept a + * query that contains inequality filters, a sort filter, or a missing kind. + */ + public static QuerySplitter getQuerySplitter() { + return com.google.datastore.utils.QuerySplitterImpl.INSTANCE; + } + + public static Comparator getKeyComparator() { + return com.google.datastore.utils.DatastoreHelper.KeyComparator.INSTANCE; + } + + /** Make a sort order for use in a query. */ + public static PropertyOrder.Builder makeOrder( + String property, PropertyOrder.Direction direction) { + return PropertyOrder.newBuilder() + .setProperty(makePropertyReference(property)) + .setDirection(direction); + } + + /** Makes an ancestor filter. */ + public static Filter.Builder makeAncestorFilter(Key ancestor) { + return makeFilter( + com.google.datastore.utils.DatastoreHelper.KEY_PROPERTY_NAME, + PropertyFilter.Operator.HAS_ANCESTOR, + makeValue(ancestor)); + } + + /** Make a filter on a property for use in a query. */ + public static Filter.Builder makeFilter( + String property, PropertyFilter.Operator operator, Value value) { + return Filter.newBuilder() + .setPropertyFilter( + PropertyFilter.newBuilder() + .setProperty(makePropertyReference(property)) + .setOp(operator) + .setValue(value)); + } + + /** Make a filter on a property for use in a query. */ + public static Filter.Builder makeFilter( + String property, PropertyFilter.Operator operator, Value.Builder value) { + return makeFilter(property, operator, value.build()); + } + + /** Make a composite filter from the given sub-filters using AND to combine filters. */ + public static Filter.Builder makeAndFilter(Filter... subfilters) { + return makeAndFilter(Arrays.asList(subfilters)); + } + + /** Make a composite filter from the given sub-filters using AND to combine filters. */ + public static Filter.Builder makeAndFilter(Iterable subfilters) { + return Filter.newBuilder() + .setCompositeFilter( + CompositeFilter.newBuilder() + .addAllFilters(subfilters) + .setOp(CompositeFilter.Operator.AND)); + } + + /** Make a property reference for use in a query. */ + public static PropertyReference.Builder makePropertyReference(String propertyName) { + return PropertyReference.newBuilder().setName(propertyName); + } + + /** Make an array value containing the specified values. */ + public static Value.Builder makeValue(Iterable values) { + return Value.newBuilder().setArrayValue(ArrayValue.newBuilder().addAllValues(values)); + } + + /** Make a list value containing the specified values. */ + public static Value.Builder makeValue(Value value1, Value value2, Value... rest) { + ArrayValue.Builder arrayValue = ArrayValue.newBuilder(); + arrayValue.addValues(value1); + arrayValue.addValues(value2); + arrayValue.addAllValues(Arrays.asList(rest)); + return Value.newBuilder().setArrayValue(arrayValue); + } + + /** Make an array value containing the specified values. */ + public static Value.Builder makeValue( + Value.Builder value1, Value.Builder value2, Value.Builder... rest) { + ArrayValue.Builder arrayValue = ArrayValue.newBuilder(); + arrayValue.addValues(value1); + arrayValue.addValues(value2); + for (Value.Builder builder : rest) { + arrayValue.addValues(builder); + } + return Value.newBuilder().setArrayValue(arrayValue); + } + + /** Make a key value. */ + public static Value.Builder makeValue(Key key) { + return Value.newBuilder().setKeyValue(key); + } + + /** Make a key value. */ + public static Value.Builder makeValue(Key.Builder key) { + return makeValue(key.build()); + } + + /** Make an integer value. */ + public static Value.Builder makeValue(long key) { + return Value.newBuilder().setIntegerValue(key); + } + + /** Make a floating point value. */ + public static Value.Builder makeValue(double value) { + return Value.newBuilder().setDoubleValue(value); + } + + /** Make a boolean value. */ + public static Value.Builder makeValue(boolean value) { + return Value.newBuilder().setBooleanValue(value); + } + + /** Make a string value. */ + public static Value.Builder makeValue(String value) { + return Value.newBuilder().setStringValue(value); + } + + /** Make an entity value. */ + public static Value.Builder makeValue(Entity entity) { + return Value.newBuilder().setEntityValue(entity); + } + + /** Make a entity value. */ + public static Value.Builder makeValue(Entity.Builder entity) { + return makeValue(entity.build()); + } + + /** Make a ByteString value. */ + public static Value.Builder makeValue(ByteString blob) { + return Value.newBuilder().setBlobValue(blob); + } + + /** Make a timestamp value given a date. */ + public static Value.Builder makeValue(Date date) { + return Value.newBuilder().setTimestampValue(toTimestamp(date.getTime() * 1000L)); + } + + /** Makes a GeoPoint value. */ + public static Value.Builder makeValue(LatLng value) { + return Value.newBuilder().setGeoPointValue(value); + } + + /** Makes a GeoPoint value. */ + public static Value.Builder makeValue(LatLng.Builder value) { + return makeValue(value.build()); + } + + private static Timestamp.Builder toTimestamp(long microseconds) { + long seconds = microseconds / MICROSECONDS_PER_SECOND; + long microsecondsRemainder = microseconds % MICROSECONDS_PER_SECOND; + if (microsecondsRemainder < 0) { + // Nanos must be positive even if microseconds is negative. + // Java modulus doesn't take care of this for us. + microsecondsRemainder += MICROSECONDS_PER_SECOND; + seconds -= 1; + } + return Timestamp.newBuilder() + .setSeconds(seconds) + .setNanos((int) microsecondsRemainder * NANOSECONDS_PER_MICROSECOND); + } + + /** + * Make a key from the specified path of kind/id-or-name pairs and/or Keys. + * + *

The id-or-name values must be either String, Long, Integer or Short. + * + *

The last id-or-name value may be omitted, in which case an entity without an id is created + * (for use with automatic id allocation). + * + *

The PartitionIds of all Keys in the path must be equal. The returned Key.Builder will use + * this PartitionId. + */ + public static Key.Builder makeKey(Object... elements) { + Key.Builder key = Key.newBuilder(); + PartitionId partitionId = null; + for (int pathIndex = 0; pathIndex < elements.length; pathIndex += 2) { + PathElement.Builder pathElement = PathElement.newBuilder(); + Object element = elements[pathIndex]; + if (element instanceof Key) { + Key subKey = (Key) element; + if (partitionId == null) { + partitionId = subKey.getPartitionId(); + } else if (!partitionId.equals(subKey.getPartitionId())) { + throw new IllegalArgumentException( + "Partition IDs did not match, found: " + + partitionId + + " and " + + subKey.getPartitionId()); + } + key.addAllPath(((Key) element).getPathList()); + // We increment by 2, but since we got a Key argument we're only consuming 1 element in this + // iteration of the loop. Decrement the index so that when we jump by 2 we end up in the + // right spot. + pathIndex--; + } else { + String kind; + try { + kind = (String) element; + } catch (ClassCastException e) { + throw new IllegalArgumentException( + "Expected string or Key, got: " + element.getClass(), e); + } + pathElement.setKind(kind); + if (pathIndex + 1 < elements.length) { + Object value = elements[pathIndex + 1]; + if (value instanceof String) { + pathElement.setName((String) value); + } else if (value instanceof Long) { + pathElement.setId((Long) value); + } else if (value instanceof Integer) { + pathElement.setId((Integer) value); + } else if (value instanceof Short) { + pathElement.setId((Short) value); + } else { + throw new IllegalArgumentException( + "Expected string or integer, got: " + value.getClass()); + } + } + key.addPath(pathElement); + } + } + if (partitionId != null && !partitionId.equals(PartitionId.getDefaultInstance())) { + key.setPartitionId(partitionId); + } + return key; + } + + /** + * @return the double contained in value + * @throws IllegalArgumentException if the value does not contain a double. + */ + public static double getDouble(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.DOUBLE_VALUE) { + throw new IllegalArgumentException("Value does not contain a double."); + } + return value.getDoubleValue(); + } + + /** + * @return the key contained in value + * @throws IllegalArgumentException if the value does not contain a key. + */ + public static Key getKey(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.KEY_VALUE) { + throw new IllegalArgumentException("Value does not contain a key."); + } + return value.getKeyValue(); + } + + /** + * @return the blob contained in value + * @throws IllegalArgumentException if the value does not contain a blob. + */ + public static ByteString getByteString(Value value) { + if (value.getMeaning() == 18 && value.getValueTypeCase() == ValueTypeCase.STRING_VALUE) { + return value.getStringValueBytes(); + } else if (value.getValueTypeCase() == ValueTypeCase.BLOB_VALUE) { + return value.getBlobValue(); + } + throw new IllegalArgumentException("Value does not contain a blob."); + } + + /** + * @return the entity contained in value + * @throws IllegalArgumentException if the value does not contain an entity. + */ + public static Entity getEntity(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.ENTITY_VALUE) { + throw new IllegalArgumentException("Value does not contain an Entity."); + } + return value.getEntityValue(); + } + + /** + * @return the string contained in value + * @throws IllegalArgumentException if the value does not contain a string. + */ + public static String getString(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.STRING_VALUE) { + throw new IllegalArgumentException("Value does not contain a string."); + } + return value.getStringValue(); + } + + /** + * @return the boolean contained in value + * @throws IllegalArgumentException if the value does not contain a boolean. + */ + public static boolean getBoolean(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.BOOLEAN_VALUE) { + throw new IllegalArgumentException("Value does not contain a boolean."); + } + return value.getBooleanValue(); + } + + /** + * @return the long contained in value + * @throws IllegalArgumentException if the value does not contain a long. + */ + public static long getLong(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.INTEGER_VALUE) { + throw new IllegalArgumentException("Value does not contain an integer."); + } + return value.getIntegerValue(); + } + + /** + * @return the timestamp in microseconds contained in value + * @throws IllegalArgumentException if the value does not contain a timestamp. + */ + public static long getTimestamp(Value value) { + if (value.getMeaning() == 18 && value.getValueTypeCase() == ValueTypeCase.INTEGER_VALUE) { + return value.getIntegerValue(); + } else if (value.getValueTypeCase() == ValueTypeCase.TIMESTAMP_VALUE) { + return toMicroseconds(value.getTimestampValue()); + } + throw new IllegalArgumentException("Value does not contain a timestamp."); + } + + private static long toMicroseconds(TimestampOrBuilder timestamp) { + // Nanosecond precision is lost. + return timestamp.getSeconds() * MICROSECONDS_PER_SECOND + + timestamp.getNanos() / NANOSECONDS_PER_MICROSECOND; + } + + /** + * @return the array contained in value as a list. + * @throws IllegalArgumentException if the value does not contain an array. + */ + public static List getList(Value value) { + if (value.getValueTypeCase() != ValueTypeCase.ARRAY_VALUE) { + throw new IllegalArgumentException("Value does not contain an array."); + } + return value.getArrayValue().getValuesList(); + } + + /** + * Convert a timestamp value into a {@link Date} clipping off the microseconds. + * + * @param value a timestamp value to convert + * @return the resulting {@link Date} + * @throws IllegalArgumentException if the value does not contain a timestamp. + */ + public static Date toDate(Value value) { + return new Date(getTimestamp(value) / 1000); + } + + /** + * @param entity the entity to insert + * @return a mutation that will insert an entity + */ + public static Mutation.Builder makeInsert(Entity entity) { + return Mutation.newBuilder().setInsert(entity); + } + + /** + * @param entity the entity to update + * @return a mutation that will update an entity + */ + public static Mutation.Builder makeUpdate(Entity entity) { + return Mutation.newBuilder().setUpdate(entity); + } + + /** + * @param entity the entity to upsert + * @return a mutation that will upsert an entity + */ + public static Mutation.Builder makeUpsert(Entity entity) { + return Mutation.newBuilder().setUpsert(entity); + } + + /** + * @param key the key of the entity to delete + * @return a mutation that will delete an entity + */ + public static Mutation.Builder makeDelete(Key key) { + return Mutation.newBuilder().setDelete(key); + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreOptions.java b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreOptions.java new file mode 100644 index 000000000000..2c8d5e48004a --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/DatastoreOptions.java @@ -0,0 +1,204 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.http.HttpRequestInitializer; +import com.google.api.client.http.HttpTransport; +import java.util.Arrays; +import java.util.List; + +/** + * An immutable object containing settings for the datastore. + * + *

Example for connecting to a datastore: + * + *

+ * DatastoreOptions options = new DatastoreOptions.Builder()
+ *     .projectId("my-project-id")
+ *     .credential(DatastoreHelper.getComputeEngineCredential())
+ *     .build();
+ * DatastoreFactory.get().create(options);
+ * 
+ * + *

The options should be passed to {@link DatastoreFactory#create}. + */ +public class DatastoreOptions { + private final String projectId; + + private final String projectEndpoint; + private final String host; + private final String localHost; + + private final HttpRequestInitializer initializer; + + private final Credential credential; + private final HttpTransport transport; + public static final List SCOPES = + Arrays.asList("https://www.googleapis.com/auth/datastore"); + + DatastoreOptions(Builder b) { + checkArgument( + b.projectId != null || b.projectEndpoint != null, + "Either project ID or project endpoint must be provided."); + this.projectId = b.projectId; + this.projectEndpoint = b.projectEndpoint; + this.host = b.host; + this.localHost = b.localHost; + this.initializer = b.initializer; + this.credential = b.credential; + this.transport = b.transport; + } + + /** Builder for {@link DatastoreOptions}. */ + public static class Builder { + private static final String PROJECT_ENDPOINT_AND_PROJECT_ID_ERROR = + "Cannot set both project endpoint and project ID."; + private static final String PROJECT_ENDPOINT_AND_HOST_ERROR = + "Can set at most one of project endpoint, host, and local host."; + + private String projectId; + + private String projectEndpoint; + private String host; + private String localHost; + private HttpRequestInitializer initializer; + private Credential credential; + private HttpTransport transport; + + public Builder() {} + + public Builder(DatastoreOptions options) { + this.projectId = options.projectId; + this.projectEndpoint = options.projectEndpoint; + this.host = options.host; + this.localHost = options.localHost; + this.initializer = options.initializer; + this.credential = options.credential; + this.transport = options.transport; + } + + public DatastoreOptions build() { + return new DatastoreOptions(this); + } + + /** Sets the project ID used to access Cloud Datastore. */ + public Builder projectId(String projectId) { + checkArgument(projectEndpoint == null, PROJECT_ENDPOINT_AND_PROJECT_ID_ERROR); + this.projectId = projectId; + return this; + } + + /** + * Sets the host used to access Cloud Datastore. To connect to the Cloud Datastore Emulator, use + * {@link #localHost} instead. + */ + public Builder host(String host) { + checkArgument(projectEndpoint == null && localHost == null, PROJECT_ENDPOINT_AND_HOST_ERROR); + if (includesScheme(host)) { + throw new IllegalArgumentException( + String.format("Host \"%s\" must not include scheme.", host)); + } + this.host = host; + return this; + } + + /** + * Configures the client to access Cloud Datastore on a local host (typically a Cloud Datastore + * Emulator instance). Call this method also configures the client not to attach credentials to + * requests. + */ + public Builder localHost(String localHost) { + checkArgument(projectEndpoint == null && host == null, PROJECT_ENDPOINT_AND_HOST_ERROR); + if (includesScheme(localHost)) { + throw new IllegalArgumentException( + String.format("Local host \"%s\" must not include scheme.", localHost)); + } + this.localHost = localHost; + return this; + } + + /** + * Sets the project endpoint used to access Cloud Datastore. Prefer using {@link #projectId} + * and/or {@link #host}/{@link #localHost} when possible. + * + * @deprecated Use {@link #projectId} and/or {@link #host}/{@link #localHost} instead. + */ + @Deprecated + public Builder projectEndpoint(String projectEndpoint) { + checkArgument(projectId == null, PROJECT_ENDPOINT_AND_PROJECT_ID_ERROR); + checkArgument(localHost == null && host == null, PROJECT_ENDPOINT_AND_HOST_ERROR); + if (!includesScheme(projectEndpoint)) { + throw new IllegalArgumentException( + String.format("Project endpoint \"%s\" must include scheme.", projectEndpoint)); + } + this.projectEndpoint = projectEndpoint; + return this; + } + + /** Sets the (optional) initializer to run on HTTP requests to Cloud Datastore. */ + public Builder initializer(HttpRequestInitializer initializer) { + this.initializer = initializer; + return this; + } + + /** Sets the Google APIs {@link Credential} used to access Cloud Datastore. */ + public Builder credential(Credential credential) { + this.credential = credential; + return this; + } + + /** Sets the transport used to access Cloud Datastore. */ + public Builder transport(HttpTransport transport) { + this.transport = transport; + return this; + } + + private static boolean includesScheme(String url) { + return url.startsWith("http://") || url.startsWith("https://"); + } + } + + public String getProjectId() { + return projectId; + } + + public String getProjectEndpoint() { + return projectEndpoint; + } + + public String getHost() { + return host; + } + + public String getLocalHost() { + return localHost; + } + + public HttpRequestInitializer getInitializer() { + return initializer; + } + + public Credential getCredential() { + return credential; + } + + public HttpTransport getTransport() { + return transport; + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/QuerySplitter.java b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/QuerySplitter.java new file mode 100644 index 000000000000..beb20a05babd --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/QuerySplitter.java @@ -0,0 +1,56 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import com.google.api.core.BetaApi; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.Query; +import com.google.protobuf.Timestamp; +import java.util.List; + +/** Provides the ability to split a query into multiple shards. */ +public interface QuerySplitter { + + /** + * Returns a list of sharded {@link Query}s for the given query. + * + *

This will create up to the desired number of splits, however it may return less splits if + * the desired number of splits is unavailable. This will happen if the number of split points + * provided by the underlying Datastore is less than the desired number, which will occur if the + * number of results for the query is too small. + * + * @param query the query to split. + * @param partition the partition the query is running in. + * @param numSplits the desired number of splits. + * @param datastore the datastore to run on. + * @throws DatastoreException if there was a datastore error while generating query splits. + * @throws IllegalArgumentException if the given query or numSplits was invalid. + */ + List getSplits(Query query, PartitionId partition, int numSplits, Datastore datastore) + throws DatastoreException; + + /** + * Same as {@link #getSplits(Query, PartitionId, int, Datastore)} but the splits are based on + * {@code readTime}, and the returned sharded {@link Query}s should also be executed with {@code + * readTime}. Reading from a timestamp is currently a private preview feature in Datastore. + */ + @BetaApi + default List getSplits( + Query query, PartitionId partition, int numSplits, Datastore datastore, Timestamp readTime) + throws DatastoreException { + throw new UnsupportedOperationException("Not implemented."); + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/QuerySplitterImpl.java b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/QuerySplitterImpl.java new file mode 100644 index 000000000000..f139b7c1fc8c --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/QuerySplitterImpl.java @@ -0,0 +1,309 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import static com.google.datastore.utils.DatastoreHelper.makeAndFilter; + +import com.google.api.core.BetaApi; +import com.google.datastore.v1.EntityResult; +import com.google.datastore.v1.Filter; +import com.google.datastore.v1.Key; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.Projection; +import com.google.datastore.v1.PropertyFilter; +import com.google.datastore.v1.PropertyFilter.Operator; +import com.google.datastore.v1.PropertyOrder.Direction; +import com.google.datastore.v1.PropertyReference; +import com.google.datastore.v1.Query; +import com.google.datastore.v1.QueryResultBatch; +import com.google.datastore.v1.QueryResultBatch.MoreResultsType; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.RunQueryRequest; +import com.google.protobuf.Timestamp; +import java.util.ArrayList; +import java.util.Collections; +import java.util.EnumSet; +import java.util.List; +import javax.annotation.Nullable; + +/** + * Provides the ability to split a query into multiple shards using Cloud Datastore. + * + *

This implementation of the QuerySplitter uses the __scatter__ property to gather random split + * points for a query. + */ +final class QuerySplitterImpl implements QuerySplitter { + + /** The number of keys to sample for each split. * */ + private static final int KEYS_PER_SPLIT = 32; + + private static final EnumSet UNSUPPORTED_OPERATORS = + EnumSet.of( + Operator.LESS_THAN, + Operator.LESS_THAN_OR_EQUAL, + Operator.GREATER_THAN, + Operator.GREATER_THAN_OR_EQUAL); + + static final QuerySplitter INSTANCE = new QuerySplitterImpl(); + + private QuerySplitterImpl() { + // No initialization required. + } + + @Override + public List getSplits( + Query query, PartitionId partition, int numSplits, Datastore datastore) + throws DatastoreException, IllegalArgumentException { + return getSplitsInternal(query, partition, numSplits, datastore, null); + } + + @BetaApi + @Override + public List getSplits( + Query query, PartitionId partition, int numSplits, Datastore datastore, Timestamp readTime) + throws DatastoreException, IllegalArgumentException { + return getSplitsInternal(query, partition, numSplits, datastore, readTime); + } + + private List getSplitsInternal( + Query query, + PartitionId partition, + int numSplits, + Datastore datastore, + @Nullable Timestamp readTime) + throws DatastoreException, IllegalArgumentException { + List splits = new ArrayList(numSplits); + if (numSplits == 1) { + splits.add(query); + return splits; + } + validateQuery(query); + validateSplitSize(numSplits); + + List scatterKeys = getScatterKeys(numSplits, query, partition, datastore, readTime); + Key lastKey = null; + for (Key nextKey : getSplitKey(scatterKeys, numSplits)) { + splits.add(createSplit(lastKey, nextKey, query)); + lastKey = nextKey; + } + splits.add(createSplit(lastKey, null, query)); + return splits; + } + + /** + * Verify that the given number of splits is not out of bounds. + * + * @param numSplits the number of splits. + * @throws IllegalArgumentException if the split size is invalid. + */ + private void validateSplitSize(int numSplits) throws IllegalArgumentException { + if (numSplits < 1) { + throw new IllegalArgumentException("The number of splits must be greater than 0."); + } + } + + /** + * Validates that we only have allowable filters. + * + *

Note that equality and ancestor filters are allowed, however they may result in inefficient + * sharding. + */ + private void validateFilter(Filter filter) throws IllegalArgumentException { + switch (filter.getFilterTypeCase()) { + case COMPOSITE_FILTER: + for (Filter subFilter : filter.getCompositeFilter().getFiltersList()) { + validateFilter(subFilter); + } + break; + case PROPERTY_FILTER: + if (UNSUPPORTED_OPERATORS.contains(filter.getPropertyFilter().getOp())) { + throw new IllegalArgumentException("Query cannot have any inequality filters."); + } + break; + default: + throw new IllegalArgumentException( + "Unsupported filter type: " + filter.getFilterTypeCase()); + } + } + + /** + * Verifies that the given query can be properly scattered. + * + * @param query the query to verify + * @throws IllegalArgumentException if the query is invalid. + */ + private void validateQuery(Query query) throws IllegalArgumentException { + if (query.getKindCount() != 1) { + throw new IllegalArgumentException("Query must have exactly one kind."); + } + if (query.getOrderCount() != 0) { + throw new IllegalArgumentException("Query cannot have any sort orders."); + } + if (query.hasFilter()) { + validateFilter(query.getFilter()); + } + } + + /** + * Create a new {@link Query} given the query and range. + * + * @param lastKey the previous key. If null then assumed to be the beginning. + * @param nextKey the next key. If null then assumed to be the end. + * @param query the desired query. + */ + private Query createSplit(Key lastKey, Key nextKey, Query query) { + if (lastKey == null && nextKey == null) { + return query; + } + List keyFilters = new ArrayList(); + if (query.hasFilter()) { + keyFilters.add(query.getFilter()); + } + if (lastKey != null) { + Filter lowerBound = + DatastoreHelper.makeFilter( + DatastoreHelper.KEY_PROPERTY_NAME, + PropertyFilter.Operator.GREATER_THAN_OR_EQUAL, + DatastoreHelper.makeValue(lastKey)) + .build(); + keyFilters.add(lowerBound); + } + if (nextKey != null) { + Filter upperBound = + DatastoreHelper.makeFilter( + DatastoreHelper.KEY_PROPERTY_NAME, + PropertyFilter.Operator.LESS_THAN, + DatastoreHelper.makeValue(nextKey)) + .build(); + keyFilters.add(upperBound); + } + return Query.newBuilder(query).setFilter(makeAndFilter(keyFilters)).build(); + } + + /** + * Gets a list of split keys given a desired number of splits. + * + *

This list will contain multiple split keys for each split. Only a single split key will be + * chosen as the split point, however providing multiple keys allows for more uniform sharding. + * + * @param numSplits the number of desired splits. + * @param query the user query. + * @param partition the partition to run the query in. + * @param datastore the datastore containing the data. + * @param readTime read time at which to get the split keys from the datastore. + * @throws com.google.datastore.utils.DatastoreException if there was an error when executing the + * datastore query. + */ + private List getScatterKeys( + int numSplits, + Query query, + PartitionId partition, + Datastore datastore, + @Nullable Timestamp readTime) + throws DatastoreException { + Query.Builder scatterPointQuery = createScatterQuery(query, numSplits); + + List keySplits = new ArrayList(); + + QueryResultBatch batch; + do { + RunQueryRequest.Builder scatterRequest = + RunQueryRequest.newBuilder().setPartitionId(partition).setQuery(scatterPointQuery); + scatterRequest.setProjectId(partition.getProjectId()); + scatterRequest.setDatabaseId(partition.getDatabaseId()); + if (readTime != null) { + scatterRequest.setReadOptions(ReadOptions.newBuilder().setReadTime(readTime).build()); + } + batch = datastore.runQuery(scatterRequest.build()).getBatch(); + for (EntityResult result : batch.getEntityResultsList()) { + keySplits.add(result.getEntity().getKey()); + } + scatterPointQuery.setStartCursor(batch.getEndCursor()); + scatterPointQuery + .getLimitBuilder() + .setValue(scatterPointQuery.getLimit().getValue() - batch.getEntityResultsCount()); + } while (batch.getMoreResults() == MoreResultsType.NOT_FINISHED); + Collections.sort(keySplits, DatastoreHelper.getKeyComparator()); + return keySplits; + } + + /** + * Creates a scatter query from the given user query + * + * @param query the user's query. + * @param numSplits the number of splits to create. + */ + private Query.Builder createScatterQuery(Query query, int numSplits) { + // TODO(pcostello): We can potentially support better splits with equality filters in our query + // if there exists a composite index on property, __scatter__, __key__. Until an API for + // metadata exists, this isn't possible. Note that ancestor and inequality queries fall into + // the same category. + Query.Builder scatterPointQuery = Query.newBuilder(); + scatterPointQuery.addAllKind(query.getKindList()); + scatterPointQuery.addOrder( + DatastoreHelper.makeOrder(DatastoreHelper.SCATTER_PROPERTY_NAME, Direction.ASCENDING)); + // There is a split containing entities before and after each scatter entity: + // ||---*------*------*------*------*------*------*---|| = scatter entity + // If we represent each split as a region before a scatter entity, there is an extra region + // following the last scatter point. Thus, we do not need the scatter entities for the last + // region. + scatterPointQuery.getLimitBuilder().setValue((numSplits - 1) * KEYS_PER_SPLIT); + scatterPointQuery.addProjection( + Projection.newBuilder().setProperty(PropertyReference.newBuilder().setName("__key__"))); + return scatterPointQuery; + } + + /** + * Given a list of keys and a number of splits find the keys to split on. + * + * @param keys the list of keys. + * @param numSplits the number of splits. + */ + private Iterable getSplitKey(List keys, int numSplits) { + // If the number of keys is less than the number of splits, we are limited in the number of + // splits we can make. + if (keys.size() < numSplits - 1) { + return keys; + } + + // Calculate the number of keys per split. This should be KEYS_PER_SPLIT, but may + // be less if there are not KEYS_PER_SPLIT * (numSplits - 1) scatter entities. + // + // Consider the following dataset, where - represents an entity and * represents an entity + // that is returned as a scatter entity: + // ||---*-----*----*-----*-----*------*----*----|| + // If we want 4 splits in this data, the optimal split would look like: + // ||---*-----*----*-----*-----*------*----*----|| + // | | | + // The scatter keys in the last region are not useful to us, so we never request them: + // ||---*-----*----*-----*-----*------*---------|| + // | | | + // With 6 scatter keys we want to set scatter points at indexes: 1, 3, 5. + // + // We keep this as a double so that any "fractional" keys per split get distributed throughout + // the splits and don't make the last split significantly larger than the rest. + double numKeysPerSplit = Math.max(1.0, ((double) keys.size()) / (numSplits - 1)); + + List keysList = new ArrayList(numSplits - 1); + // Grab the last sample for each split, otherwise the first split will be too small. + for (int i = 1; i < numSplits; i++) { + int splitIndex = (int) Math.round(i * numKeysPerSplit) - 1; + keysList.add(keys.get(splitIndex)); + } + + return keysList; + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/RemoteRpc.java b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/RemoteRpc.java new file mode 100644 index 000000000000..4d92ef6bce1b --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/RemoteRpc.java @@ -0,0 +1,239 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import com.google.api.client.http.*; +import com.google.api.client.http.protobuf.ProtoHttpContent; +import com.google.api.client.util.IOUtils; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Strings; +import com.google.protobuf.MessageLite; +import com.google.rpc.Code; +import com.google.rpc.Status; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.SocketTimeoutException; +import java.nio.charset.Charset; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.logging.Logger; + +/** + * An RPC transport that sends protocol buffers over HTTP. + * + *

This class is thread-safe. + */ +class RemoteRpc { + private static final Logger logger = Logger.getLogger(RemoteRpc.class.getName()); + + @VisibleForTesting static final String API_FORMAT_VERSION_HEADER = "X-Goog-Api-Format-Version"; + private static final String API_FORMAT_VERSION = "2"; + + @VisibleForTesting static final String X_GOOG_REQUEST_PARAMS_HEADER = "x-goog-request-params"; + + private final HttpRequestFactory client; + private final HttpRequestInitializer initializer; + private final String url; + private final AtomicInteger rpcCount = new AtomicInteger(0); + // Not final - so it can be set/reset in Unittests + private static boolean enableE2EChecksum = + Boolean.parseBoolean(System.getenv("GOOGLE_CLOUD_DATASTORE_HTTP_ENABLE_E2E_CHECKSUM")); + + RemoteRpc(HttpRequestFactory client, HttpRequestInitializer initializer, String url) { + this.client = client; + this.initializer = initializer; + this.url = url; + try { + resolveURL("dummyRpc"); + } catch (Exception e) { + throw new IllegalArgumentException( + "Unable to construct RemoteRpc due to unsupported url: <" + url + ">", e); + } + } + + /** + * Makes an RPC call using the client. Logs how long it took and any exceptions. + * + *

NOTE: The request could be an InputStream too, but the http client will need to find its + * length, which will require buffering it anyways. + * + * @throws com.google.datastore.utils.DatastoreException if the RPC fails. + */ + public InputStream call( + String methodName, MessageLite request, String projectId, String databaseId) + throws com.google.datastore.utils.DatastoreException { + logger.fine("remote datastore call " + methodName); + + long startTime = System.currentTimeMillis(); + try { + HttpResponse httpResponse; + try { + rpcCount.incrementAndGet(); + ProtoHttpContent payload = new ProtoHttpContent(request); + HttpRequest httpRequest = client.buildPostRequest(resolveURL(methodName), payload); + setHeaders(request, httpRequest, projectId, databaseId); + // Don't throw an HTTPResponseException on error. It converts the response to a String and + // throws away the original, whereas we need the raw bytes to parse it as a proto. + httpRequest.setThrowExceptionOnExecuteError(false); + // Datastore requests typically time out after 60s; set the read timeout to slightly longer + // than that by default (can be overridden via the HttpRequestInitializer). + httpRequest.setReadTimeout(65 * 1000); + if (initializer != null) { + initializer.initialize(httpRequest); + } + httpResponse = httpRequest.execute(); + if (!httpResponse.isSuccessStatusCode()) { + try (InputStream content = httpResponse.getContent()) { + throw makeException( + url, + methodName, + content, + httpResponse.getContentType(), + httpResponse.getContentCharset(), + null, + httpResponse.getStatusCode()); + } + } + InputStream inputStream = httpResponse.getContent(); + return inputStream; + } catch (SocketTimeoutException e) { + throw makeException(url, methodName, Code.DEADLINE_EXCEEDED, "Deadline exceeded", e); + } catch (IOException e) { + throw makeException(url, methodName, Code.UNAVAILABLE, "I/O error", e); + } + } finally { + long elapsedTime = System.currentTimeMillis() - startTime; + logger.fine("remote datastore call " + methodName + " took " + elapsedTime + " ms"); + } + } + + @VisibleForTesting + void setHeaders( + MessageLite request, HttpRequest httpRequest, String projectId, String databaseId) { + httpRequest.getHeaders().put(API_FORMAT_VERSION_HEADER, API_FORMAT_VERSION); + StringBuilder builder = new StringBuilder("project_id="); + builder.append(projectId); + if (!Strings.isNullOrEmpty(databaseId)) { + builder.append("&database_id="); + builder.append(databaseId); + } + httpRequest.getHeaders().put(X_GOOG_REQUEST_PARAMS_HEADER, builder.toString()); + } + + @VisibleForTesting + HttpRequestFactory getClient() { + return client; + } + + @VisibleForTesting + static void setSystemEnvE2EChecksum(boolean enableE2EChecksum) { + RemoteRpc.enableE2EChecksum = enableE2EChecksum; + } + + void resetRpcCount() { + rpcCount.set(0); + } + + int getRpcCount() { + return rpcCount.get(); + } + + public String getUrl() { + return url; + } + + GenericUrl resolveURL(String path) { + return new GenericUrl(url + ":" + path); + } + + HttpRequestFactory getHttpRequestFactory() { + return client; + } + + public static com.google.datastore.utils.DatastoreException makeException( + String url, String methodName, Code code, String message, Throwable cause) { + logger.fine("remote datastore call " + methodName + " against " + url + " failed: " + message); + return new com.google.datastore.utils.DatastoreException(methodName, code, message, cause); + } + + static DatastoreException makeException( + String url, + String methodName, + InputStream content, + String contentType, + Charset contentCharset, + Throwable cause, + int httpStatusCode) { + if (!contentType.equals("application/x-protobuf")) { + String responseContent; + try { + ByteArrayOutputStream out = new ByteArrayOutputStream(); + IOUtils.copy(content, out, false); + responseContent = out.toString(contentCharset.name()); + } catch (IOException e) { + responseContent = ""; + } + return makeException( + url, + methodName, + Code.INTERNAL, + String.format( + "Non-protobuf error: %s. HTTP status code was %d.", responseContent, httpStatusCode), + cause); + } + + Status rpcStatus; + try { + rpcStatus = Status.parseFrom(content); + } catch (IOException e) { + return makeException( + url, + methodName, + Code.INTERNAL, + String.format( + "Unable to parse Status protocol buffer: HTTP status code was %s.", httpStatusCode), + e); + } + + Code code = Code.forNumber(rpcStatus.getCode()); + if (code == null) { + return makeException( + url, + methodName, + Code.INTERNAL, + String.format( + "Invalid error code: %d. Message: %s.", rpcStatus.getCode(), rpcStatus.getMessage()), + cause); + } else if (code == Code.OK) { + // We can end up here because there was no response body (and we successfully parsed an + // empty Status message). This may happen for 401s in particular due to special handling + // in low-level HTTP libraries. + if (httpStatusCode == HttpStatusCodes.STATUS_CODE_UNAUTHORIZED) { + return makeException(url, methodName, Code.UNAUTHENTICATED, "Unauthenticated.", cause); + } + return makeException( + url, + methodName, + Code.INTERNAL, + String.format( + "Unexpected OK error code with HTTP status code of %d. Message: %s.", + httpStatusCode, rpcStatus.getMessage()), + cause); + } + + return makeException(url, methodName, code, rpcStatus.getMessage(), cause); + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/testing/MockCredential.java b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/testing/MockCredential.java new file mode 100644 index 000000000000..0f2f165e08db --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/testing/MockCredential.java @@ -0,0 +1,36 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils.testing; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.http.HttpRequest; +import java.io.IOException; + +/** Fake credential used for testing purpose. */ +public class MockCredential extends Credential { + public MockCredential() { + super( + new AccessMethod() { + @Override + public void intercept(HttpRequest request, String accessToken) throws IOException {} + + @Override + public String getAccessTokenFromRequest(HttpRequest request) { + return "MockAccessToken"; + } + }); + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/testing/MockDatastoreFactory.java b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/testing/MockDatastoreFactory.java new file mode 100644 index 000000000000..13a4539c600b --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/main/java/com/google/datastore/utils/testing/MockDatastoreFactory.java @@ -0,0 +1,132 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils.testing; + +import static com.google.common.base.Preconditions.checkState; + +import com.google.api.client.auth.oauth2.Credential; +import com.google.api.client.http.*; +import com.google.api.client.testing.http.MockHttpTransport; +import com.google.api.client.testing.http.MockLowLevelHttpRequest; +import com.google.api.client.testing.http.MockLowLevelHttpResponse; +import com.google.api.client.testing.util.TestableByteArrayInputStream; +import com.google.common.collect.Iterables; +import com.google.datastore.utils.DatastoreFactory; +import com.google.datastore.utils.DatastoreOptions; +import com.google.protobuf.Message; +import com.google.rpc.Code; +import com.google.rpc.Status; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.List; + +/** Fake Datastore factory used for testing purposes when a true Datastore service is not needed. */ +public class MockDatastoreFactory extends DatastoreFactory { + private int nextStatus; + private Message nextResponse; + private Status nextError; + private IOException nextException; + + private String lastPath; + private String lastMimeType; + private byte[] lastBody; + private List lastCookies; + private String lastApiFormatHeaderValue; + + public void setNextResponse(Message response) { + nextStatus = HttpStatusCodes.STATUS_CODE_OK; + nextResponse = response; + nextError = null; + nextException = null; + } + + public void setNextError(int status, Code code, String message) { + nextStatus = status; + nextResponse = null; + nextError = makeErrorContent(message, code); + nextException = null; + } + + public void setNextException(IOException exception) { + nextStatus = 0; + nextResponse = null; + nextError = null; + nextException = exception; + } + + @Override + public HttpRequestFactory makeClient(DatastoreOptions options) { + HttpTransport transport = + new MockHttpTransport() { + @Override + public LowLevelHttpRequest buildRequest(String method, String url) { + return new MockLowLevelHttpRequest(url) { + @Override + public LowLevelHttpResponse execute() throws IOException { + lastPath = new GenericUrl(getUrl()).getRawPath(); + lastMimeType = getContentType(); + lastCookies = getHeaderValues("Cookie"); + lastApiFormatHeaderValue = + Iterables.getOnlyElement(getHeaderValues("X-Goog-Api-Format-Version")); + ByteArrayOutputStream out = new ByteArrayOutputStream(); + getStreamingContent().writeTo(out); + lastBody = out.toByteArray(); + if (nextException != null) { + throw nextException; + } + MockLowLevelHttpResponse response = + new MockLowLevelHttpResponse() + .setStatusCode(nextStatus) + .setContentType("application/x-protobuf"); + if (nextError != null) { + checkState(nextResponse == null); + response.setContent(new TestableByteArrayInputStream(nextError.toByteArray())); + } else { + response.setContent(new TestableByteArrayInputStream(nextResponse.toByteArray())); + } + return response; + } + }; + } + }; + Credential credential = options.getCredential(); + return transport.createRequestFactory(credential); + } + + public String getLastPath() { + return lastPath; + } + + public String getLastMimeType() { + return lastMimeType; + } + + public String getLastApiFormatHeaderValue() { + return lastApiFormatHeaderValue; + } + + public byte[] getLastBody() { + return lastBody; + } + + public List getLastCookies() { + return lastCookies; + } + + private static Status makeErrorContent(String message, Code code) { + return Status.newBuilder().setCode(code.getNumber()).setMessage(message).build(); + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/DatastoreClientTest.java b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/DatastoreClientTest.java new file mode 100644 index 000000000000..c46bb1b2203e --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/DatastoreClientTest.java @@ -0,0 +1,407 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.fail; + +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpRequestInitializer; +import com.google.datastore.utils.testing.MockCredential; +import com.google.datastore.utils.testing.MockDatastoreFactory; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.EntityResult; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.QueryResultBatch; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.Message; +import com.google.rpc.Code; +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.SocketTimeoutException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link DatastoreFactory} and {@link Datastore}. */ +@RunWith(JUnit4.class) +public class DatastoreClientTest { + private static final String PROJECT_ID = "project-id"; + + private DatastoreFactory factory = new MockDatastoreFactory(); + private DatastoreOptions.Builder options = + new DatastoreOptions.Builder().projectId(PROJECT_ID).credential(new MockCredential()); + + @Test + public void options_NoProjectIdOrProjectEndpoint() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> factory.create(new DatastoreOptions.Builder().build())); + assertThat(exception) + .hasMessageThat() + .contains("Either project ID or project endpoint must be provided"); + factory.create(options.build()); + } + + @Test + public void options_ProjectIdAndProjectEndpoint() throws Exception { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .projectEndpoint( + "http://localhost:1234/datastore/v1beta42/projects/project-id")); + assertThat(exception) + .hasMessageThat() + .contains("Cannot set both project endpoint and project ID"); + } + + @Test + public void options_LocalHostAndProjectEndpoint() throws Exception { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + new DatastoreOptions.Builder() + .localHost("localhost:8080") + .projectEndpoint( + "http://localhost:1234/datastore/v1beta42/projects/project-id")); + assertThat(exception) + .hasMessageThat() + .contains("Can set at most one of project endpoint, host, and local host"); + } + + @Test + public void options_HostAndProjectEndpoint() throws Exception { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + new DatastoreOptions.Builder() + .host("foo-datastore.googleapis.com") + .projectEndpoint( + "http://localhost:1234/datastore/v1beta42/projects/project-id")); + assertThat(exception) + .hasMessageThat() + .contains("Can set at most one of project endpoint, host, and local host"); + } + + @Test + public void options_HostAndLocalHost() throws Exception { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + new DatastoreOptions.Builder() + .host("foo-datastore.googleapis.com") + .localHost("localhost:8080")); + assertThat(exception) + .hasMessageThat() + .contains("Can set at most one of project endpoint, host, and local host"); + } + + @Test + public void options_InvalidLocalHost() throws Exception { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + factory.create( + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .localHost("!not a valid url!") + .build())); + assertThat(exception).hasMessageThat().contains("Illegal character"); + } + + @Test + public void options_SchemeInLocalHost() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> new DatastoreOptions.Builder().localHost("http://localhost:8080")); + assertThat(exception) + .hasMessageThat() + .contains("Local host \"http://localhost:8080\" must not include scheme"); + } + + @Test + public void options_InvalidHost() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + factory.create( + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .host("!not a valid url!") + .build())); + assertThat(exception).hasMessageThat().contains("Illegal character"); + } + + @Test + public void options_SchemeInHost() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> new DatastoreOptions.Builder().host("http://foo-datastore.googleapis.com")); + + assertThat(exception) + .hasMessageThat() + .contains("Host \"http://foo-datastore.googleapis.com\" must not include scheme."); + } + + @Test + public void create_NullOptions() throws Exception { + assertThrows(NullPointerException.class, () -> factory.create(null)); + } + + @Test + public void create_Host() { + Datastore datastore = + factory.create( + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .host("foo-datastore.googleapis.com") + .build()); + assertThat(datastore.remoteRpc.getUrl()) + .isEqualTo("https://foo-datastore.googleapis.com/v1/projects/project-id"); + } + + @Test + public void create_LocalHost() { + Datastore datastore = + factory.create( + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .localHost("localhost:8080") + .build()); + assertThat(datastore.remoteRpc.getUrl()) + .isEqualTo("http://localhost:8080/v1/projects/project-id"); + } + + @Test + public void create_LocalHostIp() { + Datastore datastore = + factory.create( + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .localHost("127.0.0.1:8080") + .build()); + assertThat(datastore.remoteRpc.getUrl()) + .isEqualTo("http://127.0.0.1:8080/v1/projects/project-id"); + } + + @Test + public void create_DefaultHost() { + Datastore datastore = + factory.create(new DatastoreOptions.Builder().projectId(PROJECT_ID).build()); + assertThat(datastore.remoteRpc.getUrl()) + .isEqualTo("https://datastore.googleapis.com/v1/projects/project-id"); + } + + @Test + public void create_ProjectEndpoint() { + Datastore datastore = + factory.create( + new DatastoreOptions.Builder() + .projectEndpoint("http://prom-qa/datastore/v1beta42/projects/project-id") + .build()); + assertThat(datastore.remoteRpc.getUrl()) + .isEqualTo("http://prom-qa/datastore/v1beta42/projects/project-id"); + } + + @Test + public void create_ProjectEndpointNoScheme() { + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + factory.create( + new DatastoreOptions.Builder() + .projectEndpoint("localhost:1234/datastore/v1beta42/projects/project-id") + .build())); + assertThat(exception) + .hasMessageThat() + .contains( + "Project endpoint \"localhost:1234/datastore/v1beta42/projects/project-id\" must" + + " include scheme."); + } + + @Test + public void initializer() throws Exception { + options.initializer( + new HttpRequestInitializer() { + @Override + public void initialize(HttpRequest request) { + request.getHeaders().setCookie("magic"); + } + }); + Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + AllocateIdsRequest request = AllocateIdsRequest.newBuilder().build(); + AllocateIdsResponse response = AllocateIdsResponse.newBuilder().build(); + mockClient.setNextResponse(response); + assertEquals(response, datastore.allocateIds(request)); + assertEquals("magic", mockClient.getLastCookies().get(0)); + } + + @Test + public void allocateIds() throws Exception { + AllocateIdsRequest.Builder request = AllocateIdsRequest.newBuilder(); + AllocateIdsResponse.Builder response = AllocateIdsResponse.newBuilder(); + expectRpc("allocateIds", request.build(), response.build()); + } + + @Test + public void lookup() throws Exception { + LookupRequest.Builder request = LookupRequest.newBuilder(); + LookupResponse.Builder response = LookupResponse.newBuilder(); + expectRpc("lookup", request.build(), response.build()); + } + + @Test + public void beginTransaction() throws Exception { + BeginTransactionRequest.Builder request = BeginTransactionRequest.newBuilder(); + BeginTransactionResponse.Builder response = BeginTransactionResponse.newBuilder(); + response.setTransaction(ByteString.copyFromUtf8("project-id")); + expectRpc("beginTransaction", request.build(), response.build()); + } + + @Test + public void commit() throws Exception { + CommitRequest.Builder request = CommitRequest.newBuilder(); + request.setTransaction(ByteString.copyFromUtf8("project-id")); + CommitResponse.Builder response = CommitResponse.newBuilder(); + expectRpc("commit", request.build(), response.build()); + } + + @Test + public void reserveIds() throws Exception { + ReserveIdsRequest.Builder request = ReserveIdsRequest.newBuilder(); + ReserveIdsResponse.Builder response = ReserveIdsResponse.newBuilder(); + expectRpc("reserveIds", request.build(), response.build()); + } + + @Test + public void rollback() throws Exception { + RollbackRequest.Builder request = RollbackRequest.newBuilder(); + request.setTransaction(ByteString.copyFromUtf8("project-id")); + RollbackResponse.Builder response = RollbackResponse.newBuilder(); + expectRpc("rollback", request.build(), response.build()); + } + + @Test + public void runQuery() throws Exception { + RunQueryRequest.Builder request = RunQueryRequest.newBuilder(); + request.getQueryBuilder(); + RunQueryResponse.Builder response = RunQueryResponse.newBuilder(); + response + .getBatchBuilder() + .setEntityResultType(EntityResult.ResultType.FULL) + .setMoreResults(QueryResultBatch.MoreResultsType.NOT_FINISHED); + expectRpc("runQuery", request.build(), response.build()); + } + + @Test + public void runAggregationQuery() throws Exception { + RunAggregationQueryRequest.Builder request = RunAggregationQueryRequest.newBuilder(); + RunAggregationQueryResponse.Builder response = RunAggregationQueryResponse.newBuilder(); + expectRpc("runAggregationQuery", request.build(), response.build()); + } + + private void expectRpc(String methodName, Message request, Message response) throws Exception { + Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + + mockClient.setNextResponse(response); + @SuppressWarnings("rawtypes") + Class[] methodArgs = {request.getClass()}; + Method call = Datastore.class.getMethod(methodName, methodArgs); + Object[] callArgs = {request}; + assertEquals(response, call.invoke(datastore, callArgs)); + + assertEquals("/v1/projects/project-id:" + methodName, mockClient.getLastPath()); + assertEquals("application/x-protobuf", mockClient.getLastMimeType()); + assertEquals("2", mockClient.getLastApiFormatHeaderValue()); + assertArrayEquals(request.toByteArray(), mockClient.getLastBody()); + assertEquals(1, datastore.getRpcCount()); + + datastore.resetRpcCount(); + assertEquals(0, datastore.getRpcCount()); + + mockClient.setNextError(400, Code.INVALID_ARGUMENT, "oops"); + try { + call.invoke(datastore, callArgs); + fail(); + } catch (InvocationTargetException targetException) { + DatastoreException exception = (DatastoreException) targetException.getCause(); + assertEquals(Code.INVALID_ARGUMENT, exception.getCode()); + assertEquals(methodName, exception.getMethodName()); + assertEquals("oops", exception.getMessage()); + } + + SocketTimeoutException socketTimeoutException = new SocketTimeoutException("ste"); + mockClient.setNextException(socketTimeoutException); + try { + call.invoke(datastore, callArgs); + fail(); + } catch (InvocationTargetException targetException) { + DatastoreException exception = (DatastoreException) targetException.getCause(); + assertEquals(Code.DEADLINE_EXCEEDED, exception.getCode()); + assertEquals(methodName, exception.getMethodName()); + assertEquals("Deadline exceeded", exception.getMessage()); + assertSame(socketTimeoutException, exception.getCause()); + } + + IOException ioException = new IOException("ioe"); + mockClient.setNextException(ioException); + try { + call.invoke(datastore, callArgs); + fail(); + } catch (InvocationTargetException targetException) { + DatastoreException exception = (DatastoreException) targetException.getCause(); + assertEquals(Code.UNAVAILABLE, exception.getCode()); + assertEquals(methodName, exception.getMethodName()); + assertEquals("I/O error", exception.getMessage()); + assertSame(ioException, exception.getCause()); + } + + assertEquals(3, datastore.getRpcCount()); + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/DatastoreFactoryTest.java b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/DatastoreFactoryTest.java new file mode 100644 index 000000000000..51446f981a9f --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/DatastoreFactoryTest.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 + * + * 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.datastore.utils; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertTrue; + +import com.google.api.client.googleapis.auth.oauth2.GoogleCredential; +import com.google.api.client.http.HttpRequestFactory; +import com.google.api.client.http.javanet.NetHttpTransport; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Test for {@link DatastoreFactory}. */ +@RunWith(JUnit4.class) +public class DatastoreFactoryTest { + private static final String PROJECT_ID = "project-id"; + + private DatastoreFactory factory = DatastoreFactory.get(); + + /** + * Without specifying a credential or transport, the factory will create a default transport on + * its own. + */ + @Test + public void makeClient_Default() { + DatastoreOptions options = new DatastoreOptions.Builder().projectId(PROJECT_ID).build(); + HttpRequestFactory f = factory.makeClient(options); + assertNotNull(f.getTransport()); + assertTrue(f.getTransport() instanceof NetHttpTransport); + } + + /** + * Specifying a credential, but not a transport, the factory will use the transport from the + * credential. + */ + @Test + public void makeClient_WithCredential() { + NetHttpTransport transport = new NetHttpTransport(); + GoogleCredential credential = new GoogleCredential.Builder().setTransport(transport).build(); + DatastoreOptions options = + new DatastoreOptions.Builder().projectId(PROJECT_ID).credential(credential).build(); + HttpRequestFactory f = factory.makeClient(options); + assertEquals(transport, f.getTransport()); + } + + /** Specifying a transport, but not a credential, the factory will use the transport specified. */ + @Test + public void makeClient_WithTransport() { + NetHttpTransport transport = new NetHttpTransport(); + DatastoreOptions options = + new DatastoreOptions.Builder().projectId(PROJECT_ID).transport(transport).build(); + HttpRequestFactory f = factory.makeClient(options); + assertEquals(transport, f.getTransport()); + } + + /** + * Specifying both credential and transport, the factory will use the transport specified and not + * the one in the credential. + */ + @Test + public void makeClient_WithCredentialTransport() { + NetHttpTransport credTransport = new NetHttpTransport(); + NetHttpTransport transport = new NetHttpTransport(); + GoogleCredential credential = + new GoogleCredential.Builder().setTransport(credTransport).build(); + DatastoreOptions options = + new DatastoreOptions.Builder() + .projectId(PROJECT_ID) + .credential(credential) + .transport(transport) + .build(); + HttpRequestFactory f = factory.makeClient(options); + assertNotSame(credTransport, f.getTransport()); + assertEquals(transport, f.getTransport()); + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/DatastoreHelperTest.java b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/DatastoreHelperTest.java new file mode 100644 index 000000000000..db0949800f2d --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/DatastoreHelperTest.java @@ -0,0 +1,317 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import static com.google.datastore.utils.DatastoreHelper.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import com.google.datastore.v1.Key; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.Value; +import com.google.datastore.v1.Value.ValueTypeCase; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import java.util.Date; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link DatastoreHelper}. */ +@RunWith(JUnit4.class) +public class DatastoreHelperTest { + + private static final Key PARENT = + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Parent").setId(23L)).build(); + private static final Key GRANDPARENT = + Key.newBuilder() + .addPath(Key.PathElement.newBuilder().setKind("Grandparent").setId(24L)) + .build(); + private static final Key CHILD = + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Child").setId(26L)).build(); + + @Test + public void testMakeKey_BadTypeForKind() { + try { + DatastoreHelper.makeKey(new Object()); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + } + + @Test + public void testMakeKey_BadTypeForNameId() { + try { + DatastoreHelper.makeKey("kind", new Object()); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + } + + @Test + public void testMakeKey_Empty() { + assertEquals(Key.newBuilder().build(), DatastoreHelper.makeKey().build()); + } + + @Test + public void testMakeKey_Incomplete() { + assertEquals( + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Foo")).build(), + makeKey("Foo").build()); + } + + @Test + public void testMakeKey_IdInt() { + assertEquals( + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Foo").setId(1)).build(), + makeKey("Foo", 1).build()); + } + + @Test + public void testMakeKey_IdLong() { + assertEquals( + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Foo").setId(1)).build(), + makeKey("Foo", 1L).build()); + } + + @Test + public void testMakeKey_IdShort() { + assertEquals( + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Foo").setId(1)).build(), + makeKey("Foo", (short) 1).build()); + } + + @Test + public void testMakeKey_Name() { + assertEquals( + Key.newBuilder().addPath(Key.PathElement.newBuilder().setKind("Foo").setName("hi")).build(), + makeKey("Foo", "hi").build()); + } + + @Test + public void testMakeKey_KindNameKind() { + assertEquals( + Key.newBuilder() + .addPath(Key.PathElement.newBuilder().setKind("Foo").setName("hi")) + .addPath(Key.PathElement.newBuilder().setKind("Bar")) + .build(), + makeKey("Foo", "hi", "Bar").build()); + } + + @Test + public void testMakeKey_KeyKind() { + // 1 key at the beginning of the series + assertEquals( + Key.newBuilder() + .addPath(PARENT.getPath(0)) + .addPath(Key.PathElement.newBuilder().setKind("Child")) + .build(), + makeKey(PARENT, "Child").build()); + } + + @Test + public void testMakeKey_KindIdKeyKind() { + // 1 key in the middle of the series + assertEquals( + Key.newBuilder() + .addPath(Key.PathElement.newBuilder().setKind("Grandparent").setId(24L)) + .addPath(PARENT.getPath(0)) + .addPath(Key.PathElement.newBuilder().setKind("Child")) + .build(), + makeKey("Grandparent", 24L, PARENT, "Child").build()); + } + + @Test + public void testMakeKey_KindIdKey() { + // 1 key at the end of the series + assertEquals( + Key.newBuilder() + .addPath(Key.PathElement.newBuilder().setKind("Grandparent").setId(24L)) + .addPath(PARENT.getPath(0)) + .build(), + makeKey("Grandparent", 24L, PARENT).build()); + } + + @Test + public void testMakeKey_KeyKindIdKey() { + // 1 key at the beginning and 1 key at the end of the series + assertEquals( + Key.newBuilder() + .addPath(GRANDPARENT.getPath(0)) + .addPath(Key.PathElement.newBuilder().setKind("Parent").setId(23L)) + .addPath(CHILD.getPath(0)) + .build(), + makeKey(GRANDPARENT, "Parent", 23, CHILD).build()); + } + + @Test + public void testMakeKey_Key() { + // Just 1 key + assertEquals(Key.newBuilder().addPath(CHILD.getPath(0)).build(), makeKey(CHILD).build()); + } + + @Test + public void testMakeKey_KeyKey() { + // Just 2 keys + assertEquals( + Key.newBuilder().addPath(PARENT.getPath(0)).addPath(CHILD.getPath(0)).build(), + makeKey(PARENT, CHILD).build()); + } + + @Test + public void testMakeKey_KeyKeyKey() { + // Just 3 keys + assertEquals( + Key.newBuilder() + .addPath(GRANDPARENT.getPath(0)) + .addPath(PARENT.getPath(0)) + .addPath(CHILD.getPath(0)) + .build(), + makeKey(GRANDPARENT, PARENT, CHILD).build()); + } + + @Test + public void testMakeKey_KeyMultiLevelKey() { + // 1 key with 2 elements + assertEquals( + Key.newBuilder() + .addPath(GRANDPARENT.getPath(0)) + .addPath(PARENT.getPath(0)) + .addPath(CHILD.getPath(0)) + .build(), + makeKey(GRANDPARENT, makeKey(PARENT, CHILD).build()).build()); + } + + @Test + public void testMakeKey_MultiLevelKeyKey() { + // 1 key with 2 elements + assertEquals( + Key.newBuilder() + .addPath(GRANDPARENT.getPath(0)) + .addPath(PARENT.getPath(0)) + .addPath(CHILD.getPath(0)) + .build(), + makeKey(makeKey(GRANDPARENT, PARENT).build(), CHILD).build()); + } + + @Test + public void testMakeKey_MultiLevelKey() { + // 1 key with 3 elements + assertEquals( + Key.newBuilder() + .addPath(GRANDPARENT.getPath(0)) + .addPath(PARENT.getPath(0)) + .addPath(CHILD.getPath(0)) + .build(), + makeKey(makeKey(GRANDPARENT, PARENT, CHILD).build()).build()); + } + + @Test + public void testMakeKey_PartitionId() { + PartitionId partitionId = PartitionId.newBuilder().setNamespaceId("namespace-id").build(); + Key parent = PARENT.toBuilder().setPartitionId(partitionId).build(); + assertEquals( + Key.newBuilder() + .setPartitionId(partitionId) + .addPath(PARENT.getPath(0)) + .addPath(Key.PathElement.newBuilder().setKind("Child")) + .build(), + makeKey(parent, "Child").build()); + } + + @Test + public void testMakeKey_NonMatchingPartitionId2() { + PartitionId partitionId1 = PartitionId.newBuilder().setNamespaceId("namespace-id").build(); + PartitionId partitionId2 = + PartitionId.newBuilder().setNamespaceId("another-namespace-id").build(); + try { + makeKey( + PARENT.toBuilder().setPartitionId(partitionId1).build(), + CHILD.toBuilder().setPartitionId(partitionId2).build()); + fail("expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + } + + @Test + public void testMakeTimestampValue() throws Exception { + // Test cases with nanos == 0. + assertConversion(-50_000, -50, 0); + assertConversion(-1_000, -1, 0); + assertConversion(0, 0, 0); + assertConversion(1_000, 1, 0); + assertConversion(2_000, 2, 0); + assertConversion(100_000, 100, 0); + + // Test cases with nanos % 1_000_000 == 0 (no loss of precision). + assertConversion(2, 0, 2_000_000); + assertConversion(1_003, 1, 3_000_000); + assertConversion(2_005, 2, 5_000_000); + + // Timestamp specification requires that nanos >= 0 even if the timestamp + // is before the epoch. + assertConversion(0, 0, 0); + assertConversion(-250, -1, 750_000_000); // 1/4 second before epoch + assertConversion(-500, -1, 500_000_000); // 1/2 second before epoch + assertConversion(-750, -1, 250_000_000); // 3/4 second before epoch + + // If nanos % 1_000_000 != 0, precision is lost (via truncation) when + // converting to milliseconds. + assertTimestampToMilliseconds(3_100, 3, 100_000_999); + assertMillisecondsToTimestamp(3_100, 3, 100_000_000); + assertTimestampToMilliseconds(5_999, 5, 999_999_999); + assertMillisecondsToTimestamp(5_999, 5, 999_000_000); + assertTimestampToMilliseconds(7_100, 7, 100_000_001); + assertMillisecondsToTimestamp(7_100, 7, 100_000_000); + } + + private void assertConversion(long millis, long seconds, int nanos) { + assertMillisecondsToTimestamp(millis, seconds, nanos); + assertTimestampToMilliseconds(millis, seconds, nanos); + } + + private void assertMillisecondsToTimestamp(long millis, long seconds, long nanos) { + Value timestampValue = makeValue(new Date(millis)).build(); + assertEquals(ValueTypeCase.TIMESTAMP_VALUE, timestampValue.getValueTypeCase()); + assertEquals(seconds, timestampValue.getTimestampValue().getSeconds()); + assertEquals(nanos, timestampValue.getTimestampValue().getNanos()); + } + + private void assertTimestampToMilliseconds(long millis, long seconds, int nanos) { + Value.Builder value = + Value.newBuilder() + .setTimestampValue(Timestamp.newBuilder().setSeconds(seconds).setNanos(nanos)); + assertEquals(millis, DatastoreHelper.toDate(value.build()).getTime()); + } + + @Test + public void testProjectionHandling() { + assertEquals( + ByteString.copyFromUtf8("hi"), getByteString(makeValue("hi").setMeaning(18).build())); + try { + getByteString(makeValue("hi").build()); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + + assertEquals(new Date(1), toDate(makeValue(1000).setMeaning(18).build())); + try { + toDate(makeValue(1000).build()); + fail("Expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/QuerySplitterTest.java b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/QuerySplitterTest.java new file mode 100644 index 000000000000..d173576ae6a2 --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/QuerySplitterTest.java @@ -0,0 +1,365 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import static com.google.common.truth.Truth.assertThat; +import static com.google.datastore.utils.DatastoreHelper.*; +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertThrows; + +import com.google.datastore.utils.testing.MockCredential; +import com.google.datastore.utils.testing.MockDatastoreFactory; +import com.google.datastore.v1.*; +import com.google.datastore.v1.EntityResult.ResultType; +import com.google.datastore.v1.PropertyFilter.Operator; +import com.google.datastore.v1.PropertyOrder.Direction; +import com.google.datastore.v1.QueryResultBatch.MoreResultsType; +import com.google.protobuf.Int32Value; +import com.google.protobuf.Timestamp; +import java.util.List; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for {@link com.google.datastore.utils.QuerySplitterImpl}. */ +@RunWith(JUnit4.class) +public class QuerySplitterTest { + private static final String PROJECT_ID = "project-id"; + private static final PartitionId PARTITION = + PartitionId.newBuilder().setProjectId(PROJECT_ID).build(); + private static final String KIND = "test-kind"; + + private DatastoreFactory factory = new MockDatastoreFactory(); + private com.google.datastore.utils.DatastoreOptions.Builder options = + new DatastoreOptions.Builder().projectId(PROJECT_ID).credential(new MockCredential()); + + private Filter propertyFilter = makeFilter("foo", Operator.EQUAL, makeValue("value")).build(); + + private Query query = + Query.newBuilder() + .addKind(KindExpression.newBuilder().setName(KIND).build()) + .setFilter(propertyFilter) + .build(); + + private Query splitQuery = + Query.newBuilder() + .addKind(KindExpression.newBuilder().setName(KIND).build()) + .addOrder(makeOrder("__scatter__", Direction.ASCENDING)) + .addProjection(Projection.newBuilder().setProperty(makePropertyReference("__key__"))) + .build(); + + private Key splitKey0 = makeKey(KIND, String.format("%05d", 1)).setPartitionId(PARTITION).build(); + private Key splitKey1 = + makeKey(KIND, String.format("%05d", 101)).setPartitionId(PARTITION).build(); + private Key splitKey2 = + makeKey(KIND, String.format("%05d", 201)).setPartitionId(PARTITION).build(); + private Key splitKey3 = + makeKey(KIND, String.format("%05d", 301)).setPartitionId(PARTITION).build(); + + @Test + public void disallowsSortOrder() { + com.google.datastore.utils.Datastore datastore = factory.create(options.build()); + Query queryWithOrder = + query.toBuilder().addOrder(makeOrder("bar", Direction.ASCENDING)).build(); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + com.google.datastore.utils.QuerySplitterImpl.INSTANCE.getSplits( + queryWithOrder, PARTITION, 2, datastore)); + assertThat(exception).hasMessageThat().contains("Query cannot have any sort orders."); + } + + @Test + public void disallowsMultipleKinds() { + com.google.datastore.utils.Datastore datastore = factory.create(options.build()); + Query queryWithMultipleKinds = + query.toBuilder() + .addKind(KindExpression.newBuilder().setName("another-kind").build()) + .build(); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + com.google.datastore.utils.QuerySplitterImpl.INSTANCE.getSplits( + queryWithMultipleKinds, PARTITION, 2, datastore)); + assertThat(exception).hasMessageThat().contains("Query must have exactly one kind."); + } + + @Test + public void disallowsKindlessQuery() { + com.google.datastore.utils.Datastore datastore = factory.create(options.build()); + Query kindlessQuery = query.toBuilder().clearKind().build(); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + com.google.datastore.utils.QuerySplitterImpl.INSTANCE.getSplits( + kindlessQuery, PARTITION, 2, datastore)); + assertThat(exception).hasMessageThat().contains("Query must have exactly one kind."); + } + + @Test + public void disallowsInequalityFilter() { + com.google.datastore.utils.Datastore datastore = factory.create(options.build()); + Query queryWithInequality = + query.toBuilder() + .setFilter(makeFilter("foo", Operator.GREATER_THAN, makeValue("value"))) + .build(); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + com.google.datastore.utils.QuerySplitterImpl.INSTANCE.getSplits( + queryWithInequality, PARTITION, 2, datastore)); + assertThat(exception).hasMessageThat().contains("Query cannot have any inequality filters."); + } + + @Test + public void splitsMustBePositive() { + com.google.datastore.utils.Datastore datastore = factory.create(options.build()); + IllegalArgumentException exception = + assertThrows( + IllegalArgumentException.class, + () -> + com.google.datastore.utils.QuerySplitterImpl.INSTANCE.getSplits( + query, PARTITION, 0, datastore)); + assertThat(exception).hasMessageThat().contains("The number of splits must be greater than 0."); + } + + @Test + public void getSplits() throws Exception { + com.google.datastore.utils.Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + + RunQueryResponse splitQueryResponse = + RunQueryResponse.newBuilder() + .setQuery(splitQuery) + .setBatch( + QueryResultBatch.newBuilder() + .setEntityResultType(ResultType.KEY_ONLY) + .setMoreResults(MoreResultsType.NO_MORE_RESULTS) + .addEntityResults(makeKeyOnlyEntity(splitKey0)) + .addEntityResults(makeKeyOnlyEntity(splitKey1)) + .addEntityResults(makeKeyOnlyEntity(splitKey2)) + .addEntityResults(makeKeyOnlyEntity(splitKey3)) + .build()) + .build(); + + mockClient.setNextResponse(splitQueryResponse); + + List splittedQueries = + com.google.datastore.utils.QuerySplitterImpl.INSTANCE.getSplits( + query, PARTITION, 3, datastore); + + assertThat(splittedQueries) + .containsExactly( + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, null, splitKey1)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey1, splitKey3)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey3, null)) + .build()); + + RunQueryRequest expectedSplitQueryRequest = + RunQueryRequest.newBuilder() + .setPartitionId(PARTITION) + .setProjectId(PROJECT_ID) + .setQuery( + splitQuery.toBuilder().setLimit(Int32Value.newBuilder().setValue(2 * 32).build())) + .build(); + + assertArrayEquals(expectedSplitQueryRequest.toByteArray(), mockClient.getLastBody()); + } + + @Test + public void getSplitsWithDatabaseId() throws Exception { + com.google.datastore.utils.Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + + PartitionId partition = + PartitionId.newBuilder().setProjectId(PROJECT_ID).setDatabaseId("test-database").build(); + + RunQueryResponse splitQueryResponse = + RunQueryResponse.newBuilder() + .setQuery(splitQuery) + .setBatch( + QueryResultBatch.newBuilder() + .setEntityResultType(ResultType.KEY_ONLY) + .setMoreResults(MoreResultsType.NO_MORE_RESULTS) + .addEntityResults(makeKeyOnlyEntity(splitKey0)) + .addEntityResults(makeKeyOnlyEntity(splitKey1)) + .addEntityResults(makeKeyOnlyEntity(splitKey2)) + .addEntityResults(makeKeyOnlyEntity(splitKey3)) + .build()) + .build(); + + mockClient.setNextResponse(splitQueryResponse); + + List splitQueries = + com.google.datastore.utils.QuerySplitterImpl.INSTANCE.getSplits( + query, partition, 3, datastore); + + assertThat(splitQueries) + .containsExactly( + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, null, splitKey1)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey1, splitKey3)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey3, null)) + .build()); + + RunQueryRequest expectedSplitQueryRequest = + RunQueryRequest.newBuilder() + .setPartitionId(partition) + .setProjectId(PROJECT_ID) + .setDatabaseId("test-database") + .setQuery( + splitQuery.toBuilder().setLimit(Int32Value.newBuilder().setValue(2 * 32).build())) + .build(); + + assertArrayEquals(expectedSplitQueryRequest.toByteArray(), mockClient.getLastBody()); + } + + @Test + public void notEnoughSplits() throws Exception { + com.google.datastore.utils.Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + + RunQueryResponse splitQueryResponse = + RunQueryResponse.newBuilder() + .setQuery(splitQuery) + .setBatch( + QueryResultBatch.newBuilder() + .setEntityResultType(ResultType.KEY_ONLY) + .setMoreResults(MoreResultsType.NO_MORE_RESULTS) + .addEntityResults(makeKeyOnlyEntity(splitKey0)) + .build()) + .build(); + + mockClient.setNextResponse(splitQueryResponse); + + List splittedQueries = + com.google.datastore.utils.QuerySplitterImpl.INSTANCE.getSplits( + query, PARTITION, 100, datastore); + + assertThat(splittedQueries) + .containsExactly( + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, null, splitKey0)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey0, null)) + .build()); + + RunQueryRequest expectedSplitQueryRequest = + RunQueryRequest.newBuilder() + .setPartitionId(PARTITION) + .setProjectId(PROJECT_ID) + .setQuery( + splitQuery.toBuilder().setLimit(Int32Value.newBuilder().setValue(99 * 32).build())) + .build(); + + assertArrayEquals(expectedSplitQueryRequest.toByteArray(), mockClient.getLastBody()); + } + + @Test + public void getSplits_withReadTime() throws Exception { + Datastore datastore = factory.create(options.build()); + MockDatastoreFactory mockClient = (MockDatastoreFactory) factory; + + RunQueryResponse splitQueryResponse = + RunQueryResponse.newBuilder() + .setQuery(splitQuery) + .setBatch( + QueryResultBatch.newBuilder() + .setEntityResultType(ResultType.KEY_ONLY) + .setMoreResults(MoreResultsType.NO_MORE_RESULTS) + .addEntityResults(makeKeyOnlyEntity(splitKey0)) + .addEntityResults(makeKeyOnlyEntity(splitKey1)) + .addEntityResults(makeKeyOnlyEntity(splitKey2)) + .addEntityResults(makeKeyOnlyEntity(splitKey3)) + .build()) + .build(); + + mockClient.setNextResponse(splitQueryResponse); + + Timestamp readTime = Timestamp.newBuilder().setSeconds(1654651341L).build(); + + List splittedQueries = + com.google.datastore.utils.QuerySplitterImpl.INSTANCE.getSplits( + query, PARTITION, 3, datastore, readTime); + + assertThat(splittedQueries) + .containsExactly( + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, null, splitKey1)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey1, splitKey3)) + .build(), + query.toBuilder() + .setFilter(makeFilterWithKeyRange(propertyFilter, splitKey3, null)) + .build()); + + RunQueryRequest expectedSplitQueryRequest = + RunQueryRequest.newBuilder() + .setPartitionId(PARTITION) + .setProjectId(PROJECT_ID) + .setQuery( + splitQuery.toBuilder().setLimit(Int32Value.newBuilder().setValue(2 * 32).build())) + .setReadOptions(ReadOptions.newBuilder().setReadTime(readTime)) + .build(); + + assertArrayEquals(expectedSplitQueryRequest.toByteArray(), mockClient.getLastBody()); + } + + private static EntityResult makeKeyOnlyEntity(Key key) { + return EntityResult.newBuilder().setEntity(Entity.newBuilder().setKey(key).build()).build(); + } + + private static Filter makeFilterWithKeyRange(Filter originalFilter, Key startKey, Key endKey) { + Filter startKeyFilter = + startKey == null + ? null + : makeFilter("__key__", Operator.GREATER_THAN_OR_EQUAL, makeValue(startKey)).build(); + + Filter endKeyFilter = + endKey == null + ? null + : makeFilter("__key__", Operator.LESS_THAN, makeValue(endKey)).build(); + + if (startKeyFilter == null && endKeyFilter == null) { + throw new IllegalArgumentException(); + } + + if (startKeyFilter != null && endKeyFilter == null) { + return makeAndFilter(originalFilter, startKeyFilter).build(); + } + + if (startKeyFilter == null && endKeyFilter != null) { + return makeAndFilter(originalFilter, endKeyFilter).build(); + } + + return makeAndFilter(originalFilter, startKeyFilter, endKeyFilter).build(); + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/RemoteRpcTest.java b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/RemoteRpcTest.java new file mode 100644 index 000000000000..09e750d0712a --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/RemoteRpcTest.java @@ -0,0 +1,341 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.utils; + +import static org.junit.Assert.*; + +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpTransport; +import com.google.api.client.http.LowLevelHttpRequest; +import com.google.api.client.http.LowLevelHttpResponse; +import com.google.api.client.http.protobuf.ProtoHttpContent; +import com.google.api.client.util.Charsets; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.protobuf.ByteString; +import com.google.protobuf.MessageLite; +import com.google.rpc.Code; +import com.google.rpc.Status; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.zip.GZIPOutputStream; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Test for {@link RemoteRpc}. */ +@RunWith(JUnit4.class) +public class RemoteRpcTest { + + private static final String METHOD_NAME = "methodName"; + + @Test + public void testException() { + Status statusProto = + Status.newBuilder() + .setCode(Code.UNAUTHENTICATED_VALUE) + .setMessage("The request does not have valid authentication credentials.") + .build(); + DatastoreException exception = + RemoteRpc.makeException( + "url", + METHOD_NAME, + new ByteArrayInputStream(statusProto.toByteArray()), + "application/x-protobuf", + Charsets.UTF_8, + new RuntimeException(), + 401); + assertEquals(Code.UNAUTHENTICATED, exception.getCode()); + assertEquals( + "The request does not have valid authentication credentials.", exception.getMessage()); + assertEquals(METHOD_NAME, exception.getMethodName()); + } + + @Test + public void testInvalidProtoException() { + DatastoreException exception = + RemoteRpc.makeException( + "url", + METHOD_NAME, + new ByteArrayInputStream("".getBytes()), + "application/x-protobuf", + Charsets.UTF_8, + new RuntimeException(), + 401); + assertEquals(Code.INTERNAL, exception.getCode()); + assertEquals( + "Unable to parse Status protocol buffer: HTTP status code was 401.", + exception.getMessage()); + assertEquals(METHOD_NAME, exception.getMethodName()); + } + + @Test + public void testEmptyProtoException() { + Status statusProto = Status.newBuilder().build(); + DatastoreException exception = + RemoteRpc.makeException( + "url", + METHOD_NAME, + new ByteArrayInputStream(statusProto.toByteArray()), + "application/x-protobuf", + Charsets.UTF_8, + new RuntimeException(), + 404); + assertEquals(Code.INTERNAL, exception.getCode()); + assertEquals( + "Unexpected OK error code with HTTP status code of 404. Message: .", + exception.getMessage()); + assertEquals(METHOD_NAME, exception.getMethodName()); + } + + @Test + public void testEmptyProtoExceptionUnauthenticated() { + Status statusProto = Status.newBuilder().build(); + DatastoreException exception = + RemoteRpc.makeException( + "url", + METHOD_NAME, + new ByteArrayInputStream(statusProto.toByteArray()), + "application/x-protobuf", + Charsets.UTF_8, + new RuntimeException(), + 401); + assertEquals(Code.UNAUTHENTICATED, exception.getCode()); + assertEquals("Unauthenticated.", exception.getMessage()); + assertEquals(METHOD_NAME, exception.getMethodName()); + } + + @Test + public void testPlainTextException() { + DatastoreException exception = + RemoteRpc.makeException( + "url", + METHOD_NAME, + new ByteArrayInputStream("Text Error".getBytes()), + "text/plain", + Charsets.UTF_8, + new RuntimeException(), + 401); + assertEquals(Code.INTERNAL, exception.getCode()); + assertEquals( + "Non-protobuf error: Text Error. HTTP status code was 401.", exception.getMessage()); + assertEquals(METHOD_NAME, exception.getMethodName()); + } + + @Test + public void testGzip() throws IOException, DatastoreException { + BeginTransactionResponse response = newBeginTransactionResponse(); + InjectedTestValues injectedTestValues = + new InjectedTestValues(gzip(response), new byte[1], true); + RemoteRpc rpc = newRemoteRpc(injectedTestValues); + + InputStream is = + rpc.call("beginTransaction", BeginTransactionResponse.getDefaultInstance(), "", ""); + BeginTransactionResponse parsedResponse = BeginTransactionResponse.parseFrom(is); + is.close(); + + assertEquals(response, parsedResponse); + // Check that the underlying stream is exhausted. + assertEquals(-1, injectedTestValues.inputStream.read()); + } + + @Test + public void testHttpHeaders_apiFormat() throws IOException { + String projectId = "project-id"; + MessageLite request = + RollbackRequest.newBuilder().setTransaction(ByteString.copyFromUtf8(projectId)).build(); + RemoteRpc rpc = + newRemoteRpc( + new InjectedTestValues(gzip(newBeginTransactionResponse()), new byte[1], true)); + HttpRequest httpRequest = + rpc.getClient().buildPostRequest(rpc.resolveURL("blah"), new ProtoHttpContent(request)); + rpc.setHeaders(request, httpRequest, projectId, ""); + assertNotNull( + httpRequest.getHeaders().getFirstHeaderStringValue(RemoteRpc.API_FORMAT_VERSION_HEADER)); + } + + @Test + public void testHttpHeaders_prefixHeader() throws IOException { + String projectId = "my-project"; + String databaseId = "my-db"; + MessageLite request = + RollbackRequest.newBuilder() + .setTransaction(ByteString.copyFromUtf8(projectId)) + .setDatabaseId(databaseId) + .build(); + RemoteRpc rpc = + newRemoteRpc( + new InjectedTestValues(gzip(newBeginTransactionResponse()), new byte[1], true)); + HttpRequest httpRequest = + rpc.getClient().buildPostRequest(rpc.resolveURL("blah"), new ProtoHttpContent(request)); + rpc.setHeaders(request, httpRequest, projectId, databaseId); + assertEquals( + "project_id=my-project&database_id=my-db", + httpRequest.getHeaders().get(RemoteRpc.X_GOOG_REQUEST_PARAMS_HEADER)); + + MessageLite request2 = + RollbackRequest.newBuilder().setTransaction(ByteString.copyFromUtf8(projectId)).build(); + RemoteRpc rpc2 = + newRemoteRpc( + new InjectedTestValues(gzip(newBeginTransactionResponse()), new byte[1], true)); + HttpRequest httpRequest2 = + rpc2.getClient().buildPostRequest(rpc2.resolveURL("blah"), new ProtoHttpContent(request2)); + rpc2.setHeaders(request, httpRequest2, projectId, ""); + assertEquals( + "project_id=my-project", + httpRequest2.getHeaders().get(RemoteRpc.X_GOOG_REQUEST_PARAMS_HEADER)); + } + + private static BeginTransactionResponse newBeginTransactionResponse() { + return BeginTransactionResponse.newBuilder() + .setTransaction(ByteString.copyFromUtf8("blah-blah-blah")) + .build(); + } + + private static RemoteRpc newRemoteRpc(InjectedTestValues injectedTestValues) { + return new RemoteRpc( + new MyHttpTransport(injectedTestValues).createRequestFactory(), + null, + "https://www.example.com/v1/projects/p"); + } + + private byte[] gzip(BeginTransactionResponse response) throws IOException { + ByteArrayOutputStream bytesOut = new ByteArrayOutputStream(); + try (GZIPOutputStream gzipOut = new GZIPOutputStream(bytesOut)) { + response.writeTo(gzipOut); + } + return bytesOut.toByteArray(); + } + + private static class InjectedTestValues { + private final InputStream inputStream; + private final int contentLength; + private final boolean isGzip; + + public InjectedTestValues(byte[] messageBytes, byte[] additionalBytes, boolean isGzip) { + byte[] allBytes = concat(messageBytes, additionalBytes); + this.inputStream = new ByteArrayInputStream(allBytes); + this.contentLength = allBytes.length; + this.isGzip = isGzip; + } + + private static byte[] concat(byte[] a, byte[] b) { + byte[] c = new byte[a.length + b.length]; + System.arraycopy(a, 0, c, 0, a.length); + System.arraycopy(b, 0, c, a.length, b.length); + return c; + } + } + + /** {@link HttpTransport} that allows injection of the returned {@link LowLevelHttpRequest}. */ + private static class MyHttpTransport extends HttpTransport { + + private final InjectedTestValues injectedTestValues; + + public MyHttpTransport(InjectedTestValues injectedTestValues) { + this.injectedTestValues = injectedTestValues; + } + + @Override + protected LowLevelHttpRequest buildRequest(String method, String url) throws IOException { + return new MyLowLevelHttpRequest(injectedTestValues); + } + } + + /** + * {@link LowLevelHttpRequest} that allows injection of the returned {@link LowLevelHttpResponse}. + */ + private static class MyLowLevelHttpRequest extends LowLevelHttpRequest { + + private final InjectedTestValues injectedTestValues; + + public MyLowLevelHttpRequest(InjectedTestValues injectedTestValues) { + this.injectedTestValues = injectedTestValues; + } + + @Override + public void addHeader(String name, String value) throws IOException { + // Do nothing. + } + + @Override + public LowLevelHttpResponse execute() throws IOException { + return new MyLowLevelHttpResponse(injectedTestValues); + } + } + + /** {@link LowLevelHttpResponse} that allows injected properties. */ + private static class MyLowLevelHttpResponse extends LowLevelHttpResponse { + + private final InjectedTestValues injectedTestValues; + + public MyLowLevelHttpResponse(InjectedTestValues injectedTestValues) { + this.injectedTestValues = injectedTestValues; + } + + @Override + public InputStream getContent() throws IOException { + return injectedTestValues.inputStream; + } + + @Override + public String getContentEncoding() throws IOException { + return injectedTestValues.isGzip ? "gzip" : ""; + } + + @Override + public long getContentLength() throws IOException { + return injectedTestValues.contentLength; + } + + @Override + public String getContentType() throws IOException { + return "application/x-protobuf"; + } + + @Override + public String getStatusLine() throws IOException { + return null; + } + + @Override + public int getStatusCode() throws IOException { + return 200; + } + + @Override + public String getReasonPhrase() throws IOException { + return null; + } + + @Override + public int getHeaderCount() throws IOException { + return 0; + } + + @Override + public String getHeaderName(int index) throws IOException { + return null; + } + + @Override + public String getHeaderValue(int index) throws IOException { + return null; + } + } +} diff --git a/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/it/ITDatastoreProtoClientTest.java b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/it/ITDatastoreProtoClientTest.java new file mode 100644 index 000000000000..ae983cb9557e --- /dev/null +++ b/java-datastore/google-cloud-datastore-utils/src/test/java/com/google/datastore/utils/it/ITDatastoreProtoClientTest.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 + * + * 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.datastore.utils.it; + +import static com.google.datastore.utils.DatastoreHelper.makeFilter; +import static com.google.datastore.utils.DatastoreHelper.makeValue; + +import com.google.common.truth.Truth; +import com.google.datastore.utils.Datastore; +import com.google.datastore.utils.DatastoreException; +import com.google.datastore.utils.DatastoreHelper; +import com.google.datastore.v1.*; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.util.List; +import org.junit.Before; +import org.junit.Test; + +public class ITDatastoreProtoClientTest { + + private static Datastore DATASTORE; + + private static PartitionId PARTITION; + + private static final String KIND = "test-kind"; + private static final String PROJECT_ID = System.getenv(DatastoreHelper.PROJECT_ID_ENV_VAR); + + @Before + public void setUp() throws GeneralSecurityException, IOException { + DATASTORE = DatastoreHelper.getDatastoreFromEnv(); + } + + @Test + public void testQuerySplitterWithDefaultDb() throws DatastoreException { + Filter propertyFilter = + makeFilter("foo", PropertyFilter.Operator.EQUAL, makeValue("value")).build(); + Query query = + Query.newBuilder() + .addKind(KindExpression.newBuilder().setName(KIND).build()) + .setFilter(propertyFilter) + .build(); + + PARTITION = PartitionId.newBuilder().setProjectId(PROJECT_ID).build(); + + List splits = + DatastoreHelper.getQuerySplitter().getSplits(query, PARTITION, 2, DATASTORE); + Truth.assertThat(splits).isNotEmpty(); + splits.forEach( + split -> { + Truth.assertThat(split.getKind(0).getName()).isEqualTo(KIND); + Truth.assertThat(split.getFilter()).isEqualTo(propertyFilter); + }); + } + + @Test + public void testQuerySplitterWithDb() throws DatastoreException { + Filter propertyFilter = + makeFilter("foo", PropertyFilter.Operator.EQUAL, makeValue("value")).build(); + Query query = + Query.newBuilder() + .addKind(KindExpression.newBuilder().setName(KIND).build()) + .setFilter(propertyFilter) + .build(); + + PARTITION = PartitionId.newBuilder().setProjectId(PROJECT_ID).setDatabaseId("test-db").build(); + + List splits = + DatastoreHelper.getQuerySplitter().getSplits(query, PARTITION, 2, DATASTORE); + + Truth.assertThat(splits).isNotEmpty(); + splits.forEach( + split -> { + Truth.assertThat(split.getKind(0).getName()).isEqualTo(KIND); + Truth.assertThat(split.getFilter()).isEqualTo(propertyFilter); + }); + } +} diff --git a/java-datastore/google-cloud-datastore/clirr-ignored-differences.xml b/java-datastore/google-cloud-datastore/clirr-ignored-differences.xml new file mode 100644 index 000000000000..d1e3a4ff4458 --- /dev/null +++ b/java-datastore/google-cloud-datastore/clirr-ignored-differences.xml @@ -0,0 +1,106 @@ + + + + + + com/google/cloud/datastore/ReadOption$QueryAndReadOptions + * + 8001 + + + com/google/cloud/datastore/execution/request/AggregationQueryRequestProtoPreparer + *QueryAndReadOptions* + *QueryConfig* + 7005 + + + + com/google/cloud/datastore/DatastoreException + 5000 + com/google/cloud/grpc/BaseGrpcServiceException + + + + com/google/cloud/datastore/DatastoreException + 5001 + com/google/cloud/http/BaseHttpServiceException + + + com/google/cloud/datastore/Datastore + void close() + 7012 + + + com/google/cloud/datastore/spi/v1/DatastoreRpc + void close() + 7012 + + + com/google/cloud/datastore/Datastore + boolean isClosed() + 7012 + + + com/google/cloud/datastore/spi/v1/DatastoreRpc + boolean isClosed() + 7012 + + + com/google/cloud/datastore/Datastore + com.google.cloud.datastore.QueryResults run(com.google.cloud.datastore.Query, com.google.cloud.datastore.models.ExplainOptions, com.google.cloud.datastore.ReadOption[]) + 7012 + + + com/google/cloud/datastore/Datastore + com.google.cloud.datastore.AggregationResults runAggregation(com.google.cloud.datastore.AggregationQuery, com.google.cloud.datastore.models.ExplainOptions, com.google.cloud.datastore.ReadOption[]) + 7012 + + + com/google/cloud/datastore/DatastoreReader + com.google.cloud.datastore.AggregationResults runAggregation(com.google.cloud.datastore.AggregationQuery, com.google.cloud.datastore.models.ExplainOptions) + 7012 + + + com/google/cloud/datastore/QueryResults + java.util.Optional getExplainMetrics() + 7012 + + + com/google/cloud/datastore/Transaction + com.google.cloud.datastore.QueryResults run(com.google.cloud.datastore.Query, com.google.cloud.datastore.models.ExplainOptions) + 7012 + + + + com/google/cloud/datastore/execution/AggregationQueryExecutor + com.google.cloud.datastore.AggregationResults execute(com.google.cloud.datastore.AggregationQuery, com.google.cloud.datastore.ReadOption[]) + 7004 + + + com/google/cloud/datastore/execution/AggregationQueryExecutor + java.lang.Object execute(com.google.cloud.datastore.Query, com.google.cloud.datastore.ReadOption[]) + 7004 + + + com/google/cloud/datastore/execution/QueryExecutor + java.lang.Object execute(com.google.cloud.datastore.Query, com.google.cloud.datastore.ReadOption[]) + 7004 + + + com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecorator + RetryAndTraceDatastoreRpcDecorator(com.google.cloud.datastore.spi.v1.DatastoreRpc, com.google.cloud.datastore.TraceUtil, com.google.api.gax.retrying.RetrySettings, com.google.cloud.datastore.DatastoreOptions) + RetryAndTraceDatastoreRpcDecorator(com.google.cloud.datastore.spi.v1.DatastoreRpc, com.google.cloud.datastore.telemetry.TraceUtil, com.google.api.gax.retrying.RetrySettings, com.google.cloud.datastore.DatastoreOptions) + 7005 + + + + + com/google/cloud/datastore/TraceUtil + 8001 + + + com/google/cloud/datastore/testing/RemoteDatastoreHelper + 8001 + + + diff --git a/java-datastore/google-cloud-datastore/pom.xml b/java-datastore/google-cloud-datastore/pom.xml new file mode 100644 index 000000000000..fe82b404848d --- /dev/null +++ b/java-datastore/google-cloud-datastore/pom.xml @@ -0,0 +1,317 @@ + + + 4.0.0 + google-cloud-datastore + 2.33.2 + jar + Google Cloud Datastore + https://github.com/googleapis/java-datastore + + Java idiomatic client for Google Cloud Datastore. + + + com.google.cloud + google-cloud-datastore-parent + 2.33.2 + + + google-cloud-datastore + + + + + + com.google.cloud + gapic-libraries-bom + 1.61.0 + pom + import + + + + + + com.google.api.grpc + grpc-google-cloud-datastore-v1 + + + com.google.api.grpc + grpc-google-cloud-datastore-admin-v1 + + + com.google.cloud + google-cloud-core-http + + + com.google.cloud + google-cloud-core-grpc + + + com.google.api.grpc + proto-google-cloud-datastore-v1 + + + com.google.api.grpc + proto-google-cloud-datastore-admin-v1 + + + com.google.cloud.datastore + datastore-v1-proto-client + + + com.google.auth + google-auth-library-credentials + + + io.grpc + grpc-api + + + io.grpc + grpc-protobuf + + + io.grpc + grpc-stub + + + com.google.api + api-common + + + org.threeten + threetenbp + + + com.google.protobuf + protobuf-java + + + com.google.api + gax + + + com.google.api + gax-grpc + + + com.google.api + gax-httpjson + + + com.google.guava + guava + + + com.google.cloud + google-cloud-core + + + com.google.api.grpc + proto-google-common-protos + + + com.google.http-client + google-http-client + + + com.google.http-client + google-http-client-jackson2 + + + com.google.oauth-client + google-oauth-client + + + com.google.auth + google-auth-library-oauth2-http + + + io.opencensus + opencensus-api + + + com.google.code.findbugs + jsr305 + + + + + io.opentelemetry + opentelemetry-api + + + io.opentelemetry + opentelemetry-context + + + io.opentelemetry.instrumentation + opentelemetry-grpc-1.6 + + + + + + ${project.groupId} + google-cloud-core + test-jar + test + + + com.google.guava + guava-testlib + 33.4.0-jre + test + + + + com.google.api + gax + testlib + test + + + com.google.api + gax-grpc + testlib + test + + + com.google.api + gax-httpjson + testlib + test + + + junit + junit + test + + + org.easymock + easymock + test + + + com.google.truth + truth + 1.4.4 + test + + + com.google.testparameterinjector + test-parameter-injector + 1.17 + test + + + + io.opentelemetry + opentelemetry-sdk + test + + + io.opentelemetry + opentelemetry-sdk-common + test + + + io.opentelemetry + opentelemetry-sdk-testing + test + + + io.opentelemetry + opentelemetry-sdk-trace + test + + + io.opentelemetry + opentelemetry-semconv + 1.1.0-alpha + test + + + + + com.google.cloud.opentelemetry + exporter-trace + 0.15.0 + test + + + com.google.cloud + google-cloud-trace + test + + + com.google.api.grpc + proto-google-cloud-trace-v1 + test + + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + + + native + + + com.google.cloud.datastore.it.ITDatastoreConceptsTest + + + + java17 + + [17,) + + + + + org.apache.maven.plugins + maven-compiler-plugin + + UTF-8 + true + + -XDcompilePolicy=simple + --should-stop=ifError=FLOW + -Xplugin:ErrorProne -XepExcludedPaths:.*/generated-sources/.* + + -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED + + + + + com.google.errorprone + error_prone_core + ${error-prone.version} + + + + + + + + + diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/AggregationQuery.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/AggregationQuery.java new file mode 100644 index 000000000000..d54b40f1283b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/AggregationQuery.java @@ -0,0 +1,187 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import static com.google.cloud.datastore.AggregationQuery.Mode.GQL; +import static com.google.cloud.datastore.AggregationQuery.Mode.STRUCTURED; +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.cloud.datastore.aggregation.Aggregation; +import com.google.cloud.datastore.aggregation.AggregationBuilder; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +/** + * An implementation of a Google Cloud Datastore Query that returns {@link AggregationResults}, It + * can be constructed by providing a nested query ({@link StructuredQuery} or {@link GqlQuery}) to + * run the aggregations on and a set of {@link Aggregation}. + * + *

{@link StructuredQuery} example: + * + *

{@code
+ * EntityQuery selectAllQuery = Query.newEntityQueryBuilder()
+ *    .setKind("Task")
+ *    .build();
+ * AggregationQuery aggregationQuery = Query.newAggregationQueryBuilder()
+ *    .addAggregation(count().as("total_count"))
+ *    .over(selectAllQuery)
+ *    .build();
+ * AggregationResults aggregationResults = datastore.runAggregation(aggregationQuery);
+ * for (AggregationResult aggregationResult : aggregationResults) {
+ *     System.out.println(aggregationResult.get("total_count"));
+ * }
+ * }
+ * + *

{@link GqlQuery} example: + * + *

{@code
+ * GqlQuery selectAllGqlQuery = Query.newGqlQueryBuilder(
+ *         "AGGREGATE COUNT(*) AS total_count, COUNT_UP_TO(100) AS count_upto_100 OVER(SELECT * FROM Task)"
+ *     )
+ *     .setAllowLiteral(true)
+ *     .build();
+ * AggregationQuery aggregationQuery = Query.newAggregationQueryBuilder()
+ *     .over(selectAllGqlQuery)
+ *     .build();
+ * AggregationResults aggregationResults = datastore.runAggregation(aggregationQuery);
+ * for (AggregationResult aggregationResult : aggregationResults) {
+ *   System.out.println(aggregationResult.get("total_count"));
+ *   System.out.println(aggregationResult.get("count_upto_100"));
+ * }
+ * }
+ * + * @see Datastore + * queries + */ +public class AggregationQuery extends Query { + + private Set aggregations; + private StructuredQuery nestedStructuredQuery; + private final Mode mode; + private GqlQuery nestedGqlQuery; + + AggregationQuery( + String namespace, Set aggregations, StructuredQuery nestedQuery) { + super(namespace); + checkArgument( + !aggregations.isEmpty(), + "At least one aggregation is required for an aggregation query to run"); + this.aggregations = aggregations; + this.nestedStructuredQuery = nestedQuery; + this.mode = STRUCTURED; + } + + AggregationQuery(String namespace, GqlQuery gqlQuery) { + super(namespace); + this.nestedGqlQuery = gqlQuery; + this.mode = GQL; + } + + /** Returns the {@link Aggregation}(s) for this Query. */ + public Set getAggregations() { + return aggregations; + } + + /** + * Returns the underlying {@link StructuredQuery for this Query}. Returns null if created with + * {@link GqlQuery} + */ + public StructuredQuery getNestedStructuredQuery() { + return nestedStructuredQuery; + } + + /** + * Returns the underlying {@link GqlQuery for this Query}. Returns null if created with {@link + * StructuredQuery} + */ + public GqlQuery getNestedGqlQuery() { + return nestedGqlQuery; + } + + /** Returns the {@link Mode} for this query. */ + public Mode getMode() { + return mode; + } + + public static class Builder { + + private String namespace; + private Mode mode; + private final Set aggregations; + private StructuredQuery nestedStructuredQuery; + private GqlQuery nestedGqlQuery; + + public Builder() { + this.aggregations = new HashSet<>(); + } + + public Builder setNamespace(String namespace) { + this.namespace = namespace; + return this; + } + + public Builder addAggregation(AggregationBuilder aggregationBuilder) { + this.aggregations.add(aggregationBuilder.build()); + return this; + } + + public Builder addAggregation(Aggregation aggregation) { + this.aggregations.add(aggregation); + return this; + } + + public Builder addAggregations(AggregationBuilder... aggregationBuilders) { + for (AggregationBuilder builder : aggregationBuilders) { + this.aggregations.add(builder.build()); + } + return this; + } + + public Builder addAggregations(Aggregation... aggregations) { + this.aggregations.addAll(Arrays.asList(aggregations)); + return this; + } + + public Builder over(StructuredQuery nestedQuery) { + this.nestedStructuredQuery = nestedQuery; + this.mode = STRUCTURED; + return this; + } + + public Builder over(GqlQuery nestedQuery) { + this.nestedGqlQuery = nestedQuery; + this.mode = GQL; + return this; + } + + public AggregationQuery build() { + boolean nestedQueryProvided = nestedGqlQuery != null || nestedStructuredQuery != null; + checkArgument( + nestedQueryProvided, "Nested query is required for an aggregation query to run"); + + if (mode == GQL) { + return new AggregationQuery(namespace, nestedGqlQuery); + } + return new AggregationQuery(namespace, aggregations, nestedStructuredQuery); + } + } + + public enum Mode { + STRUCTURED, + GQL, + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/AggregationResult.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/AggregationResult.java new file mode 100644 index 000000000000..aa9f1ad8bdc1 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/AggregationResult.java @@ -0,0 +1,132 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import com.google.api.core.ObsoleteApi; +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Objects; + +/** Represents a result of an {@link AggregationQuery} query submission. */ +public class AggregationResult { + + private final Map> properties; + + public AggregationResult(Map> properties) { + this.properties = properties; + } + + /** + * Returns a result value for the given alias. {@link #getLong(String)} is preferred over this + * method, Use {@link #getLong(String)} wherever possible. + * + * @param alias A custom alias provided in the query or an autogenerated alias in the form of + * 'property_\d' + * @return An aggregation result value for the given alias. + */ + @ObsoleteApi("Please use getLong(String) instead, see Github issue #1175 for details.") + public Long get(String alias) { + return getLong(alias); + } + + /** + * Returns a result value for the given alias. + * + * @param alias A custom alias provided in the query or an autogenerated alias in the form of + * 'property_\d' + * @return An aggregation result value for the given alias. + */ + public Long getLong(String alias) { + Value value = properties.get(alias); + switch (value.getType()) { + case DOUBLE: + return ((Double) value.get()).longValue(); + case LONG: + return (Long) value.get(); + default: + throw new RuntimeException( + String.format("Unsupported type %s received for alias '%s'.", value.getType(), alias)); + } + } + + /** + * Returns a result value for the given alias. + * + * @param alias A custom alias provided in the query or an autogenerated alias in the form of + * 'property_\d' + * @return An aggregation result value for the given alias. + */ + public Double getDouble(String alias) { + Value value = properties.get(alias); + switch (value.getType()) { + case LONG: + return ((Long) value.get()).doubleValue(); + case DOUBLE: + return (Double) value.get(); + default: + throw new RuntimeException( + String.format("Unsupported type %s received for alias '%s'.", value.getType(), alias)); + } + } + + /** + * Returns a result value for the given alias. + * + * @param alias A custom alias provided in the query or an autogenerated alias in the form of + * 'property_\d' + * @return An aggregation result value as a {@link Number} for the given alias. + */ + public Number getNumber(String alias) { + Value value = properties.get(alias); + switch (value.getType()) { + case LONG: + return (Long) value.get(); + case DOUBLE: + return (Double) value.get(); + default: + throw new RuntimeException( + String.format("Unsupported type %s received for alias '%s'.", value.getType(), alias)); + } + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AggregationResult that = (AggregationResult) o; + return properties.equals(that.properties); + } + + @Override + public int hashCode() { + return Objects.hash(properties); + } + + @Override + public String toString() { + ToStringHelper toStringHelper = MoreObjects.toStringHelper(this); + for (Entry> entry : properties.entrySet()) { + toStringHelper.add(entry.getKey(), entry.getValue().get()); + } + return toStringHelper.toString(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/AggregationResults.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/AggregationResults.java new file mode 100644 index 000000000000..8d722ea86794 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/AggregationResults.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. + */ +package com.google.cloud.datastore; + +import static com.google.api.client.util.Preconditions.checkNotNull; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.models.ExplainMetrics; +import java.util.Iterator; +import java.util.List; +import java.util.Objects; +import java.util.Optional; + +/** + * The result of an {@link AggregationQuery} query submission. Contains a List<{@link + * AggregationResult}> and readTime {@link Timestamp} in it. + * + *

This can be used to iterate over an underlying List<{@link AggregationResult}> directly. + */ +public class AggregationResults implements Iterable { + + private final List aggregationResults; + private final Timestamp readTime; + + private final ExplainMetrics explainMetrics; + + @BetaApi + public AggregationResults( + List aggregationResults, + Timestamp readTime, + ExplainMetrics explainMetrics) { + checkNotNull(aggregationResults, "Aggregation results cannot be null"); + checkNotNull(readTime, "readTime cannot be null"); + this.aggregationResults = aggregationResults; + this.readTime = readTime; + this.explainMetrics = explainMetrics; + } + + public AggregationResults(List aggregationResults, Timestamp readTime) { + this(aggregationResults, readTime, null); + } + + /** Returns {@link Iterator} for underlying List<{@link AggregationResult}>. */ + @Override + public Iterator iterator() { + return this.aggregationResults.iterator(); + } + + public int size() { + return this.aggregationResults.size(); + } + + /** + * Returns {@code ExplainMetrics} if {@code ExplainOptions} were enabled. Otherwise, returns null. + */ + @BetaApi + public Optional getExplainMetrics() { + return Optional.ofNullable(this.explainMetrics); + } + + @InternalApi + public AggregationResult get(int index) { + return this.aggregationResults.get(index); + } + + /** Returns read timestamp this result batch was returned from. */ + public Timestamp getReadTime() { + return this.readTime; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AggregationResults that = (AggregationResults) o; + return Objects.equals(aggregationResults, that.aggregationResults) + && Objects.equals(readTime, that.readTime) + && Objects.equals(explainMetrics, that.explainMetrics); + } + + @Override + public int hashCode() { + return Objects.hash(aggregationResults, readTime, explainMetrics); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseDatastoreBatchWriter.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseDatastoreBatchWriter.java new file mode 100644 index 000000000000..a513d806bcb2 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseDatastoreBatchWriter.java @@ -0,0 +1,271 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.common.base.Preconditions; +import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** Base class for DatastoreBatchWriter. */ +public abstract class BaseDatastoreBatchWriter implements DatastoreBatchWriter { + + private final String name; + private final Map> toAdd = new LinkedHashMap<>(); + private final List> toAddAutoId = new LinkedList<>(); + private final Map> toUpdate = new LinkedHashMap<>(); + private final Map> toPut = new LinkedHashMap<>(); + private final Set toDelete = new LinkedHashSet<>(); + private boolean active = true; + + BaseDatastoreBatchWriter(String name) { + this.name = name; + } + + @SuppressWarnings("unchecked") + @Override + public final void addWithDeferredIdAllocation(FullEntity... entities) { + validateActive(); + for (FullEntity entity : entities) { + IncompleteKey key = entity.getKey(); + Preconditions.checkArgument(key != null, "Entity must have a key"); + if (key instanceof Key) { + addInternal((FullEntity) entity); + } else { + toAddAutoId.add((FullEntity) entity); + } + } + } + + private void addInternal(FullEntity entity) { + Key key = entity.getKey(); + if (toAdd.containsKey(key) || toUpdate.containsKey(key) || toPut.containsKey(key)) { + throw newInvalidRequest( + "Entity with the key %s was already added or updated in this %s", entity.getKey(), name); + } + if (toDelete.remove(key)) { + toPut.put(key, entity); + } else { + toAdd.put(key, entity); + } + } + + @Override + public final Entity add(FullEntity entity) { + return DatastoreHelper.add(this, entity); + } + + @SuppressWarnings("unchecked") + @Override + public final List add(FullEntity... entities) { + validateActive(); + List incompleteKeys = Lists.newArrayListWithExpectedSize(entities.length); + for (FullEntity entity : entities) { + IncompleteKey key = entity.getKey(); + Preconditions.checkArgument(key != null, "Entity must have a key"); + if (!(key instanceof Key)) { + incompleteKeys.add(key); + } + } + Iterator allocated; + if (!incompleteKeys.isEmpty()) { + IncompleteKey[] toAllocate = Iterables.toArray(incompleteKeys, IncompleteKey.class); + allocated = getDatastore().allocateId(toAllocate).iterator(); + } else { + allocated = Collections.emptyIterator(); + } + List answer = Lists.newArrayListWithExpectedSize(entities.length); + for (FullEntity entity : entities) { + if (entity.getKey() instanceof Key) { + addInternal((FullEntity) entity); + answer.add(Entity.convert((FullEntity) entity)); + } else { + Entity entityWithAllocatedId = Entity.newBuilder(allocated.next(), entity).build(); + addInternal(entityWithAllocatedId); + answer.add(entityWithAllocatedId); + } + } + return answer; + } + + @SafeVarargs + @Override + public final void update(Entity... entities) { + validateActive(); + for (Entity entity : entities) { + Key key = entity.getKey(); + if (toDelete.contains(key)) { + throw newInvalidRequest( + "Entity with the key %s was already deleted in this %s", entity.getKey(), name); + } + if (toAdd.remove(key) != null || toPut.containsKey(key)) { + toPut.put(key, entity); + } else { + toUpdate.put(key, entity); + } + } + } + + private void putInternal(FullEntity entity) { + Key key = entity.getKey(); + toAdd.remove(key); + toUpdate.remove(key); + toDelete.remove(key); + toPut.put(key, entity); + } + + @Override + public final Entity put(FullEntity entity) { + return DatastoreHelper.put(this, entity); + } + + @SuppressWarnings("unchecked") + @Override + public final void putWithDeferredIdAllocation(FullEntity... entities) { + validateActive(); + for (FullEntity entity : entities) { + IncompleteKey key = entity.getKey(); + Preconditions.checkArgument(key != null, "Entity must have a key"); + if (key instanceof Key) { + putInternal(Entity.convert((FullEntity) entity)); + } else { + toAddAutoId.add((FullEntity) entity); + } + } + } + + @SuppressWarnings("unchecked") + @Override + public final List put(FullEntity... entities) { + validateActive(); + List incompleteKeys = Lists.newArrayListWithExpectedSize(entities.length); + for (FullEntity entity : entities) { + IncompleteKey key = entity.getKey(); + Preconditions.checkArgument(key != null, "Entity must have a key"); + if (!(key instanceof Key)) { + incompleteKeys.add(key); + } + } + Iterator allocated; + if (!incompleteKeys.isEmpty()) { + IncompleteKey[] toAllocate = Iterables.toArray(incompleteKeys, IncompleteKey.class); + allocated = getDatastore().allocateId(toAllocate).iterator(); + } else { + allocated = Collections.emptyIterator(); + } + List answer = Lists.newArrayListWithExpectedSize(entities.length); + for (FullEntity entity : entities) { + if (entity.getKey() instanceof Key) { + putInternal((FullEntity) entity); + answer.add(Entity.convert((FullEntity) entity)); + } else { + Entity entityWithAllocatedId = Entity.newBuilder(allocated.next(), entity).build(); + putInternal(entityWithAllocatedId); + answer.add(entityWithAllocatedId); + } + } + return answer; + } + + @Override + public final void delete(Key... keys) { + validateActive(); + for (Key key : keys) { + toAdd.remove(key); + toUpdate.remove(key); + toPut.remove(key); + toDelete.add(key); + } + } + + @Override + public boolean isActive() { + return active; + } + + protected String getName() { + return name; + } + + protected Map> toAdd() { + return toAdd; + } + + protected List> toAddAutoId() { + return toAddAutoId; + } + + protected Map> toUpdate() { + return toUpdate; + } + + protected Map> toPut() { + return toPut; + } + + protected Set toDelete() { + return toDelete; + } + + protected void deactivate() { + active = false; + } + + protected void validateActive() { + if (!active) { + throw newInvalidRequest("%s is no longer active", name); + } + } + + protected DatastoreException newInvalidRequest(String msg, Object... params) { + return DatastoreException.throwInvalidRequest(String.format(msg, params)); + } + + protected List toMutationPbList() { + List mutationsPb = new ArrayList<>(); + for (FullEntity entity : toAddAutoId()) { + mutationsPb.add( + com.google.datastore.v1.Mutation.newBuilder().setInsert(entity.toPb()).build()); + } + for (FullEntity entity : toAdd().values()) { + mutationsPb.add( + com.google.datastore.v1.Mutation.newBuilder().setInsert(entity.toPb()).build()); + } + for (FullEntity entity : toUpdate().values()) { + mutationsPb.add( + com.google.datastore.v1.Mutation.newBuilder().setUpdate(entity.toPb()).build()); + } + for (FullEntity entity : toPut().values()) { + mutationsPb.add( + com.google.datastore.v1.Mutation.newBuilder().setUpsert(entity.toPb()).build()); + } + for (Key key : toDelete()) { + mutationsPb.add(com.google.datastore.v1.Mutation.newBuilder().setDelete(key.toPb()).build()); + } + return mutationsPb; + } + + protected abstract Datastore getDatastore(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseEntity.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseEntity.java new file mode 100644 index 000000000000..5bc9229e52ac --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseEntity.java @@ -0,0 +1,649 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.cloud.datastore.BlobValue.of; +import static com.google.cloud.datastore.BooleanValue.of; +import static com.google.cloud.datastore.DoubleValue.of; +import static com.google.cloud.datastore.EntityValue.of; +import static com.google.cloud.datastore.KeyValue.of; +import static com.google.cloud.datastore.LatLngValue.of; +import static com.google.cloud.datastore.ListValue.of; +import static com.google.cloud.datastore.LongValue.of; +import static com.google.cloud.datastore.NullValue.of; +import static com.google.cloud.datastore.StringValue.of; +import static com.google.cloud.datastore.TimestampValue.of; + +import com.google.cloud.Timestamp; +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableSortedMap; +import com.google.common.collect.Maps; +import java.io.Serializable; +import java.util.HashMap; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; + +/** + * A base class for entities (key and properties). An entity is a Google Cloud Datastore persistent + * data object. An entity holds one or more properties, represented by a name (as {@link String}) + * and a value (as {@link com.google.cloud.datastore.Value}), and may be associated with a key. For + * a list of possible values see {@link ValueType}. + * + * @see Google Cloud Datastore + * Entities, Properties, and Keys + */ +public abstract class BaseEntity implements Serializable { + + private static final long serialVersionUID = -9070588108769487081L; + private final ImmutableSortedMap> properties; + private final K key; + + public abstract static class Builder> { + + private K key; + private final Map> properties = new HashMap<>(); + + Builder() {} + + Builder(K key) { + setKey(key); + } + + Builder(BaseEntity entity) { + this(entity.key, entity); + } + + Builder(K key, BaseEntity entity) { + setKey(key); + setProperties(entity.properties); + } + + protected K key() { + return key; + } + + protected Map> setProperties() { + return properties; + } + + @SuppressWarnings("unchecked") + private B self() { + return (B) this; + } + + @SuppressWarnings("unchecked") + B fill(com.google.datastore.v1.Entity entityPb) { + Map> copiedProperties = Maps.newHashMap(); + for (Map.Entry entry : + entityPb.getPropertiesMap().entrySet()) { + copiedProperties.put(entry.getKey(), Value.fromPb(entry.getValue())); + } + setProperties(copiedProperties); + if (entityPb.hasKey()) { + setKey((K) IncompleteKey.fromPb(entityPb.getKey())); + } + return self(); + } + + protected B setProperties(Map> properties) { + this.properties.putAll(properties); + return self(); + } + + /** Sets the key for the entity. */ + public B setKey(K key) { + this.key = key; + return self(); + } + + /** Clears all the properties. */ + public B clear() { + properties.clear(); + return self(); + } + + /** Removes a property with the given {@code name}. */ + public B remove(String name) { + properties.remove(name); + return self(); + } + + /** + * Sets a property. + * + * @param name name of the property + * @param value value associated with the property + */ + public B set(String name, Value value) { + properties.put(name, value); + return self(); + } + + /** + * Sets a property of type {@link StringValue}. + * + * @param name name of the property + * @param value value associated with the property + */ + public B set(String name, String value) { + properties.put(name, of(value)); + return self(); + } + + /** + * Sets a list property containing elements of type {@link StringValue}. + * + * @param name name of the property + * @param first the first string in the list + * @param second the second string in the list + * @param others other strings in the list + */ + public B set(String name, String first, String second, String... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (String other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + + /** + * Sets a property of type {@link LongValue}. + * + * @param name name of the property + * @param value value associated with the property + */ + public B set(String name, long value) { + properties.put(name, of(value)); + return self(); + } + + /** + * Sets a list property containing elements of type {@link LongValue}. + * + * @param name name of the property + * @param first the first long in the list + * @param second the second long in the list + * @param others other longs in the list + */ + public B set(String name, long first, long second, long... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (long other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + + /** + * Sets a property of type {@link DoubleValue}. + * + * @param name name of the property + * @param value value associated with the property + */ + public B set(String name, double value) { + properties.put(name, of(value)); + return self(); + } + + /** + * Sets a list property containing elements of type {@link DoubleValue}. + * + * @param name name of the property + * @param first the first double in the list + * @param second the second double in the list + * @param others other doubles in the list + */ + public B set(String name, double first, double second, double... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (double other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + + /** + * Sets a property of type {@link BooleanValue}. + * + * @param name name of the property + * @param value value associated with the property + */ + public B set(String name, boolean value) { + properties.put(name, of(value)); + return self(); + } + + /** + * Sets a list property containing elements of type {@link BooleanValue}. + * + * @param name name of the property + * @param first the first boolean in the list + * @param second the second boolean in the list + * @param others other booleans in the list + */ + public B set(String name, boolean first, boolean second, boolean... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (boolean other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + + /** + * Sets a property of type {@link TimestampValue}. + * + * @param name name of the property + * @param value value associated with the property + */ + public B set(String name, Timestamp value) { + properties.put(name, of(value)); + return self(); + } + + /** + * Sets a list property containing elements of type {@link TimestampValue}. + * + * @param name name of the property + * @param first the first {@link Timestamp} in the list + * @param second the second {@link Timestamp} in the list + * @param others other {@link Timestamp}s in the list + */ + public B set(String name, Timestamp first, Timestamp second, Timestamp... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (Timestamp other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + + /** + * Sets a property of type {@link LatLng}. + * + * @param name name of the property + * @param value value associated with the property + */ + public B set(String name, LatLng value) { + properties.put(name, of(value)); + return self(); + } + + /** + * Sets a list property containing elements of type {@link LatLng}. + * + * @param name name of the property + * @param first the first {@link LatLng} in the list + * @param second the second {@link LatLng} in the list + * @param others other {@link LatLng}s in the list + */ + public B set(String name, LatLng first, LatLng second, LatLng... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (LatLng other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + + /** + * Sets a property of type {@link KeyValue}. + * + * @param name name of the property + * @param value value associated with the property + */ + public B set(String name, Key value) { + properties.put(name, of(value)); + return self(); + } + + /** + * Sets a list property containing elements of type {@link KeyValue}. + * + * @param name name of the property + * @param first the first {@link Key} in the list + * @param second the second {@link Key} in the list + * @param others other {@link Key}s in the list + */ + public B set(String name, Key first, Key second, Key... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (Key other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + + /** + * Sets a property of type {@link EntityValue}. + * + * @param name name of the property + * @param value value associated with the property + */ + public B set(String name, FullEntity value) { + properties.put(name, of(value)); + return self(); + } + + /** + * Sets a list property containing elements of type {@link EntityValue}. + * + * @param name name of the property + * @param first the first {@link FullEntity} in the list + * @param second the second {@link FullEntity} in the list + * @param others other entities in the list + */ + public B set(String name, FullEntity first, FullEntity second, FullEntity... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (FullEntity other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + + /** + * Sets a property of type {@link ListValue}. + * + * @param name name of the property + * @param values list of values associated with the property + */ + public B set(String name, List> values) { + properties.put(name, of(values)); + return self(); + } + + /** + * Sets a property of type {@link ListValue}. + * + * @param name name of the property + * @param first the first value in the list + * @param second the second value in the list + * @param others other values in the list + */ + public B set(String name, Value first, Value second, Value... others) { + properties.put(name, ListValue.newBuilder().addValue(first).addValue(second, others).build()); + return self(); + } + + /** + * Sets a property of type {@link BlobValue}. + * + * @param name name of the property + * @param value value associated with the property + */ + public B set(String name, Blob value) { + properties.put(name, of(value)); + return self(); + } + + /** + * Sets a list property containing elements of type {@link BlobValue}. + * + * @param name name of the property + * @param first the first {@link Blob} in the list + * @param second the second {@link Blob} in the list + * @param others other {@link Blob}s in the list + */ + public B set(String name, Blob first, Blob second, Blob... others) { + List values = new LinkedList<>(); + values.add(of(first)); + values.add(of(second)); + for (Blob other : others) { + values.add(of(other)); + } + properties.put(name, of(values)); + return self(); + } + + /** + * Sets a property of type {@code NullValue}. + * + * @param name name of the property + */ + public B setNull(String name) { + properties.put(name, of()); + return self(); + } + + public abstract BaseEntity build(); + } + + BaseEntity(Builder builder) { + this.key = builder.key; + this.properties = ImmutableSortedMap.copyOf(builder.properties); + } + + BaseEntity(BaseEntity from) { + this.key = from.getKey(); + this.properties = from.properties; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("key", key) + .add("properties", properties) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(key, properties); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BaseEntity)) { + return false; + } + BaseEntity other = (BaseEntity) obj; + return Objects.equals(key, other.key) && Objects.equals(properties, other.properties); + } + + /** Returns true if entity has a non-null key. */ + public boolean hasKey() { + return key != null; + } + + /** Returns the associated key or null if it does not have one. */ + public K getKey() { + return key; + } + + /** Returns {@code true} if the entity contains a property with the given {@code name}. */ + public boolean contains(String name) { + return properties.containsKey(name); + } + + /** + * Returns the {@link Value} for the given property {@code name}. + * + * @throws DatastoreException if no such property + */ + public > V getValue(String name) { + @SuppressWarnings("unchecked") + V property = (V) properties.get(name); + if (property == null) { + throw DatastoreException.throwInvalidRequest("No such property %s", name); + } + return property; + } + + /** + * Returns true if property is an instance of NullValue. + * + * @throws DatastoreException if no such property + */ + public boolean isNull(String name) { + return getValue(name) instanceof NullValue; + } + + /** + * Returns the property value as a string. + * + * @throws DatastoreException if no such property + * @throws ClassCastException if value is not a string + */ + @SuppressWarnings("unchecked") + public String getString(String name) { + return ((Value) getValue(name)).get(); + } + + /** + * Returns the property value as long. + * + * @throws DatastoreException if no such property + * @throws ClassCastException if value is not a long + */ + @SuppressWarnings("unchecked") + public long getLong(String name) { + return ((Value) getValue(name)).get(); + } + + /** + * Returns the property value as a double. + * + * @throws DatastoreException if no such property + * @throws ClassCastException if value is not a double + */ + @SuppressWarnings("unchecked") + public double getDouble(String name) { + return ((Value) getValue(name)).get(); + } + + /** + * Returns the property value as a boolean. + * + * @throws DatastoreException if no such property + * @throws ClassCastException if value is not a boolean + */ + @SuppressWarnings("unchecked") + public boolean getBoolean(String name) { + return ((Value) getValue(name)).get(); + } + + /** + * Returns the property value as a Timestamp. + * + * @throws DatastoreException if no such property + * @throws ClassCastException if value is not a Timestamp + */ + @SuppressWarnings("unchecked") + public Timestamp getTimestamp(String name) { + return ((Value) getValue(name)).get(); + } + + /** + * Returns the property value as a LatLng. + * + * @throws DatastoreException if no such property. + * @throws ClassCastException if value is not a LatLng. + */ + @SuppressWarnings("unchecked") + public LatLng getLatLng(String name) { + return ((Value) getValue(name)).get(); + } + + /** + * Returns the property value as a Key. + * + * @throws DatastoreException if no such property + * @throws ClassCastException if value is not a Key + */ + @SuppressWarnings("unchecked") + public Key getKey(String name) { + return ((Value) getValue(name)).get(); + } + + /** + * Returns the property value as an entity. + * + * @throws DatastoreException if no such property + * @throws ClassCastException if value is not an entity + */ + @SuppressWarnings("unchecked") + public FullEntity getEntity(String name) { + return ((Value>) getValue(name)).get(); + } + + /** + * Returns the property value as a list of values. + * + * @throws DatastoreException if no such property + * @throws ClassCastException if value is not a list of values + */ + @SuppressWarnings("unchecked") + public > List getList(String name) { + return (List) getValue(name).get(); + } + + /** + * Returns the property value as a blob. + * + * @throws DatastoreException if no such property + * @throws ClassCastException if value is not a blob + */ + @SuppressWarnings("unchecked") + public Blob getBlob(String name) { + return ((Value) getValue(name)).get(); + } + + /** Returns the properties name. */ + public Set getNames() { + return properties.keySet(); + } + + /** Returns the properties. */ + public Map> getProperties() { + return properties; + } + + final com.google.datastore.v1.Entity toPb() { + com.google.datastore.v1.Entity.Builder entityPb = com.google.datastore.v1.Entity.newBuilder(); + for (Map.Entry> entry : properties.entrySet()) { + entityPb.putProperties(entry.getKey(), entry.getValue().toPb()); + } + if (key != null) { + entityPb.setKey(key.toPb()); + } + return entityPb.build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseKey.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseKey.java new file mode 100644 index 000000000000..3658c3f71172 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BaseKey.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 + * + * 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.datastore; + +import static com.google.cloud.datastore.Validator.validateKind; +import static com.google.cloud.datastore.Validator.validateNamespace; +import static com.google.cloud.datastore.Validator.validateProjectId; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.io.Serializable; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; + +/** Base class for keys. */ +public abstract class BaseKey implements Serializable { + + private static final long serialVersionUID = -5897863400209818325L; + + private final String projectId; + private final String namespace; + private final String databaseId; + private final ImmutableList path; + + /** + * Base class for key builders. + * + * @param the key builder. + */ + public abstract static class Builder> { + + String projectId = ""; + String namespace = ""; + String databaseId = ""; + String kind; + final List ancestors; + + private static final int MAX_PATH = 100; + + Builder(String projectId) { + this.projectId = validateProjectId(projectId); + ancestors = new LinkedList<>(); + } + + Builder(String projectId, String kind) { + this(projectId); + this.kind = validateKind(kind); + } + + Builder(BaseKey copyFrom) { + projectId = copyFrom.getProjectId(); + namespace = copyFrom.getNamespace(); + databaseId = copyFrom.getDatabaseId(); + ancestors = new LinkedList<>(copyFrom.getAncestors()); + kind = copyFrom.getKind(); + } + + @SuppressWarnings("unchecked") + B self() { + return (B) this; + } + + /** Adds an ancestor for this key. */ + public B addAncestor(PathElement ancestor) { + Preconditions.checkState(ancestors.size() < MAX_PATH, "path can have at most 100 elements"); + ancestors.add(ancestor); + return self(); + } + + /** Adds the provided ancestors to the key. */ + public B addAncestors(PathElement ancestor, PathElement... other) { + return addAncestors(ImmutableList.builder().add(ancestor).add(other).build()); + } + + /** Adds the provided ancestors to the key. */ + public B addAncestors(Iterable ancestors) { + ImmutableList list = ImmutableList.copyOf(ancestors); + Preconditions.checkState( + this.ancestors.size() + list.size() < MAX_PATH, "path can have at most 100 elements"); + this.ancestors.addAll(list); + return self(); + } + + /** Sets the kind of the key. */ + public B setKind(String kind) { + this.kind = validateKind(kind); + return self(); + } + + /** Sets the project ID of the key. */ + public B setProjectId(String projectId) { + this.projectId = validateProjectId(projectId); + return self(); + } + + /** Sets the namespace of the key. */ + public B setNamespace(String namespace) { + this.namespace = validateNamespace(namespace); + return self(); + } + + /** Sets the database id of the key. */ + public B setDatabaseId(String databaseId) { + this.databaseId = databaseId; + return self(); + } + + protected abstract BaseKey build(); + } + + BaseKey(String projectId, String namespace, ImmutableList path) { + this(projectId, namespace, "", path); + } + + BaseKey(String projectId, String namespace, String databaseId, ImmutableList path) { + Preconditions.checkArgument(!path.isEmpty(), "Path must not be empty"); + this.projectId = projectId; + this.namespace = namespace; + this.databaseId = databaseId; + this.path = path; + } + + /** Returns the key's projectId. */ + public String getProjectId() { + return projectId; + } + + /** Returns the key's namespace or {@code null} if not provided. */ + public String getNamespace() { + return namespace; + } + + public String getDatabaseId() { + return databaseId; + } + + /** Returns an immutable list with the key's ancestors. */ + public List getAncestors() { + return getPath().subList(0, getPath().size() - 1); + } + + /** Returns an immutable list of the key's path (ancestors + self). */ + List getPath() { + return path; + } + + PathElement getLeaf() { + return getPath().get(getPath().size() - 1); + } + + /** Returns the key's kind. */ + public String getKind() { + return getLeaf().getKind(); + } + + abstract BaseKey getParent(); + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("projectId", projectId) + .add("namespace", namespace) + .add("databaseId", databaseId) + .add("path", path) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(getProjectId(), getNamespace(), getDatabaseId(), getPath()); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BaseKey)) { + return false; + } + BaseKey other = (BaseKey) obj; + return Objects.equals(getProjectId(), other.getProjectId()) + && Objects.equals(getNamespace(), other.getNamespace()) + && Objects.equals(getDatabaseId(), other.getDatabaseId()) + && Objects.equals(getPath(), other.getPath()); + } + + com.google.datastore.v1.Key toPb() { + com.google.datastore.v1.Key.Builder keyPb = com.google.datastore.v1.Key.newBuilder(); + com.google.datastore.v1.PartitionId.Builder partitionIdPb = + com.google.datastore.v1.PartitionId.newBuilder(); + partitionIdPb.setProjectId(projectId); + partitionIdPb.setDatabaseId(databaseId); + partitionIdPb.setNamespaceId(namespace); + keyPb.setPartitionId(partitionIdPb.build()); + for (PathElement pathEntry : path) { + keyPb.addPath(pathEntry.toPb()); + } + return keyPb.build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Batch.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Batch.java new file mode 100644 index 000000000000..9cd2ef10bcc3 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Batch.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 + * + * 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.datastore; + +import com.google.api.core.InternalExtensionOnly; +import java.util.List; +import javax.annotation.concurrent.NotThreadSafe; + +/** + * An interface to represent a batch of write operations. Any write operation that is applied on a + * batch will only be sent to the Datastore upon {@link #submit}. A usage example: + * + *

{@code
+ * Entity entity1 = datastore.get(key1);
+ * Batch batch = datastore.newBatch();
+ * Entity entity2 = Entity.newBuilder(key2).set("name", "John").build();
+ * entity1 = Entity.newBuilder(entity1).clear().setNull("bla").build();
+ * Entity entity3 = Entity.newBuilder(key3).set("title", "title").build();
+ * batch.update(entity1);
+ * batch.add(entity2, entity3);
+ * batch.submit();
+ * }
+ * + *

WARNING: This class maintains an internal state in terms of {@link + * java.util.LinkedHashMap} and {@link java.util.LinkedHashSet} which gets updated on every method + * call performing CRUD operations to record the mutations. Since {@link java.util.LinkedHashMap} is + * not thread safe as per its documentation, + * This class too should not be treated as a thread safe class. + */ +@NotThreadSafe +@InternalExtensionOnly +public interface Batch extends DatastoreBatchWriter { + + interface Response { + + /** Returns a list of keys generated by a batch. */ + List getGeneratedKeys(); + } + + /** + * {@inheritDoc} + * + *

If an entity for {@code entity.getKey()} does not exist, {@code entity} is inserted. + * Otherwise, {@link #submit()} will throw a {@link DatastoreException} with {@link + * DatastoreException#getReason()} equal to {@code "ALREADY_EXISTS"}. + * + * @param entity the entity to be added to the datastore + * @return The entity that was added + * @throws DatastoreException if there was any failure + */ + @Override + Entity add(FullEntity entity); + + /** + * {@inheritDoc} + * + *

If none of entities' keys exist, all entities are inserted. If any of entities' keys already + * exists, {@link #submit()} will throw a {@link DatastoreException} with {@link + * DatastoreException#getReason()} equal to {@code "ALREADY_EXISTS"}. All entities in {@code + * entities} whose key did not exist are inserted. + * + * @param entities entities to be added to the datastore + * @return A list of entities that have been added + * @throws DatastoreException if there was any failure + */ + @Override + List add(FullEntity... entities); + + /** + * Submit the batch to the Datastore. + * + * @return Response of the batch submit operation. + * @throws DatastoreException if there was any failure or if batch is no longer active + */ + Response submit(); + + /** + * Returns the batch associated {@link Datastore}. + * + * @return The batch associated datastore + */ + Datastore getDatastore(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BatchImpl.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BatchImpl.java new file mode 100644 index 000000000000..605d8b18e57e --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BatchImpl.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 + * + * 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.datastore; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +class BatchImpl extends BaseDatastoreBatchWriter implements Batch { + + private final DatastoreImpl datastore; + + static class ResponseImpl implements Batch.Response { + + private final com.google.datastore.v1.CommitResponse response; + private final int numAutoAllocatedIds; + + ResponseImpl(com.google.datastore.v1.CommitResponse response, int numAutoAllocatedIds) { + this.response = response; + this.numAutoAllocatedIds = numAutoAllocatedIds; + } + + @Override + public List getGeneratedKeys() { + Iterator results = + response.getMutationResultsList().iterator(); + List generated = new ArrayList<>(numAutoAllocatedIds); + for (int i = 0; i < numAutoAllocatedIds; i++) { + generated.add(Key.fromPb(results.next().getKey())); + } + return generated; + } + } + + BatchImpl(DatastoreImpl datastore) { + super("batch"); + this.datastore = datastore; + } + + @Override + public Batch.Response submit() { + validateActive(); + List mutationsPb = toMutationPbList(); + com.google.datastore.v1.CommitRequest.Builder requestPb = + com.google.datastore.v1.CommitRequest.newBuilder(); + requestPb.setMode(com.google.datastore.v1.CommitRequest.Mode.NON_TRANSACTIONAL); + requestPb.addAllMutations(mutationsPb); + requestPb.setProjectId(datastore.getOptions().getProjectId()); + requestPb.setDatabaseId(datastore.getOptions().getDatabaseId()); + com.google.datastore.v1.CommitResponse responsePb = datastore.commit(requestPb.build()); + deactivate(); + return new ResponseImpl(responsePb, toAddAutoId().size()); + } + + @Override + public Datastore getDatastore() { + return datastore; + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Blob.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Blob.java new file mode 100644 index 000000000000..e2127c3a1de7 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Blob.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 + * + * 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.datastore; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.protobuf.ByteString; +import java.io.BufferedInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.Serializable; +import java.nio.ByteBuffer; + +/** + * A Google Cloud Datastore Blob. This class is immutable. + * + * @see Google Cloud Datastore + * Entities, Properties, and Keys + */ +public final class Blob implements Serializable { + + private static final long serialVersionUID = 7311366042557240313L; + + private final ByteString byteString; + + Blob(ByteString byteString) { + this.byteString = checkNotNull(byteString); + } + + @Override + public String toString() { + ToStringHelper toStringHelper = MoreObjects.toStringHelper(this); + StringBuilder stBuilder = new StringBuilder(); + for (int i = 0; i < Math.min(256, byteString.size()); i++) { + stBuilder.append(String.format("%02x", byteString.byteAt(i))); + } + if (byteString.size() > 256) { + stBuilder.append("..."); + } + return toStringHelper.add("bytes", stBuilder.toString()).toString(); + } + + @Override + public int hashCode() { + return byteString.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return obj == this || obj instanceof Blob && byteString.equals(((Blob) obj).byteString); + } + + /** Returns the size of this blob. */ + public int getLength() { + return byteString.size(); + } + + /** Returns a copy as byte array. */ + public byte[] toByteArray() { + return byteString.toByteArray(); + } + + /** Returns a read-only {@link ByteBuffer} for this blob content. */ + public ByteBuffer asReadOnlyByteBuffer() { + return byteString.asReadOnlyByteBuffer(); + } + + /** Returns an {@link InputStream} for this blob content. */ + public InputStream asInputStream() { + final ByteBuffer byteBuffer = asReadOnlyByteBuffer(); + return new InputStream() { + @Override + public int read() { + return !byteBuffer.hasRemaining() ? -1 : byteBuffer.get() & 0xFF; + } + }; + } + + /** + * Copies bytes into a ByteBuffer. + * + * @throws java.nio.ReadOnlyBufferException if the target is read-only + * @throws java.nio.BufferOverflowException if the target's remaining() space is not large enough + * to hold the data + */ + public void copyTo(ByteBuffer target) { + byteString.copyTo(target); + } + + /** + * Copies bytes into a buffer. + * + * @throws IndexOutOfBoundsException if an offset or size is negative or too large + */ + public void copyTo(byte[] target) { + byteString.copyTo(target, 0); + } + + ByteString getByteString() { + return byteString; + } + + public static Blob copyFrom(byte[] bytes) { + return new Blob(ByteString.copyFrom(bytes)); + } + + public static Blob copyFrom(ByteBuffer bytes) { + return new Blob(ByteString.copyFrom(bytes)); + } + + public static Blob copyFrom(InputStream input) throws IOException { + BufferedInputStream bufferedInput = new BufferedInputStream(input); + ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + int value; + while ((value = bufferedInput.read()) != -1) { + bytes.write(value); + } + return copyFrom(bytes.toByteArray()); + } + + com.google.datastore.v1.Value toPb() { + return com.google.datastore.v1.Value.newBuilder().setBlobValue(byteString).build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BlobValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BlobValue.java new file mode 100644 index 000000000000..05c61667ec6e --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BlobValue.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 + * + * 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.datastore; + +import static com.google.datastore.v1.Value.BLOB_VALUE_FIELD_NUMBER; + +public final class BlobValue extends Value { + + private static final long serialVersionUID = -5096238337676649540L; + + static final BaseMarshaller MARSHALLER = + new BaseMarshaller() { + + private static final long serialVersionUID = -739627441374592171L; + + @Override + public int getProtoFieldId() { + return BLOB_VALUE_FIELD_NUMBER; + } + + @Override + public Builder newBuilder(Blob value) { + return BlobValue.newBuilder(value); + } + + @Override + protected Blob getValue(com.google.datastore.v1.Value from) { + return new Blob(from.getBlobValue()); + } + + @Override + protected void setValue(BlobValue from, com.google.datastore.v1.Value.Builder to) { + to.setBlobValue(from.get().getByteString()); + } + }; + + public static final class Builder extends Value.BaseBuilder { + + private Builder() { + super(ValueType.BLOB); + } + + @Override + public BlobValue build() { + return new BlobValue(this); + } + } + + public BlobValue(Blob blob) { + this(newBuilder(blob)); + } + + private BlobValue(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + public static BlobValue of(Blob blob) { + return new BlobValue(blob); + } + + public static Builder newBuilder(Blob blob) { + return new Builder().set(blob); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BooleanValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BooleanValue.java new file mode 100644 index 000000000000..09f23e9bbcfe --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/BooleanValue.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 + * + * 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.datastore; + +import static com.google.datastore.v1.Value.BOOLEAN_VALUE_FIELD_NUMBER; + +public final class BooleanValue extends Value { + + private static final long serialVersionUID = -6692551696100439451L; + + static final BaseMarshaller MARSHALLER = + new BaseMarshaller() { + + private static final long serialVersionUID = 5178009712526977429L; + + @Override + public int getProtoFieldId() { + return BOOLEAN_VALUE_FIELD_NUMBER; + } + + @Override + public Builder newBuilder(Boolean value) { + return BooleanValue.newBuilder(value); + } + + @Override + protected Boolean getValue(com.google.datastore.v1.Value from) { + return from.getBooleanValue(); + } + + @Override + protected void setValue(BooleanValue from, com.google.datastore.v1.Value.Builder to) { + to.setBooleanValue(from.get()); + } + }; + + public static final class Builder extends Value.BaseBuilder { + + private Builder() { + super(ValueType.BOOLEAN); + } + + @Override + public BooleanValue build() { + return new BooleanValue(this); + } + } + + public BooleanValue(boolean value) { + this(newBuilder(value)); + } + + private BooleanValue(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + public static BooleanValue of(boolean value) { + return new BooleanValue(value); + } + + public static Builder newBuilder(boolean value) { + return new Builder().set(value); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Cursor.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Cursor.java new file mode 100644 index 000000000000..f67e1c264da0 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Cursor.java @@ -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. + */ + +package com.google.cloud.datastore; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.io.BaseEncoding; +import com.google.protobuf.ByteString; +import java.io.Serializable; + +/** + * A Google Cloud Datastore cursor. The cursor can be used to as a starting point or an ending point + * for a {@link Query} + */ +public final class Cursor implements Serializable { + + private static final long serialVersionUID = 4688656124180503551L; + + private final ByteString byteString; + + Cursor(ByteString byteString) { + this.byteString = byteString; + } + + @Override + public int hashCode() { + return byteString.hashCode(); + } + + @Override + public boolean equals(Object obj) { + return obj == this || obj instanceof Cursor && byteString.equals(((Cursor) obj).byteString); + } + + @Override + public String toString() { + ToStringHelper toStringHelper = MoreObjects.toStringHelper(this); + StringBuilder stBuilder = new StringBuilder(); + for (int i = 0; i < byteString.size(); i++) { + stBuilder.append(String.format("%02x", byteString.byteAt(i))); + } + return toStringHelper.add("bytes", stBuilder.toString()).toString(); + } + + ByteString getByteString() { + return byteString; + } + + /** Returns the cursor in an encoded form that can be used as part of a URL. */ + public String toUrlSafe() { + return BaseEncoding.base64Url().encode(byteString.toByteArray()); + } + + /** Create a {@code Cursor} given its URL safe encoded form. */ + public static Cursor fromUrlSafe(String urlSafe) { + try { + return Cursor.copyFrom(BaseEncoding.base64Url().decode(urlSafe)); + } catch (IllegalArgumentException e) { + throw new IllegalStateException("Unexpected decoding exception", e); + } + } + + public static Cursor copyFrom(byte[] bytes) { + return new Cursor(ByteString.copyFrom(checkNotNull(bytes))); + } + + com.google.datastore.v1.Value toPb() { + return com.google.datastore.v1.Value.newBuilder().setBlobValue(byteString).build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Datastore.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Datastore.java new file mode 100644 index 000000000000..fd1174fe874b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Datastore.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 + * + * 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.datastore; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.Service; +import com.google.cloud.datastore.models.ExplainOptions; +import com.google.datastore.v1.TransactionOptions; +import java.util.Iterator; +import java.util.List; + +/** An interface for Google Cloud Datastore. */ +@InternalExtensionOnly +public interface Datastore extends Service, DatastoreReaderWriter, AutoCloseable { + + /** + * Returns a new Datastore transaction. + * + * @param options a transaction option indicating the mode of the transaction (read-only or + * read-write) + * @throws DatastoreException upon failure + */ + Transaction newTransaction(TransactionOptions options); + + /** + * Returns a new Datastore transaction. + * + * @throws DatastoreException upon failure + */ + Transaction newTransaction(); + + /** + * A callback for running with a transactional {@link + * com.google.cloud.datastore.DatastoreReaderWriter}. The associated transaction will be committed + * after a successful return from the {@code run} method. Any propagated exception will cause the + * transaction to be rolled-back. + * + * @param the type of the return value + */ + interface TransactionCallable { + /** + * Callback's invoke method for the TransactionCallable. + * + * @param readerWriter DatastoreReaderWriter associated with the new transaction + * @return T The transaction result + * @throws Exception upon failure + */ + T run(DatastoreReaderWriter readerWriter) throws Exception; + } + + /** + * Invokes the callback's {@link Datastore.TransactionCallable#run} method with a {@link + * DatastoreReaderWriter} that is associated with a new transaction. The transaction will be + * committed upon successful invocation. Any thrown exception will cause the transaction to + * rollback and will be propagated as a {@link DatastoreException} with the original exception as + * its root cause. + * + *

Example of running in a transaction. + * + *

{@code
+   * String callableResult = "my_callable_result";
+   * TransactionCallable callable = new TransactionCallable() {
+   *   public String run(DatastoreReaderWriter readerWriter) {
+   *     // use readerWriter to run in transaction
+   *     return callableResult;
+   *   }
+   * };
+   * String result = datastore.runInTransaction(callable);
+   * }
+ * + * @param callable the callback to call with a newly created transactional readerWriter + * @throws DatastoreException upon failure + */ + T runInTransaction(TransactionCallable callable); + + /** + * Invokes the callback's {@link Datastore.TransactionCallable#run} method with a {@link + * DatastoreReaderWriter} that is associated with a new transaction. The transaction will be + * committed upon successful invocation. Any thrown exception will cause the transaction to + * rollback and will be propagated as a {@link DatastoreException} with the original exception as + * its root cause. If {@link TransactionOptions} is set to read-write mode, previous transaction + * Id in the options will be automatically populated each time a transaction is retried. + * + *

Example of running in a transaction. + * + *

{@code
+   * String callableResult = "my_callable_result";
+   * TransactionCallable callable = new TransactionCallable() {
+   *   public String run(DatastoreReaderWriter readerWriter) {
+   *     // use readerWriter to run in transaction
+   *     return callableResult;
+   *   }
+   * };
+   *
+   * TransactionOptions options = TransactionOptions.newBuilder()
+   *     .setReadWrite(TransactionOptions.ReadWrite
+   *         .getDefaultInstance())
+   *     .build();
+   *
+   * String result = datastore.runInTransaction(callable, options);
+   * }
+ * + * @param callable the callback to call with a newly created transactional readerWriter + * @param options the Transaction options indicating whether the transaction mode is Read-only or + * Read-Write + * @throws DatastoreException upon failure + */ + T runInTransaction(TransactionCallable callable, TransactionOptions options); + + /** + * Returns a new Batch for processing multiple write operations in one request. + * + *

Example of starting a new batch. + * + *

{@code
+   * String keyName1 = "my_key_name_1";
+   * String keyName2 = "my_key_name_2";
+   * Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
+   * Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
+   * Batch batch = datastore.newBatch();
+   * Entity entity1 = Entity.newBuilder(key1).set("name", "John").build();
+   * Entity entity2 = Entity.newBuilder(key2).set("title", "title").build();
+   * batch.add(entity1);
+   * batch.add(entity2);
+   * batch.submit();
+   * }
+ */ + Batch newBatch(); + + /** + * Allocate a unique id for the given key. The returned key will have the same information + * (projectId, kind, namespace and ancestors) as the given key and will have a newly assigned id. + * + *

Example of allocating an id. + * + *

{@code
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
+   * IncompleteKey incompleteKey = keyFactory.newKey();
+   *
+   * // let cloud datastore automatically assign an id
+   * Key key = datastore.allocateId(incompleteKey);
+   * }
+ * + * @throws DatastoreException upon failure + */ + Key allocateId(IncompleteKey key); + + /** + * Returns a list of keys using the allocated ids ordered by the input. + * + *

Example of allocating multiple ids in a single batch. + * + *

{@code
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
+   * IncompleteKey incompleteKey1 = keyFactory.newKey();
+   * IncompleteKey incompleteKey2 = keyFactory.newKey();
+   *
+   * // let cloud datastore automatically assign the ids
+   * List keys = datastore.allocateId(incompleteKey1, incompleteKey2);
+   * }
+ * + * @throws DatastoreException upon failure + * @see #allocateId(IncompleteKey) + */ + List allocateId(IncompleteKey... keys); + + /** + * Reserve one or more keys, preventing them from being automatically allocated by Datastore. + * + *

Example of reserving multiple ids in a single batch. + * + *

{@code
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
+   * Key key1 = keyFactory.newKey(10);
+   * Key key2 = keyFactory.newKey("name");
+   * List keys = datastore.reserveIds(key1, key2);
+   *
+   * }
+ * + * @throws DatastoreException upon failure + */ + List reserveIds(Key... keys); + + /** + * {@inheritDoc} + * + *

If an entity for {@code entity.getKey()} does not exist, {@code entity} is inserted. + * Otherwise, a {@link DatastoreException} is thrown with {@link DatastoreException#getReason()} + * equal to {@code "ALREADY_EXISTS"}. + * + *

Example of adding a single entity. + * + *

{@code
+   * String keyName = "my_key_name";
+   * Key key = datastore.newKeyFactory().setKind("MyKind").newKey(keyName);
+   * Entity.Builder entityBuilder = Entity.newBuilder(key);
+   * entityBuilder.set("propertyName", "value");
+   * Entity entity = entityBuilder.build();
+   * try {
+   *   datastore.add(entity);
+   * } catch (DatastoreException ex) {
+   *   if ("ALREADY_EXISTS".equals(ex.getReason())) {
+   *     // entity.getKey() already exists
+   *   }
+   * }
+   * }
+ * + * @throws DatastoreException upon failure or if an entity for {@code entity.getKey()} already + * exists + */ + @Override + Entity add(FullEntity entity); + + /** + * {@inheritDoc} + * + *

If none of entities' keys exist, all entities are inserted. If any of entities' keys already + * exists the method throws a {@link DatastoreException} with {@link + * DatastoreException#getReason()} equal to {@code "ALREADY_EXISTS"}. All entities in {@code + * entities} whose key did not exist are inserted. To achieve a transactional behavior, use {@link + * Transaction}. + * + *

Example of adding multiple entities. + * + *

{@code
+   * String keyName1 = "my_key_name1";
+   * String keyName2 = "my_key_name2";
+   * Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
+   * Entity.Builder entityBuilder1 = Entity.newBuilder(key1);
+   * entityBuilder1.set("propertyName", "value1");
+   * Entity entity1 = entityBuilder1.build();
+   *
+   * Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
+   * Entity.Builder entityBuilder2 = Entity.newBuilder(key2);
+   * entityBuilder2.set("propertyName", "value2");
+   * Entity entity2 = entityBuilder2.build();
+   *
+   * try {
+   *   datastore.add(entity1, entity2);
+   * } catch (DatastoreException ex) {
+   *   if ("ALREADY_EXISTS".equals(ex.getReason())) {
+   *     // at least one of entity1.getKey() and entity2.getKey() already exists
+   *   }
+   * }
+   * }
+ * + * @throws DatastoreException upon failure or if any of entities' keys already exists + */ + @Override + List add(FullEntity... entities); + + /** + * {@inheritDoc} + * + *

Example of updating multiple entities. + * + *

{@code
+   * String keyName1 = "my_key_name_1";
+   * String keyName2 = "my_key_name_2";
+   * Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
+   * Entity.Builder entityBuilder1 = Entity.newBuilder(key1);
+   * entityBuilder1.set("propertyName", "updatedValue1");
+   * Entity entity1 = entityBuilder1.build();
+   *
+   * Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
+   * Entity.Builder entityBuilder2 = Entity.newBuilder(key2);
+   * entityBuilder2.set("propertyName", "updatedValue2");
+   * Entity entity2 = entityBuilder2.build();
+   *
+   * datastore.update(entity1, entity2);
+   * }
+ * + * @throws DatastoreException upon failure + */ + @Override + void update(Entity... entities); + + /** + * {@inheritDoc} + * + *

Example of putting a single entity. + * + *

{@code
+   * String keyName = "my_key_name";
+   * Key key = datastore.newKeyFactory().setKind("MyKind").newKey(keyName);
+   * Entity.Builder entityBuilder = Entity.newBuilder(key);
+   * entityBuilder.set("propertyName", "value");
+   * Entity entity = entityBuilder.build();
+   * datastore.put(entity);
+   * }
+ * + * @throws DatastoreException upon failure + */ + @Override + Entity put(FullEntity entity); + + /** + * {@inheritDoc} + * + *

Example of putting multiple entities. + * + *

{@code
+   * String keyName1 = "my_key_name1";
+   * String keyName2 = "my_key_name2";
+   * Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
+   * Entity.Builder entityBuilder1 = Entity.newBuilder(key1);
+   * entityBuilder1.set("propertyName", "value1");
+   * Entity entity1 = entityBuilder1.build();
+   *
+   * Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
+   * Entity.Builder entityBuilder2 = Entity.newBuilder(key2);
+   * entityBuilder2.set("propertyName", "value2");
+   * Entity entity2 = entityBuilder2.build();
+   *
+   * datastore.put(entity1, entity2);
+   * }
+ * + * @throws DatastoreException upon failure + */ + @Override + List put(FullEntity... entities); + + /** + * {@inheritDoc} + * + *

Example of deleting multiple entities. + * + *

{@code
+   * String keyName1 = "my_key_name1";
+   * String keyName2 = "my_key_name2";
+   * Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
+   * Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
+   * datastore.delete(key1, key2);
+   * }
+ * + * @throws DatastoreException upon failure + */ + @Override + void delete(Key... keys); + + /** + * Returns a new KeyFactory for this service + * + *

Example of creating a {@code KeyFactory}. + * + *

{@code
+   * KeyFactory keyFactory = datastore.newKeyFactory();
+   * }
+ */ + KeyFactory newKeyFactory(); + + /** + * Returns an {@link Entity} for the given {@link Key} or {@code null} if it doesn't exist. {@link + * ReadOption}s can be specified if desired. + * + *

Example of getting an entity. + * + *

{@code
+   * String keyName = "my_key_name";
+   * Key key = datastore.newKeyFactory().setKind("MyKind").newKey(keyName);
+   * Entity entity = datastore.get(key);
+   * // Do something with the entity
+   * }
+ * + * @throws DatastoreException upon failure + */ + Entity get(Key key, ReadOption... options); + + /** + * Returns an {@link Entity} for each given {@link Key} that exists in the Datastore. The order of + * the result is unspecified. Results are loaded lazily, so it is possible to get a {@code + * DatastoreException} from the returned {@code Iterator}'s {@link Iterator#hasNext hasNext} or + * {@link Iterator#next next} methods. {@link ReadOption}s can be specified if desired. + * + *

Example of getting multiple entity objects. + * + *

{@code
+   * String firstKeyName = "my_first_key_name";
+   * String secondKeyName = "my_second_key_name";
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
+   * Key firstKey = keyFactory.newKey(firstKeyName);
+   * Key secondKey = keyFactory.newKey(secondKeyName);
+   * Iterator entitiesIterator = datastore.get(Lists.newArrayList(firstKey, secondKey));
+   * List entities = Lists.newArrayList();
+   * while (entitiesIterator.hasNext()) {
+   *   Entity entity = entitiesIterator.next();
+   *   // do something with the entity
+   *   entities.add(entity);
+   * }
+   * }
+ * + * @throws DatastoreException upon failure + * @see #get(Key) + */ + Iterator get(Iterable keys, ReadOption... options); + + /** + * Returns a list with a value for each given key (ordered by input). {@code null} values are + * returned for nonexistent keys. When possible prefer using {@link #get(Key...)} to avoid eagerly + * loading the results. {@link ReadOption}s can be specified if desired. + * + *

Example of fetching a list of Entity objects. + * + *

{@code
+   * String firstKeyName = "my_first_key_name";
+   * String secondKeyName = "my_second_key_name";
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
+   * Key firstKey = keyFactory.newKey(firstKeyName);
+   * Key secondKey = keyFactory.newKey(secondKeyName);
+   * List entities = datastore.fetch(Lists.newArrayList(firstKey, secondKey));
+   * for (Entity entity : entities) {
+   *   // do something with the entity
+   * }
+   * }
+ */ + List fetch(Iterable keys, ReadOption... options); + + /** + * Submits a {@link Query} and returns its result. {@link ReadOption}s can be specified if + * desired. + * + *

Example of running a query to find all entities of one kind. + * + *

{@code
+   * String kind = "my_kind";
+   * StructuredQuery query = Query.newEntityQueryBuilder()
+   *     .setKind(kind)
+   *     .build();
+   * QueryResults results = datastore.run(query);
+   * List entities = Lists.newArrayList();
+   * while (results.hasNext()) {
+   *   Entity result = results.next();
+   *   // do something with result
+   *   entities.add(result);
+   * }
+   * }
+ * + *

Example of running a query to find all entities with a matching property value. + * + *

{@code
+   * String kind = "my_kind";
+   * String property = "my_property";
+   * String value = "my_value";
+   * StructuredQuery query = Query.newEntityQueryBuilder()
+   *     .setKind(kind)
+   *     .setFilter(PropertyFilter.eq(property, value))
+   *     .build();
+   * QueryResults results = datastore.run(query);
+   * List entities = Lists.newArrayList();
+   * while (results.hasNext()) {
+   *   Entity result = results.next();
+   *   // do something with result
+   *   entities.add(result);
+   * }
+   * }
+ * + * @throws DatastoreException upon failure + */ + QueryResults run(Query query, ReadOption... options); + + /** + * Submits a {@link Query} with specified {@link com.google.cloud.datastore.models.ExplainOptions} + * and returns its result. {@link ReadOption}s can be specified if desired. + * + *

Example of running a query to find all entities of one kind. + * + *

{@code
+   * String kind = "my_kind";
+   * StructuredQuery query = Query.newEntityQueryBuilder()
+   *     .setKind(kind)
+   *     .build();
+   * QueryResults results = datastore.run(query, ExplainOptions.newBuilder().setAnalyze(true).build());
+   * }
+ * + * @throws DatastoreException upon failure + */ + @BetaApi + QueryResults run(Query query, ExplainOptions explainOptions, ReadOption... options); + + /** + * Submits a {@link AggregationQuery} and returns {@link AggregationResults}. {@link ReadOption}s + * can be specified if desired. + * + *

Example of running an {@link AggregationQuery} to find the count of entities of one kind. + * + *

{@link StructuredQuery} example: + * + *

{@code
+   * EntityQuery selectAllQuery = Query.newEntityQueryBuilder()
+   *    .setKind("Task")
+   *    .build();
+   * AggregationQuery aggregationQuery = Query.newAggregationQueryBuilder()
+   *    .addAggregation(count().as("total_count"))
+   *    .over(selectAllQuery)
+   *    .build();
+   * AggregationResults aggregationResults = datastore.runAggregation(aggregationQuery);
+   * for (AggregationResult aggregationResult : aggregationResults) {
+   *     System.out.println(aggregationResult.get("total_count"));
+   * }
+   * }
+ * + *

{@link GqlQuery} example: + * + *

{@code
+   * GqlQuery selectAllGqlQuery = Query.newGqlQueryBuilder(
+   *         "AGGREGATE COUNT(*) AS total_count, COUNT_UP_TO(100) AS count_upto_100 OVER(SELECT * FROM Task)"
+   *     )
+   *     .setAllowLiteral(true)
+   *     .build();
+   * AggregationQuery aggregationQuery = Query.newAggregationQueryBuilder()
+   *     .over(selectAllGqlQuery)
+   *     .build();
+   * AggregationResults aggregationResults = datastore.runAggregation(aggregationQuery);
+   * for (AggregationResult aggregationResult : aggregationResults) {
+   *   System.out.println(aggregationResult.get("total_count"));
+   *   System.out.println(aggregationResult.get("count_upto_100"));
+   * }
+   * }
+ * + * @throws DatastoreException upon failure + * @return {@link AggregationResults} + */ + AggregationResults runAggregation(AggregationQuery query, ReadOption... options); + + /** + * Submits a {@link AggregationQuery} with specified {@link + * com.google.cloud.datastore.models.ExplainOptions} and returns {@link AggregationResults}. + * {@link ReadOption}s can be specified if desired. + * + *

Example of running an {@link AggregationQuery} to find the count of entities of one kind. + * + *

{@link StructuredQuery} example: + * + *

{@code
+   * EntityQuery selectAllQuery = Query.newEntityQueryBuilder()
+   *    .setKind("Task")
+   *    .build();
+   * AggregationQuery aggregationQuery = Query.newAggregationQueryBuilder()
+   *    .addAggregation(count().as("total_count"))
+   *    .over(selectAllQuery)
+   *    .build();
+   * AggregationResults aggregationResults = datastore.runAggregation(aggregationQuery, ExplainOptions.newBuilder().setAnalyze(true).build());
+   * }
+ * + * @throws DatastoreException upon failure + * @return {@link AggregationResults} + */ + @BetaApi + AggregationResults runAggregation( + AggregationQuery query, ExplainOptions explainOptions, ReadOption... options); + + /** + * 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 Datastore client + * is no longer usable. + */ + @Override + void close() throws Exception; + + /** Returns true if this background resource has been shut down. */ + boolean isClosed(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreBatchWriter.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreBatchWriter.java new file mode 100644 index 000000000000..38ff7b6d04ae --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreBatchWriter.java @@ -0,0 +1,121 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.api.core.InternalExtensionOnly; +import java.util.List; +import javax.annotation.concurrent.NotThreadSafe; + +/** + * An interface to represent a batch of write operations. All write operation for a batch writer + * will be applied to the Datastore in one RPC call. + * + *

WARNING: This class maintains an internal state in terms of {@link + * java.util.LinkedHashMap} and {@link java.util.LinkedHashSet} which gets updated on every method + * call performing CRUD operations to record the mutations. Since {@link java.util.LinkedHashMap} is + * not thread safe as per its documentation, + * This class too should not be treated as a thread safe class. + */ +@NotThreadSafe +@InternalExtensionOnly +public interface DatastoreBatchWriter extends DatastoreWriter { + + /** + * Datastore add operation. This method will also allocate id for any entity with an incomplete + * key. As opposed to {@link #add(FullEntity)} and {@link #add(FullEntity...)}, this method will + * defer any necessary id allocation to submit time. + * + * @throws IllegalArgumentException if any of the given entities is missing a key + * @throws DatastoreException if a given entity with a complete key was already added to this + * writer or if not active + */ + void addWithDeferredIdAllocation(FullEntity... entities); + + /** + * {@inheritDoc} If {@code entity} has a complete key and was already marked for deletion in this + * writer, the operation will be changed to {@link #put}. + * + * @throws DatastoreException if a given entity with the same complete key was already added to + * this writer, if writer is not active or if id allocation for an entity with an incomplete + * key failed + */ + @Override + Entity add(FullEntity entity); + + /** + * {@inheritDoc} For entities with complete keys that were marked for deletion in this writer the + * operation will be changed to {@link #put}. + * + * @throws DatastoreException if a given entity with the same complete key was already added to + * this writer, if writer is not active or if id allocation for an entity with an incomplete + * key failed + */ + @Override + List add(FullEntity... entities); + + /** + * {@inheritDoc} This operation will be converted to {@link #put} operation for entities that were + * already added or put in this writer. + * + * @throws DatastoreException if an entity is marked for deletion in this writer or if not active + */ + @Override + void update(Entity... entities); + + /** + * {@inheritDoc} This operation will also remove from this batch any prior writes for entities + * with the same keys. + * + * @throws DatastoreException if not active + */ + @Override + void delete(Key... keys); + + /** + * Datastore put operation. This method will also allocate id for any entity with an incomplete + * key. As opposed to {@link #put(FullEntity)} and {@link #put(FullEntity...)}, this method will + * defer any necessary id allocation to submit time. + * + * @throws IllegalArgumentException if any of the given entities is missing a key + * @throws DatastoreException if not active + */ + void putWithDeferredIdAllocation(FullEntity... entities); + + /** + * {@inheritDoc} This operation will also remove from this writer any prior writes for the same + * entity. + * + * @throws DatastoreException if not active or if id allocation for an entity with an incomplete + * key failed + */ + @Override + Entity put(FullEntity entity); + + /** + * {@inheritDoc} This operation will also remove from this writer any prior writes for the same + * entities. + * + * @throws DatastoreException if not active or if id allocation for an entity with an incomplete + * key failed + */ + @Override + List put(FullEntity... entities); + + /** Returns {@code true} if still active (write operations were not sent to the Datastore). */ + boolean isActive(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreException.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreException.java new file mode 100644 index 000000000000..0b46b4b07790 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreException.java @@ -0,0 +1,163 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.api.gax.grpc.GrpcStatusCode; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.StatusCode; +import com.google.cloud.BaseServiceException; +import com.google.cloud.RetryHelper.RetryHelperException; +import com.google.cloud.http.BaseHttpServiceException; +import com.google.common.base.Strings; +import com.google.common.collect.ImmutableSet; +import io.grpc.StatusException; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.Set; + +/** + * Datastore service exception. + * + * @see Google Cloud + * Datastore error codes + */ +public final class DatastoreException extends BaseHttpServiceException { + + // see https://cloud.google.com/datastore/docs/concepts/errors#Error_Codes + private static final Set RETRYABLE_ERRORS = + ImmutableSet.of( + new Error(10, "ABORTED", false), + new Error(4, "DEADLINE_EXCEEDED", false), + new Error(14, "UNAVAILABLE", true)); + private static final long serialVersionUID = 2663750991205874435L; + + public DatastoreException(int code, String message, String reason) { + this(code, message, reason, true, null); + } + + public DatastoreException(int code, String message, Throwable cause) { + super(code, message, null, true, RETRYABLE_ERRORS, cause); + } + + public DatastoreException(int code, String message, String reason, Throwable cause) { + super(code, message, reason, true, RETRYABLE_ERRORS, cause); + } + + public DatastoreException( + int code, String message, String reason, boolean idempotent, Throwable cause) { + super(code, message, reason, idempotent, RETRYABLE_ERRORS, cause); + } + + public DatastoreException(IOException exception) { + super(exception, true, RETRYABLE_ERRORS); + } + + /** + * Translate RetryHelperException to the DatastoreException that caused the error. This method + * will always throw an exception. + * + * @throws DatastoreException when {@code ex} was caused by a {@code DatastoreException} + */ + static DatastoreException translateAndThrow(RetryHelperException ex) { + BaseServiceException.translate(ex); + throw transformThrowable(ex); + } + + static BaseServiceException transformThrowable(Throwable t) { + if (t instanceof BaseServiceException) { + return (BaseServiceException) t; + } + if (t.getCause() instanceof BaseServiceException) { + return (BaseServiceException) t.getCause(); + } + if (t instanceof ApiException) { + return asDatastoreException((ApiException) t); + } + if (t.getCause() instanceof ApiException) { + return asDatastoreException((ApiException) t.getCause()); + } + return getDatastoreException(t); + } + + private static DatastoreException getDatastoreException(Throwable t) { + // unwrap a RetryHelperException if that is what is being translated + if (t instanceof RetryHelperException) { + return new DatastoreException(UNKNOWN_CODE, t.getMessage(), null, t.getCause()); + } + return new DatastoreException(UNKNOWN_CODE, t.getMessage(), t); + } + + static DatastoreException asDatastoreException(ApiException apiEx) { + int datastoreStatusCode = 0; + StatusCode statusCode = apiEx.getStatusCode(); + if (statusCode instanceof GrpcStatusCode) { + GrpcStatusCode gsc = (GrpcStatusCode) statusCode; + datastoreStatusCode = + GrpcToDatastoreCodeTranslation.grpcCodeToDatastoreStatusCode(gsc.getTransportCode()); + } + + // If there is a gRPC exception in our cause, pull its error message up to be our + // message otherwise, create a generic error message with the status code. + String statusCodeName = statusCode.getCode().name(); + String statusExceptionMessage = getStatusExceptionMessage(apiEx); + + String message; + if (statusExceptionMessage != null) { + message = statusCodeName + ": " + statusExceptionMessage; + } else { + message = "Error: " + statusCodeName; + } + + String reason = ""; + if (Strings.isNullOrEmpty(apiEx.getReason())) { + if (apiEx.getStatusCode() != null) { + reason = apiEx.getStatusCode().getCode().name(); + } + } + // It'd be better to use ExceptionData and BaseServiceException#(ExceptionData) but, + // BaseHttpServiceException does not pass that through so we're stuck using this for now. + // TODO: When we can break the coupling to BaseHttpServiceException replace this + return new DatastoreException(datastoreStatusCode, message, reason, apiEx); + } + + private static String getStatusExceptionMessage(Exception apiEx) { + if (apiEx.getMessage() != null) { + return apiEx.getMessage(); + } else { + Throwable cause = apiEx.getCause(); + if (cause instanceof StatusRuntimeException || cause instanceof StatusException) { + return cause.getMessage(); + } + return null; + } + } + + /** + * Throw a DatastoreException with {@code FAILED_PRECONDITION} reason and the {@code message} in a + * nested exception. + * + * @throws DatastoreException every time + */ + static DatastoreException throwInvalidRequest(String massage, Object... params) { + throw new DatastoreException( + UNKNOWN_CODE, String.format(massage, params), "FAILED_PRECONDITION"); + } + + static DatastoreException propagateUserException(Exception ex) { + throw new DatastoreException(BaseServiceException.UNKNOWN_CODE, ex.getMessage(), null, ex); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreFactory.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreFactory.java new file mode 100644 index 000000000000..b29786f95c43 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreFactory.java @@ -0,0 +1,24 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.ServiceFactory; + +/** An interface for Datastore factories. */ +@InternalExtensionOnly +public interface DatastoreFactory extends ServiceFactory {} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreHelper.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreHelper.java new file mode 100644 index 000000000000..bc7e399f2500 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreHelper.java @@ -0,0 +1,89 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.common.collect.Iterators; +import com.google.common.collect.Maps; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * Provide functionality that should be added to the appropriate interfaces via Java 8 default + * methods. + */ +class DatastoreHelper { + + private DatastoreHelper() {} + + static Key allocateId(Datastore service, IncompleteKey key) { + return service.allocateId(new IncompleteKey[] {key}).get(0); + } + + static Entity get(Transaction reader, Key key) { + return Iterators.getNext(reader.get(new Key[] {key}), null); + } + + static Entity get(Datastore reader, Key key, ReadOption... options) { + return Iterators.getNext(reader.get(Collections.singletonList(key), options), null); + } + + static Entity add(DatastoreWriter writer, FullEntity entity) { + return writer.add(new FullEntity[] {entity}).get(0); + } + + static Entity put(DatastoreWriter writer, FullEntity entity) { + return writer.put(new FullEntity[] {entity}).get(0); + } + + static KeyFactory newKeyFactory(DatastoreOptions options) { + return new KeyFactory(options.getProjectId(), options.getNamespace(), options.getDatabaseId()); + } + + /** + * Returns a list with a value for each given key (ordered by input). {@code null} values are + * returned for nonexistent keys. + */ + static List fetch(Transaction reader, Key... keys) { + return compileEntities(keys, reader.get(keys)); + } + + /** + * Returns a list with a value for each given key (ordered by input). {@code null} values are + * returned for nonexistent keys. + */ + static List fetch(Datastore reader, Key[] keys, ReadOption... options) { + return compileEntities(keys, reader.get(Arrays.asList(keys), options)); + } + + private static List compileEntities(Key[] keys, Iterator entities) { + Map map = Maps.newHashMapWithExpectedSize(keys.length); + while (entities.hasNext()) { + Entity entity = entities.next(); + map.put(entity.getKey(), entity); + } + List list = new ArrayList<>(keys.length); + for (Key key : keys) { + // this will include nulls for nonexistent keys + list.add(map.get(key)); + } + return list; + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java new file mode 100644 index 000000000000..22f20d68c3b2 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreImpl.java @@ -0,0 +1,844 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_DEFERRED; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_DOCUMENT_COUNT; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_MISSING; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_MORE_RESULTS; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_READ_CONSISTENCY; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_RECEIVED; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_TRANSACTIONAL; +import static com.google.cloud.datastore.telemetry.TraceUtil.ATTRIBUTES_KEY_TRANSACTION_ID; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_ALLOCATE_IDS; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_BEGIN_TRANSACTION; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_COMMIT; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_LOOKUP; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RESERVE_IDS; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_ROLLBACK; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RUN_QUERY; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_COMMIT; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_LOOKUP; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_RUN; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_RUN_QUERY; + +import com.google.api.core.BetaApi; +import com.google.api.gax.retrying.RetrySettings; +import com.google.cloud.BaseService; +import com.google.cloud.ExceptionHandler; +import com.google.cloud.RetryHelper; +import com.google.cloud.RetryHelper.RetryHelperException; +import com.google.cloud.ServiceOptions; +import com.google.cloud.datastore.execution.AggregationQueryExecutor; +import com.google.cloud.datastore.spi.v1.DatastoreRpc; +import com.google.cloud.datastore.telemetry.TraceUtil; +import com.google.cloud.datastore.telemetry.TraceUtil.Scope; +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; +import com.google.common.collect.AbstractIterator; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterables; +import com.google.common.collect.Sets; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.ExplainOptions; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.datastore.v1.TransactionOptions; +import com.google.protobuf.ByteString; +import io.opentelemetry.context.Context; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.Callable; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.annotation.Nullable; + +final class DatastoreImpl extends BaseService implements Datastore { + + Logger logger = Logger.getLogger(Datastore.class.getName()); + private final DatastoreRpc datastoreRpc; + private final RetrySettings retrySettings; + private static final ExceptionHandler TRANSACTION_EXCEPTION_HANDLER = + TransactionExceptionHandler.build(); + private static final ExceptionHandler TRANSACTION_OPERATION_EXCEPTION_HANDLER = + TransactionOperationExceptionHandler.build(); + + private final com.google.cloud.datastore.telemetry.TraceUtil otelTraceUtil = + getOptions().getTraceUtil(); + + private final ReadOptionProtoPreparer readOptionProtoPreparer; + private final AggregationQueryExecutor aggregationQueryExecutor; + + DatastoreImpl(DatastoreOptions options) { + super(options); + this.datastoreRpc = options.getDatastoreRpcV1(); + retrySettings = + MoreObjects.firstNonNull(options.getRetrySettings(), ServiceOptions.getNoRetrySettings()); + + readOptionProtoPreparer = new ReadOptionProtoPreparer(); + aggregationQueryExecutor = + new AggregationQueryExecutor( + new RetryAndTraceDatastoreRpcDecorator( + datastoreRpc, otelTraceUtil, retrySettings, options), + options); + } + + @Override + public Batch newBatch() { + return new BatchImpl(this); + } + + @Override + public Transaction newTransaction(TransactionOptions transactionOptions) { + return new TransactionImpl(this, transactionOptions); + } + + @Override + public Transaction newTransaction() { + return new TransactionImpl(this); + } + + static class TracedReadWriteTransactionCallable implements Callable { + private final Datastore datastore; + private final TransactionCallable callable; + private volatile TransactionOptions options; + private volatile Transaction transaction; + + private final TraceUtil.Span parentSpan; + + TracedReadWriteTransactionCallable( + Datastore datastore, + TransactionCallable callable, + TransactionOptions options, + @Nullable com.google.cloud.datastore.telemetry.TraceUtil.Span parentSpan) { + this.datastore = datastore; + this.callable = callable; + this.options = options; + this.transaction = null; + this.parentSpan = parentSpan; + } + + Datastore getDatastore() { + return datastore; + } + + TransactionOptions getOptions() { + return options; + } + + Transaction getTransaction() { + return transaction; + } + + void setPrevTransactionId(ByteString transactionId) { + TransactionOptions.ReadWrite readWrite = + TransactionOptions.ReadWrite.newBuilder().setPreviousTransaction(transactionId).build(); + options = options.toBuilder().setReadWrite(readWrite).build(); + } + + @Override + public T call() throws DatastoreException { + try (io.opentelemetry.context.Scope ignored = + Context.current().with(parentSpan.getSpan()).makeCurrent()) { + transaction = datastore.newTransaction(options); + T value = callable.run(transaction); + transaction.commit(); + return value; + } catch (Exception ex) { + transaction.rollback(); + throw DatastoreException.propagateUserException(ex); + } finally { + if (transaction.isActive()) { + transaction.rollback(); + } + if (options != null + && options.getModeCase().equals(TransactionOptions.ModeCase.READ_WRITE)) { + setPrevTransactionId(transaction.getTransactionId()); + } + } + } + } + + @Override + public void close() throws Exception { + try { + datastoreRpc.close(); + } catch (Exception e) { + logger.log(Level.WARNING, "Failed to close channels", e); + } + } + + @Override + public boolean isClosed() { + return datastoreRpc.isClosed(); + } + + static class ReadWriteTransactionCallable implements Callable { + private final Datastore datastore; + private final TransactionCallable callable; + private volatile TransactionOptions options; + private volatile Transaction transaction; + + ReadWriteTransactionCallable( + Datastore datastore, TransactionCallable callable, TransactionOptions options) { + this.datastore = datastore; + this.callable = callable; + this.options = options; + this.transaction = null; + } + + Datastore getDatastore() { + return datastore; + } + + TransactionOptions getOptions() { + return options; + } + + Transaction getTransaction() { + return transaction; + } + + void setPrevTransactionId(ByteString transactionId) { + TransactionOptions.ReadWrite readWrite = + TransactionOptions.ReadWrite.newBuilder().setPreviousTransaction(transactionId).build(); + options = options.toBuilder().setReadWrite(readWrite).build(); + } + + @Override + public T call() throws DatastoreException { + try { + transaction = datastore.newTransaction(options); + T value = callable.run(transaction); + transaction.commit(); + return value; + } catch (Exception ex) { + transaction.rollback(); + throw DatastoreException.propagateUserException(ex); + } finally { + if (transaction.isActive()) { + transaction.rollback(); + } + if (options != null + && options.getModeCase().equals(TransactionOptions.ModeCase.READ_WRITE)) { + setPrevTransactionId(transaction.getTransactionId()); + } + } + } + } + + @Override + public T runInTransaction(final TransactionCallable callable) { + TraceUtil.Span span = otelTraceUtil.startSpan(SPAN_NAME_TRANSACTION_RUN); + Callable transactionCallable = + (getOptions().getOpenTelemetryOptions().isEnabled() + ? new TracedReadWriteTransactionCallable( + this, callable, /* transactionOptions= */ null, span) + : new ReadWriteTransactionCallable(this, callable, /* transactionOptions= */ null)); + try (Scope ignored = span.makeCurrent()) { + return RetryHelper.runWithRetries( + transactionCallable, + retrySettings, + TRANSACTION_EXCEPTION_HANDLER, + getOptions().getClock()); + } catch (RetryHelperException e) { + span.end(e); + throw DatastoreException.translateAndThrow(e); + } finally { + span.end(); + } + } + + @Override + public T runInTransaction( + final TransactionCallable callable, TransactionOptions transactionOptions) { + TraceUtil.Span span = otelTraceUtil.startSpan(SPAN_NAME_TRANSACTION_RUN); + + Callable transactionCallable = + (getOptions().getOpenTelemetryOptions().isEnabled() + ? new TracedReadWriteTransactionCallable(this, callable, transactionOptions, span) + : new ReadWriteTransactionCallable(this, callable, transactionOptions)); + + try (Scope ignored = span.makeCurrent()) { + return RetryHelper.runWithRetries( + transactionCallable, + retrySettings, + TRANSACTION_EXCEPTION_HANDLER, + getOptions().getClock()); + } catch (RetryHelperException e) { + span.end(e); + throw DatastoreException.translateAndThrow(e); + } finally { + span.end(); + } + } + + @Override + public QueryResults run(Query query) { + return run(Optional.empty(), query, null); + } + + @Override + public QueryResults run(Query query, ReadOption... options) { + return run(toReadOptionsPb(options), query, null); + } + + @Override + @BetaApi + public QueryResults run( + Query query, + com.google.cloud.datastore.models.ExplainOptions explainOptions, + ReadOption... options) { + return run(toReadOptionsPb(options), query, explainOptions.toPb()); + } + + @SuppressWarnings("unchecked") + QueryResults run( + Optional readOptionsPb, Query query, ExplainOptions explainOptions) { + return new QueryResultsImpl( + this, readOptionsPb, (RecordQuery) query, query.getNamespace(), explainOptions); + } + + @Override + public AggregationResults runAggregation(AggregationQuery query) { + return aggregationQueryExecutor.execute(query, null); + } + + @Override + public AggregationResults runAggregation(AggregationQuery query, ReadOption... options) { + return aggregationQueryExecutor.execute(query, null, options); + } + + @Override + @BetaApi + public AggregationResults runAggregation( + AggregationQuery query, com.google.cloud.datastore.models.ExplainOptions explainOptions) { + return aggregationQueryExecutor.execute(query, explainOptions); + } + + @Override + @BetaApi + public AggregationResults runAggregation( + AggregationQuery query, + com.google.cloud.datastore.models.ExplainOptions explainOptions, + ReadOption... options) { + return aggregationQueryExecutor.execute(query, explainOptions, options); + } + + com.google.datastore.v1.RunQueryResponse runQuery( + final com.google.datastore.v1.RunQueryRequest requestPb) { + ReadOptions readOptions = requestPb.getReadOptions(); + boolean isTransactional = readOptions.hasTransaction() || readOptions.hasNewTransaction(); + String spanName = (isTransactional ? SPAN_NAME_TRANSACTION_RUN_QUERY : SPAN_NAME_RUN_QUERY); + com.google.cloud.datastore.telemetry.TraceUtil.Span span = otelTraceUtil.startSpan(spanName); + + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { + RunQueryResponse response = + RetryHelper.runWithRetries( + () -> datastoreRpc.runQuery(requestPb), + retrySettings, + requestPb.getReadOptions().getTransaction().isEmpty() + ? EXCEPTION_HANDLER + : TRANSACTION_OPERATION_EXCEPTION_HANDLER, + getOptions().getClock()); + span.addEvent( + spanName + " complete.", + new ImmutableMap.Builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, response.getBatch().getEntityResultsCount()) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, isTransactional) + .put(ATTRIBUTES_KEY_READ_CONSISTENCY, readOptions.getReadConsistency().toString()) + .put( + ATTRIBUTES_KEY_TRANSACTION_ID, + (isTransactional + ? requestPb.getReadOptions().getTransaction().toStringUtf8() + : "")) + .put(ATTRIBUTES_KEY_MORE_RESULTS, response.getBatch().getMoreResults().toString()) + .build()); + return response; + } catch (RetryHelperException e) { + span.end(e); + throw DatastoreException.translateAndThrow(e); + } finally { + span.end(); + } + } + + @Override + public Key allocateId(IncompleteKey key) { + return DatastoreHelper.allocateId(this, key); + } + + private boolean verifyIncompleteKeyType(IncompleteKey... keys) { + for (IncompleteKey key : keys) { + if (key instanceof Key) { + return false; + } + } + return true; + } + + @Override + public List allocateId(IncompleteKey... keys) { + Preconditions.checkArgument( + verifyIncompleteKeyType(keys), "keys must be IncompleteKey instances"); + if (keys.length == 0) { + return Collections.emptyList(); + } + com.google.datastore.v1.AllocateIdsRequest.Builder requestPb = + com.google.datastore.v1.AllocateIdsRequest.newBuilder(); + for (IncompleteKey key : keys) { + requestPb.addKeys(trimNameOrId(key).toPb()); + } + requestPb.setProjectId(getOptions().getProjectId()); + requestPb.setDatabaseId(getOptions().getDatabaseId()); + com.google.datastore.v1.AllocateIdsResponse responsePb = allocateIds(requestPb.build()); + ImmutableList.Builder keyList = ImmutableList.builder(); + for (com.google.datastore.v1.Key keyPb : responsePb.getKeysList()) { + keyList.add(Key.fromPb(keyPb)); + } + return keyList.build(); + } + + private com.google.datastore.v1.AllocateIdsResponse allocateIds( + final com.google.datastore.v1.AllocateIdsRequest requestPb) { + com.google.cloud.datastore.telemetry.TraceUtil.Span span = + otelTraceUtil.startSpan(SPAN_NAME_ALLOCATE_IDS); + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { + return RetryHelper.runWithRetries( + new Callable() { + @Override + public com.google.datastore.v1.AllocateIdsResponse call() throws DatastoreException { + return datastoreRpc.allocateIds(requestPb); + } + }, + retrySettings, + EXCEPTION_HANDLER, + getOptions().getClock()); + } catch (RetryHelperException e) { + span.end(e); + throw DatastoreException.translateAndThrow(e); + } finally { + span.end(); + } + } + + private IncompleteKey trimNameOrId(IncompleteKey key) { + if (key instanceof Key) { + return IncompleteKey.newBuilder(key).build(); + } + return key; + } + + @Override + public Entity add(FullEntity entity) { + return DatastoreHelper.add(this, entity); + } + + @SuppressWarnings("unchecked") + @Override + public List add(FullEntity... entities) { + if (entities.length == 0) { + return Collections.emptyList(); + } + List mutationsPb = new ArrayList<>(); + Map completeEntities = new LinkedHashMap<>(); + for (FullEntity entity : entities) { + Entity completeEntity = null; + if (entity.getKey() instanceof Key) { + completeEntity = Entity.convert((FullEntity) entity); + } + if (completeEntity != null) { + if (completeEntities.put(completeEntity.getKey(), completeEntity) != null) { + throw DatastoreException.throwInvalidRequest( + "Duplicate entity with the key %s", entity.getKey()); + } + } else { + Preconditions.checkArgument(entity.hasKey(), "Entity %s is missing a key", entity); + } + mutationsPb.add( + com.google.datastore.v1.Mutation.newBuilder().setInsert(entity.toPb()).build()); + } + com.google.datastore.v1.CommitResponse commitResponse = commitMutation(mutationsPb); + Iterator mutationResults = + commitResponse.getMutationResultsList().iterator(); + ImmutableList.Builder responseBuilder = ImmutableList.builder(); + for (FullEntity entity : entities) { + Entity completeEntity = completeEntities.get(entity.getKey()); + if (completeEntity != null) { + responseBuilder.add(completeEntity); + mutationResults.next(); + } else { + responseBuilder.add( + Entity.newBuilder(Key.fromPb(mutationResults.next().getKey()), entity).build()); + } + } + return responseBuilder.build(); + } + + @Override + public Entity get(Key key) { + return DatastoreHelper.get(this, key); + } + + @Override + public Entity get(Key key, ReadOption... options) { + return DatastoreHelper.get(this, key, options); + } + + @Override + public Iterator get(Key... keys) { + return get(Optional.empty(), keys); + } + + @Override + public Iterator get(Iterable keys, ReadOption... options) { + return get(toReadOptionsPb(options), Iterables.toArray(keys, Key.class)); + } + + private Optional toReadOptionsPb(ReadOption... options) { + if (options == null) { + return Optional.empty(); + } + return this.readOptionProtoPreparer.prepare(Arrays.asList(options)); + } + + @Override + public List fetch(Key... keys) { + return DatastoreHelper.fetch(this, keys); + } + + @Override + public List fetch(Iterable keys, ReadOption... options) { + return DatastoreHelper.fetch(this, Iterables.toArray(keys, Key.class), options); + } + + Iterator get(Optional readOptionsPb, final Key... keys) { + if (keys.length == 0) { + return Collections.emptyIterator(); + } + com.google.datastore.v1.LookupRequest.Builder requestPb = + com.google.datastore.v1.LookupRequest.newBuilder(); + readOptionsPb.ifPresent(requestPb::setReadOptions); + for (Key k : Sets.newLinkedHashSet(Arrays.asList(keys))) { + requestPb.addKeys(k.toPb()); + } + requestPb.setProjectId(getOptions().getProjectId()); + requestPb.setDatabaseId(getOptions().getDatabaseId()); + return new ResultsIterator(requestPb); + } + + final class ResultsIterator extends AbstractIterator { + + private final com.google.datastore.v1.LookupRequest.Builder requestPb; + Iterator iter; + + ResultsIterator(com.google.datastore.v1.LookupRequest.Builder requestPb) { + this.requestPb = requestPb; + loadResults(); + } + + private void loadResults() { + com.google.datastore.v1.LookupResponse responsePb = lookup(requestPb.build()); + iter = responsePb.getFoundList().iterator(); + requestPb.clearKeys(); + if (responsePb.getDeferredCount() > 0) { + requestPb.addAllKeys(responsePb.getDeferredList()); + } + } + + @SuppressWarnings("unchecked") + @Override + protected Entity computeNext() { + while (!iter.hasNext()) { + if (requestPb.getKeysCount() == 0) { + return endOfData(); + } + loadResults(); + } + return Entity.fromPb(iter.next().getEntity()); + } + } + + com.google.datastore.v1.LookupResponse lookup( + final com.google.datastore.v1.LookupRequest requestPb) { + ReadOptions readOptions = requestPb.getReadOptions(); + boolean isTransactional = readOptions.hasTransaction() || readOptions.hasNewTransaction(); + String spanName = (isTransactional ? SPAN_NAME_TRANSACTION_LOOKUP : SPAN_NAME_LOOKUP); + com.google.cloud.datastore.telemetry.TraceUtil.Span span = otelTraceUtil.startSpan(spanName); + + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { + return RetryHelper.runWithRetries( + () -> { + com.google.datastore.v1.LookupResponse response = datastoreRpc.lookup(requestPb); + span.addEvent( + spanName + " complete.", + new ImmutableMap.Builder() + .put(ATTRIBUTES_KEY_RECEIVED, response.getFoundCount()) + .put(ATTRIBUTES_KEY_MISSING, response.getMissingCount()) + .put(ATTRIBUTES_KEY_DEFERRED, response.getDeferredCount()) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, isTransactional) + .put( + ATTRIBUTES_KEY_TRANSACTION_ID, + isTransactional ? readOptions.getTransaction().toStringUtf8() : "") + .build()); + return response; + }, + retrySettings, + requestPb.getReadOptions().getTransaction().isEmpty() + ? EXCEPTION_HANDLER + : TRANSACTION_OPERATION_EXCEPTION_HANDLER, + getOptions().getClock()); + } catch (RetryHelperException e) { + span.end(e); + throw DatastoreException.translateAndThrow(e); + } finally { + span.end(); + } + } + + @Override + public List reserveIds(Key... keys) { + ReserveIdsRequest.Builder requestPb = ReserveIdsRequest.newBuilder(); + for (Key key : keys) { + requestPb.addKeys(key.toPb()); + } + requestPb.setProjectId(getOptions().getProjectId()); + requestPb.setDatabaseId(getOptions().getDatabaseId()); + com.google.datastore.v1.ReserveIdsResponse responsePb = reserveIds(requestPb.build()); + ImmutableList.Builder keyList = ImmutableList.builder(); + if (responsePb.isInitialized()) { + for (Key key : keys) { + keyList.add(key); + } + } + return keyList.build(); + } + + com.google.datastore.v1.ReserveIdsResponse reserveIds( + final com.google.datastore.v1.ReserveIdsRequest requestPb) { + com.google.cloud.datastore.telemetry.TraceUtil.Span span = + otelTraceUtil.startSpan(SPAN_NAME_RESERVE_IDS); + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { + return RetryHelper.runWithRetries( + new Callable() { + @Override + public com.google.datastore.v1.ReserveIdsResponse call() throws DatastoreException { + return datastoreRpc.reserveIds(requestPb); + } + }, + retrySettings, + EXCEPTION_HANDLER, + getOptions().getClock()); + } catch (RetryHelperException e) { + span.end(e); + throw DatastoreException.translateAndThrow(e); + } finally { + span.end(); + } + } + + @Override + public void update(Entity... entities) { + if (entities.length > 0) { + List mutationsPb = new ArrayList<>(); + Map dedupEntities = new LinkedHashMap<>(); + for (Entity entity : entities) { + dedupEntities.put(entity.getKey(), entity); + } + for (Entity entity : dedupEntities.values()) { + mutationsPb.add( + com.google.datastore.v1.Mutation.newBuilder().setUpdate(entity.toPb()).build()); + } + commitMutation(mutationsPb); + } + } + + @Override + public Entity put(FullEntity entity) { + return DatastoreHelper.put(this, entity); + } + + @SuppressWarnings("unchecked") + @Override + public List put(FullEntity... entities) { + if (entities.length == 0) { + return Collections.emptyList(); + } + List mutationsPb = new ArrayList<>(); + Map dedupEntities = new LinkedHashMap<>(); + for (FullEntity entity : entities) { + Preconditions.checkArgument(entity.hasKey(), "Entity %s is missing a key", entity); + if (entity.getKey() instanceof Key) { + Entity completeEntity = Entity.convert((FullEntity) entity); + dedupEntities.put(completeEntity.getKey(), completeEntity); + } else { + mutationsPb.add( + com.google.datastore.v1.Mutation.newBuilder().setUpsert(entity.toPb()).build()); + } + } + for (Entity entity : dedupEntities.values()) { + mutationsPb.add( + com.google.datastore.v1.Mutation.newBuilder().setUpsert(entity.toPb()).build()); + } + com.google.datastore.v1.CommitResponse commitResponse = commitMutation(mutationsPb); + Iterator mutationResults = + commitResponse.getMutationResultsList().iterator(); + ImmutableList.Builder responseBuilder = ImmutableList.builder(); + for (FullEntity entity : entities) { + Entity completeEntity = dedupEntities.get(entity.getKey()); + if (completeEntity != null) { + responseBuilder.add(completeEntity); + } else { + responseBuilder.add( + Entity.newBuilder(Key.fromPb(mutationResults.next().getKey()), entity).build()); + } + } + return responseBuilder.build(); + } + + @Override + public void delete(Key... keys) { + if (keys.length > 0) { + List mutationsPb = new ArrayList<>(); + Set dedupKeys = new LinkedHashSet<>(Arrays.asList(keys)); + for (Key key : dedupKeys) { + mutationsPb.add( + com.google.datastore.v1.Mutation.newBuilder().setDelete(key.toPb()).build()); + } + commitMutation(mutationsPb); + } + } + + @Override + public KeyFactory newKeyFactory() { + return DatastoreHelper.newKeyFactory(getOptions()); + } + + private com.google.datastore.v1.CommitResponse commitMutation( + List mutationsPb) { + com.google.datastore.v1.CommitRequest.Builder requestPb = + com.google.datastore.v1.CommitRequest.newBuilder(); + requestPb.setMode(com.google.datastore.v1.CommitRequest.Mode.NON_TRANSACTIONAL); + requestPb.setProjectId(getOptions().getProjectId()); + requestPb.setDatabaseId(getOptions().getDatabaseId()); + requestPb.addAllMutations(mutationsPb); + return commit(requestPb.build()); + } + + com.google.datastore.v1.CommitResponse commit( + final com.google.datastore.v1.CommitRequest requestPb) { + final boolean isTransactional = + requestPb.hasTransaction() || requestPb.hasSingleUseTransaction(); + final String spanName = isTransactional ? SPAN_NAME_TRANSACTION_COMMIT : SPAN_NAME_COMMIT; + com.google.cloud.datastore.telemetry.TraceUtil.Span span = otelTraceUtil.startSpan(spanName); + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { + CommitResponse response = + RetryHelper.runWithRetries( + () -> datastoreRpc.commit(requestPb), + retrySettings, + requestPb.getTransaction().isEmpty() + ? EXCEPTION_HANDLER + : TRANSACTION_OPERATION_EXCEPTION_HANDLER, + getOptions().getClock()); + span.addEvent( + spanName + " complete.", + new ImmutableMap.Builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, response.getMutationResultsCount()) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, isTransactional) + .put( + ATTRIBUTES_KEY_TRANSACTION_ID, + isTransactional ? requestPb.getTransaction().toStringUtf8() : "") + .build()); + return response; + } catch (RetryHelperException e) { + span.end(e); + throw DatastoreException.translateAndThrow(e); + } finally { + span.end(); + } + } + + ByteString requestTransactionId( + com.google.datastore.v1.BeginTransactionRequest.Builder requestPb) { + return beginTransaction(requestPb.build()).getTransaction(); + } + + com.google.datastore.v1.BeginTransactionResponse beginTransaction( + final com.google.datastore.v1.BeginTransactionRequest requestPb) { + com.google.cloud.datastore.telemetry.TraceUtil.Span span = + otelTraceUtil.startSpan(SPAN_NAME_BEGIN_TRANSACTION); + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope scope = span.makeCurrent()) { + return RetryHelper.runWithRetries( + () -> datastoreRpc.beginTransaction(requestPb), + retrySettings, + EXCEPTION_HANDLER, + getOptions().getClock()); + } catch (RetryHelperException e) { + span.end(e); + throw DatastoreException.translateAndThrow(e); + } finally { + span.end(); + } + } + + void rollbackTransaction(ByteString transaction) { + com.google.datastore.v1.RollbackRequest.Builder requestPb = + com.google.datastore.v1.RollbackRequest.newBuilder(); + requestPb.setTransaction(transaction); + requestPb.setProjectId(getOptions().getProjectId()); + requestPb.setDatabaseId(getOptions().getDatabaseId()); + rollback(requestPb.build()); + } + + void rollback(final com.google.datastore.v1.RollbackRequest requestPb) { + com.google.cloud.datastore.telemetry.TraceUtil.Span span = + otelTraceUtil.startSpan(SPAN_NAME_ROLLBACK); + try (Scope scope = span.makeCurrent()) { + RetryHelper.runWithRetries( + new Callable() { + @Override + public Void call() throws DatastoreException { + datastoreRpc.rollback(requestPb); + return null; + } + }, + retrySettings, + EXCEPTION_HANDLER, + getOptions().getClock()); + span.addEvent( + SPAN_NAME_ROLLBACK, + new ImmutableMap.Builder() + .put(ATTRIBUTES_KEY_TRANSACTION_ID, requestPb.getTransaction().toStringUtf8()) + .build()); + } catch (RetryHelperException e) { + span.end(e); + throw DatastoreException.translateAndThrow(e); + } finally { + span.end(); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOpenTelemetryOptions.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOpenTelemetryOptions.java new file mode 100644 index 000000000000..847e36c83d19 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOpenTelemetryOptions.java @@ -0,0 +1,97 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import io.opentelemetry.api.OpenTelemetry; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class DatastoreOpenTelemetryOptions { + private final boolean enabled; + private final @Nullable OpenTelemetry openTelemetry; + + DatastoreOpenTelemetryOptions(Builder builder) { + this.enabled = builder.enabled; + this.openTelemetry = builder.openTelemetry; + } + + public boolean isEnabled() { + return enabled; + } + + @Nullable + public OpenTelemetry getOpenTelemetry() { + return openTelemetry; + } + + @Nonnull + public DatastoreOpenTelemetryOptions.Builder toBuilder() { + return new DatastoreOpenTelemetryOptions.Builder(this); + } + + @Nonnull + public static DatastoreOpenTelemetryOptions.Builder newBuilder() { + return new DatastoreOpenTelemetryOptions.Builder(); + } + + public static class Builder { + + private boolean enabled; + + @Nullable private OpenTelemetry openTelemetry; + + private Builder() { + enabled = false; + openTelemetry = null; + } + + private Builder(DatastoreOpenTelemetryOptions options) { + this.enabled = options.enabled; + this.openTelemetry = options.openTelemetry; + } + + @Nonnull + public DatastoreOpenTelemetryOptions build() { + return new DatastoreOpenTelemetryOptions(this); + } + + /** + * Sets whether tracing should be enabled. + * + * @param enabled Whether tracing should be enabled. + */ + @Nonnull + public DatastoreOpenTelemetryOptions.Builder setTracingEnabled(boolean enabled) { + this.enabled = enabled; + return this; + } + + /** + * Sets the {@link OpenTelemetry} to use with this Datastore instance. If telemetry collection + * is enabled, but an `OpenTelemetry` is not provided, the Datastore SDK will attempt to use the + * `GlobalOpenTelemetry`. + * + * @param openTelemetry The OpenTelemetry that should be used by this Datastore instance. + */ + @Nonnull + public DatastoreOpenTelemetryOptions.Builder setOpenTelemetry( + @Nonnull OpenTelemetry openTelemetry) { + this.openTelemetry = openTelemetry; + return this; + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOptions.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOptions.java new file mode 100644 index 000000000000..942f3d08aa54 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreOptions.java @@ -0,0 +1,369 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.cloud.datastore.Validator.validateNamespace; + +import com.google.api.core.ApiFunction; +import com.google.api.core.BetaApi; +import com.google.api.gax.grpc.ChannelPoolSettings; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.rpc.TransportChannelProvider; +import com.google.cloud.ServiceDefaults; +import com.google.cloud.ServiceOptions; +import com.google.cloud.ServiceRpc; +import com.google.cloud.TransportOptions; +import com.google.cloud.datastore.spi.DatastoreRpcFactory; +import com.google.cloud.datastore.spi.v1.DatastoreRpc; +import com.google.cloud.datastore.spi.v1.GrpcDatastoreRpc; +import com.google.cloud.datastore.spi.v1.HttpDatastoreRpc; +import com.google.cloud.datastore.v1.DatastoreSettings; +import com.google.cloud.grpc.GrpcTransportOptions; +import com.google.cloud.http.HttpTransportOptions; +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableSet; +import io.grpc.ManagedChannelBuilder; +import java.io.IOException; +import java.lang.reflect.Method; +import java.util.Objects; +import java.util.Set; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +public class DatastoreOptions extends ServiceOptions { + + private static final long serialVersionUID = -1018382430058137336L; + private static final String API_SHORT_NAME = "Datastore"; + private static final String DATASTORE_SCOPE = "https://www.googleapis.com/auth/datastore"; + private static final Set SCOPES = ImmutableSet.of(DATASTORE_SCOPE); + private static final String DEFAULT_DATABASE_ID = ""; + public static final String PROJECT_ID_ENV_VAR = "DATASTORE_PROJECT_ID"; + public static final String LOCAL_HOST_ENV_VAR = "DATASTORE_EMULATOR_HOST"; + public static final int INIT_CHANNEL_COUNT = 1; + public static final int MIN_CHANNEL_COUNT = 1; + public static final int MAX_CHANNEL_COUNT = 4; + + private transient TransportChannelProvider channelProvider = null; + + private final String namespace; + private final String databaseId; + + private final transient @Nonnull DatastoreOpenTelemetryOptions openTelemetryOptions; + private final transient @Nonnull com.google.cloud.datastore.telemetry.TraceUtil traceUtil; + + public static class DefaultDatastoreFactory implements DatastoreFactory { + + private static final DatastoreFactory INSTANCE = new DefaultDatastoreFactory(); + + @Override + public Datastore create(DatastoreOptions options) { + return new DatastoreImpl(options); + } + } + + public static class DefaultDatastoreRpcFactory implements DatastoreRpcFactory { + + private static final DatastoreRpcFactory INSTANCE = new DefaultDatastoreRpcFactory(); + + @Override + public ServiceRpc create(DatastoreOptions options) { + try { + if (options.getTransportOptions() instanceof GrpcTransportOptions) { + return new GrpcDatastoreRpc(options); + } else { + return new HttpDatastoreRpc(options); + } + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + + @Nonnull + com.google.cloud.datastore.telemetry.TraceUtil getTraceUtil() { + return traceUtil; + } + + @BetaApi + @Nonnull + public DatastoreOpenTelemetryOptions getOpenTelemetryOptions() { + return openTelemetryOptions; + } + + public static class Builder extends ServiceOptions.Builder { + + private String namespace; + private String databaseId; + private TransportChannelProvider channelProvider = null; + private String host; + private TransportOptions transportOptions; + + @Nullable private DatastoreOpenTelemetryOptions openTelemetryOptions = null; + + private Builder() {} + + private Builder(DatastoreOptions options) { + super(options); + this.namespace = options.namespace; + this.databaseId = options.databaseId; + this.openTelemetryOptions = options.openTelemetryOptions; + this.channelProvider = validateChannelProvider(options.channelProvider); + } + + @Override + public Builder setTransportOptions(TransportOptions transportOptions) { + if (!(transportOptions instanceof HttpTransportOptions)) { + throw new IllegalArgumentException( + "Only http transport is allowed for " + API_SHORT_NAME + "."); + } + this.transportOptions = transportOptions; + return super.setTransportOptions(transportOptions); + } + + /** + * Sets the transport to gRPC. Note this functionality is experimental and subject to change. + */ + @BetaApi + public Builder setTransportOptions(GrpcTransportOptions transportOptions) { + this.transportOptions = transportOptions; + return super.setTransportOptions(transportOptions); + } + + @Override + public Builder setHost(String host) { + this.host = host; + return super.setHost(host); + } + + /** + * Sets the {@link TransportChannelProvider} to use with this Datastore client. + * + *

This is only compatible with clients using a gRPC transport (see {@code + * DatastoreOptions#setTransportOptions(GrpcTransportOptions)} for more details). + * + *

This functionality is experimental and subject to change. + * + * @param channelProvider A InstantiatingGrpcChannelProvider object that defines the transport + * provider for this client. + */ + @BetaApi + public Builder setChannelProvider(TransportChannelProvider channelProvider) { + this.channelProvider = validateChannelProvider(channelProvider); + return this; + } + + @Override + public DatastoreOptions build() { + if (this.host == null && this.transportOptions instanceof GrpcTransportOptions) { + this.setHost(DatastoreSettings.getDefaultEndpoint()); + } + return new DatastoreOptions(this); + } + + /** Sets the default namespace to be used by the datastore service. */ + public Builder setNamespace(String namespace) { + this.namespace = validateNamespace(namespace); + return this; + } + + public Builder setDatabaseId(String databaseId) { + this.databaseId = databaseId; + return this; + } + + /** + * Sets the {@link DatastoreOpenTelemetryOptions} to be used for this Firestore instance. + * + * @param openTelemetryOptions The `DatastoreOpenTelemetryOptions` to use. + */ + @BetaApi + @Nonnull + public Builder setOpenTelemetryOptions( + @Nonnull DatastoreOpenTelemetryOptions openTelemetryOptions) { + this.openTelemetryOptions = openTelemetryOptions; + return this; + } + } + + private static TransportChannelProvider validateChannelProvider( + TransportChannelProvider channelProvider) { + if (channelProvider != null && !(channelProvider instanceof InstantiatingGrpcChannelProvider)) { + throw new IllegalArgumentException( + "Only GRPC channels are allowed for " + API_SHORT_NAME + "."); + } + return channelProvider; + } + + private DatastoreOptions(Builder builder) { + super(DatastoreFactory.class, DatastoreRpcFactory.class, builder, new DatastoreDefaults()); + + this.openTelemetryOptions = + builder.openTelemetryOptions != null + ? builder.openTelemetryOptions + : DatastoreOpenTelemetryOptions.newBuilder().build(); + this.traceUtil = com.google.cloud.datastore.telemetry.TraceUtil.getInstance(this); + + namespace = MoreObjects.firstNonNull(builder.namespace, defaultNamespace()); + databaseId = MoreObjects.firstNonNull(builder.databaseId, DEFAULT_DATABASE_ID); + + if (getTransportOptions() instanceof HttpTransportOptions && builder.channelProvider != null) { + throw new IllegalArgumentException( + "Only gRPC transport allows setting of channel provider or credentials provider"); + } else if (getTransportOptions() instanceof GrpcTransportOptions) { + if (builder.channelProvider == null) { + /* + The default gRPC connection pool is configured with a minimum of 1 channel. + The maximum channel count automatically defaults to 200 (Defined in gax-grpc). + */ + ChannelPoolSettings datastoreChannelPoolSettings = + ChannelPoolSettings.builder() + .setInitialChannelCount(INIT_CHANNEL_COUNT) + .setMinChannelCount(MIN_CHANNEL_COUNT) + .build(); + + ApiFunction channelConfigurator = + this.traceUtil.getChannelConfigurator(); + if (channelConfigurator == null) { + this.channelProvider = + GrpcTransportOptions.setUpChannelProvider( + DatastoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelPoolSettings(datastoreChannelPoolSettings), + this); + } else { + // Intercept the grpc channel calls to add telemetry info. + this.channelProvider = + GrpcTransportOptions.setUpChannelProvider( + DatastoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelPoolSettings(datastoreChannelPoolSettings) + .setChannelConfigurator(channelConfigurator), + this); + } + } else { + this.channelProvider = builder.channelProvider; + } + } + } + + public TransportChannelProvider getTransportChannelProvider() { + return channelProvider; + } + + @Override + protected String getDefaultHost() { + String host = System.getProperty(LOCAL_HOST_ENV_VAR, System.getenv(LOCAL_HOST_ENV_VAR)); + return host != null ? host : com.google.datastore.v1.client.DatastoreFactory.DEFAULT_HOST; + } + + @Override + protected String getDefaultProject() { + String projectId = System.getProperty(PROJECT_ID_ENV_VAR, System.getenv(PROJECT_ID_ENV_VAR)); + return projectId != null ? projectId : super.getDefaultProject(); + } + + private static class DatastoreDefaults implements ServiceDefaults { + + private final TransportOptions TRANSPORT_OPTIONS = getDefaultTransportOptionsBuilder().build(); + + @Override + public DatastoreFactory getDefaultServiceFactory() { + return DefaultDatastoreFactory.INSTANCE; + } + + @Override + public DatastoreRpcFactory getDefaultRpcFactory() { + return DefaultDatastoreRpcFactory.INSTANCE; + } + + @Override + public TransportOptions getDefaultTransportOptions() { + return TRANSPORT_OPTIONS; + } + + public static HttpTransportOptions.Builder getDefaultTransportOptionsBuilder() { + return HttpTransportOptions.newBuilder(); + } + } + + public static HttpTransportOptions getDefaultHttpTransportOptions() { + return HttpTransportOptions.newBuilder().build(); + } + + public static GrpcTransportOptions getDefaultGrpcTransportOptions() { + return GrpcTransportOptions.newBuilder().build(); + } + + /** Returns the default namespace to be used by the datastore service. */ + public String getNamespace() { + return namespace; + } + + public String getDatabaseId() { + return this.databaseId; + } + + /** Returns a default {@code DatastoreOptions} instance. */ + public static DatastoreOptions getDefaultInstance() { + return newBuilder().build(); + } + + private static String defaultNamespace() { + try { + Class clazz = Class.forName("com.google.appengine.api.NamespaceManager"); + Method method = clazz.getMethod("get"); + String namespace = (String) method.invoke(null); + return MoreObjects.firstNonNull(namespace, ""); + } catch (Exception ignore) { + // return empty string (Datastore default namespace) if could not automatically determine + return ""; + } + } + + @Override + protected Set getScopes() { + return SCOPES; + } + + protected DatastoreRpc getDatastoreRpcV1() { + return (DatastoreRpc) getRpc(); + } + + @SuppressWarnings("unchecked") + @Override + public Builder toBuilder() { + return new Builder(this); + } + + @Override + public int hashCode() { + return Objects.hash(baseHashCode(), namespace, databaseId); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof DatastoreOptions)) { + return false; + } + DatastoreOptions other = (DatastoreOptions) obj; + return baseEquals(other) + && Objects.equals(namespace, other.namespace) + && Objects.equals(databaseId, other.databaseId); + } + + public static Builder newBuilder() { + return new Builder(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreReader.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreReader.java new file mode 100644 index 000000000000..e1121073ebbd --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreReader.java @@ -0,0 +1,76 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.datastore.models.ExplainOptions; +import java.util.Iterator; +import java.util.List; + +/** An interface to represent Google Cloud Datastore read operations. */ +@InternalExtensionOnly +public interface DatastoreReader { + + /** + * Returns an {@link Entity} for the given {@link Key} or {@code null} if it doesn't exist. + * + * @throws DatastoreException upon failure + */ + Entity get(Key key); + + /** + * Returns an {@link Entity} for each given {@link Key} that exists in the Datastore. The order of + * the result is unspecified. Results are loaded lazily, so it is possible to get a {@code + * DatastoreException} from the returned {@code Iterator}'s {@link Iterator#hasNext hasNext} or + * {@link Iterator#next next} methods. + * + * @throws DatastoreException upon failure + * @see #get(Key) + */ + Iterator get(Key... keys); + + /** + * Returns a list with a value for each given key (ordered by input). {@code null} values are + * returned for nonexistent keys. When possible prefer using {@link #get(Key...)} to avoid eagerly + * loading the results. + */ + List fetch(Key... keys); + + /** + * Submits a {@link Query} and returns its result. + * + * @throws DatastoreException upon failure + */ + QueryResults run(Query query); + + /** + * Submits a {@link AggregationQuery} and returns {@link AggregationResults}. + * + * @throws DatastoreException upon failure + */ + AggregationResults runAggregation(AggregationQuery query); + + /** + * Submits a {@link AggregationQuery} with a specified {@link + * com.google.cloud.datastore.models.ExplainOptions} and returns {@link AggregationResults}. + * + * @throws DatastoreException upon failure + */ + @BetaApi + AggregationResults runAggregation(AggregationQuery query, ExplainOptions explainOptions); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreReaderWriter.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreReaderWriter.java new file mode 100644 index 000000000000..287e040294e9 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreReaderWriter.java @@ -0,0 +1,23 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.api.core.InternalExtensionOnly; + +/** An interface that combines both Google Cloud Datastore read and write operations. */ +@InternalExtensionOnly +public interface DatastoreReaderWriter extends DatastoreReader, DatastoreWriter {} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreUtils.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreUtils.java new file mode 100644 index 000000000000..bac611ed4b25 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreUtils.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 + * + * 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.datastore; + +import com.google.api.core.InternalApi; +import com.google.cloud.NoCredentials; +import com.google.common.base.Strings; +import java.net.InetAddress; +import java.net.URL; + +@InternalApi +public class DatastoreUtils { + + public static boolean isEmulator(DatastoreOptions datastoreOptions) { + return isLocalHost(datastoreOptions.getHost()) + || NoCredentials.getInstance().equals(datastoreOptions.getCredentials()); + } + + public static boolean isLocalHost(String host) { + if (Strings.isNullOrEmpty(host)) { + return false; + } + try { + String normalizedHost = "http://" + removeScheme(host); + InetAddress hostAddr = InetAddress.getByName(new URL(normalizedHost).getHost()); + return hostAddr.isAnyLocalAddress() || hostAddr.isLoopbackAddress(); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + + public static String removeScheme(String url) { + if (url != null) { + url = url.toLowerCase(); + if (url.startsWith("https://")) { + return url.substring("https://".length()); + } else if (url.startsWith("http://")) { + return url.substring("http://".length()); + } + } + return url; + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreWriter.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreWriter.java new file mode 100644 index 000000000000..97a75470eb5a --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DatastoreWriter.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 + * + * 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.datastore; + +import com.google.api.core.InternalExtensionOnly; +import java.util.List; + +/** An interface to represent Google Cloud Datastore write operations. */ +@InternalExtensionOnly +public interface DatastoreWriter { + + /** + * Datastore add operation: inserts the provided entity. This method will automatically allocate + * an id if necessary. + * + * @param entity the entity to add + * @return an {@code Entity} with the same properties and a key that is either newly allocated or + * the same one if key is already complete + * @throws DatastoreException upon failure + * @throws IllegalArgumentException if the given entity is missing a key + */ + Entity add(FullEntity entity); + + /** + * Datastore add operation: inserts the provided entities. This method will automatically allocate + * id for any entity with an incomplete key. + * + * @return a list of {@code Entity} ordered by input with the same properties and a key that is + * either newly allocated or the same one if was already complete + * @throws DatastoreException upon failure + * @throws IllegalArgumentException if any of the given entities is missing a key + * @see #add(FullEntity) + */ + List add(FullEntity... entities); + + /** + * A Datastore update operation. The operation will fail if an entity with the same key does not + * already exist. + * + * @throws DatastoreException upon failure + */ + void update(Entity... entities); + + /** + * A Datastore put (a.k.a upsert) operation: inserts an entity if it does not exist, updates it + * otherwise. This method will automatically allocate an id if necessary. + * + * @param entity the entity to put + * @return an {@code Entity} with the same properties and a key that is either newly allocated or + * the same one if key is already complete + * @throws DatastoreException upon failure + * @throws IllegalArgumentException if the given entity is missing a key + */ + Entity put(FullEntity entity); + + /** + * A Datastore put (a.k.a upsert) operation: creates an entity if it does not exist, updates it + * otherwise. This method will automatically allocate id for any entity with an incomplete key. + * + * @return a list of updated or inserted {@code Entity}, ordered by input. Returned keys are + * either newly allocated or the same one if was already complete. + * @throws DatastoreException upon failure + * @throws IllegalArgumentException if any of the given entities is missing a key + */ + List put(FullEntity... entities); + + /** A datastore delete operation. It is OK to request the deletion of a non-existing key. */ + void delete(Key... keys); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DoubleValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DoubleValue.java new file mode 100644 index 000000000000..230b29d176ce --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/DoubleValue.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 + * + * 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.datastore; + +import static com.google.datastore.v1.Value.DOUBLE_VALUE_FIELD_NUMBER; + +public final class DoubleValue extends Value { + + private static final long serialVersionUID = -6282769624277370453L; + + static final BaseMarshaller MARSHALLER = + new BaseMarshaller() { + + private static final long serialVersionUID = -48735616199736169L; + + @Override + public int getProtoFieldId() { + return DOUBLE_VALUE_FIELD_NUMBER; + } + + @Override + public Builder newBuilder(Double value) { + return DoubleValue.newBuilder(value); + } + + @Override + protected Double getValue(com.google.datastore.v1.Value from) { + return from.getDoubleValue(); + } + + @Override + protected void setValue(DoubleValue from, com.google.datastore.v1.Value.Builder to) { + to.setDoubleValue(from.get()); + } + }; + + public static final class Builder extends Value.BaseBuilder { + + public Builder() { + super(ValueType.DOUBLE); + } + + @Override + public DoubleValue build() { + return new DoubleValue(this); + } + } + + public DoubleValue(double value) { + this(newBuilder(value)); + } + + private DoubleValue(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + public static DoubleValue of(double value) { + return new DoubleValue(value); + } + + public static Builder newBuilder(double value) { + return new Builder().set(value); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Entity.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Entity.java new file mode 100644 index 000000000000..5cc3096f7927 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Entity.java @@ -0,0 +1,102 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.Preconditions; + +/** + * An entity is the Google Cloud Datastore persistent data object for a specific key. An entity will + * always have a complete {@link Key}. + */ +public final class Entity extends FullEntity { + + private static final long serialVersionUID = 2312315289215899118L; + + public static final class Builder extends BaseEntity.Builder { + + private Builder() {} + + private Builder(Key key) { + super(checkNotNull(key)); + } + + private Builder(Entity entity) { + super(entity); + } + + private Builder(Key key, FullEntity entity) { + setProperties(entity.getProperties()); + setKey(key); + } + + @Override + public Builder setKey(Key key) { + super.setKey(checkNotNull(key)); + return this; + } + + @Override + public Entity build() { + Preconditions.checkState(key() != null); + return new Entity(this); + } + } + + Entity(Builder builder) { + super(builder); + } + + Entity(FullEntity from) { + super(from); + Preconditions.checkArgument(from.getKey() != null); + } + + static Entity convert(FullEntity from) { + if (from instanceof Entity) { + return (Entity) from; + } + return new Entity(from); + } + + public static Builder newBuilder(Key key) { + return new Builder(key); + } + + public static Builder newBuilder(Entity copyFrom) { + return new Builder(copyFrom); + } + + public static Builder newBuilder(Key key, FullEntity copyFrom) { + return new Builder(key, copyFrom); + } + + public static Entity fromPb(com.google.datastore.v1.Entity entityPb) { + return new Builder().fill(entityPb).build(); + } + + /** + * Returns the size in bytes of the protobuf form of the provided entity. + * + * @param entity object whose size is measured. + */ + public static int calculateSerializedSize(BaseEntity entity) { + checkNotNull(entity); + return entity.toPb().getSerializedSize(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/EntityQuery.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/EntityQuery.java new file mode 100644 index 000000000000..1a39074868f6 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/EntityQuery.java @@ -0,0 +1,63 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +/** + * An implementation of a Google Cloud Datastore entity query that can be constructed by providing + * all the specific query elements. + * + * @see Datastore + * queries + */ +public final class EntityQuery extends StructuredQuery { + + private static final long serialVersionUID = -4748310327736758820L; + + /** A {@code EntityQuery} builder for queries that return {@link Entity} results. */ + public static final class Builder extends StructuredQuery.BuilderImpl { + + Builder(EntityQuery query) { + super(query); + } + + Builder() { + super(ResultType.ENTITY); + } + + @Override + Builder mergeFrom(com.google.datastore.v1.Query queryPb) { + super.mergeFrom(queryPb); + clearProjection(); + clearDistinctOn(); + return this; + } + + @Override + public EntityQuery build() { + return new EntityQuery(this); + } + } + + EntityQuery(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder(this); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/EntityValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/EntityValue.java new file mode 100644 index 000000000000..2ebb5cffc2a3 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/EntityValue.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 + * + * 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.datastore; + +import static com.google.datastore.v1.Value.ENTITY_VALUE_FIELD_NUMBER; + +public class EntityValue extends Value> { + + private static final long serialVersionUID = 2231420223179039760L; + + static final BaseMarshaller, EntityValue, Builder> MARSHALLER = + new BaseMarshaller, EntityValue, Builder>() { + + private static final long serialVersionUID = 7349141367266671632L; + + @Override + public int getProtoFieldId() { + return ENTITY_VALUE_FIELD_NUMBER; + } + + @Override + public Builder newBuilder(FullEntity value) { + return EntityValue.newBuilder(value); + } + + @Override + protected FullEntity getValue(com.google.datastore.v1.Value from) { + return FullEntity.fromPb(from.getEntityValue()); + } + + @Override + protected void setValue(EntityValue from, com.google.datastore.v1.Value.Builder to) { + to.setEntityValue(from.get().toPb()); + } + }; + + public static final class Builder extends Value.BaseBuilder, EntityValue, Builder> { + + private Builder() { + super(ValueType.ENTITY); + } + + @Override + public EntityValue build() { + return new EntityValue(this); + } + } + + public EntityValue(FullEntity entity) { + this(newBuilder(entity)); + } + + private EntityValue(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + public static EntityValue of(FullEntity entity) { + return new EntityValue(entity); + } + + public static Builder newBuilder(FullEntity entity) { + return new Builder().set(entity); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/FullEntity.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/FullEntity.java new file mode 100644 index 000000000000..0fbe1e644964 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/FullEntity.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 + * + * 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.datastore; + +/** + * A full entity is a {@link BaseEntity} that holds all the properties associated with a Datastore + * entity (as opposed to {@link ProjectionEntity}). + */ +public class FullEntity extends BaseEntity { + + private static final long serialVersionUID = -2075539363782670624L; + + public static class Builder extends BaseEntity.Builder> { + + Builder() {} + + Builder(K key) { + super(key); + } + + Builder(FullEntity entity) { + super(entity); + } + + @Override + public FullEntity build() { + return new FullEntity<>(this); + } + } + + FullEntity(BaseEntity.Builder builder) { + super(builder); + } + + FullEntity(FullEntity from) { + super(from); + } + + public static Builder newBuilder() { + return new Builder<>(); + } + + public static Builder newBuilder(K key) { + return new Builder<>(key); + } + + public static Builder newBuilder(FullEntity copyFrom) { + return new Builder<>(copyFrom); + } + + public static FullEntity fromPb(com.google.datastore.v1.Entity entityPb) { + return new Builder<>().fill(entityPb).build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GqlQuery.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GqlQuery.java new file mode 100644 index 000000000000..969216eafba4 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GqlQuery.java @@ -0,0 +1,533 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.cloud.datastore.Validator.validateNamespace; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.core.InternalApi; +import com.google.cloud.Timestamp; +import com.google.common.base.MoreObjects; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSortedMap; +import com.google.common.primitives.Booleans; +import com.google.common.primitives.Doubles; +import com.google.common.primitives.Longs; +import io.grpc.Status; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.TreeMap; + +/** + * A Google Cloud Datastore GQL query. + * + *

A usage example: + * + *

When the type of the results is known the preferred usage would be: + * + *

{@code
+ * Query query =
+ *     Query.newGqlQueryBuilder(Query.ResultType.ENTITY, "select * from kind").build();
+ * QueryResults results = datastore.run(query);
+ * while (results.hasNext()) {
+ *   Entity entity = results.next();
+ *   ...
+ * }
+ * }
+ * + *

When the type of the results is unknown you can use this approach: + * + *

{@code
+ * Query query = Query.newGqlQueryBuilder("select __key__ from kind").build();
+ * QueryResults results = datastore.run(query);
+ * if (Key.class.isAssignableFrom(results.getResultClass())) {
+ *   QueryResults keys = (QueryResults) results;
+ *   while (keys.hasNext()) {
+ *     Key key = keys.next();
+ *     ...
+ *   }
+ * }
+ * }
+ * + * @param the type of the result values this query will produce + * @see GQL Reference + */ +public final class GqlQuery extends Query implements RecordQuery { + + private static final long serialVersionUID = -5514894742849230793L; + + private final String queryString; + private final boolean allowLiteral; + private final ImmutableMap namedBindings; + private final ImmutableList positionalBindings; + + private final ResultType resultType; + + static final class Binding implements Serializable { + + private static final long serialVersionUID = 2344746877591371548L; + + private final Cursor cursor; + private final Value value; + + Binding(Cursor cursor) { + this.cursor = checkNotNull(cursor); + value = null; + } + + Binding(Value value) { + this.value = checkNotNull(value); + cursor = null; + } + + Object getCursorOrValue() { + return MoreObjects.firstNonNull(cursor, value); + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this).add("cursor", cursor).add("value", value).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(cursor, value); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Binding)) { + return false; + } + Binding other = (Binding) obj; + return Objects.equals(cursor, other.cursor) && Objects.equals(value, other.value); + } + + com.google.datastore.v1.GqlQueryParameter toPb() { + com.google.datastore.v1.GqlQueryParameter.Builder argPb = + com.google.datastore.v1.GqlQueryParameter.newBuilder(); + if (cursor != null) { + argPb.setCursor(cursor.getByteString()); + } + if (value != null) { + argPb.setValue(value.toPb()); + } + return argPb.build(); + } + + static Binding fromPb(com.google.datastore.v1.GqlQueryParameter argPb) { + switch (argPb.getParameterTypeCase()) { + case CURSOR: + return new Binding(new Cursor(argPb.getCursor())); + case VALUE: + return new Binding(Value.fromPb(argPb.getValue())); + default: + throw new AssertionError("Unexpected enum value " + argPb.getParameterTypeCase()); + } + } + } + + /** A GQL query builder. */ + public static final class Builder { + + private final ResultType resultType; + private String namespace; + private String queryString; + private boolean allowLiteral; + private final Map namedBindings = new TreeMap<>(); + private final List positionalBindings = new LinkedList<>(); + + Builder(ResultType resultType, String query) { + this.resultType = checkNotNull(resultType); + queryString = checkNotNull(query); + } + + /** Sets the GQL query. */ + public Builder setQuery(String query) { + queryString = checkNotNull(query); + return this; + } + + /** Sets the namespace for the GQL query. */ + public Builder setNamespace(String namespace) { + this.namespace = validateNamespace(namespace); + return this; + } + + /** + * Sets whether the query string can contain literals. When {@code false}, the query string must + * not contain any literals and instead must bind all values. + */ + public Builder setAllowLiteral(boolean allowLiteral) { + this.allowLiteral = allowLiteral; + return this; + } + + public Builder clearBindings() { + namedBindings.clear(); + positionalBindings.clear(); + return this; + } + + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param cursor a {@link Cursor} object that binds to a given name + */ + public Builder setBinding(String name, Cursor cursor) { + namedBindings.put(name, new Binding(cursor)); + return this; + } + + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a String object or a list of String objects that binds to a given name + */ + public Builder setBinding(String name, String... value) { + namedBindings.put(name, toBinding(StringValue.MARSHALLER, Arrays.asList(value))); + return this; + } + + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a long value or a list of long values that binds to a given name + */ + public Builder setBinding(String name, long... value) { + namedBindings.put(name, toBinding(LongValue.MARSHALLER, Longs.asList(value))); + return this; + } + + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a double value or a list of double values that binds to a given name + */ + public Builder setBinding(String name, double... value) { + namedBindings.put(name, toBinding(DoubleValue.MARSHALLER, Doubles.asList(value))); + return this; + } + + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a boolean value or a list of boolean values that binds to a given name + */ + public Builder setBinding(String name, boolean... value) { + namedBindings.put(name, toBinding(BooleanValue.MARSHALLER, Booleans.asList(value))); + return this; + } + + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a {@link Timestamp} object or a list of {@link Timestamp} objects that binds to + * a given name + */ + public Builder setBinding(String name, Timestamp... value) { + namedBindings.put(name, toBinding(TimestampValue.MARSHALLER, Arrays.asList(value))); + return this; + } + + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a {@link Key} object or a list of {@link Key} objects that binds to a given name + */ + public Builder setBinding(String name, Key... value) { + namedBindings.put(name, toBinding(KeyValue.MARSHALLER, Arrays.asList(value))); + return this; + } + + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a {@link FullEntity} object or a list of {@link FullEntity} objects that binds + * to a given name + */ + @Deprecated + public Builder setBinding(String name, FullEntity... value) { + throw new DatastoreException( + Status.Code.UNIMPLEMENTED.value(), "Binding entities is not supported.", "UNIMPLEMENTED"); + } + + /** + * Sets a new named binding. + * + * @param name name of the binding + * @param value a {@link Blob} object or list of {@link Blob} objects that binds to a given name + */ + public Builder setBinding(String name, Blob... value) { + namedBindings.put(name, toBinding(BlobValue.MARSHALLER, Arrays.asList(value))); + return this; + } + + /** + * Sets a new named binding with null value. + * + * @param name of the binding + */ + public Builder setNullBinding(String name) { + namedBindings.put(name, toBinding(NullValue.MARSHALLER, new ArrayList())); + return this; + } + + /** + * Sets a new positional binding. + * + * @param cursor a {@link Cursor} object to be set as a new positional binding + */ + public Builder addBinding(Cursor cursor) { + positionalBindings.add(new Binding(cursor)); + return this; + } + + /** + * Sets a new positional binding. + * + * @param value a String object or a list of String objects to be set as a new positional + * binding + */ + public Builder addBinding(String... value) { + positionalBindings.add(toBinding(StringValue.MARSHALLER, Arrays.asList(value))); + return this; + } + + /** + * Sets a new positional binding. + * + * @param value a long value or a list of long values to be set as a new positional binding + */ + public Builder addBinding(long... value) { + positionalBindings.add(toBinding(LongValue.MARSHALLER, Longs.asList(value))); + return this; + } + + /** + * Sets a new positional binding. + * + * @param value a double value or a list of double values to be set as a new positional binding + */ + public Builder addBinding(double... value) { + positionalBindings.add(toBinding(DoubleValue.MARSHALLER, Doubles.asList(value))); + return this; + } + + /** + * Sets a new positional binding. + * + * @param value a boolean value or a list of boolean values to be set as a new positional + * binding + */ + public Builder addBinding(boolean... value) { + positionalBindings.add(toBinding(BooleanValue.MARSHALLER, Booleans.asList(value))); + return this; + } + + /** + * Sets a new positional binding. + * + * @param value a {@link Timestamp} object or a list of {@link Timestamp} objects to be set as a + * new positional binding + */ + public Builder addBinding(Timestamp... value) { + positionalBindings.add(toBinding(TimestampValue.MARSHALLER, Arrays.asList(value))); + return this; + } + + /** + * Sets a new positional binding. + * + * @param value a {@link Key} object or a list of {@link Key} objects to be set as a new + * positional binding + */ + public Builder addBinding(Key... value) { + positionalBindings.add(toBinding(KeyValue.MARSHALLER, Arrays.asList(value))); + return this; + } + + /** + * Sets a new positional binding. + * + * @param value a {@link FullEntity} object or a list of {@link FullEntity} objects to be set as + * a new positional binding + */ + @Deprecated + public Builder addBinding(FullEntity... value) { + throw new DatastoreException( + Status.Code.UNIMPLEMENTED.value(), "Binding entities is not supported.", "UNIMPLEMENTED"); + } + + /** + * Sets a new positional binding. + * + * @param value a {@link Blob} object or a list of {@link Blob} objects to be set as a new + * positional binding + */ + public Builder addBinding(Blob... value) { + positionalBindings.add(toBinding(BlobValue.MARSHALLER, Arrays.asList(value))); + return this; + } + + public GqlQuery build() { + return new GqlQuery<>(this); + } + + private static Binding toBinding( + Value.BuilderFactory builderFactory, List values) { + List> list = new ArrayList<>(values.size()); + for (Object object : values) { + @SuppressWarnings("unchecked") + V v = (V) object; + list.add(builderFactory.newBuilder(v).build()); + } + Value value; + if (list.isEmpty()) { + value = new NullValue(); + } else if (list.size() == 1) { + value = list.get(0); + } else { + value = new ListValue(list); + } + return new Binding(value); + } + } + + private GqlQuery(Builder builder) { + super(builder.namespace); + resultType = checkNotNull(builder.resultType); + queryString = builder.queryString; + allowLiteral = builder.allowLiteral; + namedBindings = ImmutableMap.copyOf(builder.namedBindings); + positionalBindings = ImmutableList.copyOf(builder.positionalBindings); + } + + /** Returns the query string for this query. */ + public String getQueryString() { + return queryString; + } + + /** + * Returns whether the query string can contain literals. When {@code false}, the query string + * must not contain any literals and instead must bind all values. + */ + public boolean allowLiteral() { + return allowLiteral; + } + + /** Returns an immutable map of named bindings. */ + public Map getNamedBindings() { + ImmutableMap.Builder builder = ImmutableSortedMap.naturalOrder(); + for (Map.Entry binding : namedBindings.entrySet()) { + builder.put(binding.getKey(), binding.getValue().getCursorOrValue()); + } + return builder.buildOrThrow(); + } + + @InternalApi + public Map getNamedBindingsMap() { + return namedBindings; + } + + @InternalApi + public List getPositionalBindingsMap() { + return positionalBindings; + } + + /** Returns an immutable list of positional bindings (using original order). */ + public List getNumberArgs() { + ImmutableList.Builder builder = ImmutableList.builder(); + for (Binding binding : positionalBindings) { + builder.add(binding.getCursorOrValue()); + } + return builder.build(); + } + + @Override + public ResultType getType() { + return resultType; + } + + @Override + public String toString() { + return toStringHelper() + .add("type", getType()) + .add("queryString", queryString) + .add("allowLiteral", allowLiteral) + .add("namedBindings", namedBindings) + .add("positionalBindings", positionalBindings) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash( + getNamespace(), queryString, allowLiteral, namedBindings, positionalBindings); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GqlQuery)) { + return false; + } + GqlQuery other = (GqlQuery) obj; + return Objects.equals(getNamespace(), other.getNamespace()) + && Objects.equals(queryString, other.queryString) + && allowLiteral == other.allowLiteral + && Objects.equals(namedBindings, other.namedBindings) + && Objects.equals(positionalBindings, other.positionalBindings); + } + + com.google.datastore.v1.GqlQuery toPb() { + GqlQueryProtoPreparer protoPreparer = new GqlQueryProtoPreparer(); + return protoPreparer.prepare(this); + } + + @InternalApi + @Override + public void populatePb(com.google.datastore.v1.RunQueryRequest.Builder requestPb) { + requestPb.setGqlQuery(toPb()); + } + + @InternalApi + @Override + public RecordQuery nextQuery(com.google.datastore.v1.RunQueryResponse responsePb) { + return StructuredQuery.fromPb(getType(), getNamespace(), responsePb.getQuery()) + .nextQuery(responsePb); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GqlQueryProtoPreparer.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GqlQueryProtoPreparer.java new file mode 100644 index 000000000000..2b362e913151 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GqlQueryProtoPreparer.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.GqlQuery.Binding; +import com.google.cloud.datastore.execution.request.ProtoPreparer; +import java.util.Map; + +@InternalApi +public class GqlQueryProtoPreparer + implements ProtoPreparer, com.google.datastore.v1.GqlQuery> { + + @Override + public com.google.datastore.v1.GqlQuery prepare(GqlQuery gqlQuery) { + com.google.datastore.v1.GqlQuery.Builder queryPb = + com.google.datastore.v1.GqlQuery.newBuilder(); + + queryPb.setQueryString(gqlQuery.getQueryString()); + queryPb.setAllowLiterals(gqlQuery.allowLiteral()); + for (Map.Entry entry : gqlQuery.getNamedBindingsMap().entrySet()) { + queryPb.putNamedBindings(entry.getKey(), entry.getValue().toPb()); + } + for (Binding argument : gqlQuery.getPositionalBindingsMap()) { + queryPb.addPositionalBindings(argument.toPb()); + } + + return queryPb.build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GrpcToDatastoreCodeTranslation.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GrpcToDatastoreCodeTranslation.java new file mode 100644 index 000000000000..1b6f85651e23 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/GrpcToDatastoreCodeTranslation.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 + * + * 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.datastore; + +import com.google.api.gax.grpc.GrpcStatusCode; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.rpc.Code; +import io.grpc.Status; +import java.util.Map; +import java.util.function.Function; + +final class GrpcToDatastoreCodeTranslation { + /** Mappings between gRPC status codes and their corresponding code numbers. */ + private static final ImmutableList STATUS_CODE_MAPPINGS = + ImmutableList.of( + StatusCodeMapping.of(Code.OK.getNumber(), Status.Code.OK), + StatusCodeMapping.of(Code.DATA_LOSS.getNumber(), Status.Code.DATA_LOSS), + StatusCodeMapping.of(Code.INVALID_ARGUMENT.getNumber(), Status.Code.INVALID_ARGUMENT), + StatusCodeMapping.of(Code.OUT_OF_RANGE.getNumber(), Status.Code.OUT_OF_RANGE), + StatusCodeMapping.of(Code.UNAUTHENTICATED.getNumber(), Status.Code.UNAUTHENTICATED), + StatusCodeMapping.of(Code.PERMISSION_DENIED.getNumber(), Status.Code.PERMISSION_DENIED), + StatusCodeMapping.of(Code.NOT_FOUND.getNumber(), Status.Code.NOT_FOUND), + StatusCodeMapping.of(Code.ALREADY_EXISTS.getNumber(), Status.Code.ALREADY_EXISTS), + StatusCodeMapping.of( + Code.FAILED_PRECONDITION.getNumber(), Status.Code.FAILED_PRECONDITION), + StatusCodeMapping.of(Code.RESOURCE_EXHAUSTED.getNumber(), Status.Code.RESOURCE_EXHAUSTED), + StatusCodeMapping.of(Code.INTERNAL.getNumber(), Status.Code.INTERNAL), + StatusCodeMapping.of(Code.UNIMPLEMENTED.getNumber(), Status.Code.UNIMPLEMENTED), + StatusCodeMapping.of(Code.UNAVAILABLE.getNumber(), Status.Code.UNAVAILABLE), + StatusCodeMapping.of(Code.DEADLINE_EXCEEDED.getNumber(), Status.Code.DEADLINE_EXCEEDED), + StatusCodeMapping.of(Code.ABORTED.getNumber(), Status.Code.ABORTED), + StatusCodeMapping.of(Code.CANCELLED.getNumber(), Status.Code.CANCELLED), + StatusCodeMapping.of(Code.UNKNOWN.getNumber(), Status.Code.UNKNOWN)); + + /** Index our {@link StatusCodeMapping} for constant time lookup by {@link Status.Code} */ + private static final Map GRPC_CODE_INDEX = + STATUS_CODE_MAPPINGS.stream() + .collect( + ImmutableMap.toImmutableMap(StatusCodeMapping::getGrpcCode, Function.identity())); + + static int grpcCodeToDatastoreStatusCode(Status.Code code) { + StatusCodeMapping found = GRPC_CODE_INDEX.get(code); + // theoretically it's possible for gRPC to add a new code we haven't mapped here, if this + // happens fall through to our default of 0 + if (found != null) { + return found.getDatastoreCode(); + } else { + return 0; + } + } + + /** + * Simple tuple class to bind together our corresponding http status code and {@link Status.Code} + * while providing easy access to the correct {@link GrpcStatusCode} where necessary. + */ + private static final class StatusCodeMapping { + + private final int datastoreCode; + + private final Status.Code grpcCode; + + private StatusCodeMapping(int datastoreCode, Status.Code grpcCode) { + this.datastoreCode = datastoreCode; + this.grpcCode = grpcCode; + } + + public int getDatastoreCode() { + return datastoreCode; + } + + public Status.Code getGrpcCode() { + return grpcCode; + } + + static StatusCodeMapping of(int datastoreCode, Status.Code grpcCode) { + return new StatusCodeMapping(datastoreCode, grpcCode); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/IncompleteKey.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/IncompleteKey.java new file mode 100644 index 000000000000..c795bf623311 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/IncompleteKey.java @@ -0,0 +1,124 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.util.List; + +/** An incomplete key (without a name or id). This class is immutable. */ +public class IncompleteKey extends BaseKey { + + private static final long serialVersionUID = 4947014765344279019L; + + public static class Builder extends BaseKey.Builder { + + private Builder(String projectId, String kind) { + super(projectId, kind); + } + + private Builder(String projectId, String kind, String databaseId) { + super(projectId, kind); + this.databaseId = databaseId; + } + + private Builder(IncompleteKey copyFrom) { + super(copyFrom); + } + + @Override + public IncompleteKey build() { + ImmutableList path = + ImmutableList.builder().addAll(ancestors).add(PathElement.of(kind)).build(); + return new IncompleteKey(projectId, namespace, databaseId, path); + } + } + + IncompleteKey(String projectId, String namespace, ImmutableList path) { + super(projectId, namespace, path); + } + + IncompleteKey( + String projectId, String namespace, String databaseId, ImmutableList path) { + super(projectId, namespace, databaseId, path); + } + + static IncompleteKey fromPb(com.google.datastore.v1.Key keyPb) { + String projectId = ""; + String namespace = ""; + String databaseId = ""; + if (keyPb.hasPartitionId()) { + com.google.datastore.v1.PartitionId partitionIdPb = keyPb.getPartitionId(); + projectId = partitionIdPb.getProjectId(); + namespace = partitionIdPb.getNamespaceId(); + databaseId = partitionIdPb.getDatabaseId(); + } + List pathElementsPb = keyPb.getPathList(); + Preconditions.checkArgument(!pathElementsPb.isEmpty(), "Path must not be empty"); + ImmutableList.Builder pathBuilder = ImmutableList.builder(); + for (com.google.datastore.v1.Key.PathElement pathElementPb : pathElementsPb) { + pathBuilder.add(PathElement.fromPb(pathElementPb)); + } + ImmutableList path = pathBuilder.build(); + PathElement leaf = path.get(path.size() - 1); + if (leaf.getNameOrId() != null) { + return new Key(projectId, namespace, databaseId, path); + } + return new IncompleteKey(projectId, namespace, databaseId, path); + } + + /** Returns the key's parent. */ + @Override + public Key getParent() { + List ancestors = getAncestors(); + if (ancestors.isEmpty()) { + return null; + } + PathElement parent = ancestors.get(ancestors.size() - 1); + Key.Builder keyBuilder; + if (parent.hasName()) { + keyBuilder = + Key.newBuilder(getProjectId(), parent.getKind(), parent.getName(), getDatabaseId()); + } else { + keyBuilder = + Key.newBuilder(getProjectId(), parent.getKind(), parent.getId(), getDatabaseId()); + } + String namespace = getNamespace(); + if (namespace != null) { + keyBuilder.setNamespace(namespace); + } + return keyBuilder.addAncestors(ancestors.subList(0, ancestors.size() - 1)).build(); + } + + public static Builder newBuilder(String projectId, String kind) { + return new Builder(projectId, kind); + } + + public static Builder newBuilderWithDatabaseId(String projectId, String kind, String databaseId) { + return new Builder(projectId, kind, databaseId); + } + + public static Builder newBuilder(IncompleteKey copyFrom) { + return new Builder(copyFrom); + } + + public static Builder newBuilder(Key parent, String kind) { + return newBuilderWithDatabaseId(parent.getProjectId(), kind, parent.getDatabaseId()) + .setNamespace(parent.getNamespace()) + .addAncestors(parent.getPath()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Key.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Key.java new file mode 100644 index 000000000000..a15ed89ce565 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Key.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 + * + * 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.datastore; + +import static java.nio.charset.StandardCharsets.UTF_8; + +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.protobuf.TextFormat; +import java.io.UnsupportedEncodingException; +import java.net.URLDecoder; +import java.net.URLEncoder; + +/** + * A key that is guaranteed to be complete and could be used to reference a Google Cloud Datastore + * {@link Entity}. This class is immutable. + * + * @see Google Cloud Datastore + * Entities, Properties, and Keys + */ +public final class Key extends IncompleteKey { + + private static final long serialVersionUID = 2563249643000943477L; + + public static final class Builder extends BaseKey.Builder { + + private String name; + private Long id; + + private Builder(String projectId, String kind, String name) { + super(projectId, kind); + this.name = name; + } + + private Builder(String projectId, String kind, long id) { + super(projectId, kind); + this.id = id; + } + + private Builder(String projectId, String kind, long id, String databaseId) { + super(projectId, kind); + this.id = id; + this.databaseId = databaseId; + } + + private Builder(String projectId, String kind, String name, String databaseId) { + super(projectId, kind); + this.name = name; + this.databaseId = databaseId; + } + + private Builder(IncompleteKey copyFrom, String name) { + super(copyFrom); + this.name = name; + } + + private Builder(IncompleteKey copyFrom, long id) { + super(copyFrom); + this.id = id; + } + + private Builder(Key copyFrom) { + super(copyFrom); + if (copyFrom.hasId()) { + id = copyFrom.getId(); + } else { + name = copyFrom.getName(); + } + } + + /** Sets the name of this key. */ + public Builder setName(String name) { + this.name = name; + id = null; + return this; + } + + /** Sets the ID of this key. */ + public Builder setId(long id) { + this.id = id; + name = null; + return this; + } + + @Override + public Key build() { + ImmutableList.Builder pathBuilder = + ImmutableList.builder().addAll(ancestors); + if (id == null) { + pathBuilder.add(PathElement.of(kind, name)); + } else { + pathBuilder.add(PathElement.of(kind, id)); + } + return new Key(projectId, namespace, databaseId, pathBuilder.build()); + } + } + + Key(String projectId, String namespace, ImmutableList path) { + super(projectId, namespace, path); + Preconditions.checkArgument(getNameOrId() != null); + } + + Key(String projectId, String namespace, String databaseId, ImmutableList path) { + super(projectId, namespace, databaseId, path); + Preconditions.checkArgument(getNameOrId() != null); + } + + public boolean hasId() { + return getLeaf().hasId(); + } + + /** Returns the key's id or {@code null} if it has a name instead. */ + public Long getId() { + return getLeaf().getId(); + } + + public boolean hasName() { + return getLeaf().hasName(); + } + + /** Returns the key's name or {@code null} if it has an id instead. */ + public String getName() { + return getLeaf().getName(); + } + + /** Returns the key's ID (as {@link Long}) or name (as {@link String}). Never {@code null}. */ + public Object getNameOrId() { + return getLeaf().getNameOrId(); + } + + /** Returns the key in an encoded form that can be used as part of a URL. */ + public String toUrlSafe() { + try { + return URLEncoder.encode(TextFormat.printer().printToString(toPb()), UTF_8.name()); + } catch (UnsupportedEncodingException e) { + throw new IllegalStateException("Unexpected encoding exception", e); + } + } + + /** + * Create a {@code Key} given its URL safe encoded form. + * + * @throws IllegalArgumentException when decoding fails + */ + public static Key fromUrlSafe(String urlSafe) { + try { + String utf8Str = URLDecoder.decode(urlSafe, UTF_8.name()); + com.google.datastore.v1.Key.Builder builder = com.google.datastore.v1.Key.newBuilder(); + TextFormat.merge(utf8Str, builder); + return fromPb(builder.build()); + } catch (UnsupportedEncodingException e) { + throw new IllegalStateException("Unexpected decoding exception", e); + } catch (TextFormat.ParseException e) { + throw new IllegalArgumentException("Could not parse key", e); + } + } + + static Key fromPb(com.google.datastore.v1.Key keyPb) { + IncompleteKey key = IncompleteKey.fromPb(keyPb); + Preconditions.checkState(key instanceof Key, "Key is not complete"); + return (Key) key; + } + + public static Builder newBuilder(String projectId, String kind, String name) { + return new Builder(projectId, kind, name); + } + + public static Builder newBuilder(String projectId, String kind, String name, String databaseId) { + return new Builder(projectId, kind, name, databaseId); + } + + public static Builder newBuilder(String projectId, String kind, long id) { + return new Builder(projectId, kind, id); + } + + public static Builder newBuilder(String projectId, String kind, long id, String databaseId) { + return new Builder(projectId, kind, id, databaseId); + } + + public static Builder newBuilder(Key copyFrom) { + return new Builder(copyFrom); + } + + public static Builder newBuilder(IncompleteKey copyFrom, String name) { + return new Builder(copyFrom, name); + } + + public static Builder newBuilder(IncompleteKey copyFrom, long id) { + return new Builder(copyFrom, id); + } + + public static Builder newBuilder(Key parent, String kind, String name) { + Builder builder = newBuilder(parent.getProjectId(), kind, name, parent.getDatabaseId()); + addParentToBuilder(parent, builder); + return builder; + } + + public static Builder newBuilder(Key parent, String kind, long id) { + Builder builder = newBuilder(parent.getProjectId(), kind, id, parent.getDatabaseId()); + addParentToBuilder(parent, builder); + return builder; + } + + private static void addParentToBuilder(Key parent, Builder builder) { + builder.setNamespace(parent.getNamespace()); + builder.addAncestors(parent.getAncestors()); + if (parent.hasId()) { + builder.addAncestors(PathElement.of(parent.getKind(), parent.getId())); + } else { + builder.addAncestors(PathElement.of(parent.getKind(), parent.getName())); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyFactory.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyFactory.java new file mode 100644 index 000000000000..f9ba5706a3a1 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyFactory.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 + * + * 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.datastore; + +import com.google.common.collect.ImmutableList; + +/** + * A helper for creating keys for a specific {@link Datastore}, using its associated projectId and + * namespace. + */ +public final class KeyFactory extends BaseKey.Builder { + + private final String initialProjectId; + private final String initialNamespace; + private final String initialDatabaseId; + + public KeyFactory(String projectId) { + this(projectId, ""); + } + + public KeyFactory(String projectId, String namespace) { + this(projectId, namespace, ""); + } + + public KeyFactory(String projectId, String namespace, String databaseId) { + super(projectId); + setNamespace(namespace); + setDatabaseId(databaseId); + this.initialProjectId = projectId; + this.initialNamespace = namespace; + this.initialDatabaseId = databaseId; + } + + public IncompleteKey newKey() { + ImmutableList path = + ImmutableList.builder().addAll(ancestors).add(PathElement.of(kind)).build(); + return new IncompleteKey(projectId, namespace, databaseId, path); + } + + public Key newKey(String name) { + ImmutableList path = + ImmutableList.builder() + .addAll(ancestors) + .add(PathElement.of(kind, name)) + .build(); + return new Key(projectId, namespace, databaseId, path); + } + + public Key newKey(long id) { + ImmutableList path = + ImmutableList.builder() + .addAll(ancestors) + .add(PathElement.of(kind, id)) + .build(); + return new Key(projectId, namespace, databaseId, path); + } + + /** + * Resets the KeyFactory to its initial state. + * + * @return {@code this} for chaining + */ + public KeyFactory reset() { + setProjectId(initialProjectId); + setNamespace(initialNamespace); + setDatabaseId(initialDatabaseId); + kind = null; + ancestors.clear(); + return this; + } + + @Override + protected IncompleteKey build() { + return newKey(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyQuery.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyQuery.java new file mode 100644 index 000000000000..591dfd47240b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyQuery.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 + * + * 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.datastore; + +/** + * An implementation of a Google Cloud Datastore key-only query that can be constructed by providing + * all the specific query elements. + * + * @see Datastore + * queries + */ +public final class KeyQuery extends StructuredQuery { + + private static final long serialVersionUID = 1187064062245269457L; + + /** A {@code KeyQuery} builder for queries that return {@link Key} results. */ + public static final class Builder extends StructuredQuery.BuilderImpl { + + Builder(KeyQuery query) { + super(query); + } + + Builder() { + super(ResultType.KEY); + setProjection(KEY_PROPERTY_NAME); + } + + @Override + Builder mergeFrom(com.google.datastore.v1.Query queryPb) { + super.mergeFrom(queryPb); + setProjection(KEY_PROPERTY_NAME); + clearDistinctOn(); + return this; + } + + @Override + public KeyQuery build() { + return new KeyQuery(this); + } + } + + KeyQuery(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder(this); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyValue.java new file mode 100644 index 000000000000..5a30bd9204d6 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/KeyValue.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 + * + * 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.datastore; + +import static com.google.datastore.v1.Value.KEY_VALUE_FIELD_NUMBER; + +public final class KeyValue extends Value { + + private static final long serialVersionUID = 571775607775319610L; + + static final BaseMarshaller MARSHALLER = + new BaseMarshaller() { + + private static final long serialVersionUID = -4653913699919198594L; + + @Override + public int getProtoFieldId() { + return KEY_VALUE_FIELD_NUMBER; + } + + @Override + public Builder newBuilder(Key key) { + return KeyValue.newBuilder(key); + } + + @Override + protected Key getValue(com.google.datastore.v1.Value from) { + return Key.fromPb(from.getKeyValue()); + } + + @Override + protected void setValue(KeyValue from, com.google.datastore.v1.Value.Builder to) { + to.setKeyValue(from.get().toPb()); + } + }; + + public static final class Builder extends Value.BaseBuilder { + + public Builder() { + super(ValueType.KEY); + } + + @Override + public KeyValue build() { + return new KeyValue(this); + } + } + + public KeyValue(Key key) { + this(newBuilder(key)); + } + + private KeyValue(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + public static KeyValue of(Key key) { + return new KeyValue(key); + } + + public static Builder newBuilder(Key key) { + return new Builder().set(key); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/LatLng.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/LatLng.java new file mode 100644 index 000000000000..3b5f476e4b2e --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/LatLng.java @@ -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. + */ + +package com.google.cloud.datastore; + +import static com.google.common.base.Preconditions.checkArgument; + +import java.io.Serializable; +import java.util.Objects; + +/** + * A Google Cloud Datastore LatLng (represented by latitude and longitude in degrees). This class is + * immutable. + * + * @see Google Cloud Datastore + * Entities, Properties, and Keys + */ +public final class LatLng implements Serializable { + + private static final long serialVersionUID = -3739859034159591779L; + + private final double latitude; + private final double longitude; + + LatLng(double latitude, double longitude) { + checkArgument( + latitude >= -90.0 && latitude <= 90.0, "latitude must be in the range [-90, 90] degrees"); + checkArgument( + longitude >= -180.0 && longitude <= 180.0, + "latitude must be in the range [-180, 180] degrees"); + this.latitude = latitude; + this.longitude = longitude; + } + + /** Returns the latitude. */ + public double getLatitude() { + return latitude; + } + + /** Returns the longitude. */ + public double getLongitude() { + return longitude; + } + + @Override + public String toString() { + return Double.toString(latitude) + ", " + Double.toString(longitude); + } + + @Override + public int hashCode() { + return Objects.hash(latitude, longitude); + } + + @Override + public boolean equals(Object obj) { + return obj == this + || (obj instanceof LatLng + && this.latitude == ((LatLng) obj).latitude + && this.longitude == ((LatLng) obj).longitude); + } + + public static LatLng of(double latitude, double longitude) { + return new LatLng(latitude, longitude); + } + + protected com.google.type.LatLng toPb() { + return com.google.type.LatLng.newBuilder() + .setLatitude(latitude) + .setLongitude(longitude) + .build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/LatLngValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/LatLngValue.java new file mode 100644 index 000000000000..2500bd2aac2c --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/LatLngValue.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 + * + * 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.datastore; + +import static com.google.datastore.v1.Value.GEO_POINT_VALUE_FIELD_NUMBER; + +public final class LatLngValue extends Value { + + private static final long serialVersionUID = 565308388087634597L; + + static final BaseMarshaller MARSHALLER = + new BaseMarshaller() { + + private static final long serialVersionUID = -5226207069346124222L; + + @Override + public int getProtoFieldId() { + return GEO_POINT_VALUE_FIELD_NUMBER; + } + + @Override + public Builder newBuilder(LatLng value) { + return LatLngValue.newBuilder(value); + } + + @Override + protected LatLng getValue(com.google.datastore.v1.Value from) { + return new LatLng( + from.getGeoPointValue().getLatitude(), from.getGeoPointValue().getLongitude()); + } + + @Override + protected void setValue(LatLngValue from, com.google.datastore.v1.Value.Builder to) { + to.setGeoPointValue(from.get().toPb()); + } + }; + + public static final class Builder extends Value.BaseBuilder { + + private Builder() { + super(ValueType.LAT_LNG); + } + + @Override + public LatLngValue build() { + return new LatLngValue(this); + } + } + + public LatLngValue(LatLng value) { + this(newBuilder(value)); + } + + private LatLngValue(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + public static LatLngValue of(LatLng value) { + return new LatLngValue(value); + } + + public static Builder newBuilder(LatLng value) { + return new Builder().set(value); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ListValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ListValue.java new file mode 100644 index 000000000000..2c9e8ee32460 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ListValue.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 + * + * 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.datastore; + +import static com.google.datastore.v1.Value.ARRAY_VALUE_FIELD_NUMBER; + +import com.google.cloud.Timestamp; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.List; + +/** A Google Cloud Datastore list value. A list value is a list of {@link Value} objects. */ +public final class ListValue extends Value>> { + + private static final long serialVersionUID = -5121887228607148857L; + + static final BaseMarshaller>, ListValue, Builder> MARSHALLER = + new BaseMarshaller>, ListValue, Builder>() { + + private static final long serialVersionUID = 7720473855548179942L; + + @Override + public int getProtoFieldId() { + return ARRAY_VALUE_FIELD_NUMBER; + } + + @Override + public Builder newBuilder(List> values) { + return ListValue.newBuilder().set(values); + } + + @Override + protected List> getValue(com.google.datastore.v1.Value from) { + List> properties = new ArrayList<>(from.getArrayValue().getValuesCount()); + for (com.google.datastore.v1.Value valuePb : from.getArrayValue().getValuesList()) { + properties.add(Value.fromPb(valuePb)); + } + return properties; + } + + @Override + protected void setValue(ListValue from, com.google.datastore.v1.Value.Builder to) { + List propertiesPb = new ArrayList<>(); + for (Value property : from.get()) { + propertiesPb.add(property.toPb()); + } + to.setArrayValue( + com.google.datastore.v1.ArrayValue.newBuilder().addAllValues(propertiesPb)); + } + }; + + public static final class Builder + extends Value.BaseBuilder>, ListValue, Builder> { + + private ImmutableList.Builder> listBuilder = ImmutableList.builder(); + + private Builder() { + super(ValueType.LIST); + } + + private void addValueHelper(Value value) { + // see datastore.proto definition for list_value + Preconditions.checkArgument(value.getType() != ValueType.LIST, "Cannot contain another list"); + listBuilder.add(value); + } + + /** Adds the provided values to the {@code ListValue} builder. */ + public Builder addValue(Value first, Value... other) { + addValueHelper(first); + for (Value value : other) { + addValueHelper(value); + } + return this; + } + + /** Adds the provided string values to the {@code ListValue} builder. */ + public Builder addValue(String first, String... other) { + listBuilder.add(StringValue.of(first)); + for (String value : other) { + listBuilder.add(StringValue.of(value)); + } + return this; + } + + /** Adds the provided long values to the {@code ListValue} builder. */ + public Builder addValue(long first, long... other) { + listBuilder.add(LongValue.of(first)); + for (long value : other) { + listBuilder.add(LongValue.of(value)); + } + return this; + } + + /** Adds the provided double values to the {@code ListValue} builder. */ + public Builder addValue(double first, double... other) { + listBuilder.add(DoubleValue.of(first)); + for (double value : other) { + listBuilder.add(DoubleValue.of(value)); + } + return this; + } + + /** Adds the provided boolean values to the {@code ListValue} builder. */ + public Builder addValue(boolean first, boolean... other) { + listBuilder.add(BooleanValue.of(first)); + for (boolean value : other) { + listBuilder.add(BooleanValue.of(value)); + } + return this; + } + + /** Adds the provided {@code Timestamp} values to the {@code ListValue} builder. */ + public Builder addValue(Timestamp first, Timestamp... other) { + listBuilder.add(TimestampValue.of(first)); + for (Timestamp value : other) { + listBuilder.add(TimestampValue.of(value)); + } + return this; + } + + /** Adds the provided {@code LatLng} values to the {@code ListValue} builder. */ + public Builder addValue(LatLng first, LatLng... other) { + listBuilder.add(LatLngValue.of(first)); + for (LatLng value : other) { + listBuilder.add(LatLngValue.of(value)); + } + return this; + } + + /** Adds the provided {@code Key} values to the {@code ListValue} builder. */ + public Builder addValue(Key first, Key... other) { + listBuilder.add(KeyValue.of(first)); + for (Key value : other) { + listBuilder.add(KeyValue.of(value)); + } + return this; + } + + /** Adds the provided {@code FullEntity} values to the {@code ListValue} builder. */ + public Builder addValue(FullEntity first, FullEntity... other) { + listBuilder.add(EntityValue.of(first)); + for (FullEntity value : other) { + listBuilder.add(EntityValue.of(value)); + } + return this; + } + + /** Adds the provided {@code Blob} values to the {@code ListValue} builder. */ + public Builder addValue(Blob first, Blob... other) { + listBuilder.add(BlobValue.of(first)); + for (Blob value : other) { + listBuilder.add(BlobValue.of(value)); + } + return this; + } + + /** + * Sets the list of values of this {@code ListValue} builder to {@code values}. The provided + * list is copied. + * + * @see com.google.cloud.datastore.Value.BaseBuilder#set(java.lang.Object) + */ + @Override + public Builder set(List> values) { + listBuilder = ImmutableList.builder(); + for (Value value : values) { + addValue(value); + } + return this; + } + + @Override + public List> get() { + return listBuilder.build(); + } + + /** Creates a {@code ListValue} object. */ + @Override + public ListValue build() { + return new ListValue(this); + } + } + + public ListValue(List> values) { + this(newBuilder().set(values)); + } + + public ListValue(Value first, Value... other) { + this(new Builder().addValue(first, other)); + } + + private ListValue(Builder builder) { + super(builder); + } + + /** Returns a builder for the list value object. */ + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + /** Creates a {@code ListValue} object given a list of {@code Value} objects. */ + public static ListValue of(List> values) { + return new ListValue(values); + } + + /** Creates a {@code ListValue} object given a number of {@code Value} objects. */ + public static ListValue of(Value first, Value... other) { + return new ListValue(first, other); + } + + /** Creates a {@code ListValue} object given a number of string values. */ + public static ListValue of(String first, String... other) { + return newBuilder().addValue(first, other).build(); + } + + /** Creates a {@code ListValue} object given a number of long values. */ + public static ListValue of(long first, long... other) { + return newBuilder().addValue(first, other).build(); + } + + /** Creates a {@code ListValue} object given a number of double values. */ + public static ListValue of(double first, double... other) { + return newBuilder().addValue(first, other).build(); + } + + /** Creates a {@code ListValue} object given a number of boolean values. */ + public static ListValue of(boolean first, boolean... other) { + return newBuilder().addValue(first, other).build(); + } + + /** Creates a {@code ListValue} object given a number of {@code Timestamp} values. */ + public static ListValue of(Timestamp first, Timestamp... other) { + return newBuilder().addValue(first, other).build(); + } + + /** Creates a {@code ListValue} object given a number of {@code LatLng} values. */ + public static ListValue of(LatLng first, LatLng... other) { + return newBuilder().addValue(first, other).build(); + } + + /** Creates a {@code ListValue} object given a number of {@code Key} values. */ + public static ListValue of(Key first, Key... other) { + return newBuilder().addValue(first, other).build(); + } + + /** Creates a {@code ListValue} object given a number of {@code FullEntity} values. */ + public static ListValue of(FullEntity first, FullEntity... other) { + return newBuilder().addValue(first, other).build(); + } + + /** Creates a {@code ListValue} object given a number of {@code Blob} values. */ + public static ListValue of(Blob first, Blob... other) { + return newBuilder().addValue(first, other).build(); + } + + /** Returns a builder for {@code ListValue} objects. */ + public static Builder newBuilder() { + return new Builder(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/LongValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/LongValue.java new file mode 100644 index 000000000000..11911a11a907 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/LongValue.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 + * + * 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.datastore; + +import static com.google.datastore.v1.Value.INTEGER_VALUE_FIELD_NUMBER; + +public final class LongValue extends Value { + + private static final long serialVersionUID = -3433015349912039278L; + + static final BaseMarshaller MARSHALLER = + new BaseMarshaller() { + + private static final long serialVersionUID = -8359920606872800391L; + + @Override + public int getProtoFieldId() { + return INTEGER_VALUE_FIELD_NUMBER; + } + + @Override + public Builder newBuilder(Long value) { + return LongValue.newBuilder(value); + } + + @Override + protected Long getValue(com.google.datastore.v1.Value from) { + return from.getIntegerValue(); + } + + @Override + protected void setValue(LongValue from, com.google.datastore.v1.Value.Builder to) { + to.setIntegerValue(from.get()); + } + }; + + public static final class Builder extends Value.BaseBuilder { + + private Builder() { + super(ValueType.LONG); + } + + @Override + public LongValue build() { + return new LongValue(this); + } + } + + public LongValue(long value) { + this(newBuilder(value)); + } + + private LongValue(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + public static LongValue of(long value) { + return new LongValue(value); + } + + public static Builder newBuilder(long value) { + return new Builder().set(value); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/NullValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/NullValue.java new file mode 100644 index 000000000000..2e5c18404889 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/NullValue.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 + * + * 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.datastore; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.datastore.v1.Value.NULL_VALUE_FIELD_NUMBER; + +public final class NullValue extends Value { + + private static final long serialVersionUID = 2089084567599008130L; + + static final BaseMarshaller MARSHALLER = + new BaseMarshaller() { + + private static final long serialVersionUID = 6997769137212338027L; + + @Override + public Builder newBuilder(Void value) { + return NullValue.newBuilder(); + } + + @Override + public int getProtoFieldId() { + return NULL_VALUE_FIELD_NUMBER; + } + + @Override + protected Void getValue(com.google.datastore.v1.Value from) { + return null; + } + + @Override + protected void setValue(NullValue from, com.google.datastore.v1.Value.Builder to) { + to.setNullValue(com.google.protobuf.NullValue.NULL_VALUE); + } + }; + + public static final class Builder extends Value.BaseBuilder { + + private Builder() { + super(ValueType.NULL); + } + + @Override + public NullValue build() { + return new NullValue(this); + } + + @Override + public Builder set(Void value) { + checkArgument(value == null, "Only null values are allowed"); + return this; + } + } + + public NullValue() { + this(newBuilder()); + } + + private NullValue(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + public static NullValue of() { + return new NullValue(); + } + + public static Builder newBuilder() { + return new Builder(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/PathElement.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/PathElement.java new file mode 100644 index 000000000000..80fc70085857 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/PathElement.java @@ -0,0 +1,138 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.common.base.Preconditions.checkArgument; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.common.base.MoreObjects; +import com.google.common.base.Strings; +import java.io.Serializable; +import java.util.Objects; + +/** Represents a single element in a key's path. */ +public final class PathElement implements Serializable { + + private static final long serialVersionUID = -777300414390493910L; + + private final String kind; + private final Long id; + private final String name; + + private PathElement(String kind, String name, Long id) { + this.kind = checkNotNull(kind, "kind must not be null"); + this.name = name; + this.id = id; + } + + /** Returns the kind of this path element. */ + public String getKind() { + return kind; + } + + public boolean hasId() { + return id != null; + } + + /** Returns the ID of this path element. */ + public Long getId() { + return id; + } + + public boolean hasName() { + return name != null; + } + + /** Returns the name of this path element. */ + public String getName() { + return name; + } + + /** + * Returns the path element's ID (as {@link Long}) or name (as {@link String}). Never {@code + * null}. + */ + public Object getNameOrId() { + return id == null ? name : id; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("kind", kind) + .add("id", id) + .add("name", name) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(kind, id, name); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PathElement)) { + return false; + } + PathElement other = (PathElement) obj; + return Objects.equals(kind, other.kind) + && Objects.equals(id, other.id) + && Objects.equals(name, other.name); + } + + com.google.datastore.v1.Key.PathElement toPb() { + com.google.datastore.v1.Key.PathElement.Builder pathElementPb = + com.google.datastore.v1.Key.PathElement.newBuilder(); + pathElementPb.setKind(kind); + if (id != null) { + pathElementPb.setId(id); + } else if (name != null) { + pathElementPb.setName(name); + } + return pathElementPb.build(); + } + + static PathElement fromPb(com.google.datastore.v1.Key.PathElement pathElementPb) { + String kind = pathElementPb.getKind(); + switch (pathElementPb.getIdTypeCase()) { + case ID: + return of(kind, pathElementPb.getId()); + case NAME: + return of(kind, pathElementPb.getName()); + default: + return of(kind); + } + } + + static PathElement of(String kind) { + return new PathElement(kind, null, null); + } + + public static PathElement of(String kind, String name) { + checkArgument(!Strings.isNullOrEmpty(name), "name must not be empty or null"); + return new PathElement(kind, name, null); + } + + public static PathElement of(String kind, long id) { + checkArgument(id != 0, "id must not be equal to zero"); + return new PathElement(kind, null, id); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ProjectionEntity.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ProjectionEntity.java new file mode 100644 index 000000000000..bb8d4889b869 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ProjectionEntity.java @@ -0,0 +1,81 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.cloud.Timestamp; +import com.google.protobuf.ByteString; + +/** + * A projection entity is a result of a Google Cloud Datastore projection query. A projection entity + * holds one or more properties, represented by a name (as {@link String}) and a value (as {@link + * Value}), and may have a {@link Key}. + * + * @see Google Cloud + * Datastore projection queries + * @see Google Cloud Datastore + * Entities, Properties, and Keys + */ +public final class ProjectionEntity extends BaseEntity { + + private static final long serialVersionUID = -3399517537444851544L; + + public static final class Builder extends BaseEntity.Builder { + + Builder() {} + + private Builder(ProjectionEntity entity) { + super(entity); + } + + @Override + public ProjectionEntity build() { + return new ProjectionEntity(this); + } + } + + ProjectionEntity(Builder builder) { + super(builder); + } + + @SuppressWarnings({"unchecked", "deprecation"}) + @Override + public Timestamp getTimestamp(String name) { + Value value = getValue(name); + if (value.getMeaning() == 18 && value instanceof LongValue) { + return Timestamp.ofTimeMicroseconds(getLong(name)); + } + return ((Value) value).get(); + } + + @SuppressWarnings({"unchecked", "deprecation"}) + @Override + public Blob getBlob(String name) { + Value value = getValue(name); + if (value.getMeaning() == 18 && value instanceof StringValue) { + return new Blob(ByteString.copyFromUtf8(getString(name))); + } + return ((Value) value).get(); + } + + static ProjectionEntity fromPb(com.google.datastore.v1.Entity entityPb) { + return new Builder().fill(entityPb).build(); + } + + public static Builder newBuilder(ProjectionEntity copyFrom) { + return new Builder(copyFrom); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ProjectionEntityQuery.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ProjectionEntityQuery.java new file mode 100644 index 000000000000..b2f626160322 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ProjectionEntityQuery.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 + * + * 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.datastore; + +/** + * An implementation of a Google Cloud Datastore projection entity query that can be constructed by + * providing all the specific query elements. + * + * @see Datastore + * queries + */ +public final class ProjectionEntityQuery extends StructuredQuery { + + private static final long serialVersionUID = 6217728277947673577L; + + /** + * A {@code ProjectionEntityQuery} builder for queries that return {@link ProjectionEntity} + * results. + */ + public static final class Builder extends StructuredQuery.BuilderImpl { + + Builder(ProjectionEntityQuery query) { + super(query); + } + + Builder() { + super(ResultType.PROJECTION_ENTITY); + } + + /** Clears the projection clause. */ + @Override + public Builder clearProjection() { + super.clearProjection(); + return this; + } + + /** + * Sets the query's projection clause (clearing any previously specified Projection settings). + */ + @Override + public Builder setProjection(String projection, String... others) { + super.setProjection(projection, others); + return this; + } + + /** Adds one or more projections to the existing projection clause. */ + @Override + public Builder addProjection(String projection, String... others) { + super.addProjection(projection, others); + return this; + } + + /** Clears the group by clause. */ + @Override + public Builder clearDistinctOn() { + super.clearDistinctOn(); + return this; + } + + /** + * Sets the query's distinct on clause (clearing any previously specified distinct on settings). + */ + @Override + public Builder setDistinctOn(String property, String... others) { + super.setDistinctOn(property, others); + return this; + } + + /** Adds one or more properties to the existing group by clause. */ + @Override + public Builder addDistinctOn(String property, String... others) { + super.addDistinctOn(property, others); + return this; + } + + @Override + public ProjectionEntityQuery build() { + return new ProjectionEntityQuery(this); + } + } + + ProjectionEntityQuery(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder(this); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Query.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Query.java new file mode 100644 index 000000000000..b078015b6b89 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Query.java @@ -0,0 +1,301 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.api.core.InternalApi; +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.collect.Maps; +import java.io.Serializable; +import java.util.Map; + +/** + * A Google Cloud Datastore query. For usage examples see {@link GqlQuery}, {@link StructuredQuery} + * and {@link AggregationQuery}. + * + *

Note that queries require proper indexing. See Cloud Datastore Index + * Configuration for help configuring indexes. + * + * @param the type of the values returned by this query. + * @see Datastore Queries + */ +public abstract class Query implements Serializable { + + private static final long serialVersionUID = 7967659059395653941L; + + private final String namespace; + + /** + * This class represents the expected type of the result. ENTITY: A full entity represented by + * {@link Entity}. PROJECTION_ENTITY: A projection entity, represented by {@link + * ProjectionEntity}. KEY: An entity's {@link Key}. + */ + public abstract static class ResultType implements Serializable { + + private static final long serialVersionUID = 2104157695425806623L; + private static final Map> + PB_TO_INSTANCE = Maps.newEnumMap(com.google.datastore.v1.EntityResult.ResultType.class); + + static final ResultType UNKNOWN = + new ResultType(null, Object.class) { + + private static final long serialVersionUID = 1602329532153860907L; + + @Override + Object convert(com.google.datastore.v1.Entity entityPb) { + if (entityPb.getPropertiesMap().isEmpty()) { + if (!entityPb.hasKey()) { + return null; + } + return Key.fromPb(entityPb.getKey()); + } + return ProjectionEntity.fromPb(entityPb); + } + }; + + public static final ResultType ENTITY = + new ResultType(com.google.datastore.v1.EntityResult.ResultType.FULL, Entity.class) { + + private static final long serialVersionUID = 7712959777507168274L; + + @Override + Entity convert(com.google.datastore.v1.Entity entityPb) { + return Entity.fromPb(entityPb); + } + }; + + public static final ResultType KEY = + new ResultType(com.google.datastore.v1.EntityResult.ResultType.KEY_ONLY, Key.class) { + + private static final long serialVersionUID = -8514289244104446252L; + + @Override + Key convert(com.google.datastore.v1.Entity entityPb) { + return Key.fromPb(entityPb.getKey()); + } + }; + + public static final ResultType PROJECTION_ENTITY = + new ResultType( + com.google.datastore.v1.EntityResult.ResultType.PROJECTION, ProjectionEntity.class) { + + private static final long serialVersionUID = -7591409419690650246L; + + @Override + ProjectionEntity convert(com.google.datastore.v1.Entity entityPb) { + return ProjectionEntity.fromPb(entityPb); + } + }; + + private final Class resultClass; + private final com.google.datastore.v1.EntityResult.ResultType queryType; + + private ResultType( + com.google.datastore.v1.EntityResult.ResultType queryType, Class resultClass) { + this.queryType = queryType; + this.resultClass = resultClass; + if (queryType != null) { + PB_TO_INSTANCE.put(queryType, this); + } + } + + public Class resultClass() { + return resultClass; + } + + @InternalApi + public com.google.datastore.v1.EntityResult.ResultType getQueryType() { + return this.queryType; + } + + @Override + public int hashCode() { + return resultClass.hashCode(); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ResultType)) { + return false; + } + ResultType other = (ResultType) obj; + return resultClass.equals(other.resultClass); + } + + @Override + public String toString() { + ToStringHelper toStringHelper = MoreObjects.toStringHelper(this); + toStringHelper.add("queryType", queryType); + toStringHelper.add("resultClass", resultClass); + return toStringHelper.toString(); + } + + boolean isAssignableFrom(ResultType otherResultType) { + return resultClass.isAssignableFrom(otherResultType.resultClass); + } + + abstract V convert(com.google.datastore.v1.Entity entityPb); + + static ResultType fromPb(com.google.datastore.v1.EntityResult.ResultType typePb) { + return MoreObjects.firstNonNull(PB_TO_INSTANCE.get(typePb), UNKNOWN); + } + } + + Query(String namespace) { + this.namespace = namespace; + } + + public String getNamespace() { + return namespace; + } + + ToStringHelper toStringHelper() { + return MoreObjects.toStringHelper(this).add("namespace", namespace); + } + + /** + * Returns a new {@link GqlQuery} builder. + * + *

Example of creating and running a GQL query. + * + *

{@code
+   * String kind = "my_kind";
+   * String gqlQuery = "select * from " + kind;
+   * Query query = Query.newGqlQueryBuilder(gqlQuery).build();
+   * QueryResults results = datastore.run(query);
+   * // Use results
+   * }
+ * + * @see GQL Reference + */ + public static GqlQuery.Builder newGqlQueryBuilder(String gql) { + return newGqlQueryBuilder(ResultType.UNKNOWN, gql); + } + + /** + * Returns a new {@link GqlQuery} builder. + * + *

Example of creating and running a typed GQL query. + * + *

{@code
+   * String kind = "my_kind";
+   * String gqlQuery = "select * from " + kind;
+   * Query query = Query.newGqlQueryBuilder(Query.ResultType.ENTITY, gqlQuery).build();
+   * QueryResults results = datastore.run(query);
+   * // Use results
+   * }
+ * + * @see GQL Reference + */ + public static GqlQuery.Builder newGqlQueryBuilder(ResultType resultType, String gql) { + return new GqlQuery.Builder<>(resultType, gql); + } + + /** + * Returns a new {@link StructuredQuery} builder for full (complete entities) queries. + * + *

Example of creating and running an entity query. + * + *

{@code
+   * String kind = "my_kind";
+   * Query query = Query.newEntityQueryBuilder().setKind(kind).build();
+   * QueryResults results = datastore.run(query);
+   * // Use results
+   * }
+ */ + public static EntityQuery.Builder newEntityQueryBuilder() { + return new EntityQuery.Builder(); + } + + /** + * Returns a new {@link StructuredQuery} builder for key only queries. + * + *

Example of creating and running a key query. + * + *

{@code
+   * String kind = "my_kind";
+   * Query query = Query.newKeyQueryBuilder().setKind(kind).build();
+   * QueryResults results = datastore.run(query);
+   * // Use results
+   * }
+ */ + public static KeyQuery.Builder newKeyQueryBuilder() { + return new KeyQuery.Builder(); + } + + /** + * Returns a new {@link StructuredQuery} builder for projection queries. + * + *

Example of creating and running a projection entity query. + * + *

{@code
+   * String kind = "my_kind";
+   * String property = "my_property";
+   * Query query = Query.newProjectionEntityQueryBuilder()
+   *     .setKind(kind)
+   *     .addProjection(property)
+   *     .build();
+   * QueryResults results = datastore.run(query);
+   * // Use results
+   * }
+ */ + public static ProjectionEntityQuery.Builder newProjectionEntityQueryBuilder() { + return new ProjectionEntityQuery.Builder(); + } + + /** + * Returns a new {@link AggregationQuery} builder. + * + *

Example of creating and running an {@link AggregationQuery}. + * + *

{@link StructuredQuery} example: + * + *

{@code
+   * EntityQuery selectAllQuery = Query.newEntityQueryBuilder()
+   *    .setKind("Task")
+   *    .build();
+   * AggregationQuery aggregationQuery = Query.newAggregationQueryBuilder()
+   *    .addAggregation(count().as("total_count"))
+   *    .over(selectAllQuery)
+   *    .build();
+   * AggregationResults aggregationResults = datastore.runAggregation(aggregationQuery);
+   * // Use aggregationResults
+   * }
+ * + *

{@link GqlQuery} example: + * + *

{@code
+   * GqlQuery selectAllGqlQuery = Query.newGqlQueryBuilder(
+   *         "AGGREGATE COUNT(*) AS total_count OVER(SELECT * FROM Task)"
+   *     )
+   *     .setAllowLiteral(true)
+   *     .build();
+   * AggregationQuery aggregationQuery = Query.newAggregationQueryBuilder()
+   *     .over(selectAllGqlQuery)
+   *     .build();
+   * AggregationResults aggregationResults = datastore.runAggregation(aggregationQuery);
+   * // Use aggregationResults
+   * }
+ */ + public static AggregationQuery.Builder newAggregationQueryBuilder() { + return new AggregationQuery.Builder(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/QueryResults.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/QueryResults.java new file mode 100644 index 000000000000..efd03c67ba1f --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/QueryResults.java @@ -0,0 +1,81 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.datastore.models.ExplainMetrics; +import com.google.datastore.v1.QueryResultBatch; +import java.util.Iterator; +import java.util.Optional; + +/** + * The result of a Google Cloud Datastore query submission. When the result is not typed it is + * possible to cast it to its appropriate type according to the {@link #getResultClass} value. + * Results are loaded lazily in batches, where batch size is set by Cloud Datastore. As a result, it + * is possible to get a {@code DatastoreException} upon {@link Iterator#hasNext hasNext} or {@link + * Iterator#next next} calls. + * + * @param the type of the results value. + */ +@InternalExtensionOnly +public interface QueryResults extends Iterator { + + /** Returns the actual class of the result's values. */ + Class getResultClass(); + + /** + * Returns the Cursor for the point after the value returned in the last {@link #next} call. This + * cursor can be used to issue subsequent queries (with the same constraints) that may return + * additional results. + * + *

A simple use case: + * + *

{@code
+   * Query query = Query.newEntityQueryBuilder()
+   *     .setKind("Person")
+   *     .setFilter(PropertyFilter.eq("favoriteFood", "pizza"))
+   *     .build();
+   * QueryResults results = datastore.run(query);
+   * // Consume some results (using results.next()) and do any other actions as necessary.
+   * query = query.toBuilder().setStartCursor(results.getCursorAfter()).build();
+   * results = datastore.run(query); // now we will iterate over all entities not yet consumed
+   * }
+ */ + Cursor getCursorAfter(); + + /** + * Returns the number of results skipped, typically because of an offset. + * + *

A simple use case to count entities: + * + *

{@code
+   * Query query = Query.newKeyQueryBuilder().setOffset(Integer.MAX_VALUE).build();
+   * QueryResults result = datasore.datastore.run(query);
+   * if (!result.hasNext()) {
+   *  int numberOfEntities = result.getSkippedResults();
+   * }
+   * }
+ */ + int getSkippedResults(); + + /** Returns MoreResults state of the query after the current batch. */ + QueryResultBatch.MoreResultsType getMoreResults(); + + @BetaApi + Optional getExplainMetrics(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/QueryResultsImpl.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/QueryResultsImpl.java new file mode 100644 index 000000000000..138bc3d3c9d5 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/QueryResultsImpl.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 + * + * 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.datastore; + +import com.google.api.core.BetaApi; +import com.google.cloud.datastore.Query.ResultType; +import com.google.cloud.datastore.models.ExplainMetrics; +import com.google.common.base.Preconditions; +import com.google.common.collect.AbstractIterator; +import com.google.datastore.v1.ExplainOptions; +import com.google.datastore.v1.QueryResultBatch.MoreResultsType; +import com.google.datastore.v1.ReadOptions; +import com.google.protobuf.ByteString; +import java.util.Iterator; +import java.util.Objects; +import java.util.Optional; + +class QueryResultsImpl extends AbstractIterator implements QueryResults { + + private final DatastoreImpl datastore; + private final Optional readOptionsPb; + private final com.google.datastore.v1.PartitionId partitionIdPb; + private final ResultType queryResultType; + private RecordQuery query; + private ResultType actualResultType; + private com.google.datastore.v1.RunQueryResponse runQueryResponsePb; + private com.google.datastore.v1.Query mostRecentQueryPb; + private boolean lastBatch; + private Iterator entityResultPbIter; + private ByteString cursor; + private MoreResultsType moreResults; + private final ExplainOptions explainOptions; + private ExplainMetrics explainMetrics; + + QueryResultsImpl( + DatastoreImpl datastore, + Optional readOptionsPb, + RecordQuery query, + String namespace, + ExplainOptions explainOptions) { + this.datastore = datastore; + this.readOptionsPb = readOptionsPb; + this.query = query; + queryResultType = query.getType(); + this.explainOptions = explainOptions; + com.google.datastore.v1.PartitionId.Builder pbBuilder = + com.google.datastore.v1.PartitionId.newBuilder(); + pbBuilder.setProjectId(datastore.getOptions().getProjectId()); + pbBuilder.setDatabaseId(datastore.getOptions().getDatabaseId()); + if (namespace != null) { + pbBuilder.setNamespaceId(namespace); + } else if (datastore.getOptions().getNamespace() != null) { + pbBuilder.setNamespaceId(datastore.getOptions().getNamespace()); + } + partitionIdPb = pbBuilder.build(); + sendRequest(); + if (runQueryResponsePb.getBatch().getSkippedResults() > 0) { + cursor = runQueryResponsePb.getBatch().getSkippedCursor(); + } else { + cursor = mostRecentQueryPb.getStartCursor(); + } + } + + private void sendRequest() { + com.google.datastore.v1.RunQueryRequest.Builder requestPb = + com.google.datastore.v1.RunQueryRequest.newBuilder(); + readOptionsPb.ifPresent(requestPb::setReadOptions); + requestPb.setPartitionId(partitionIdPb); + requestPb.setProjectId(datastore.getOptions().getProjectId()); + requestPb.setDatabaseId(datastore.getOptions().getDatabaseId()); + if (explainOptions != null) { + requestPb.setExplainOptions(explainOptions); + } + query.populatePb(requestPb); + runQueryResponsePb = datastore.runQuery(requestPb.build()); + mostRecentQueryPb = requestPb.getQuery(); + moreResults = runQueryResponsePb.getBatch().getMoreResults(); + lastBatch = moreResults != MoreResultsType.NOT_FINISHED; + entityResultPbIter = runQueryResponsePb.getBatch().getEntityResultsList().iterator(); + actualResultType = ResultType.fromPb(runQueryResponsePb.getBatch().getEntityResultType()); + if (Objects.equals(queryResultType, ResultType.PROJECTION_ENTITY)) { + // projection entity can represent all type of results + actualResultType = ResultType.PROJECTION_ENTITY; + } + boolean isExplain = + explainOptions != null + && actualResultType.getQueryType() == null + && !explainOptions.getAnalyze(); + Preconditions.checkState( + queryResultType.isAssignableFrom(actualResultType) || isExplain, + "Unexpected result type or explain options set " + + actualResultType + + " vs " + + queryResultType + + ", explain options = false"); + if (runQueryResponsePb.hasExplainMetrics()) { + this.explainMetrics = new ExplainMetrics(runQueryResponsePb.getExplainMetrics()); + } + } + + @Override + protected T computeNext() { + while (!entityResultPbIter.hasNext() && !lastBatch) { + query = query.nextQuery(runQueryResponsePb); + sendRequest(); + } + if (!entityResultPbIter.hasNext()) { + cursor = runQueryResponsePb.getBatch().getEndCursor(); + return endOfData(); + } + com.google.datastore.v1.EntityResult entityResultPb = entityResultPbIter.next(); + cursor = entityResultPb.getCursor(); + @SuppressWarnings("unchecked") + T result = (T) actualResultType.convert(entityResultPb.getEntity()); + return result; + } + + @Override + public Class getResultClass() { + return actualResultType.resultClass(); + } + + @Override + public Cursor getCursorAfter() { + return new Cursor(cursor); + } + + @Override + public int getSkippedResults() { + return runQueryResponsePb.getBatch().getSkippedResults(); + } + + @Override + public MoreResultsType getMoreResults() { + return moreResults; + } + + @Override + @BetaApi + public Optional getExplainMetrics() { + return Optional.ofNullable(this.explainMetrics); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RawValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RawValue.java new file mode 100644 index 000000000000..d74e4794639b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RawValue.java @@ -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. + */ + +package com.google.cloud.datastore; + +public final class RawValue extends Value { + + private static final long serialVersionUID = 6615860024753061102L; + + static final BaseMarshaller MARSHALLER = + new BaseMarshaller() { + + private static final long serialVersionUID = -5724906360924425548L; + + @Override + public Builder newBuilder(com.google.datastore.v1.Value value) { + return RawValue.newBuilder(value); + } + + @Override + public int getProtoFieldId() { + return 0; + } + + @Override + protected com.google.datastore.v1.Value getValue(com.google.datastore.v1.Value from) { + return from; + } + + @Override + protected void setValue(RawValue from, com.google.datastore.v1.Value.Builder to) { + to.mergeFrom(from.get()); + } + }; + + public static final class Builder + extends Value.BaseBuilder { + + private Builder() { + super(ValueType.RAW_VALUE); + } + + @Override + public RawValue build() { + return new RawValue(this); + } + } + + private RawValue(Builder builder) { + super(builder); + } + + RawValue(com.google.datastore.v1.Value valuePb) { + this(newBuilder(valuePb)); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + static RawValue of(com.google.datastore.v1.Value valuePb) { + return new RawValue(valuePb); + } + + static Builder newBuilder(com.google.datastore.v1.Value valuePb) { + Builder builder = new Builder(); + builder.setExcludeFromIndexes(valuePb.getExcludeFromIndexes()); + builder.setMeaning(valuePb.getMeaning()); + builder.set(valuePb); + return builder; + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ReadOption.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ReadOption.java new file mode 100644 index 000000000000..0d3fd6c77aec --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ReadOption.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 + * + * 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.datastore; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.cloud.Timestamp; +import com.google.common.collect.ImmutableMap; +import com.google.datastore.v1.ExplainOptions; +import com.google.protobuf.ByteString; +import java.io.Serializable; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +/** + * Specifies options for read operations in Datastore, namely getting/fetching entities and running + * queries. + */ +public abstract class ReadOption implements Serializable { + + private static final long serialVersionUID = -4406964829189800528L; + + /** + * Specifies eventual consistency for reads from Datastore. Lookups and ancestor queries using + * this option permit Datastore to return stale results. + */ + public static final class EventualConsistency extends ReadOption { + + private static final long serialVersionUID = -6959530217724666172L; + + private final boolean eventualConsistency; + + private EventualConsistency(boolean eventualConsistency) { + this.eventualConsistency = eventualConsistency; + } + + public boolean isEventual() { + return eventualConsistency; + } + } + + /** + * Reads entities as they were at the given time. This may not be older than 270 seconds. This + * value is only supported for Cloud Firestore in Datastore mode. + */ + public static final class ReadTime extends ReadOption { + + private static final long serialVersionUID = -6780321449114616067L; + + private final Timestamp time; + + private ReadTime(Timestamp time) { + this.time = time; + } + + public Timestamp time() { + return time; + } + } + + /** Specifies transaction to be used when running a {@link Query}. */ + @InternalApi + static class TransactionId extends ReadOption { + + private final ByteString transactionId; + + TransactionId(ByteString transactionId) { + this.transactionId = transactionId; + } + + public ByteString getTransactionId() { + return transactionId; + } + } + + private ReadOption() {} + + /** + * Returns a {@code ReadOption} that specifies eventual consistency, allowing Datastore to return + * stale results from gets, fetches, and ancestor queries. + */ + public static EventualConsistency eventualConsistency() { + return new EventualConsistency(true); + } + + /** + * Returns a {@code ReadOption} that specifies read time, allowing Datastore to return results + * from lookups and queries at a particular timestamp. This feature is currently in private + * preview. + */ + @BetaApi + public static ReadTime readTime(Timestamp time) { + return new ReadTime(time); + } + + /** + * Returns a {@code ReadOption} that specifies transaction id, allowing Datastore to execute a + * {@link Query} in this transaction. + */ + @InternalApi + public static ReadOption transactionId(String transactionId) { + return new TransactionId(ByteString.copyFrom(transactionId.getBytes())); + } + + /** + * Returns a {@code ReadOption} that specifies transaction id, allowing Datastore to execute a + * {@link Query} in this transaction. + */ + @InternalApi + public static ReadOption transactionId(ByteString transactionId) { + return new TransactionId(transactionId); + } + + static Map, ReadOption> asImmutableMap(ReadOption... options) { + ImmutableMap.Builder, ReadOption> builder = ImmutableMap.builder(); + for (ReadOption option : options) { + builder.put(option.getClass(), option); + } + return builder.buildOrThrow(); + } + + static Map, ReadOption> asImmutableMap(List options) { + ImmutableMap.Builder, ReadOption> builder = ImmutableMap.builder(); + for (ReadOption option : options) { + builder.put(option.getClass(), option); + } + return builder.buildOrThrow(); + } + + @InternalApi + public static class QueryConfig> { + + Q query; + List readOptions; + ExplainOptions explainOptions; + + private QueryConfig(Q query, ExplainOptions explainOptions, List readOptions) { + this.query = query; + this.explainOptions = explainOptions; + this.readOptions = readOptions; + } + + private QueryConfig(Q query, ExplainOptions explainOptions) { + this(query, explainOptions, Collections.emptyList()); + } + + public Q getQuery() { + return query; + } + + public ExplainOptions getExplainOptions() { + return this.explainOptions; + } + + public List getReadOptions() { + return readOptions; + } + + public static > QueryConfig create( + Q query, ExplainOptions explainOptions) { + return new QueryConfig<>(query, explainOptions); + } + + public static > QueryConfig create( + Q query, ExplainOptions explainOptions, List readOptions) { + return new QueryConfig<>(query, explainOptions, readOptions); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ReadOptionProtoPreparer.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ReadOptionProtoPreparer.java new file mode 100644 index 000000000000..d6b667c83a6c --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ReadOptionProtoPreparer.java @@ -0,0 +1,77 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.ReadOption.EventualConsistency; +import com.google.cloud.datastore.ReadOption.ReadTime; +import com.google.cloud.datastore.ReadOption.TransactionId; +import com.google.cloud.datastore.execution.request.ProtoPreparer; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.ReadOptions.ReadConsistency; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.stream.Collectors; + +@InternalApi +public class ReadOptionProtoPreparer + implements ProtoPreparer, Optional> { + + @Override + public Optional prepare(List options) { + if (options == null || options.isEmpty()) { + return Optional.empty(); + } + com.google.datastore.v1.ReadOptions readOptionsPb = null; + Map, ReadOption> optionsByType = ReadOption.asImmutableMap(options); + + boolean moreThanOneReadOption = optionsByType.keySet().size() > 1; + if (moreThanOneReadOption) { + throw DatastoreException.throwInvalidRequest( + String.format("Can not use %s together.", getInvalidOptions(optionsByType))); + } + + if (optionsByType.containsKey(EventualConsistency.class)) { + readOptionsPb = ReadOptions.newBuilder().setReadConsistency(ReadConsistency.EVENTUAL).build(); + } + + if (optionsByType.containsKey(ReadTime.class)) { + readOptionsPb = + ReadOptions.newBuilder() + .setReadTime(((ReadTime) optionsByType.get(ReadTime.class)).time().toProto()) + .build(); + } + + if (optionsByType.containsKey(TransactionId.class)) { + readOptionsPb = + ReadOptions.newBuilder() + .setTransaction( + ((TransactionId) optionsByType.get(TransactionId.class)).getTransactionId()) + .build(); + } + return Optional.ofNullable(readOptionsPb); + } + + private String getInvalidOptions(Map, ReadOption> optionsByType) { + String regex = "([a-z])([A-Z]+)"; + String replacement = "$1 $2"; + return optionsByType.keySet().stream() + .map(Class::getSimpleName) + .map(s -> s.replaceAll(regex, replacement).toLowerCase()) + .collect(Collectors.joining(", ")); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RecordQuery.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RecordQuery.java new file mode 100644 index 000000000000..f54213ab7587 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RecordQuery.java @@ -0,0 +1,33 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.Query.ResultType; + +/** An internal marker interface to represent {@link Query} that returns the entity records. */ +@InternalApi +public interface RecordQuery { + + @InternalApi + ResultType getType(); + + @InternalApi + void populatePb(com.google.datastore.v1.RunQueryRequest.Builder requestPb); + + @InternalApi + RecordQuery nextQuery(com.google.datastore.v1.RunQueryResponse responsePb); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecorator.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecorator.java new file mode 100644 index 000000000000..b8a179783733 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/RetryAndTraceDatastoreRpcDecorator.java @@ -0,0 +1,138 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import static com.google.cloud.BaseService.EXCEPTION_HANDLER; + +import com.google.api.core.InternalApi; +import com.google.api.gax.retrying.RetrySettings; +import com.google.cloud.RetryHelper; +import com.google.cloud.RetryHelper.RetryHelperException; +import com.google.cloud.datastore.spi.v1.DatastoreRpc; +import com.google.cloud.datastore.telemetry.TraceUtil; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import java.util.concurrent.Callable; + +/** + * An implementation of {@link DatastoreRpc} which acts as a Decorator and decorates the underlying + * {@link DatastoreRpc} with the logic of retry and Traceability. + */ +@InternalApi +public class RetryAndTraceDatastoreRpcDecorator implements DatastoreRpc { + + private final DatastoreRpc datastoreRpc; + private final com.google.cloud.datastore.telemetry.TraceUtil otelTraceUtil; + private final RetrySettings retrySettings; + private final DatastoreOptions datastoreOptions; + + public RetryAndTraceDatastoreRpcDecorator( + DatastoreRpc datastoreRpc, + TraceUtil otelTraceUtil, + RetrySettings retrySettings, + DatastoreOptions datastoreOptions) { + this.datastoreRpc = datastoreRpc; + this.retrySettings = retrySettings; + this.datastoreOptions = datastoreOptions; + this.otelTraceUtil = otelTraceUtil; + } + + @Override + public AllocateIdsResponse allocateIds(AllocateIdsRequest request) { + throw new UnsupportedOperationException("Not implemented."); + } + + @Override + public BeginTransactionResponse beginTransaction(BeginTransactionRequest request) + throws DatastoreException { + throw new UnsupportedOperationException("Not implemented."); + } + + @Override + public CommitResponse commit(CommitRequest request) { + throw new UnsupportedOperationException("Not implemented."); + } + + @Override + public LookupResponse lookup(LookupRequest request) { + throw new UnsupportedOperationException("Not implemented."); + } + + @Override + public ReserveIdsResponse reserveIds(ReserveIdsRequest request) { + throw new UnsupportedOperationException("Not implemented."); + } + + @Override + public RollbackResponse rollback(RollbackRequest request) { + throw new UnsupportedOperationException("Not implemented."); + } + + @Override + public RunQueryResponse runQuery(RunQueryRequest request) { + throw new UnsupportedOperationException("Not implemented."); + } + + @Override + public RunAggregationQueryResponse runAggregationQuery(RunAggregationQueryRequest request) { + ReadOptions readOptions = request.getReadOptions(); + boolean isTransactional = readOptions.hasTransaction() || readOptions.hasNewTransaction(); + String spanName = + (isTransactional + ? com.google.cloud.datastore.telemetry.TraceUtil + .SPAN_NAME_TRANSACTION_RUN_AGGREGATION_QUERY + : com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RUN_AGGREGATION_QUERY); + return invokeRpc(() -> datastoreRpc.runAggregationQuery(request), spanName); + } + + @Override + public void close() throws Exception { + datastoreRpc.close(); + } + + @Override + public boolean isClosed() { + return datastoreRpc.isClosed(); + } + + public O invokeRpc(Callable block, String startSpan) { + com.google.cloud.datastore.telemetry.TraceUtil.Span span = otelTraceUtil.startSpan(startSpan); + try (com.google.cloud.datastore.telemetry.TraceUtil.Scope ignored = span.makeCurrent()) { + return RetryHelper.runWithRetries( + block, this.retrySettings, EXCEPTION_HANDLER, this.datastoreOptions.getClock()); + } catch (RetryHelperException e) { + span.end(e); + throw DatastoreException.translateAndThrow(e); + } finally { + span.end(); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/StringValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/StringValue.java new file mode 100644 index 000000000000..d457d6f735fa --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/StringValue.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 + * + * 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.datastore; + +import static com.google.datastore.v1.Value.STRING_VALUE_FIELD_NUMBER; + +public final class StringValue extends Value { + + private static final long serialVersionUID = -8709280401468276732L; + + static final BaseMarshaller MARSHALLER = + new BaseMarshaller() { + + private static final long serialVersionUID = -635109599283869091L; + + @Override + public int getProtoFieldId() { + return STRING_VALUE_FIELD_NUMBER; + } + + @Override + public Builder newBuilder(String value) { + return StringValue.newBuilder(value); + } + + @Override + protected String getValue(com.google.datastore.v1.Value from) { + return from.getStringValue(); + } + + @Override + protected void setValue(StringValue from, com.google.datastore.v1.Value.Builder to) { + to.setStringValue(from.get()); + } + }; + + public static final class Builder extends Value.BaseBuilder { + + private Builder() { + super(ValueType.STRING); + } + + @Override + public StringValue build() { + return new StringValue(this); + } + } + + public StringValue(String value) { + this(newBuilder(value)); + } + + private StringValue(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + public static StringValue of(String value) { + return new StringValue(value); + } + + public static Builder newBuilder(String value) { + return new Builder().set(value); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/StructuredQuery.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/StructuredQuery.java new file mode 100644 index 000000000000..f1e8479cde57 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/StructuredQuery.java @@ -0,0 +1,1076 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.cloud.datastore.BlobValue.of; +import static com.google.cloud.datastore.BooleanValue.of; +import static com.google.cloud.datastore.DoubleValue.of; +import static com.google.cloud.datastore.KeyValue.of; +import static com.google.cloud.datastore.LongValue.of; +import static com.google.cloud.datastore.StringValue.of; +import static com.google.cloud.datastore.TimestampValue.of; +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.api.core.ApiFunction; +import com.google.api.core.InternalApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.StringEnumType; +import com.google.cloud.StringEnumValue; +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.Query.ResultType; +import com.google.common.base.MoreObjects; +import com.google.common.base.MoreObjects.ToStringHelper; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.Objects; + +/** + * An implementation of a Google Cloud Datastore Query that can be constructed by providing all the + * specific query elements. + * + *

A usage example: + * + *

A simple query that returns all entities for a specific kind + * + *

{@code
+ * Query query = Query.newEntityQueryBuilder().setKind(kind).build();
+ * QueryResults results = datastore.run(query);
+ * while (results.hasNext()) {
+ *   Entity entity = results.next();
+ *   ...
+ * }
+ * }
+ * + *

A simple key-only query of all entities for a specific kind + * + *

{@code
+ * Query keyOnlyQuery =  Query.newKeyQueryBuilder().setKind(KIND1).build();
+ * QueryResults results = datastore.run(keyOnlyQuery);
+ * ...
+ * }
+ * + *

A less trivial example of a projection query that returns the first 10 results of "age" and + * "name" properties (sorted and grouped by "age") with an age greater than 18 + * + *

{@code
+ * Query query = Query.newProjectionEntityQueryBuilder()
+ *     .setKind(kind)
+ *     .setProjection(Projection.property("age"), Projection.first("name"))
+ *     .setFilter(PropertyFilter.gt("age", 18))
+ *     .setGroupBy("age")
+ *     .setOrderBy(OrderBy.asc("age"))
+ *     .setLimit(10)
+ *     .build();
+ * QueryResults results = datastore.run(query);
+ * ...
+ * }
+ * + * @param the type of the result values this query will produce + * @see Datastore + * queries + */ +public abstract class StructuredQuery extends Query implements RecordQuery { + + private static final long serialVersionUID = 546838955624019594L; + static final String KEY_PROPERTY_NAME = "__key__"; + + private final String kind; + private final ImmutableList projection; + private final Filter filter; + private final ImmutableList distinctOn; + private final ImmutableList orderBy; + private final Cursor startCursor; + private final Cursor endCursor; + private final int offset; + private final Integer limit; + + private final ResultType resultType; + + public abstract static class Filter implements Serializable { + + private static final long serialVersionUID = -6443285436239990860L; + + Filter() {} + + abstract com.google.datastore.v1.Filter toPb(); + + static Filter fromPb(com.google.datastore.v1.Filter filterPb) { + switch (filterPb.getFilterTypeCase()) { + case COMPOSITE_FILTER: + return CompositeFilter.fromPb(filterPb.getCompositeFilter()); + case PROPERTY_FILTER: + return PropertyFilter.fromPb(filterPb.getPropertyFilter()); + default: + throw new AssertionError("Unexpected enum value " + filterPb.getFilterTypeCase()); + } + } + } + + /** A class representing a filter composed of a combination of other filters. */ + public static final class CompositeFilter extends Filter { + + private static final long serialVersionUID = 3610352685739360009L; + private final Operator operator; + private final ImmutableList filters; + + static final class Operator extends StringEnumValue { + private static final long serialVersionUID = -4806600805752138487L; + + private Operator(String constant) { + super(constant); + } + + private static final ApiFunction CONSTRUCTOR = + new ApiFunction() { + @Override + public Operator apply(String constant) { + return new Operator(constant); + } + }; + + private static final StringEnumType type = + new StringEnumType(Operator.class, CONSTRUCTOR); + + static final Operator AND = type.createAndRegister("AND"); + + static final Operator OR = type.createAndRegister("OR"); + + com.google.datastore.v1.CompositeFilter.Operator toPb() { + return com.google.datastore.v1.CompositeFilter.Operator.valueOf(name()); + } + + static Operator fromPb(com.google.datastore.v1.CompositeFilter.Operator operatorPb) { + return valueOf(operatorPb.name()); + } + + /** + * Get the Operator for the given String constant, and throw an exception if the constant is + * not recognized. + */ + static Operator valueOfStrict(String constant) { + return type.valueOfStrict(constant); + } + + /** Get the Operator for the given String constant, and allow unrecognized values. */ + static Operator valueOf(String constant) { + return type.valueOf(constant); + } + + /** Return the known values for Operator. */ + static Operator[] values() { + return type.values(); + } + } + + private CompositeFilter(Operator operator, Filter first, Filter... other) { + this.operator = operator; + this.filters = + ImmutableList.builder().add(first).addAll(Arrays.asList(other)).build(); + } + + private CompositeFilter(Operator operator, ImmutableList filters) { + this.operator = operator; + this.filters = filters; + Preconditions.checkArgument(!filters.isEmpty(), "filters list must not be empty"); + } + + @Override + public String toString() { + ToStringHelper toStringHelper = MoreObjects.toStringHelper(this); + toStringHelper.add("operator", operator); + toStringHelper.add("filters", filters); + return toStringHelper.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(operator, filters); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CompositeFilter)) { + return false; + } + CompositeFilter other = (CompositeFilter) obj; + return operator.equals(other.operator) && filters.equals(other.filters); + } + + static CompositeFilter fromPb(com.google.datastore.v1.CompositeFilter compositeFilterPb) { + Operator operator = Operator.fromPb(compositeFilterPb.getOp()); + ImmutableList.Builder filters = ImmutableList.builder(); + for (com.google.datastore.v1.Filter filterPb : compositeFilterPb.getFiltersList()) { + Filter currFilter = Filter.fromPb(filterPb); + if (currFilter != null) { + filters.add(currFilter); + } + } + return new CompositeFilter(operator, filters.build()); + } + + public static CompositeFilter and(Filter first, Filter... other) { + return new CompositeFilter(Operator.AND, first, other); + } + + public static CompositeFilter or(Filter first, Filter... other) { + return new CompositeFilter(Operator.OR, first, other); + } + + @Override + com.google.datastore.v1.Filter toPb() { + com.google.datastore.v1.Filter.Builder filterPb = com.google.datastore.v1.Filter.newBuilder(); + com.google.datastore.v1.CompositeFilter.Builder compositeFilterPb = + filterPb.getCompositeFilterBuilder(); + compositeFilterPb.setOp(operator.toPb()); + for (Filter filter : filters) { + compositeFilterPb.addFilters(filter.toPb()); + } + return filterPb.build(); + } + } + + /** A class representing a filter based on a single property or ancestor. */ + public static final class PropertyFilter extends Filter { + + private static final long serialVersionUID = -4514695915258598597L; + + private final String property; + private final Operator operator; + private final Value value; + + static final class Operator extends StringEnumValue { + private static final long serialVersionUID = 4105765859141068029L; + + private Operator(String constant) { + super(constant); + } + + private static final ApiFunction CONSTRUCTOR = + new ApiFunction() { + @Override + public Operator apply(String constant) { + return new Operator(constant); + } + }; + + private static final StringEnumType type = + new StringEnumType(Operator.class, CONSTRUCTOR); + + static final Operator LESS_THAN = type.createAndRegister("LESS_THAN"); + static final Operator LESS_THAN_OR_EQUAL = type.createAndRegister("LESS_THAN_OR_EQUAL"); + static final Operator GREATER_THAN = type.createAndRegister("GREATER_THAN"); + static final Operator GREATER_THAN_OR_EQUAL = type.createAndRegister("GREATER_THAN_OR_EQUAL"); + static final Operator EQUAL = type.createAndRegister("EQUAL"); + static final Operator IN = type.createAndRegister("IN"); + static final Operator NOT_EQUAL = type.createAndRegister("NOT_EQUAL"); + static final Operator HAS_ANCESTOR = type.createAndRegister("HAS_ANCESTOR"); + static final Operator NOT_IN = type.createAndRegister("NOT_IN"); + + com.google.datastore.v1.PropertyFilter.Operator toPb() { + return com.google.datastore.v1.PropertyFilter.Operator.valueOf(name()); + } + + static Operator fromPb(com.google.datastore.v1.PropertyFilter.Operator operatorPb) { + return valueOf(operatorPb.name()); + } + + /** + * Get the Operator for the given String constant, and throw an exception if the constant is + * not recognized. + */ + static Operator valueOfStrict(String constant) { + return type.valueOfStrict(constant); + } + + /** Get the Operator for the given String constant, and allow unrecognized values. */ + static Operator valueOf(String constant) { + return type.valueOf(constant); + } + + /** Return the known values for Operator. */ + static Operator[] values() { + return type.values(); + } + } + + private PropertyFilter(String property, Operator operator, Value value) { + this.property = checkNotNull(property); + this.operator = checkNotNull(operator); + this.value = checkNotNull(value); + } + + static PropertyFilter fromPb(com.google.datastore.v1.PropertyFilter propertyFilterPb) { + String property = propertyFilterPb.getProperty().getName(); + Operator operator = Operator.fromPb(propertyFilterPb.getOp()); + Value value = Value.fromPb(propertyFilterPb.getValue()); + return new PropertyFilter(property, operator, value); + } + + @Override + public String toString() { + ToStringHelper toStringHelper = MoreObjects.toStringHelper(this); + toStringHelper.add("property", property); + toStringHelper.add("operator", operator); + toStringHelper.add("value", value); + return toStringHelper.toString(); + } + + @Override + public int hashCode() { + return Objects.hash(property, operator, value); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PropertyFilter)) { + return false; + } + PropertyFilter other = (PropertyFilter) obj; + return property.equals(other.property) + && operator.equals(other.operator) + && Objects.equals(value, other.value); + } + + public static PropertyFilter lt(String property, Value value) { + return new PropertyFilter(property, Operator.LESS_THAN, value); + } + + public static PropertyFilter lt(String property, String value) { + return new PropertyFilter(property, Operator.LESS_THAN, of(value)); + } + + public static PropertyFilter lt(String property, long value) { + return new PropertyFilter(property, Operator.LESS_THAN, of(value)); + } + + public static PropertyFilter lt(String property, double value) { + return new PropertyFilter(property, Operator.LESS_THAN, of(value)); + } + + public static PropertyFilter lt(String property, boolean value) { + return new PropertyFilter(property, Operator.LESS_THAN, of(value)); + } + + public static PropertyFilter lt(String property, Timestamp value) { + return new PropertyFilter(property, Operator.LESS_THAN, of(value)); + } + + public static PropertyFilter lt(String property, Key value) { + return new PropertyFilter(property, Operator.LESS_THAN, of(value)); + } + + public static PropertyFilter lt(String property, Blob value) { + return new PropertyFilter(property, Operator.LESS_THAN, of(value)); + } + + public static PropertyFilter le(String property, Value value) { + return new PropertyFilter(property, Operator.LESS_THAN_OR_EQUAL, value); + } + + public static PropertyFilter le(String property, String value) { + return new PropertyFilter(property, Operator.LESS_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter le(String property, long value) { + return new PropertyFilter(property, Operator.LESS_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter le(String property, double value) { + return new PropertyFilter(property, Operator.LESS_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter le(String property, boolean value) { + return new PropertyFilter(property, Operator.LESS_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter le(String property, Timestamp value) { + return new PropertyFilter(property, Operator.LESS_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter le(String property, Key value) { + return new PropertyFilter(property, Operator.LESS_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter le(String property, Blob value) { + return new PropertyFilter(property, Operator.LESS_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter gt(String property, Value value) { + return new PropertyFilter(property, Operator.GREATER_THAN, value); + } + + public static PropertyFilter gt(String property, String value) { + return new PropertyFilter(property, Operator.GREATER_THAN, of(value)); + } + + public static PropertyFilter gt(String property, long value) { + return new PropertyFilter(property, Operator.GREATER_THAN, of(value)); + } + + public static PropertyFilter gt(String property, double value) { + return new PropertyFilter(property, Operator.GREATER_THAN, of(value)); + } + + public static PropertyFilter gt(String property, boolean value) { + return new PropertyFilter(property, Operator.GREATER_THAN, of(value)); + } + + public static PropertyFilter gt(String property, Timestamp value) { + return new PropertyFilter(property, Operator.GREATER_THAN, of(value)); + } + + public static PropertyFilter gt(String property, Key value) { + return new PropertyFilter(property, Operator.GREATER_THAN, of(value)); + } + + public static PropertyFilter gt(String property, Blob value) { + return new PropertyFilter(property, Operator.GREATER_THAN, of(value)); + } + + public static PropertyFilter ge(String property, Value value) { + return new PropertyFilter(property, Operator.GREATER_THAN_OR_EQUAL, value); + } + + public static PropertyFilter ge(String property, String value) { + return new PropertyFilter(property, Operator.GREATER_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter ge(String property, long value) { + return new PropertyFilter(property, Operator.GREATER_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter ge(String property, double value) { + return new PropertyFilter(property, Operator.GREATER_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter ge(String property, boolean value) { + return new PropertyFilter(property, Operator.GREATER_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter ge(String property, Timestamp value) { + return new PropertyFilter(property, Operator.GREATER_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter ge(String property, Key value) { + return new PropertyFilter(property, Operator.GREATER_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter ge(String property, Blob value) { + return new PropertyFilter(property, Operator.GREATER_THAN_OR_EQUAL, of(value)); + } + + public static PropertyFilter eq(String property, Value value) { + return new PropertyFilter(property, Operator.EQUAL, value); + } + + public static PropertyFilter eq(String property, String value) { + return new PropertyFilter(property, Operator.EQUAL, of(value)); + } + + public static PropertyFilter eq(String property, long value) { + return new PropertyFilter(property, Operator.EQUAL, of(value)); + } + + public static PropertyFilter eq(String property, double value) { + return new PropertyFilter(property, Operator.EQUAL, of(value)); + } + + public static PropertyFilter eq(String property, boolean value) { + return new PropertyFilter(property, Operator.EQUAL, of(value)); + } + + public static PropertyFilter eq(String property, Timestamp value) { + return new PropertyFilter(property, Operator.EQUAL, of(value)); + } + + public static PropertyFilter eq(String property, Key value) { + return new PropertyFilter(property, Operator.EQUAL, of(value)); + } + + public static PropertyFilter eq(String property, Blob value) { + return new PropertyFilter(property, Operator.EQUAL, of(value)); + } + + public static PropertyFilter neq(String property, Value value) { + return new PropertyFilter(property, Operator.NOT_EQUAL, value); + } + + public static PropertyFilter neq(String property, String value) { + return new PropertyFilter(property, Operator.NOT_EQUAL, of(value)); + } + + public static PropertyFilter neq(String property, long value) { + return new PropertyFilter(property, Operator.NOT_EQUAL, of(value)); + } + + public static PropertyFilter neq(String property, double value) { + return new PropertyFilter(property, Operator.NOT_EQUAL, of(value)); + } + + public static PropertyFilter neq(String property, boolean value) { + return new PropertyFilter(property, Operator.NOT_EQUAL, of(value)); + } + + public static PropertyFilter neq(String property, Timestamp value) { + return new PropertyFilter(property, Operator.NOT_EQUAL, of(value)); + } + + public static PropertyFilter neq(String property, Key value) { + return new PropertyFilter(property, Operator.NOT_EQUAL, of(value)); + } + + public static PropertyFilter neq(String property, Blob value) { + return new PropertyFilter(property, Operator.NOT_EQUAL, of(value)); + } + + public static PropertyFilter in(String property, ListValue value) { + return new PropertyFilter(property, Operator.IN, value); + } + + public static PropertyFilter not_in(String property, ListValue value) { + return new PropertyFilter(property, Operator.NOT_IN, value); + } + + public static PropertyFilter hasAncestor(Key key) { + return new PropertyFilter(KEY_PROPERTY_NAME, Operator.HAS_ANCESTOR, of(key)); + } + + public static PropertyFilter isNull(String property) { + return new PropertyFilter(property, Operator.EQUAL, NullValue.of()); + } + + @Override + com.google.datastore.v1.Filter toPb() { + com.google.datastore.v1.Filter.Builder filterPb = com.google.datastore.v1.Filter.newBuilder(); + com.google.datastore.v1.PropertyFilter.Builder propertyFilterPb = + filterPb.getPropertyFilterBuilder(); + propertyFilterPb.getPropertyBuilder().setName(property); + propertyFilterPb.setOp(operator.toPb()); + if (value != null) { + propertyFilterPb.setValue(value.toPb()); + } + return filterPb.build(); + } + } + + public static final class OrderBy implements Serializable { + + private static final long serialVersionUID = 4091186784814400031L; + + private final String property; + private final Direction direction; + + public static final class Direction extends StringEnumValue { + private static final long serialVersionUID = -6938125060419556331L; + + private Direction(String constant) { + super(constant); + } + + private static final ApiFunction CONSTRUCTOR = + new ApiFunction() { + @Override + public Direction apply(String constant) { + return new Direction(constant); + } + }; + + private static final StringEnumType type = + new StringEnumType(Direction.class, CONSTRUCTOR); + + public static final Direction ASCENDING = type.createAndRegister("ASCENDING"); + public static final Direction DESCENDING = type.createAndRegister("DESCENDING"); + + com.google.datastore.v1.PropertyOrder.Direction toPb() { + return com.google.datastore.v1.PropertyOrder.Direction.valueOf(name()); + } + + static Direction fromPb(com.google.datastore.v1.PropertyOrder.Direction directionPb) { + return valueOf(directionPb.name()); + } + + /** + * Get the Direction for the given String constant, and throw an exception if the constant is + * not recognized. + */ + static Direction valueOfStrict(String constant) { + return type.valueOfStrict(constant); + } + + /** Get the Direction for the given String constant, and allow unrecognized values. */ + static Direction valueOf(String constant) { + return type.valueOf(constant); + } + + /** Return the known values for Direction. */ + static Direction[] values() { + return type.values(); + } + } + + public OrderBy(String property, Direction direction) { + this.property = checkNotNull(property); + this.direction = checkNotNull(direction); + } + + @Override + public int hashCode() { + return Objects.hash(property, direction); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OrderBy)) { + return false; + } + OrderBy other = (OrderBy) obj; + return property.equals(other.property) && direction.equals(other.direction); + } + + /** Returns the property according to which the query result should be ordered. */ + public String getProperty() { + return property; + } + + /** Returns the order's direction. */ + public Direction getDirection() { + return direction; + } + + com.google.datastore.v1.PropertyOrder toPb() { + return com.google.datastore.v1.PropertyOrder.newBuilder() + .setDirection(direction.toPb()) + .setProperty( + com.google.datastore.v1.PropertyReference.newBuilder().setName(property).build()) + .build(); + } + + public static OrderBy asc(String property) { + return new OrderBy(property, OrderBy.Direction.ASCENDING); + } + + public static OrderBy desc(String property) { + return new OrderBy(property, OrderBy.Direction.DESCENDING); + } + + static OrderBy fromPb(com.google.datastore.v1.PropertyOrder propertyOrderPb) { + String property = propertyOrderPb.getProperty().getName(); + Direction direction = Direction.fromPb(propertyOrderPb.getDirection()); + return new OrderBy(property, direction); + } + + @Override + public String toString() { + ToStringHelper toStringHelper = MoreObjects.toStringHelper(this); + toStringHelper.add("property", getProperty()); + toStringHelper.add("direction", getDirection()); + return toStringHelper.toString(); + } + } + + /** + * Interface for StructuredQuery builders. + * + * @param the type of result the query returns. + */ + @InternalExtensionOnly + public interface Builder { + + /** Sets the namespace for the query. */ + Builder setNamespace(String namespace); + + /** Sets the kind for the query. */ + Builder setKind(String kind); + + /** Sets the start cursor for the query. */ + Builder setStartCursor(Cursor startCursor); + + /** Sets the end cursor for the query. */ + Builder setEndCursor(Cursor endCursor); + + /** Sets the offset for the query. */ + Builder setOffset(int offset); + + /** Sets the limit for the query. */ + Builder setLimit(Integer limit); + + Builder setFilter(Filter filter); + + /** Clears any previously specified order by settings. */ + Builder clearOrderBy(); + + /** Sets the query's order by clause (clearing any previously specified order by settings). */ + Builder setOrderBy(OrderBy orderBy, OrderBy... others); + + /** Adds settings to the existing order by clause. */ + Builder addOrderBy(OrderBy orderBy, OrderBy... others); + + StructuredQuery build(); + } + + /** + * Base class for StructuredQuery builders. + * + * @param the type of result the query returns. + * @param the query builder. + */ + abstract static class BuilderImpl> implements Builder { + + private final ResultType resultType; + private String namespace; + private String kind; + private final List projection = new LinkedList<>(); + private Filter filter; + private final List distinctOn = new LinkedList<>(); + private final List orderBy = new LinkedList<>(); + private Cursor startCursor; + private Cursor endCursor; + private int offset; + private Integer limit; + + BuilderImpl(ResultType resultType) { + this.resultType = resultType; + } + + BuilderImpl(StructuredQuery query) { + this(query.getType()); + namespace = query.getNamespace(); + kind = query.kind; + projection.addAll(query.projection); + filter = query.filter; + distinctOn.addAll(query.distinctOn); + orderBy.addAll(query.orderBy); + startCursor = query.startCursor; + endCursor = query.endCursor; + offset = query.offset; + limit = query.limit; + } + + @SuppressWarnings("unchecked") + B self() { + return (B) this; + } + + @Override + public B setNamespace(String namespace) { + this.namespace = namespace; + return self(); + } + + @Override + public B setKind(String kind) { + this.kind = kind; + return self(); + } + + @Override + public B setStartCursor(Cursor startCursor) { + this.startCursor = startCursor; + return self(); + } + + @Override + public B setEndCursor(Cursor endCursor) { + this.endCursor = endCursor; + return self(); + } + + @Override + public B setOffset(int offset) { + Preconditions.checkArgument(offset >= 0, "offset must not be negative"); + this.offset = offset; + return self(); + } + + @Override + public B setLimit(Integer limit) { + Preconditions.checkArgument(limit == null || limit >= 0, "limit must not be negative"); + this.limit = limit; + return self(); + } + + @Override + public B setFilter(Filter filter) { + this.filter = filter; + return self(); + } + + @Override + public B clearOrderBy() { + orderBy.clear(); + return self(); + } + + @Override + public B setOrderBy(OrderBy orderBy, OrderBy... others) { + clearOrderBy(); + addOrderBy(orderBy, others); + return self(); + } + + @Override + public B addOrderBy(OrderBy orderBy, OrderBy... others) { + this.orderBy.add(orderBy); + Collections.addAll(this.orderBy, others); + return self(); + } + + B clearProjection() { + projection.clear(); + return self(); + } + + B setProjection(String projection, String... others) { + clearProjection(); + addProjection(projection, others); + return self(); + } + + B addProjection(String projection, String... others) { + this.projection.add(projection); + Collections.addAll(this.projection, others); + return self(); + } + + B clearDistinctOn() { + distinctOn.clear(); + return self(); + } + + B setDistinctOn(String property, String... others) { + clearDistinctOn(); + addDistinctOn(property, others); + return self(); + } + + B addDistinctOn(String property, String... others) { + this.distinctOn.add(property); + Collections.addAll(this.distinctOn, others); + return self(); + } + + B mergeFrom(com.google.datastore.v1.Query queryPb) { + if (queryPb.getKindCount() > 0) { + setKind(queryPb.getKind(0).getName()); + } + if (!queryPb.getStartCursor().isEmpty()) { + setStartCursor(new Cursor(queryPb.getStartCursor())); + } + if (!queryPb.getEndCursor().isEmpty()) { + setEndCursor(new Cursor(queryPb.getEndCursor())); + } + setOffset(queryPb.getOffset()); + if (queryPb.hasLimit()) { + setLimit(queryPb.getLimit().getValue()); + } + if (queryPb.hasFilter()) { + Filter currFilter = Filter.fromPb(queryPb.getFilter()); + if (currFilter != null) { + setFilter(currFilter); + } + } + for (com.google.datastore.v1.PropertyOrder orderByPb : queryPb.getOrderList()) { + addOrderBy(OrderBy.fromPb(orderByPb)); + } + for (com.google.datastore.v1.Projection projectionPb : queryPb.getProjectionList()) { + addProjection(projectionPb.getProperty().getName()); + } + for (com.google.datastore.v1.PropertyReference distinctOnPb : queryPb.getDistinctOnList()) { + addDistinctOn(distinctOnPb.getName()); + } + return self(); + } + } + + StructuredQuery(BuilderImpl builder) { + super(builder.namespace); + resultType = checkNotNull(builder.resultType); + kind = builder.kind; + projection = ImmutableList.copyOf(builder.projection); + filter = builder.filter; + distinctOn = ImmutableList.copyOf(builder.distinctOn); + orderBy = ImmutableList.copyOf(builder.orderBy); + startCursor = builder.startCursor; + endCursor = builder.endCursor; + offset = builder.offset; + limit = builder.limit; + } + + @Override + public String toString() { + return toStringHelper() + .add("type", getType()) + .add("kind", kind) + .add("startCursor", startCursor) + .add("endCursor", endCursor) + .add("offset", offset) + .add("limit", limit) + .add("filter", filter) + .add("orderBy", orderBy) + .add("projection", projection) + .add("distinctOn", distinctOn) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash( + getNamespace(), + kind, + startCursor, + endCursor, + offset, + limit, + filter, + orderBy, + projection, + distinctOn); + } + + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StructuredQuery)) { + return false; + } + StructuredQuery other = (StructuredQuery) obj; + return Objects.equals(getNamespace(), other.getNamespace()) + && Objects.equals(kind, other.kind) + && Objects.equals(startCursor, other.startCursor) + && Objects.equals(endCursor, other.endCursor) + && Objects.equals(offset, other.offset) + && Objects.equals(limit, other.limit) + && Objects.equals(filter, other.filter) + && Objects.equals(orderBy, other.orderBy) + && Objects.equals(projection, other.projection) + && Objects.equals(distinctOn, other.distinctOn); + } + + /** Returns the kind for this query. */ + public String getKind() { + return kind; + } + + boolean isKeyOnly() { + return projection.size() == 1 && KEY_PROPERTY_NAME.equals(projection.get(0)); + } + + /** Returns the projection for this query. */ + public List getProjection() { + return projection; + } + + /** Returns the filter for this query. */ + public Filter getFilter() { + return filter; + } + + /** Returns the distinct on clause for this query. */ + public List getDistinctOn() { + return distinctOn; + } + + /** Returns the order by clause for this query. */ + public List getOrderBy() { + return orderBy; + } + + /** Returns the start cursor for this query. */ + public Cursor getStartCursor() { + return startCursor; + } + + /** Returns the end cursor for this query. */ + public Cursor getEndCursor() { + return endCursor; + } + + /** Returns the offset for this query. */ + public int getOffset() { + return offset; + } + + /** Returns the limit for this query. */ + public Integer getLimit() { + return limit; + } + + public abstract Builder toBuilder(); + + @InternalApi + @Override + public ResultType getType() { + return resultType; + } + + @InternalApi + @Override + public void populatePb(com.google.datastore.v1.RunQueryRequest.Builder requestPb) { + requestPb.setQuery(toPb()); + } + + @InternalApi + @Override + public StructuredQuery nextQuery(com.google.datastore.v1.RunQueryResponse responsePb) { + Builder builder = toBuilder(); + builder.setStartCursor(new Cursor(responsePb.getBatch().getEndCursor())); + if (offset > 0 && responsePb.getBatch().getSkippedResults() < offset) { + builder.setOffset(offset - responsePb.getBatch().getSkippedResults()); + } else { + builder.setOffset(0); + if (limit != null) { + builder.setLimit(limit - responsePb.getBatch().getEntityResultsCount()); + } + } + return builder.build(); + } + + com.google.datastore.v1.Query toPb() { + StructuredQueryProtoPreparer protoPreparer = new StructuredQueryProtoPreparer(); + return protoPreparer.prepare(this); + } + + @SuppressWarnings("unchecked") + static StructuredQuery fromPb( + ResultType resultType, String namespace, com.google.datastore.v1.Query queryPb) { + BuilderImpl builder; + if (resultType.equals(ResultType.ENTITY)) { + builder = new EntityQuery.Builder(); + } else if (resultType.equals(ResultType.KEY)) { + builder = new KeyQuery.Builder(); + } else { + builder = new ProjectionEntityQuery.Builder(); + } + return (StructuredQuery) builder.setNamespace(namespace).mergeFrom(queryPb).build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/StructuredQueryProtoPreparer.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/StructuredQueryProtoPreparer.java new file mode 100644 index 000000000000..42c0b757e51b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/StructuredQueryProtoPreparer.java @@ -0,0 +1,66 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.execution.request.ProtoPreparer; +import com.google.datastore.v1.Query; +import com.google.protobuf.Int32Value; + +@InternalApi +public class StructuredQueryProtoPreparer implements ProtoPreparer, Query> { + + @Override + public Query prepare(StructuredQuery query) { + com.google.datastore.v1.Query.Builder queryPb = com.google.datastore.v1.Query.newBuilder(); + if (query.getKind() != null) { + queryPb.addKindBuilder().setName(query.getKind()); + } + if (query.getStartCursor() != null) { + queryPb.setStartCursor(query.getStartCursor().getByteString()); + } + if (query.getEndCursor() != null) { + queryPb.setEndCursor(query.getEndCursor().getByteString()); + } + if (query.getOffset() > 0) { + queryPb.setOffset(query.getOffset()); + } + if (query.getLimit() != null) { + queryPb.setLimit(Int32Value.of(query.getLimit())); + } + if (query.getFilter() != null) { + queryPb.setFilter(query.getFilter().toPb()); + } + for (OrderBy value : query.getOrderBy()) { + queryPb.addOrder(value.toPb()); + } + for (String value : query.getDistinctOn()) { + queryPb.addDistinctOn( + com.google.datastore.v1.PropertyReference.newBuilder().setName(value).build()); + } + for (String value : query.getProjection()) { + com.google.datastore.v1.Projection expressionPb = + com.google.datastore.v1.Projection.newBuilder() + .setProperty( + com.google.datastore.v1.PropertyReference.newBuilder().setName(value).build()) + .build(); + queryPb.addProjection(expressionPb); + } + + return queryPb.build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TimestampValue.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TimestampValue.java new file mode 100644 index 000000000000..46386dd601f8 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TimestampValue.java @@ -0,0 +1,85 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.datastore.v1.Value.TIMESTAMP_VALUE_FIELD_NUMBER; + +import com.google.cloud.Timestamp; + +public final class TimestampValue extends Value { + + private static final long serialVersionUID = -8502433575902990648L; + + static final BaseMarshaller MARSHALLER = + new BaseMarshaller() { + + private static final long serialVersionUID = -5789520029958113745L; + + @Override + public int getProtoFieldId() { + return TIMESTAMP_VALUE_FIELD_NUMBER; + } + + @Override + public Builder newBuilder(Timestamp value) { + return TimestampValue.newBuilder(value); + } + + @Override + protected Timestamp getValue(com.google.datastore.v1.Value from) { + return Timestamp.fromProto(from.getTimestampValue()); + } + + @Override + protected void setValue(TimestampValue from, com.google.datastore.v1.Value.Builder to) { + to.setTimestampValue(from.get().toProto()); + } + }; + + public static final class Builder extends Value.BaseBuilder { + + private Builder() { + super(ValueType.TIMESTAMP); + } + + @Override + public TimestampValue build() { + return new TimestampValue(this); + } + } + + public TimestampValue(Timestamp timestamp) { + this(newBuilder(timestamp)); + } + + private TimestampValue(Builder builder) { + super(builder); + } + + @Override + public Builder toBuilder() { + return new Builder().mergeFrom(this); + } + + public static TimestampValue of(Timestamp timestamp) { + return new TimestampValue(timestamp); + } + + public static Builder newBuilder(Timestamp timestamp) { + return new Builder().set(timestamp); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Transaction.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Transaction.java new file mode 100644 index 000000000000..3d783e53a528 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Transaction.java @@ -0,0 +1,468 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.datastore.models.ExplainOptions; +import com.google.protobuf.ByteString; +import java.util.Iterator; +import java.util.List; +import javax.annotation.concurrent.NotThreadSafe; + +/** + * A Google cloud datastore transaction. Similar to {@link Batch} any write operation that is + * applied on a transaction will only be sent to the Datastore upon {@link #commit}. A call to + * {@link #rollback} will invalidate the transaction and discard the changes. Any read operation + * that is done by a transaction will be part of it and therefore a {@code commit} is guaranteed to + * fail if an entity was modified outside the transaction after it was read. Write operation on this + * transaction will not be reflected by read operation (as the changes are only sent to the + * Datastore upon {@code commit}. A usage example: + * + *
{@code
+ * Transaction transaction = datastore.newTransaction();
+ * try {
+ *   Entity entity = transaction.get(key);
+ *   if (!entity.contains("last_name") || entity.isNull("last_name")) {
+ *     String[] name = entity.getString("name").split(" ");
+ *     entity = Entity.newBuilder(entity)
+ *         .remove("name")
+ *         .set("first_name", name[0])
+ *         .set("last_name", name[1])
+ *         .build();
+ *     transaction.update(entity);
+ *     transaction.commit();
+ *   }
+ * } finally {
+ *   if (transaction.isActive()) {
+ *     transaction.rollback();
+ *   }
+ * }
+ * }
+ * + * @see Google Cloud + * Datastore transactions + *

WARNING: This class maintains an internal state in terms of {@link + * java.util.LinkedHashMap} and {@link java.util.LinkedHashSet} which gets updated on every + * method call performing CRUD operations to record the mutations. Since {@link + * java.util.LinkedHashMap} is not thread safe as per its documentation, + * This class too should not be treated as a thread safe class. + */ +@NotThreadSafe +@InternalExtensionOnly +public interface Transaction extends DatastoreBatchWriter, DatastoreReaderWriter { + + interface Response { + + /** Returns a list of keys generated by a transaction. */ + List getGeneratedKeys(); + } + + /** + * {@inheritDoc} The requested entity will be part of this Datastore transaction (so a commit is + * guaranteed to fail if entity was changed by others after it was seen by this transaction) but + * any write changes in this transaction will not be reflected by the returned entity. + * + *

Example of getting an entity for a given key. + * + *

{@code
+   * String keyName = "my_key_name";
+   * Key key = datastore.newKeyFactory().setKind("MyKind").newKey(keyName);
+   * Entity entity = transaction.get(key);
+   * transaction.commit();
+   * // Do something with the entity
+   * }
+ * + * @throws DatastoreException upon failure or if no longer active + */ + @Override + Entity get(Key key); + + /** + * {@inheritDoc} The requested entities will be part of this Datastore transaction (so a commit is + * guaranteed to fail if any of the entities was changed by others after they were seen by this + * transaction) but any write changes in this transaction will not be reflected by the returned + * entities. + * + *

Example of getting entities for several keys. + * + *

{@code
+   * String firstKeyName = "my_first_key_name";
+   * String secondKeyName = "my_second_key_name";
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
+   * Key firstKey = keyFactory.newKey(firstKeyName);
+   * Key secondKey = keyFactory.newKey(secondKeyName);
+   * Iterator entitiesIterator = transaction.get(firstKey, secondKey);
+   * List entities = Lists.newArrayList();
+   * while (entitiesIterator.hasNext()) {
+   *   Entity entity = entitiesIterator.next();
+   *   // do something with the entity
+   *   entities.add(entity);
+   * }
+   * transaction.commit();
+   * }
+ * + * @throws DatastoreException upon failure or if no longer active + */ + @Override + Iterator get(Key... key); + + /** + * {@inheritDoc} The requested entities will be part of this Datastore transaction (so a commit is + * guaranteed to fail if any of the entities was changed by others after they were seen by this + * transaction) but any write changes in this transaction will not be reflected by the returned + * entities. + * + *

Example of fetching a list of entities for several keys. + * + *

{@code
+   * String firstKeyName = "my_first_key_name";
+   * String secondKeyName = "my_second_key_name";
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
+   * Key firstKey = keyFactory.newKey(firstKeyName);
+   * Key secondKey = keyFactory.newKey(secondKeyName);
+   * List entities = transaction.fetch(firstKey, secondKey);
+   * for (Entity entity : entities) {
+   *   // do something with the entity
+   * }
+   * transaction.commit();
+   * }
+ * + * @throws DatastoreException upon failure or if no longer active + */ + @Override + List fetch(Key... keys); + + /** + * {@inheritDoc} The entities returned by the result of this query will be part of this Datastore + * transaction (so a commit is guaranteed to fail if any of the entities was changed by others + * after the query was performed) but any write changes in this transaction will not be reflected + * by the result. + * + *

Example of running a query to find all entities with an ancestor. + * + *

{@code
+   * String parentKeyName = "my_parent_key_name";
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("ParentKind");
+   * Key parentKey = keyFactory.newKey(parentKeyName);
+   * // Build a query
+   * Query query = Query.newEntityQueryBuilder()
+   *     .setKind("MyKind")
+   *     .setFilter(PropertyFilter.hasAncestor(parentKey))
+   *     .build();
+   * QueryResults results = transaction.run(query);
+   * List entities = Lists.newArrayList();
+   * while (results.hasNext()) {
+   *   Entity result = results.next();
+   *   // do something with result
+   *   entities.add(result);
+   * }
+   * transaction.commit();
+   * }
+ * + * @throws DatastoreException upon failure or if no longer active + */ + @Override + QueryResults run(Query query); + + @BetaApi + QueryResults run(Query query, ExplainOptions explainOptions); + + /** + * Datastore add operation. This method will also allocate id for any entity with an incomplete + * key. As opposed to {@link #add(FullEntity)} and {@link #add(FullEntity...)}, this method will + * defer any necessary id allocation to commit time. + * + *

Example of adding multiple entities with deferred id allocation. + * + *

{@code
+   * IncompleteKey key1 = datastore.newKeyFactory().setKind("MyKind").newKey();
+   * FullEntity.Builder entityBuilder1 = FullEntity.newBuilder(key1);
+   * entityBuilder1.set("propertyName", "value1");
+   * FullEntity entity1 = entityBuilder1.build();
+   *
+   * IncompleteKey key2 = datastore.newKeyFactory().setKind("MyKind").newKey();
+   * FullEntity.Builder entityBuilder2 = FullEntity.newBuilder(key2);
+   * entityBuilder2.set("propertyName", "value2");
+   * FullEntity entity2 = entityBuilder2.build();
+   *
+   * transaction.addWithDeferredIdAllocation(entity1, entity2);
+   * Response response = transaction.commit();
+   * }
+ * + * @throws DatastoreException if a given entity with a complete key was already added to this + * transaction or if the transaction is no longer active + */ + void addWithDeferredIdAllocation(FullEntity... entities); + + /** + * {@inheritDoc} + * + *

Example of adding a single entity. + * + *

{@code
+   * String keyName = "my_key_name";
+   * Key key = datastore.newKeyFactory().setKind("MyKind").newKey(keyName);
+   * Entity.Builder entityBuilder = Entity.newBuilder(key);
+   * entityBuilder.set("propertyName", "value");
+   * Entity entity = entityBuilder.build();
+   * transaction.add(entity);
+   * transaction.commit();
+   * }
+ * + * @throws DatastoreException if a given entity with the same complete key was already added to + * this writer, if the transaction is no longer active or if id allocation for an entity with + * an incomplete key failed + */ + @Override + Entity add(FullEntity entity); + + /** + * {@inheritDoc} + * + *

Example of adding multiple entities. + * + *

{@code
+   * String keyName1 = "my_key_name1";
+   * String keyName2 = "my_key_name2";
+   * Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
+   * Entity.Builder entityBuilder1 = Entity.newBuilder(key1);
+   * entityBuilder1.set("propertyName", "value1");
+   * Entity entity1 = entityBuilder1.build();
+   *
+   * Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
+   * Entity.Builder entityBuilder2 = Entity.newBuilder(key2);
+   * entityBuilder2.set("propertyName", "value2");
+   * Entity entity2 = entityBuilder2.build();
+   *
+   * transaction.add(entity1, entity2);
+   * transaction.commit();
+   * }
+ * + * @throws DatastoreException if a given entity with the same complete key was already added to + * this writer, if the transaction is no longer active or if id allocation for an entity with + * an incomplete key failed + */ + @Override + List add(FullEntity... entities); + + /** + * {@inheritDoc} This operation will be converted to {@link #put} operation for entities that were + * already added or put in this writer. + * + *

Example of updating multiple entities. + * + *

{@code
+   * String keyName1 = "my_key_name1";
+   * String keyName2 = "my_key_name2";
+   * Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
+   * Entity.Builder entityBuilder1 = Entity.newBuilder(key1);
+   * entityBuilder1.set("propertyName", "value3");
+   * Entity entity1 = entityBuilder1.build();
+   *
+   * Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
+   * Entity.Builder entityBuilder2 = Entity.newBuilder(key2);
+   * entityBuilder2.set("propertyName", "value4");
+   * Entity entity2 = entityBuilder2.build();
+   *
+   * transaction.update(entity1, entity2);
+   * transaction.commit();
+   * }
+ * + * @throws DatastoreException if an entity is marked for deletion in this transaction or if the + * transaction is no longer active + */ + @Override + void update(Entity... entities); + + /** + * {@inheritDoc} This operation will also remove from this transaction any prior writes for + * entities with the same keys. + * + *

Example of deleting multiple entities. + * + *

{@code
+   * String keyName1 = "my_key_name1";
+   * String keyName2 = "my_key_name2";
+   * Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
+   * Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
+   * transaction.delete(key1, key2);
+   * transaction.commit();
+   * }
+ * + * @throws DatastoreException upon failure or if no longer active + */ + @Override + void delete(Key... keys); + + /** + * Datastore put operation. This method will also allocate id for any entity with an incomplete + * key. As opposed to {@link #put(FullEntity)} and {@link #put(FullEntity...)}, this method will + * defer any necessary id allocation to commit time. + * + *

Example of putting multiple entities with deferred id allocation. + * + *

{@code
+   * IncompleteKey key1 = datastore.newKeyFactory().setKind("MyKind").newKey();
+   * FullEntity.Builder entityBuilder1 = FullEntity.newBuilder(key1);
+   * entityBuilder1.set("propertyName", "value1");
+   * FullEntity entity1 = entityBuilder1.build();
+   *
+   * IncompleteKey key2 = datastore.newKeyFactory().setKind("MyKind").newKey();
+   * FullEntity.Builder entityBuilder2 = FullEntity.newBuilder(key2);
+   * entityBuilder2.set("propertyName", "value2");
+   * FullEntity entity2 = entityBuilder2.build();
+   *
+   * transaction.putWithDeferredIdAllocation(entity1, entity2);
+   * Response response = transaction.commit();
+   * }
+ * + * @throws IllegalArgumentException if any of the given entities is missing a key + * @throws DatastoreException if no longer active + */ + void putWithDeferredIdAllocation(FullEntity... entities); + + /** + * {@inheritDoc} This operation will also remove from this transaction any prior writes for the + * same entity. + * + *

Example of putting a single entity. + * + *

{@code
+   * String keyName = "my_key_name";
+   * Key key = datastore.newKeyFactory().setKind("MyKind").newKey(keyName);
+   * Entity.Builder entityBuilder = Entity.newBuilder(key);
+   * entityBuilder.set("propertyName", "value");
+   * Entity entity = entityBuilder.build();
+   * transaction.put(entity);
+   * transaction.commit();
+   * }
+ * + * @throws DatastoreException if id allocation for an entity with an incomplete key failed or if + * the transaction is no longer active + */ + @Override + Entity put(FullEntity entity); + + /** + * {@inheritDoc} This operation will also remove from this transaction any prior writes for the + * same entities. + * + *

Example of putting multiple entities. + * + *

{@code
+   * String keyName1 = "my_key_name1";
+   * String keyName2 = "my_key_name2";
+   * Key key1 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName1);
+   * Entity.Builder entityBuilder1 = Entity.newBuilder(key1);
+   * entityBuilder1.set("propertyName", "value1");
+   * Entity entity1 = entityBuilder1.build();
+   *
+   * Key key2 = datastore.newKeyFactory().setKind("MyKind").newKey(keyName2);
+   * Entity.Builder entityBuilder2 = Entity.newBuilder(key2);
+   * entityBuilder2.set("propertyName", "value2");
+   * Entity entity2 = entityBuilder2.build();
+   *
+   * transaction.put(entity1, entity2);
+   * transaction.commit();
+   * }
+ * + * @throws DatastoreException if id allocation for an entity with an incomplete key failed or if + * the transaction is no longer active + */ + @Override + List put(FullEntity... entities); + + /** + * Commit the transaction. + * + *

Example of committing a transaction. + * + *

{@code
+   * // create an entity
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
+   * Key key = datastore.allocateId(keyFactory.newKey());
+   * Entity entity = Entity.newBuilder(key).set("description", "commit()").build();
+   *
+   * // add the entity and commit
+   * try {
+   *   transaction.put(entity);
+   *   transaction.commit();
+   * } catch (DatastoreException ex) {
+   *   // handle exception
+   * }
+   * }
+ * + * @throws DatastoreException if could not commit the transaction or if no longer active + */ + Response commit(); + + /** + * Rollback the transaction. + * + *

Example of rolling back a transaction. + * + *

{@code
+   * // create an entity
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
+   * Key key = datastore.allocateId(keyFactory.newKey());
+   * Entity entity = Entity.newBuilder(key).set("description", "rollback()").build();
+   *
+   * // add the entity and rollback
+   * transaction.put(entity);
+   * transaction.rollback();
+   * // calling transaction.commit() now would fail
+   * }
+ * + * @throws DatastoreException if transaction was already committed + */ + void rollback(); + + /** + * Returns {@code true} if the transaction is still active (was not committed or rolledback). + * + *

Example of verifying if a transaction is active. + * + *

{@code
+   * // create an entity
+   * KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind");
+   * Key key = datastore.allocateId(keyFactory.newKey());
+   * Entity entity = Entity.newBuilder(key).set("description", "active()").build();
+   * // calling transaction.active() now would return true
+   * try {
+   *   // add the entity and commit
+   *   transaction.put(entity);
+   *   transaction.commit();
+   * } finally {
+   *   // if committing succeeded
+   *   // then transaction.active() will be false
+   *   if (transaction.isActive()) {
+   *     // otherwise it's true and we need to rollback
+   *     transaction.rollback();
+   *   }
+   * }
+   * }
+ */ + @Override + boolean isActive(); + + /** Returns the transaction associated {@link Datastore}. */ + Datastore getDatastore(); + + ByteString getTransactionId(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionExceptionHandler.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionExceptionHandler.java new file mode 100644 index 000000000000..a291dfd4f48c --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionExceptionHandler.java @@ -0,0 +1,67 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.api.core.BetaApi; +import com.google.cloud.ExceptionHandler; +import com.google.cloud.ExceptionHandler.Interceptor; + +@BetaApi +public class TransactionExceptionHandler { + public static final Interceptor TRANSACTION_EXCEPTION_HANDLER_INTERCEPTOR = + new Interceptor() { + + private static final long serialVersionUID = -1240723093072535978L; + + private static final int ABORTED_CODE = 10; + + @Override + public RetryResult beforeEval(Exception exception) { + if (exception instanceof DatastoreException) { + DatastoreException e = getInnerException((DatastoreException) exception); + if (e.getCode() == ABORTED_CODE + || e.getReason() != null && e.getReason().equals("ABORTED")) { + return Interceptor.RetryResult.RETRY; + } + } + return Interceptor.RetryResult.CONTINUE_EVALUATION; + } + + @Override + public RetryResult afterEval(Exception exception, RetryResult retryResult) { + return Interceptor.RetryResult.CONTINUE_EVALUATION; + } + + private DatastoreException getInnerException(DatastoreException exception) { + while (exception.getCause() instanceof DatastoreException) { + exception = (DatastoreException) exception.getCause(); + } + return exception; + } + }; + + public static ExceptionHandler build() { + return ExceptionHandler.newBuilder() + .abortOn(RuntimeException.class) + .addInterceptors( + DatastoreImpl.EXCEPTION_HANDLER_INTERCEPTOR, TRANSACTION_EXCEPTION_HANDLER_INTERCEPTOR) + .build(); + } + + /** Intentionally private empty constructor to disable instantiation of this class. */ + private TransactionExceptionHandler() {} +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionImpl.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionImpl.java new file mode 100644 index 000000000000..a5bd1f419281 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionImpl.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 + * + * 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.datastore; + +import static com.google.cloud.datastore.ReadOption.transactionId; + +import com.google.api.core.BetaApi; +import com.google.cloud.datastore.models.ExplainOptions; +import com.google.cloud.datastore.telemetry.TraceUtil; +import com.google.common.collect.ImmutableList; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.TransactionOptions; +import com.google.protobuf.ByteString; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Optional; +import javax.annotation.Nonnull; + +final class TransactionImpl extends BaseDatastoreBatchWriter implements Transaction { + + private final DatastoreImpl datastore; + private final ByteString transactionId; + private boolean rolledback; + + private final ReadOptionProtoPreparer readOptionProtoPreparer; + + @Nonnull private final TraceUtil traceUtil; + + static class ResponseImpl implements Transaction.Response { + + private final com.google.datastore.v1.CommitResponse response; + private final int numAutoAllocatedIds; + + ResponseImpl(com.google.datastore.v1.CommitResponse response, int numAutoAllocatedIds) { + this.response = response; + this.numAutoAllocatedIds = numAutoAllocatedIds; + } + + @Override + public List getGeneratedKeys() { + Iterator results = + response.getMutationResultsList().iterator(); + List generated = new ArrayList<>(numAutoAllocatedIds); + for (int i = 0; i < numAutoAllocatedIds; i++) { + generated.add(Key.fromPb(results.next().getKey())); + } + return generated; + } + } + + TransactionImpl(DatastoreImpl datastore) { + this(datastore, null); + } + + TransactionImpl(DatastoreImpl datastore, TransactionOptions options) { + super("transaction"); + this.datastore = datastore; + com.google.datastore.v1.BeginTransactionRequest.Builder requestPb = + com.google.datastore.v1.BeginTransactionRequest.newBuilder(); + + requestPb.setProjectId(this.datastore.getOptions().getProjectId()); + requestPb.setDatabaseId(this.datastore.getOptions().getDatabaseId()); + + if (options != null) { + requestPb.setTransactionOptions(options); + } + + transactionId = datastore.requestTransactionId(requestPb); + this.readOptionProtoPreparer = new ReadOptionProtoPreparer(); + this.traceUtil = datastore.getOptions().getTraceUtil(); + } + + @Override + public Entity get(Key key) { + return DatastoreHelper.get(this, key); + } + + @Override + public Iterator get(Key... keys) { + validateActive(); + Optional readOptions = + this.readOptionProtoPreparer.prepare(ImmutableList.of(transactionId(transactionId))); + return datastore.get(readOptions, keys); + } + + @Override + public List fetch(Key... keys) { + validateActive(); + return DatastoreHelper.fetch(this, keys); + } + + @Override + public QueryResults run(Query query) { + validateActive(); + Optional readOptions = + this.readOptionProtoPreparer.prepare(ImmutableList.of(transactionId(transactionId))); + return datastore.run(readOptions, query, null); + } + + @Override + @BetaApi + public QueryResults run(Query query, ExplainOptions explainOptions) { + validateActive(); + Optional readOptions = + this.readOptionProtoPreparer.prepare(ImmutableList.of(transactionId(transactionId))); + return datastore.run(readOptions, query, explainOptions.toPb()); + } + + @Override + public AggregationResults runAggregation(AggregationQuery query) { + return datastore.runAggregation(query, transactionId(transactionId)); + } + + @Override + @BetaApi + public AggregationResults runAggregation(AggregationQuery query, ExplainOptions explainOptions) { + return datastore.runAggregation(query, explainOptions, transactionId(transactionId)); + } + + @Override + public Transaction.Response commit() { + validateActive(); + List mutationsPb = toMutationPbList(); + com.google.datastore.v1.CommitRequest.Builder requestPb = + com.google.datastore.v1.CommitRequest.newBuilder(); + requestPb.setMode(com.google.datastore.v1.CommitRequest.Mode.TRANSACTIONAL); + requestPb.setTransaction(transactionId); + requestPb.addAllMutations(mutationsPb); + requestPb.setProjectId(datastore.getOptions().getProjectId()); + requestPb.setDatabaseId(datastore.getOptions().getDatabaseId()); + com.google.datastore.v1.CommitResponse responsePb = datastore.commit(requestPb.build()); + deactivate(); + return new ResponseImpl(responsePb, toAddAutoId().size()); + } + + @Override + public void rollback() { + if (rolledback) { + return; + } + validateActive(); + datastore.rollbackTransaction(transactionId); + deactivate(); + rolledback = true; + } + + @Override + public Datastore getDatastore() { + return datastore; + } + + @Override + public ByteString getTransactionId() { + return transactionId; + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionOperationExceptionHandler.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionOperationExceptionHandler.java new file mode 100644 index 000000000000..0d73738e79a4 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/TransactionOperationExceptionHandler.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 + * + * 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.datastore; + +import com.google.api.core.BetaApi; +import com.google.cloud.BaseService; +import com.google.cloud.ExceptionHandler; +import com.google.cloud.ExceptionHandler.Interceptor; + +@BetaApi +public class TransactionOperationExceptionHandler { + + public static final Interceptor TRANSACTION_OPERATION_EXCEPTION_HANDLER_INTERCEPTOR = + new Interceptor() { + + private static final long serialVersionUID = -1240723093072535978L; + + private static final int ABORTED_CODE = 10; + + @Override + public RetryResult beforeEval(Exception exception) { + if (exception instanceof DatastoreException) { + DatastoreException e = getInnerException((DatastoreException) exception); + if (e.getCode() == ABORTED_CODE + || e.getReason() != null && e.getReason().equals("ABORTED")) { + return RetryResult.NO_RETRY; + } + } + return BaseService.EXCEPTION_HANDLER_INTERCEPTOR.beforeEval(exception); + } + + @Override + public RetryResult afterEval(Exception exception, RetryResult retryResult) { + return BaseService.EXCEPTION_HANDLER_INTERCEPTOR.afterEval(exception, retryResult); + } + + private DatastoreException getInnerException(DatastoreException exception) { + while (exception.getCause() instanceof DatastoreException) { + exception = (DatastoreException) exception.getCause(); + } + return exception; + } + }; + + public static ExceptionHandler build() { + return ExceptionHandler.newBuilder() + .abortOn(RuntimeException.class) + .addInterceptors(TRANSACTION_OPERATION_EXCEPTION_HANDLER_INTERCEPTOR) + .build(); + } + + /** Intentionally private empty constructor to disable instantiation of this class. */ + private TransactionOperationExceptionHandler() {} +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Validator.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Validator.java new file mode 100644 index 000000000000..881fb09e752a --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Validator.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 + * + * 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.datastore; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.common.base.Strings; +import java.util.regex.Pattern; + +/** Utility to validate Datastore type/values. */ +final class Validator { + + private static final Pattern PROJECT_ID_PATTERN = + Pattern.compile( + "([a-z\\d\\-]{1,100}~)?([a-z\\d][a-z\\d\\-\\.]{0,99}:)?([a-z\\d][a-z\\d\\-]{0,99})"); + private static final int MAX_NAMESPACE_LENGTH = 100; + private static final Pattern NAMESPACE_PATTERN = + Pattern.compile("[0-9A-Za-z\\._\\-]{0," + MAX_NAMESPACE_LENGTH + "}"); + + private Validator() { + // utility class + } + + static String validateProjectId(String projectId) { + checkArgument(!Strings.isNullOrEmpty(projectId), "projectId can't be empty or null"); + checkArgument( + PROJECT_ID_PATTERN.matcher(projectId).matches(), + "projectId " + + projectId + + " does not match the required pattern: " + + PROJECT_ID_PATTERN.pattern()); + return projectId; + } + + static String validateNamespace(String namespace) { + checkArgument(namespace != null, "Namespace cannot be null. Leave unset for default."); + checkArgument( + namespace.length() <= MAX_NAMESPACE_LENGTH, + "namespace must not contain more than 100 characters"); + checkArgument( + NAMESPACE_PATTERN.matcher(namespace).matches(), + "namespace must the following pattern: " + NAMESPACE_PATTERN.pattern()); + return namespace; + } + + static String validateKind(String kind) { + checkArgument(!Strings.isNullOrEmpty(kind), "kind must not be empty or null"); + return kind; + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Value.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Value.java new file mode 100644 index 000000000000..40cb52d5947e --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/Value.java @@ -0,0 +1,221 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.common.base.Preconditions.checkNotNull; + +import com.google.cloud.GcpLaunchStage; +import com.google.common.base.MoreObjects; +import com.google.datastore.v1.Value.ValueTypeCase; +import java.io.Serializable; +import java.util.Objects; + +/** + * Base class for all Google Cloud Datastore value types. All values must be associated with a + * non-null content (except {@link NullValue}). All values are immutable (including their content). + * To edit (a copy) use {@link #toBuilder()}. Unsupported value (deprecated or unrecognized) would + * be represented by {@link RawValue}. + * + * @param the type of the content for this value + */ +public abstract class Value implements Serializable { + + private static final long serialVersionUID = 8532411152601335280L; + + private final ValueType valueType; + private final boolean excludeFromIndexes; + private final int meaning; + private final V value; + + interface BuilderFactory, B extends ValueBuilder> + extends java.io.Serializable { + B newBuilder(V value); + } + + abstract static class BaseMarshaller, B extends ValueBuilder> + implements ValueMarshaller, BuilderFactory { + + private static final long serialVersionUID = -5224067974180563797L; + + @SuppressWarnings("deprecation") + @Override + public final B fromProto(com.google.datastore.v1.Value proto) { + B builder = newBuilder(getValue(proto)); + builder.setExcludeFromIndexes(proto.getExcludeFromIndexes()); + builder.setMeaning(proto.getMeaning()); + return builder; + } + + @SuppressWarnings("deprecation") + @Override + public final com.google.datastore.v1.Value toProto(P value) { + com.google.datastore.v1.Value.Builder builder = com.google.datastore.v1.Value.newBuilder(); + builder.setExcludeFromIndexes(value.excludeFromIndexes()); + builder.setMeaning(value.getMeaning()); + setValue(value, builder); + return builder.build(); + } + + BaseMarshaller() {} + + protected abstract V getValue(com.google.datastore.v1.Value from); + + protected abstract void setValue(P from, com.google.datastore.v1.Value.Builder to); + } + + abstract static class BaseBuilder, B extends BaseBuilder> + implements ValueBuilder { + + private final ValueType valueType; + private boolean excludeFromIndexes; + private int meaning; + private V value; + + BaseBuilder(ValueType valueType) { + this.valueType = valueType; + } + + @Override + public ValueType getValueType() { + return valueType; + } + + @Override + public B mergeFrom(P other) { + excludeFromIndexes = other.excludeFromIndexes(); + meaning = other.getMeaning(); + set(other.get()); + return self(); + } + + @Override + public boolean getExcludeFromIndexes() { + return excludeFromIndexes; + } + + @Override + public B setExcludeFromIndexes(boolean excludeFromIndexes) { + this.excludeFromIndexes = excludeFromIndexes; + return self(); + } + + @GcpLaunchStage.Deprecated + @Override + public int getMeaning() { + return meaning; + } + + @GcpLaunchStage.Deprecated + @Override + public B setMeaning(int meaning) { + this.meaning = meaning; + return self(); + } + + @Override + public V get() { + return value; + } + + @Override + public B set(V value) { + this.value = checkNotNull(value); + return self(); + } + + @SuppressWarnings("unchecked") + private B self() { + return (B) this; + } + + @Override + public abstract P build(); + } + + @SuppressWarnings("deprecation") +

, B extends BaseBuilder> Value(ValueBuilder builder) { + valueType = builder.getValueType(); + excludeFromIndexes = builder.getExcludeFromIndexes(); + meaning = builder.getMeaning(); + value = builder.get(); + } + + /** Returns the type of this value. */ + public final ValueType getType() { + return valueType; + } + + /** Returns whether this value should be excluded from indexes. */ + public final boolean excludeFromIndexes() { + return excludeFromIndexes; + } + + @GcpLaunchStage.Deprecated + final int getMeaning() { + return meaning; + } + + public final V get() { + return value; + } + + public abstract ValueBuilder toBuilder(); + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("valueType", valueType) + .add("excludeFromIndexes", excludeFromIndexes) + .add("meaning", meaning) + .add("value", value) + .toString(); + } + + @Override + public int hashCode() { + return Objects.hash(valueType, excludeFromIndexes, meaning, value); + } + + @Override + @SuppressWarnings("unchecked") + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!getClass().isInstance(obj)) { + return false; + } + Value other = (Value) obj; + return Objects.equals(valueType, other.valueType) + && Objects.equals(excludeFromIndexes, other.excludeFromIndexes) + && Objects.equals(meaning, other.meaning) + && Objects.equals(value, other.value); + } + + @SuppressWarnings("unchecked") + com.google.datastore.v1.Value toPb() { + return getType().getMarshaller().toProto(this); + } + + public static Value fromPb(com.google.datastore.v1.Value proto) { + ValueTypeCase descriptorId = proto.getValueTypeCase(); + ValueType valueType = ValueType.getByDescriptorId(descriptorId.getNumber()); + return valueType == null + ? RawValue.MARSHALLER.fromProto(proto).build() + : valueType.getMarshaller().fromProto(proto).build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ValueBuilder.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ValueBuilder.java new file mode 100644 index 000000000000..2c5f0cabcb93 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ValueBuilder.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 + * + * 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.datastore; + +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.GcpLaunchStage; + +/** + * A common interface for Value builders. + * + * @param the data type that the {@code Value} object holds. + * @param

the value type. + * @param the value type's associated builder. + */ +@InternalExtensionOnly +public interface ValueBuilder, B extends ValueBuilder> { + + ValueType getValueType(); + + B mergeFrom(P other); + + boolean getExcludeFromIndexes(); + + B setExcludeFromIndexes(boolean excludeFromIndexes); + + /** Deprecated. This library preserves the field for backwards compatibility. */ + @GcpLaunchStage.Deprecated + int getMeaning(); + + /** Deprecated. This library preserves the field for backwards compatibility. */ + @GcpLaunchStage.Deprecated + B setMeaning(int meaning); + + V get(); + + B set(V value); + + P build(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ValueMarshaller.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ValueMarshaller.java new file mode 100644 index 000000000000..ecfab4bf127e --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ValueMarshaller.java @@ -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. + */ + +package com.google.cloud.datastore; + +import java.io.Serializable; + +/** A common interface for Value marshallers. */ +interface ValueMarshaller, B extends ValueBuilder> + extends Serializable { + + B fromProto(com.google.datastore.v1.Value proto); + + com.google.datastore.v1.Value toProto(P value); + + int getProtoFieldId(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ValueType.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ValueType.java new file mode 100644 index 000000000000..66ce37d1c218 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/ValueType.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 + * + * 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.datastore; + +import com.google.common.collect.ImmutableMap; + +/** + * The type of a Datastore property. + * + * @see Google + * Cloud Datastore types + */ +public enum ValueType { + + /** Represents a {@code null} value. */ + NULL(NullValue.MARSHALLER), + + /** Represents a {@code string} value. */ + STRING(StringValue.MARSHALLER), + + /** Represents an entity value. */ + ENTITY(EntityValue.MARSHALLER), + + /** Represents a {@code list} of {@link Value}s. */ + LIST(ListValue.MARSHALLER), + + /** Represents a {@code key} as a value. */ + KEY(KeyValue.MARSHALLER), + + /** Represents a {@code long} value. */ + LONG(LongValue.MARSHALLER), + + /** Represents a {@code double} value. */ + DOUBLE(DoubleValue.MARSHALLER), + + /** Represents a {@code boolean} value. */ + BOOLEAN(BooleanValue.MARSHALLER), + + /** Represents a {@link com.google.cloud.Timestamp} value. */ + TIMESTAMP(TimestampValue.MARSHALLER), + + /** Represents a {@link Blob} value. */ + BLOB(BlobValue.MARSHALLER), + + /** Represents a raw/unparsed value. */ + RAW_VALUE(RawValue.MARSHALLER), + + /** Represents a {@link LatLng} value. */ + LAT_LNG(LatLngValue.MARSHALLER); + + private static final ImmutableMap DESCRIPTOR_TO_TYPE_MAP; + + @SuppressWarnings("rawtypes") + private final ValueMarshaller marshaller; + + static { + ImmutableMap.Builder builder = ImmutableMap.builder(); + for (ValueType valueType : ValueType.values()) { + int fieldId = valueType.getMarshaller().getProtoFieldId(); + if (fieldId > 0) { + builder.put(fieldId, valueType); + } + } + DESCRIPTOR_TO_TYPE_MAP = builder.buildOrThrow(); + } + + , B extends ValueBuilder> ValueType( + ValueMarshaller marshaller) { + this.marshaller = marshaller; + } + + ValueMarshaller getMarshaller() { + return marshaller; + } + + static ValueType getByDescriptorId(int descriptorId) { + return DESCRIPTOR_TO_TYPE_MAP.get(descriptorId); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClient.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClient.java new file mode 100644 index 000000000000..a0530e22fa49 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClient.java @@ -0,0 +1,1184 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.admin.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.datastore.admin.v1.stub.DatastoreAdminStub; +import com.google.cloud.datastore.admin.v1.stub.DatastoreAdminStubSettings; +import com.google.common.util.concurrent.MoreExecutors; +import com.google.datastore.admin.v1.CreateIndexRequest; +import com.google.datastore.admin.v1.DeleteIndexRequest; +import com.google.datastore.admin.v1.EntityFilter; +import com.google.datastore.admin.v1.ExportEntitiesMetadata; +import com.google.datastore.admin.v1.ExportEntitiesRequest; +import com.google.datastore.admin.v1.ExportEntitiesResponse; +import com.google.datastore.admin.v1.GetIndexRequest; +import com.google.datastore.admin.v1.ImportEntitiesMetadata; +import com.google.datastore.admin.v1.ImportEntitiesRequest; +import com.google.datastore.admin.v1.Index; +import com.google.datastore.admin.v1.IndexOperationMetadata; +import com.google.datastore.admin.v1.ListIndexesRequest; +import com.google.datastore.admin.v1.ListIndexesResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: Google Cloud Datastore Admin API + * + *

The Datastore Admin API provides several admin services for Cloud Datastore. + * + *

Concepts: Project, namespace, kind, and entity as defined in the Google Cloud Datastore API. + * + *

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

EntityFilter: Allows specifying a subset of entities in a project. This is specified as a + * combination of kinds and namespaces (either or both of which may be all). + * + *

Export/Import Service: + * + *

- The Export/Import service provides the ability to copy all or a subset of entities to/from + * Google Cloud Storage. - Exported data may be imported into Cloud Datastore for any Google Cloud + * Platform project. It is not restricted to the export source project. It is possible to export + * from one project and then import into another. - Exported data can also be loaded into Google + * BigQuery for analysis. - Exports and imports are performed asynchronously. An Operation resource + * is created for each export/import. The state (including any errors encountered) of the + * export/import may be queried via the Operation resource. + * + *

Index Service: + * + *

- The index service manages Cloud Datastore composite indexes. - Index creation and deletion + * are 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. + * + *

Operation Service: + * + *

- 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 not yet done may be cancelled. The request + * to cancel is asynchronous and the operation may continue to run for some time after the request + * to cancel is made. - An operation that is done may be deleted so that it is no longer listed as + * part of the Operation collection. - ListOperations returns all pending operations, but not + * completed operations. - Operations are created by service DatastoreAdmin, 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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+ *   GetIndexRequest request =
+ *       GetIndexRequest.newBuilder()
+ *           .setProjectId("projectId-894832108")
+ *           .setIndexId("indexId1943291277")
+ *           .build();
+ *   Index response = datastoreAdminClient.getIndex(request);
+ * }
+ * }
+ * + *

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

ExportEntities

Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage system, such as Google Cloud Storage. Recent updates to entities 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.

+ *

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

+ *
    + *
  • exportEntitiesAsync(ExportEntitiesRequest request) + *

+ *

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

+ *
    + *
  • exportEntitiesAsync(String projectId, Map<String, String> labels, EntityFilter entityFilter, String outputUrlPrefix) + *

+ *

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

+ *
    + *
  • exportEntitiesOperationCallable() + *

  • exportEntitiesCallable() + *

+ *

ImportEntities

Imports entities into Google Cloud Datastore. Existing entities with the same key 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 ImportEntities operation is cancelled, it is possible that a subset of the data has already been imported to Cloud Datastore.

+ *

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

+ *
    + *
  • importEntitiesAsync(ImportEntitiesRequest request) + *

+ *

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

+ *
    + *
  • importEntitiesAsync(String projectId, Map<String, String> labels, String inputUrl, EntityFilter entityFilter) + *

+ *

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

+ *
    + *
  • importEntitiesOperationCallable() + *

  • importEntitiesCallable() + *

+ *

CreateIndex

Creates the specified index. A newly created index's initial state is `CREATING`. On completion of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status. + *

During index creation, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then re-creating the index with [create] [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. + *

Indexes with a single property cannot be created.

+ *

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

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

+ *

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

+ *

DeleteIndex

Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state. On successful execution of the request, the index will be in a `DELETING` [state][google.datastore.admin.v1.Index.State]. And on completion of the returned [google.longrunning.Operation][google.longrunning.Operation], the index will be removed. + *

During index deletion, the process could result in an error, in which case the index will move to the `ERROR` state. The process can be recovered by fixing the data that caused the error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.

+ *

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

+ *
    + *
  • deleteIndexAsync(DeleteIndexRequest request) + *

+ *

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

+ *
    + *
  • deleteIndexOperationCallable() + *

  • deleteIndexCallable() + *

+ *

GetIndex

Gets an index.

+ *

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

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

+ *

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

+ *
    + *
  • getIndexCallable() + *

+ *

ListIndexes

Lists the indexes that match the specified filters. Datastore uses an eventually consistent query to fetch the list of indexes and may occasionally return stale results.

+ *

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

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

+ *

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

+ *
+ * + *

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 DatastoreAdminSettings 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
+ * DatastoreAdminSettings datastoreAdminSettings =
+ *     DatastoreAdminSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create(datastoreAdminSettings);
+ * }
+ * + *

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
+ * DatastoreAdminSettings datastoreAdminSettings =
+ *     DatastoreAdminSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create(datastoreAdminSettings);
+ * }
+ * + *

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
+ * DatastoreAdminSettings datastoreAdminSettings =
+ *     DatastoreAdminSettings.newHttpJsonBuilder().build();
+ * DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create(datastoreAdminSettings);
+ * }
+ * + *

Please refer to the GitHub repository's samples for more quickstart code snippets. + */ +@Generated("by gapic-generator-java") +public class DatastoreAdminClient implements BackgroundResource { + private final DatastoreAdminSettings settings; + private final DatastoreAdminStub stub; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; + + /** Constructs an instance of DatastoreAdminClient with default settings. */ + public static final DatastoreAdminClient create() throws IOException { + return create(DatastoreAdminSettings.newBuilder().build()); + } + + /** + * Constructs an instance of DatastoreAdminClient, 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 DatastoreAdminClient create(DatastoreAdminSettings settings) + throws IOException { + return new DatastoreAdminClient(settings); + } + + /** + * Constructs an instance of DatastoreAdminClient, using the given stub for making calls. This is + * for advanced usage - prefer using create(DatastoreAdminSettings). + */ + public static final DatastoreAdminClient create(DatastoreAdminStub stub) { + return new DatastoreAdminClient(stub); + } + + /** + * Constructs an instance of DatastoreAdminClient, 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 DatastoreAdminClient(DatastoreAdminSettings settings) throws IOException { + this.settings = settings; + this.stub = ((DatastoreAdminStubSettings) settings.getStubSettings()).createStub(); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); + } + + protected DatastoreAdminClient(DatastoreAdminStub 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 DatastoreAdminSettings getSettings() { + return settings; + } + + public DatastoreAdminStub 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. + /** + * Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage + * system, such as Google Cloud Storage. Recent updates to entities 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. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   String projectId = "projectId-894832108";
+   *   Map labels = new HashMap<>();
+   *   EntityFilter entityFilter = EntityFilter.newBuilder().build();
+   *   String outputUrlPrefix = "outputUrlPrefix-1132598048";
+   *   ExportEntitiesResponse response =
+   *       datastoreAdminClient
+   *           .exportEntitiesAsync(projectId, labels, entityFilter, outputUrlPrefix)
+   *           .get();
+   * }
+   * }
+ * + * @param projectId Required. Project ID against which to make the request. + * @param labels Client-assigned labels. + * @param entityFilter Description of what data from the project is included in the export. + * @param outputUrlPrefix Required. Location for the export metadata and data files. + *

The full resource URL of the external storage location. Currently, only Google Cloud + * Storage is supported. So output_url_prefix should be of the form: + * `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the name of the Cloud Storage + * bucket and `NAMESPACE_PATH` is an optional Cloud Storage namespace path (this is not a + * Cloud Datastore namespace). For more information about Cloud Storage namespace paths, see + * [Object name + * considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + *

The resulting files will be nested deeper than the specified URL prefix. The final + * output URL will be provided in the + * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] + * field. That value should be used for subsequent ImportEntities operations. + *

By nesting the data files deeper, the same Cloud Storage bucket can be used in multiple + * ExportEntities operations without conflict. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture exportEntitiesAsync( + String projectId, + Map labels, + EntityFilter entityFilter, + String outputUrlPrefix) { + ExportEntitiesRequest request = + ExportEntitiesRequest.newBuilder() + .setProjectId(projectId) + .putAllLabels(labels) + .setEntityFilter(entityFilter) + .setOutputUrlPrefix(outputUrlPrefix) + .build(); + return exportEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage + * system, such as Google Cloud Storage. Recent updates to entities 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. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   ExportEntitiesRequest request =
+   *       ExportEntitiesRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .putAllLabels(new HashMap())
+   *           .setEntityFilter(EntityFilter.newBuilder().build())
+   *           .setOutputUrlPrefix("outputUrlPrefix-1132598048")
+   *           .build();
+   *   ExportEntitiesResponse response = datastoreAdminClient.exportEntitiesAsync(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 exportEntitiesAsync( + ExportEntitiesRequest request) { + return exportEntitiesOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage + * system, such as Google Cloud Storage. Recent updates to entities 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. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   ExportEntitiesRequest request =
+   *       ExportEntitiesRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .putAllLabels(new HashMap())
+   *           .setEntityFilter(EntityFilter.newBuilder().build())
+   *           .setOutputUrlPrefix("outputUrlPrefix-1132598048")
+   *           .build();
+   *   OperationFuture future =
+   *       datastoreAdminClient.exportEntitiesOperationCallable().futureCall(request);
+   *   // Do something.
+   *   ExportEntitiesResponse response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable< + ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata> + exportEntitiesOperationCallable() { + return stub.exportEntitiesOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Exports a copy of all or a subset of entities from Google Cloud Datastore to another storage + * system, such as Google Cloud Storage. Recent updates to entities 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. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   ExportEntitiesRequest request =
+   *       ExportEntitiesRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .putAllLabels(new HashMap())
+   *           .setEntityFilter(EntityFilter.newBuilder().build())
+   *           .setOutputUrlPrefix("outputUrlPrefix-1132598048")
+   *           .build();
+   *   ApiFuture future =
+   *       datastoreAdminClient.exportEntitiesCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable exportEntitiesCallable() { + return stub.exportEntitiesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Imports entities into Google Cloud Datastore. Existing entities with the same key 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 ImportEntities operation is cancelled, it is + * possible that a subset of the data has already been imported to Cloud Datastore. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   String projectId = "projectId-894832108";
+   *   Map labels = new HashMap<>();
+   *   String inputUrl = "inputUrl470706501";
+   *   EntityFilter entityFilter = EntityFilter.newBuilder().build();
+   *   datastoreAdminClient.importEntitiesAsync(projectId, labels, inputUrl, entityFilter).get();
+   * }
+   * }
+ * + * @param projectId Required. Project ID against which to make the request. + * @param labels Client-assigned labels. + * @param inputUrl Required. The full resource URL of the external storage location. Currently, + * only Google Cloud Storage is supported. So input_url should be of the form: + * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where `BUCKET_NAME` is + * the name of the Cloud Storage bucket, `NAMESPACE_PATH` is an optional Cloud Storage + * namespace path (this is not a Cloud Datastore namespace), and + * `OVERALL_EXPORT_METADATA_FILE` is the metadata file written by the ExportEntities + * operation. For more information about Cloud Storage namespace paths, see [Object name + * considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + *

For more information, see + * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. + * @param entityFilter Optionally specify which kinds/namespaces are to be imported. If provided, + * the list must be a subset of the EntityFilter used in creating the export, otherwise a + * FAILED_PRECONDITION error will be returned. If no filter is specified then all entities + * from the export are imported. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final OperationFuture importEntitiesAsync( + String projectId, Map labels, String inputUrl, EntityFilter entityFilter) { + ImportEntitiesRequest request = + ImportEntitiesRequest.newBuilder() + .setProjectId(projectId) + .putAllLabels(labels) + .setInputUrl(inputUrl) + .setEntityFilter(entityFilter) + .build(); + return importEntitiesAsync(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Imports entities into Google Cloud Datastore. Existing entities with the same key 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 ImportEntities operation is cancelled, it is + * possible that a subset of the data has already been imported to Cloud Datastore. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   ImportEntitiesRequest request =
+   *       ImportEntitiesRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .putAllLabels(new HashMap())
+   *           .setInputUrl("inputUrl470706501")
+   *           .setEntityFilter(EntityFilter.newBuilder().build())
+   *           .build();
+   *   datastoreAdminClient.importEntitiesAsync(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 importEntitiesAsync( + ImportEntitiesRequest request) { + return importEntitiesOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Imports entities into Google Cloud Datastore. Existing entities with the same key 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 ImportEntities operation is cancelled, it is + * possible that a subset of the data has already been imported to Cloud Datastore. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   ImportEntitiesRequest request =
+   *       ImportEntitiesRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .putAllLabels(new HashMap())
+   *           .setInputUrl("inputUrl470706501")
+   *           .setEntityFilter(EntityFilter.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       datastoreAdminClient.importEntitiesOperationCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final OperationCallable + importEntitiesOperationCallable() { + return stub.importEntitiesOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Imports entities into Google Cloud Datastore. Existing entities with the same key 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 ImportEntities operation is cancelled, it is + * possible that a subset of the data has already been imported to Cloud Datastore. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   ImportEntitiesRequest request =
+   *       ImportEntitiesRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .putAllLabels(new HashMap())
+   *           .setInputUrl("inputUrl470706501")
+   *           .setEntityFilter(EntityFilter.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       datastoreAdminClient.importEntitiesCallable().futureCall(request);
+   *   // Do something.
+   *   future.get();
+   * }
+   * }
+ */ + public final UnaryCallable importEntitiesCallable() { + return stub.importEntitiesCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates the specified index. A newly created index's initial state is `CREATING`. On completion + * of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be + * `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status. + * + *

During index creation, the process could result in an error, in which case the index will + * move to the `ERROR` state. The process can be recovered by fixing the data that caused the + * error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], + * then re-creating the index with [create] + * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. + * + *

Indexes with a single property cannot be created. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   CreateIndexRequest request =
+   *       CreateIndexRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setIndex(Index.newBuilder().build())
+   *           .build();
+   *   Index response = datastoreAdminClient.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 the specified index. A newly created index's initial state is `CREATING`. On completion + * of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be + * `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status. + * + *

During index creation, the process could result in an error, in which case the index will + * move to the `ERROR` state. The process can be recovered by fixing the data that caused the + * error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], + * then re-creating the index with [create] + * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. + * + *

Indexes with a single property cannot be created. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   CreateIndexRequest request =
+   *       CreateIndexRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setIndex(Index.newBuilder().build())
+   *           .build();
+   *   OperationFuture future =
+   *       datastoreAdminClient.createIndexOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Index response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + createIndexOperationCallable() { + return stub.createIndexOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates the specified index. A newly created index's initial state is `CREATING`. On completion + * of the returned [google.longrunning.Operation][google.longrunning.Operation], the state will be + * `READY`. If the index already exists, the call will return an `ALREADY_EXISTS` status. + * + *

During index creation, the process could result in an error, in which case the index will + * move to the `ERROR` state. The process can be recovered by fixing the data that caused the + * error, removing the index with [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], + * then re-creating the index with [create] + * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. + * + *

Indexes with a single property cannot be created. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   CreateIndexRequest request =
+   *       CreateIndexRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setIndex(Index.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = datastoreAdminClient.createIndexCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable createIndexCallable() { + return stub.createIndexCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state. + * On successful execution of the request, the index will be in a `DELETING` + * [state][google.datastore.admin.v1.Index.State]. And on completion of the returned + * [google.longrunning.Operation][google.longrunning.Operation], the index will be removed. + * + *

During index deletion, the process could result in an error, in which case the index will + * move to the `ERROR` state. The process can be recovered by fixing the data that caused the + * error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] + * again. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   DeleteIndexRequest request =
+   *       DeleteIndexRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setIndexId("indexId1943291277")
+   *           .build();
+   *   Index response = datastoreAdminClient.deleteIndexAsync(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 deleteIndexAsync( + DeleteIndexRequest request) { + return deleteIndexOperationCallable().futureCall(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state. + * On successful execution of the request, the index will be in a `DELETING` + * [state][google.datastore.admin.v1.Index.State]. And on completion of the returned + * [google.longrunning.Operation][google.longrunning.Operation], the index will be removed. + * + *

During index deletion, the process could result in an error, in which case the index will + * move to the `ERROR` state. The process can be recovered by fixing the data that caused the + * error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] + * again. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   DeleteIndexRequest request =
+   *       DeleteIndexRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setIndexId("indexId1943291277")
+   *           .build();
+   *   OperationFuture future =
+   *       datastoreAdminClient.deleteIndexOperationCallable().futureCall(request);
+   *   // Do something.
+   *   Index response = future.get();
+   * }
+   * }
+ */ + public final OperationCallable + deleteIndexOperationCallable() { + return stub.deleteIndexOperationCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes an existing index. An index can only be deleted if it is in a `READY` or `ERROR` state. + * On successful execution of the request, the index will be in a `DELETING` + * [state][google.datastore.admin.v1.Index.State]. And on completion of the returned + * [google.longrunning.Operation][google.longrunning.Operation], the index will be removed. + * + *

During index deletion, the process could result in an error, in which case the index will + * move to the `ERROR` state. The process can be recovered by fixing the data that caused the + * error, followed by calling [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] + * again. + * + *

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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   DeleteIndexRequest request =
+   *       DeleteIndexRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setIndexId("indexId1943291277")
+   *           .build();
+   *   ApiFuture future = datastoreAdminClient.deleteIndexCallable().futureCall(request);
+   *   // Do something.
+   *   Operation response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable deleteIndexCallable() { + return stub.deleteIndexCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets an 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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   GetIndexRequest request =
+   *       GetIndexRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setIndexId("indexId1943291277")
+   *           .build();
+   *   Index response = datastoreAdminClient.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 an 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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   GetIndexRequest request =
+   *       GetIndexRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setIndexId("indexId1943291277")
+   *           .build();
+   *   ApiFuture future = datastoreAdminClient.getIndexCallable().futureCall(request);
+   *   // Do something.
+   *   Index response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getIndexCallable() { + return stub.getIndexCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists the indexes that match the specified filters. Datastore uses an eventually consistent + * query to fetch the list of indexes and may occasionally return stale 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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   ListIndexesRequest request =
+   *       ListIndexesRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   for (Index element : datastoreAdminClient.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 the indexes that match the specified filters. Datastore uses an eventually consistent + * query to fetch the list of indexes and may occasionally return stale 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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   ListIndexesRequest request =
+   *       ListIndexesRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   ApiFuture future = datastoreAdminClient.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 the indexes that match the specified filters. Datastore uses an eventually consistent + * query to fetch the list of indexes and may occasionally return stale 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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+   *   ListIndexesRequest request =
+   *       ListIndexesRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setFilter("filter-1274492040")
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListIndexesResponse response = datastoreAdminClient.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(); + } + + @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); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminSettings.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminSettings.java new file mode 100644 index 000000000000..e3912dd53bc7 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/DatastoreAdminSettings.java @@ -0,0 +1,362 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.admin.v1; + +import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.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.datastore.admin.v1.stub.DatastoreAdminStubSettings; +import com.google.datastore.admin.v1.CreateIndexRequest; +import com.google.datastore.admin.v1.DeleteIndexRequest; +import com.google.datastore.admin.v1.ExportEntitiesMetadata; +import com.google.datastore.admin.v1.ExportEntitiesRequest; +import com.google.datastore.admin.v1.ExportEntitiesResponse; +import com.google.datastore.admin.v1.GetIndexRequest; +import com.google.datastore.admin.v1.ImportEntitiesMetadata; +import com.google.datastore.admin.v1.ImportEntitiesRequest; +import com.google.datastore.admin.v1.Index; +import com.google.datastore.admin.v1.IndexOperationMetadata; +import com.google.datastore.admin.v1.ListIndexesRequest; +import com.google.datastore.admin.v1.ListIndexesResponse; +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 DatastoreAdminClient}. + * + *

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

    + *
  • The default service address (datastore.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
+ * DatastoreAdminSettings.Builder datastoreAdminSettingsBuilder =
+ *     DatastoreAdminSettings.newBuilder();
+ * datastoreAdminSettingsBuilder
+ *     .getIndexSettings()
+ *     .setRetrySettings(
+ *         datastoreAdminSettingsBuilder
+ *             .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());
+ * DatastoreAdminSettings datastoreAdminSettings = datastoreAdminSettingsBuilder.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 exportEntities: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * DatastoreAdminSettings.Builder datastoreAdminSettingsBuilder =
+ *     DatastoreAdminSettings.newBuilder();
+ * TimedRetryAlgorithm timedRetryAlgorithm =
+ *     OperationalTimedPollAlgorithm.create(
+ *         RetrySettings.newBuilder()
+ *             .setInitialRetryDelayDuration(Duration.ofMillis(500))
+ *             .setRetryDelayMultiplier(1.5)
+ *             .setMaxRetryDelayDuration(Duration.ofMillis(5000))
+ *             .setTotalTimeoutDuration(Duration.ofHours(24))
+ *             .build());
+ * datastoreAdminSettingsBuilder
+ *     .createClusterOperationSettings()
+ *     .setPollingAlgorithm(timedRetryAlgorithm)
+ *     .build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class DatastoreAdminSettings extends ClientSettings { + + /** Returns the object with the settings used for calls to exportEntities. */ + public UnaryCallSettings exportEntitiesSettings() { + return ((DatastoreAdminStubSettings) getStubSettings()).exportEntitiesSettings(); + } + + /** Returns the object with the settings used for calls to exportEntities. */ + public OperationCallSettings< + ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata> + exportEntitiesOperationSettings() { + return ((DatastoreAdminStubSettings) getStubSettings()).exportEntitiesOperationSettings(); + } + + /** Returns the object with the settings used for calls to importEntities. */ + public UnaryCallSettings importEntitiesSettings() { + return ((DatastoreAdminStubSettings) getStubSettings()).importEntitiesSettings(); + } + + /** Returns the object with the settings used for calls to importEntities. */ + public OperationCallSettings + importEntitiesOperationSettings() { + return ((DatastoreAdminStubSettings) getStubSettings()).importEntitiesOperationSettings(); + } + + /** Returns the object with the settings used for calls to createIndex. */ + public UnaryCallSettings createIndexSettings() { + return ((DatastoreAdminStubSettings) getStubSettings()).createIndexSettings(); + } + + /** Returns the object with the settings used for calls to createIndex. */ + public OperationCallSettings + createIndexOperationSettings() { + return ((DatastoreAdminStubSettings) getStubSettings()).createIndexOperationSettings(); + } + + /** Returns the object with the settings used for calls to deleteIndex. */ + public UnaryCallSettings deleteIndexSettings() { + return ((DatastoreAdminStubSettings) getStubSettings()).deleteIndexSettings(); + } + + /** Returns the object with the settings used for calls to deleteIndex. */ + public OperationCallSettings + deleteIndexOperationSettings() { + return ((DatastoreAdminStubSettings) getStubSettings()).deleteIndexOperationSettings(); + } + + /** Returns the object with the settings used for calls to getIndex. */ + public UnaryCallSettings getIndexSettings() { + return ((DatastoreAdminStubSettings) getStubSettings()).getIndexSettings(); + } + + /** Returns the object with the settings used for calls to listIndexes. */ + public PagedCallSettings + listIndexesSettings() { + return ((DatastoreAdminStubSettings) getStubSettings()).listIndexesSettings(); + } + + public static final DatastoreAdminSettings create(DatastoreAdminStubSettings stub) + throws IOException { + return new DatastoreAdminSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return DatastoreAdminStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return DatastoreAdminStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DatastoreAdminStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return DatastoreAdminStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return DatastoreAdminStubSettings.defaultGrpcTransportProviderBuilder(); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DatastoreAdminStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return DatastoreAdminStubSettings.defaultTransportChannelProvider(); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DatastoreAdminStubSettings.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 DatastoreAdminSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for DatastoreAdminSettings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(DatastoreAdminStubSettings.newBuilder(clientContext)); + } + + protected Builder(DatastoreAdminSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(DatastoreAdminStubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(DatastoreAdminStubSettings.newBuilder()); + } + + private static Builder createHttpJsonDefault() { + return new Builder(DatastoreAdminStubSettings.newHttpJsonBuilder()); + } + + public DatastoreAdminStubSettings.Builder getStubSettingsBuilder() { + return ((DatastoreAdminStubSettings.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 exportEntities. */ + public UnaryCallSettings.Builder exportEntitiesSettings() { + return getStubSettingsBuilder().exportEntitiesSettings(); + } + + /** Returns the builder for the settings used for calls to exportEntities. */ + public OperationCallSettings.Builder< + ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata> + exportEntitiesOperationSettings() { + return getStubSettingsBuilder().exportEntitiesOperationSettings(); + } + + /** Returns the builder for the settings used for calls to importEntities. */ + public UnaryCallSettings.Builder importEntitiesSettings() { + return getStubSettingsBuilder().importEntitiesSettings(); + } + + /** Returns the builder for the settings used for calls to importEntities. */ + public OperationCallSettings.Builder + importEntitiesOperationSettings() { + return getStubSettingsBuilder().importEntitiesOperationSettings(); + } + + /** 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 deleteIndex. */ + public UnaryCallSettings.Builder deleteIndexSettings() { + return getStubSettingsBuilder().deleteIndexSettings(); + } + + /** Returns the builder for the settings used for calls to deleteIndex. */ + public OperationCallSettings.Builder + deleteIndexOperationSettings() { + return getStubSettingsBuilder().deleteIndexOperationSettings(); + } + + /** 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 listIndexes. */ + public PagedCallSettings.Builder< + ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse> + listIndexesSettings() { + return getStubSettingsBuilder().listIndexesSettings(); + } + + @Override + public DatastoreAdminSettings build() throws IOException { + return new DatastoreAdminSettings(this); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/gapic_metadata.json b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/gapic_metadata.json new file mode 100644 index 000000000000..205eb5dcde05 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/gapic_metadata.json @@ -0,0 +1,36 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "java", + "protoPackage": "google.datastore.admin.v1", + "libraryPackage": "com.google.cloud.datastore.admin.v1", + "services": { + "DatastoreAdmin": { + "clients": { + "grpc": { + "libraryClient": "DatastoreAdminClient", + "rpcs": { + "CreateIndex": { + "methods": ["createIndexAsync", "createIndexOperationCallable", "createIndexCallable"] + }, + "DeleteIndex": { + "methods": ["deleteIndexAsync", "deleteIndexOperationCallable", "deleteIndexCallable"] + }, + "ExportEntities": { + "methods": ["exportEntitiesAsync", "exportEntitiesAsync", "exportEntitiesOperationCallable", "exportEntitiesCallable"] + }, + "GetIndex": { + "methods": ["getIndex", "getIndexCallable"] + }, + "ImportEntities": { + "methods": ["importEntitiesAsync", "importEntitiesAsync", "importEntitiesOperationCallable", "importEntitiesCallable"] + }, + "ListIndexes": { + "methods": ["listIndexes", "listIndexesPagedCallable", "listIndexesCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/package-info.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/package-info.java new file mode 100644 index 000000000000..9e41866814a6 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/package-info.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. + */ + +/** + * A client to Cloud Datastore API + * + *

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

======================= DatastoreAdminClient ======================= + * + *

Service Description: Google Cloud Datastore Admin API + * + *

The Datastore Admin API provides several admin services for Cloud Datastore. + * + *

Concepts: Project, namespace, kind, and entity as defined in the Google Cloud Datastore API. + * + *

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

EntityFilter: Allows specifying a subset of entities in a project. This is specified as a + * combination of kinds and namespaces (either or both of which may be all). + * + *

Export/Import Service: + * + *

- The Export/Import service provides the ability to copy all or a subset of entities to/from + * Google Cloud Storage. - Exported data may be imported into Cloud Datastore for any Google Cloud + * Platform project. It is not restricted to the export source project. It is possible to export + * from one project and then import into another. - Exported data can also be loaded into Google + * BigQuery for analysis. - Exports and imports are performed asynchronously. An Operation resource + * is created for each export/import. The state (including any errors encountered) of the + * export/import may be queried via the Operation resource. + * + *

Index Service: + * + *

- The index service manages Cloud Datastore composite indexes. - Index creation and deletion + * are 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. + * + *

Operation Service: + * + *

- 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 not yet done may be cancelled. The request + * to cancel is asynchronous and the operation may continue to run for some time after the request + * to cancel is made. - An operation that is done may be deleted so that it is no longer listed as + * part of the Operation collection. - ListOperations returns all pending operations, but not + * completed operations. - Operations are created by service DatastoreAdmin, but are accessed via + * service google.longrunning.Operations. + * + *

Sample for DatastoreAdminClient: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require 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 (DatastoreAdminClient datastoreAdminClient = DatastoreAdminClient.create()) {
+ *   GetIndexRequest request =
+ *       GetIndexRequest.newBuilder()
+ *           .setProjectId("projectId-894832108")
+ *           .setIndexId("indexId1943291277")
+ *           .build();
+ *   Index response = datastoreAdminClient.getIndex(request);
+ * }
+ * }
+ */ +@Generated("by gapic-generator-java") +package com.google.cloud.datastore.admin.v1; + +import javax.annotation.Generated; diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStub.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStub.java new file mode 100644 index 000000000000..87e0db23e0fd --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStub.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. + */ + +package com.google.cloud.datastore.admin.v1.stub; + +import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.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.datastore.admin.v1.CreateIndexRequest; +import com.google.datastore.admin.v1.DeleteIndexRequest; +import com.google.datastore.admin.v1.ExportEntitiesMetadata; +import com.google.datastore.admin.v1.ExportEntitiesRequest; +import com.google.datastore.admin.v1.ExportEntitiesResponse; +import com.google.datastore.admin.v1.GetIndexRequest; +import com.google.datastore.admin.v1.ImportEntitiesMetadata; +import com.google.datastore.admin.v1.ImportEntitiesRequest; +import com.google.datastore.admin.v1.Index; +import com.google.datastore.admin.v1.IndexOperationMetadata; +import com.google.datastore.admin.v1.ListIndexesRequest; +import com.google.datastore.admin.v1.ListIndexesResponse; +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 DatastoreAdmin service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public abstract class DatastoreAdminStub implements BackgroundResource { + + public OperationsStub getOperationsStub() { + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; + } + + public OperationCallable + exportEntitiesOperationCallable() { + throw new UnsupportedOperationException("Not implemented: exportEntitiesOperationCallable()"); + } + + public UnaryCallable exportEntitiesCallable() { + throw new UnsupportedOperationException("Not implemented: exportEntitiesCallable()"); + } + + public OperationCallable + importEntitiesOperationCallable() { + throw new UnsupportedOperationException("Not implemented: importEntitiesOperationCallable()"); + } + + public UnaryCallable importEntitiesCallable() { + throw new UnsupportedOperationException("Not implemented: importEntitiesCallable()"); + } + + public OperationCallable + createIndexOperationCallable() { + throw new UnsupportedOperationException("Not implemented: createIndexOperationCallable()"); + } + + public UnaryCallable createIndexCallable() { + throw new UnsupportedOperationException("Not implemented: createIndexCallable()"); + } + + public OperationCallable + deleteIndexOperationCallable() { + throw new UnsupportedOperationException("Not implemented: deleteIndexOperationCallable()"); + } + + public UnaryCallable deleteIndexCallable() { + throw new UnsupportedOperationException("Not implemented: deleteIndexCallable()"); + } + + public UnaryCallable getIndexCallable() { + throw new UnsupportedOperationException("Not implemented: getIndexCallable()"); + } + + public UnaryCallable listIndexesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listIndexesPagedCallable()"); + } + + public UnaryCallable listIndexesCallable() { + throw new UnsupportedOperationException("Not implemented: listIndexesCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStubSettings.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStubSettings.java new file mode 100644 index 000000000000..7564c3ad3cfe --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/DatastoreAdminStubSettings.java @@ -0,0 +1,754 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.admin.v1.stub; + +import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.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.datastore.admin.v1.CreateIndexRequest; +import com.google.datastore.admin.v1.DeleteIndexRequest; +import com.google.datastore.admin.v1.ExportEntitiesMetadata; +import com.google.datastore.admin.v1.ExportEntitiesRequest; +import com.google.datastore.admin.v1.ExportEntitiesResponse; +import com.google.datastore.admin.v1.GetIndexRequest; +import com.google.datastore.admin.v1.ImportEntitiesMetadata; +import com.google.datastore.admin.v1.ImportEntitiesRequest; +import com.google.datastore.admin.v1.Index; +import com.google.datastore.admin.v1.IndexOperationMetadata; +import com.google.datastore.admin.v1.ListIndexesRequest; +import com.google.datastore.admin.v1.ListIndexesResponse; +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 DatastoreAdminStub}. + * + *

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

    + *
  • The default service address (datastore.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
+ * DatastoreAdminStubSettings.Builder datastoreAdminSettingsBuilder =
+ *     DatastoreAdminStubSettings.newBuilder();
+ * datastoreAdminSettingsBuilder
+ *     .getIndexSettings()
+ *     .setRetrySettings(
+ *         datastoreAdminSettingsBuilder
+ *             .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());
+ * DatastoreAdminStubSettings datastoreAdminSettings = datastoreAdminSettingsBuilder.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 exportEntities: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * DatastoreAdminStubSettings.Builder datastoreAdminSettingsBuilder =
+ *     DatastoreAdminStubSettings.newBuilder();
+ * TimedRetryAlgorithm timedRetryAlgorithm =
+ *     OperationalTimedPollAlgorithm.create(
+ *         RetrySettings.newBuilder()
+ *             .setInitialRetryDelayDuration(Duration.ofMillis(500))
+ *             .setRetryDelayMultiplier(1.5)
+ *             .setMaxRetryDelayDuration(Duration.ofMillis(5000))
+ *             .setTotalTimeoutDuration(Duration.ofHours(24))
+ *             .build());
+ * datastoreAdminSettingsBuilder
+ *     .createClusterOperationSettings()
+ *     .setPollingAlgorithm(timedRetryAlgorithm)
+ *     .build();
+ * }
+ */ +@Generated("by gapic-generator-java") +public class DatastoreAdminStubSettings 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 exportEntitiesSettings; + private final OperationCallSettings< + ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata> + exportEntitiesOperationSettings; + private final UnaryCallSettings importEntitiesSettings; + private final OperationCallSettings + importEntitiesOperationSettings; + private final UnaryCallSettings createIndexSettings; + private final OperationCallSettings + createIndexOperationSettings; + private final UnaryCallSettings deleteIndexSettings; + private final OperationCallSettings + deleteIndexOperationSettings; + private final UnaryCallSettings getIndexSettings; + private final PagedCallSettings + listIndexesSettings; + + 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 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); + } + }; + + /** Returns the object with the settings used for calls to exportEntities. */ + public UnaryCallSettings exportEntitiesSettings() { + return exportEntitiesSettings; + } + + /** Returns the object with the settings used for calls to exportEntities. */ + public OperationCallSettings< + ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata> + exportEntitiesOperationSettings() { + return exportEntitiesOperationSettings; + } + + /** Returns the object with the settings used for calls to importEntities. */ + public UnaryCallSettings importEntitiesSettings() { + return importEntitiesSettings; + } + + /** Returns the object with the settings used for calls to importEntities. */ + public OperationCallSettings + importEntitiesOperationSettings() { + return importEntitiesOperationSettings; + } + + /** 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 deleteIndex. */ + public UnaryCallSettings deleteIndexSettings() { + return deleteIndexSettings; + } + + /** Returns the object with the settings used for calls to deleteIndex. */ + public OperationCallSettings + deleteIndexOperationSettings() { + return deleteIndexOperationSettings; + } + + /** 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 listIndexes. */ + public PagedCallSettings + listIndexesSettings() { + return listIndexesSettings; + } + + public DatastoreAdminStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcDatastoreAdminStub.create(this); + } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDatastoreAdminStub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); + } + + /** Returns the default service name. */ + @Override + public String getServiceName() { + return "datastore"; + } + + /** 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 "datastore.googleapis.com:443"; + } + + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "datastore.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(DatastoreAdminStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(DatastoreAdminStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DatastoreAdminStubSettings.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 DatastoreAdminStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + exportEntitiesSettings = settingsBuilder.exportEntitiesSettings().build(); + exportEntitiesOperationSettings = settingsBuilder.exportEntitiesOperationSettings().build(); + importEntitiesSettings = settingsBuilder.importEntitiesSettings().build(); + importEntitiesOperationSettings = settingsBuilder.importEntitiesOperationSettings().build(); + createIndexSettings = settingsBuilder.createIndexSettings().build(); + createIndexOperationSettings = settingsBuilder.createIndexOperationSettings().build(); + deleteIndexSettings = settingsBuilder.deleteIndexSettings().build(); + deleteIndexOperationSettings = settingsBuilder.deleteIndexOperationSettings().build(); + getIndexSettings = settingsBuilder.getIndexSettings().build(); + listIndexesSettings = settingsBuilder.listIndexesSettings().build(); + } + + /** Builder for DatastoreAdminStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final UnaryCallSettings.Builder + exportEntitiesSettings; + private final OperationCallSettings.Builder< + ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata> + exportEntitiesOperationSettings; + private final UnaryCallSettings.Builder + importEntitiesSettings; + private final OperationCallSettings.Builder< + ImportEntitiesRequest, Empty, ImportEntitiesMetadata> + importEntitiesOperationSettings; + private final UnaryCallSettings.Builder createIndexSettings; + private final OperationCallSettings.Builder + createIndexOperationSettings; + private final UnaryCallSettings.Builder deleteIndexSettings; + private final OperationCallSettings.Builder + deleteIndexOperationSettings; + private final UnaryCallSettings.Builder getIndexSettings; + private final PagedCallSettings.Builder< + ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse> + listIndexesSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "no_retry_0_codes", ImmutableSet.copyOf(Lists.newArrayList())); + definitions.put( + "retry_policy_1_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); + 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_0_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_1_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + exportEntitiesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + exportEntitiesOperationSettings = OperationCallSettings.newBuilder(); + importEntitiesSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + importEntitiesOperationSettings = OperationCallSettings.newBuilder(); + createIndexSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + createIndexOperationSettings = OperationCallSettings.newBuilder(); + deleteIndexSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteIndexOperationSettings = OperationCallSettings.newBuilder(); + getIndexSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listIndexesSettings = PagedCallSettings.newBuilder(LIST_INDEXES_PAGE_STR_FACT); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + exportEntitiesSettings, + importEntitiesSettings, + createIndexSettings, + deleteIndexSettings, + getIndexSettings, + listIndexesSettings); + initDefaults(this); + } + + protected Builder(DatastoreAdminStubSettings settings) { + super(settings); + + exportEntitiesSettings = settings.exportEntitiesSettings.toBuilder(); + exportEntitiesOperationSettings = settings.exportEntitiesOperationSettings.toBuilder(); + importEntitiesSettings = settings.importEntitiesSettings.toBuilder(); + importEntitiesOperationSettings = settings.importEntitiesOperationSettings.toBuilder(); + createIndexSettings = settings.createIndexSettings.toBuilder(); + createIndexOperationSettings = settings.createIndexOperationSettings.toBuilder(); + deleteIndexSettings = settings.deleteIndexSettings.toBuilder(); + deleteIndexOperationSettings = settings.deleteIndexOperationSettings.toBuilder(); + getIndexSettings = settings.getIndexSettings.toBuilder(); + listIndexesSettings = settings.listIndexesSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + exportEntitiesSettings, + importEntitiesSettings, + createIndexSettings, + deleteIndexSettings, + getIndexSettings, + listIndexesSettings); + } + + 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 + .exportEntitiesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); + + builder + .importEntitiesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); + + builder + .createIndexSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); + + builder + .deleteIndexSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")); + + builder + .getIndexSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .listIndexesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_1_params")); + + builder + .exportEntitiesOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(ExportEntitiesResponse.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(ExportEntitiesMetadata.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 + .importEntitiesOperationSettings() + .setInitialCallSettings( + UnaryCallSettings + .newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_params")) + .build()) + .setResponseTransformer( + ProtoOperationTransformers.ResponseTransformer.create(Empty.class)) + .setMetadataTransformer( + ProtoOperationTransformers.MetadataTransformer.create(ImportEntitiesMetadata.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 + .createIndexOperationSettings() + .setInitialCallSettings( + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_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 + .deleteIndexOperationSettings() + .setInitialCallSettings( + UnaryCallSettings.newUnaryCallSettingsBuilder() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_0_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())); + + 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 exportEntities. */ + public UnaryCallSettings.Builder exportEntitiesSettings() { + return exportEntitiesSettings; + } + + /** Returns the builder for the settings used for calls to exportEntities. */ + public OperationCallSettings.Builder< + ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata> + exportEntitiesOperationSettings() { + return exportEntitiesOperationSettings; + } + + /** Returns the builder for the settings used for calls to importEntities. */ + public UnaryCallSettings.Builder importEntitiesSettings() { + return importEntitiesSettings; + } + + /** Returns the builder for the settings used for calls to importEntities. */ + public OperationCallSettings.Builder + importEntitiesOperationSettings() { + return importEntitiesOperationSettings; + } + + /** 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 deleteIndex. */ + public UnaryCallSettings.Builder deleteIndexSettings() { + return deleteIndexSettings; + } + + /** Returns the builder for the settings used for calls to deleteIndex. */ + public OperationCallSettings.Builder + deleteIndexOperationSettings() { + return deleteIndexOperationSettings; + } + + /** 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 listIndexes. */ + public PagedCallSettings.Builder< + ListIndexesRequest, ListIndexesResponse, ListIndexesPagedResponse> + listIndexesSettings() { + return listIndexesSettings; + } + + @Override + public DatastoreAdminStubSettings build() throws IOException { + return new DatastoreAdminStubSettings(this); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminCallableFactory.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminCallableFactory.java new file mode 100644 index 000000000000..47629c9a7206 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminCallableFactory.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.datastore.admin.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 DatastoreAdmin service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class GrpcDatastoreAdminCallableFactory 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-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminStub.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminStub.java new file mode 100644 index 000000000000..4d72d06cb4b3 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/GrpcDatastoreAdminStub.java @@ -0,0 +1,391 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.admin.v1.stub; + +import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.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.datastore.admin.v1.CreateIndexRequest; +import com.google.datastore.admin.v1.DeleteIndexRequest; +import com.google.datastore.admin.v1.ExportEntitiesMetadata; +import com.google.datastore.admin.v1.ExportEntitiesRequest; +import com.google.datastore.admin.v1.ExportEntitiesResponse; +import com.google.datastore.admin.v1.GetIndexRequest; +import com.google.datastore.admin.v1.ImportEntitiesMetadata; +import com.google.datastore.admin.v1.ImportEntitiesRequest; +import com.google.datastore.admin.v1.Index; +import com.google.datastore.admin.v1.IndexOperationMetadata; +import com.google.datastore.admin.v1.ListIndexesRequest; +import com.google.datastore.admin.v1.ListIndexesResponse; +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 DatastoreAdmin service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcDatastoreAdminStub extends DatastoreAdminStub { + private static final MethodDescriptor + exportEntitiesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/ExportEntities") + .setRequestMarshaller( + ProtoUtils.marshaller(ExportEntitiesRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + importEntitiesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/ImportEntities") + .setRequestMarshaller( + ProtoUtils.marshaller(ImportEntitiesRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor createIndexMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/CreateIndex") + .setRequestMarshaller(ProtoUtils.marshaller(CreateIndexRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor deleteIndexMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/DeleteIndex") + .setRequestMarshaller(ProtoUtils.marshaller(DeleteIndexRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Operation.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor getIndexMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/GetIndex") + .setRequestMarshaller(ProtoUtils.marshaller(GetIndexRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Index.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + listIndexesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/ListIndexes") + .setRequestMarshaller(ProtoUtils.marshaller(ListIndexesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListIndexesResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private final UnaryCallable exportEntitiesCallable; + private final OperationCallable< + ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata> + exportEntitiesOperationCallable; + private final UnaryCallable importEntitiesCallable; + private final OperationCallable + importEntitiesOperationCallable; + private final UnaryCallable createIndexCallable; + private final OperationCallable + createIndexOperationCallable; + private final UnaryCallable deleteIndexCallable; + private final OperationCallable + deleteIndexOperationCallable; + private final UnaryCallable getIndexCallable; + private final UnaryCallable listIndexesCallable; + private final UnaryCallable + listIndexesPagedCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + public static final GrpcDatastoreAdminStub create(DatastoreAdminStubSettings settings) + throws IOException { + return new GrpcDatastoreAdminStub(settings, ClientContext.create(settings)); + } + + public static final GrpcDatastoreAdminStub create(ClientContext clientContext) + throws IOException { + return new GrpcDatastoreAdminStub( + DatastoreAdminStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcDatastoreAdminStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcDatastoreAdminStub( + DatastoreAdminStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcDatastoreAdminStub, 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 GrpcDatastoreAdminStub(DatastoreAdminStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcDatastoreAdminCallableFactory()); + } + + /** + * Constructs an instance of GrpcDatastoreAdminStub, 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 GrpcDatastoreAdminStub( + DatastoreAdminStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings exportEntitiesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(exportEntitiesMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + GrpcCallSettings importEntitiesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(importEntitiesMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + GrpcCallSettings createIndexTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createIndexMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + GrpcCallSettings deleteIndexTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteIndexMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("index_id", String.valueOf(request.getIndexId())); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + GrpcCallSettings getIndexTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getIndexMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("index_id", String.valueOf(request.getIndexId())); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + GrpcCallSettings listIndexesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listIndexesMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + + this.exportEntitiesCallable = + callableFactory.createUnaryCallable( + exportEntitiesTransportSettings, settings.exportEntitiesSettings(), clientContext); + this.exportEntitiesOperationCallable = + callableFactory.createOperationCallable( + exportEntitiesTransportSettings, + settings.exportEntitiesOperationSettings(), + clientContext, + operationsStub); + this.importEntitiesCallable = + callableFactory.createUnaryCallable( + importEntitiesTransportSettings, settings.importEntitiesSettings(), clientContext); + this.importEntitiesOperationCallable = + callableFactory.createOperationCallable( + importEntitiesTransportSettings, + settings.importEntitiesOperationSettings(), + clientContext, + operationsStub); + this.createIndexCallable = + callableFactory.createUnaryCallable( + createIndexTransportSettings, settings.createIndexSettings(), clientContext); + this.createIndexOperationCallable = + callableFactory.createOperationCallable( + createIndexTransportSettings, + settings.createIndexOperationSettings(), + clientContext, + operationsStub); + this.deleteIndexCallable = + callableFactory.createUnaryCallable( + deleteIndexTransportSettings, settings.deleteIndexSettings(), clientContext); + this.deleteIndexOperationCallable = + callableFactory.createOperationCallable( + deleteIndexTransportSettings, + settings.deleteIndexOperationSettings(), + clientContext, + operationsStub); + this.getIndexCallable = + callableFactory.createUnaryCallable( + getIndexTransportSettings, settings.getIndexSettings(), clientContext); + this.listIndexesCallable = + callableFactory.createUnaryCallable( + listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); + this.listIndexesPagedCallable = + callableFactory.createPagedCallable( + listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + @Override + public UnaryCallable exportEntitiesCallable() { + return exportEntitiesCallable; + } + + @Override + public OperationCallable + exportEntitiesOperationCallable() { + return exportEntitiesOperationCallable; + } + + @Override + public UnaryCallable importEntitiesCallable() { + return importEntitiesCallable; + } + + @Override + public OperationCallable + importEntitiesOperationCallable() { + return importEntitiesOperationCallable; + } + + @Override + public UnaryCallable createIndexCallable() { + return createIndexCallable; + } + + @Override + public OperationCallable + createIndexOperationCallable() { + return createIndexOperationCallable; + } + + @Override + public UnaryCallable deleteIndexCallable() { + return deleteIndexCallable; + } + + @Override + public OperationCallable + deleteIndexOperationCallable() { + return deleteIndexOperationCallable; + } + + @Override + public UnaryCallable getIndexCallable() { + return getIndexCallable; + } + + @Override + public UnaryCallable listIndexesCallable() { + return listIndexesCallable; + } + + @Override + public UnaryCallable listIndexesPagedCallable() { + return listIndexesPagedCallable; + } + + @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-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/HttpJsonDatastoreAdminCallableFactory.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/HttpJsonDatastoreAdminCallableFactory.java new file mode 100644 index 000000000000..bb9ec0e59723 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/HttpJsonDatastoreAdminCallableFactory.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.datastore.admin.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 DatastoreAdmin service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class HttpJsonDatastoreAdminCallableFactory + 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-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/HttpJsonDatastoreAdminStub.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/HttpJsonDatastoreAdminStub.java new file mode 100644 index 000000000000..5fe4db69959b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/admin/v1/stub/HttpJsonDatastoreAdminStub.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. + */ + +package com.google.cloud.datastore.admin.v1.stub; + +import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.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.common.collect.ImmutableMap; +import com.google.datastore.admin.v1.CreateIndexRequest; +import com.google.datastore.admin.v1.DeleteIndexRequest; +import com.google.datastore.admin.v1.ExportEntitiesMetadata; +import com.google.datastore.admin.v1.ExportEntitiesRequest; +import com.google.datastore.admin.v1.ExportEntitiesResponse; +import com.google.datastore.admin.v1.GetIndexRequest; +import com.google.datastore.admin.v1.ImportEntitiesMetadata; +import com.google.datastore.admin.v1.ImportEntitiesRequest; +import com.google.datastore.admin.v1.Index; +import com.google.datastore.admin.v1.IndexOperationMetadata; +import com.google.datastore.admin.v1.ListIndexesRequest; +import com.google.datastore.admin.v1.ListIndexesResponse; +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 DatastoreAdmin service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class HttpJsonDatastoreAdminStub extends DatastoreAdminStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(ExportEntitiesResponse.getDescriptor()) + .add(IndexOperationMetadata.getDescriptor()) + .add(Index.getDescriptor()) + .add(ExportEntitiesMetadata.getDescriptor()) + .add(ImportEntitiesMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + exportEntitiesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/ExportEntities") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}:export", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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().clearProjectId().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ExportEntitiesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + importEntitiesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/ImportEntities") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}:import", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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().clearProjectId().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (ImportEntitiesRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createIndexMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/CreateIndex") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}/indexes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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 + deleteIndexMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/DeleteIndex") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}/indexes/{indexId}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "indexId", request.getIndexId()); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteIndexRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor getIndexMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/GetIndex") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}/indexes/{indexId}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "indexId", request.getIndexId()); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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 + listIndexesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.admin.v1.DatastoreAdmin/ListIndexes") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}/indexes", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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 final UnaryCallable exportEntitiesCallable; + private final OperationCallable< + ExportEntitiesRequest, ExportEntitiesResponse, ExportEntitiesMetadata> + exportEntitiesOperationCallable; + private final UnaryCallable importEntitiesCallable; + private final OperationCallable + importEntitiesOperationCallable; + private final UnaryCallable createIndexCallable; + private final OperationCallable + createIndexOperationCallable; + private final UnaryCallable deleteIndexCallable; + private final OperationCallable + deleteIndexOperationCallable; + private final UnaryCallable getIndexCallable; + private final UnaryCallable listIndexesCallable; + private final UnaryCallable + listIndexesPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonDatastoreAdminStub create(DatastoreAdminStubSettings settings) + throws IOException { + return new HttpJsonDatastoreAdminStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDatastoreAdminStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonDatastoreAdminStub( + DatastoreAdminStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDatastoreAdminStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDatastoreAdminStub( + DatastoreAdminStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDatastoreAdminStub, 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 HttpJsonDatastoreAdminStub( + DatastoreAdminStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonDatastoreAdminCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDatastoreAdminStub, 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 HttpJsonDatastoreAdminStub( + DatastoreAdminStubSettings 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/*/operations/*}:cancel") + .build()) + .put( + "google.longrunning.Operations.DeleteOperation", + HttpRule.newBuilder().setDelete("/v1/{name=projects/*/operations/*}").build()) + .put( + "google.longrunning.Operations.GetOperation", + HttpRule.newBuilder().setGet("/v1/{name=projects/*/operations/*}").build()) + .put( + "google.longrunning.Operations.ListOperations", + HttpRule.newBuilder().setGet("/v1/{name=projects/*}/operations").build()) + .build()); + + HttpJsonCallSettings exportEntitiesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(exportEntitiesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings importEntitiesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(importEntitiesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings createIndexTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createIndexMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings deleteIndexTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteIndexMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("index_id", String.valueOf(request.getIndexId())); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings getIndexTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getIndexMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("index_id", String.valueOf(request.getIndexId())); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings listIndexesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listIndexesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("project_id", String.valueOf(request.getProjectId())); + return builder.build(); + }) + .build(); + + this.exportEntitiesCallable = + callableFactory.createUnaryCallable( + exportEntitiesTransportSettings, settings.exportEntitiesSettings(), clientContext); + this.exportEntitiesOperationCallable = + callableFactory.createOperationCallable( + exportEntitiesTransportSettings, + settings.exportEntitiesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.importEntitiesCallable = + callableFactory.createUnaryCallable( + importEntitiesTransportSettings, settings.importEntitiesSettings(), clientContext); + this.importEntitiesOperationCallable = + callableFactory.createOperationCallable( + importEntitiesTransportSettings, + settings.importEntitiesOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createIndexCallable = + callableFactory.createUnaryCallable( + createIndexTransportSettings, settings.createIndexSettings(), clientContext); + this.createIndexOperationCallable = + callableFactory.createOperationCallable( + createIndexTransportSettings, + settings.createIndexOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteIndexCallable = + callableFactory.createUnaryCallable( + deleteIndexTransportSettings, settings.deleteIndexSettings(), clientContext); + this.deleteIndexOperationCallable = + callableFactory.createOperationCallable( + deleteIndexTransportSettings, + settings.deleteIndexOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getIndexCallable = + callableFactory.createUnaryCallable( + getIndexTransportSettings, settings.getIndexSettings(), clientContext); + this.listIndexesCallable = + callableFactory.createUnaryCallable( + listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); + this.listIndexesPagedCallable = + callableFactory.createPagedCallable( + listIndexesTransportSettings, settings.listIndexesSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(exportEntitiesMethodDescriptor); + methodDescriptors.add(importEntitiesMethodDescriptor); + methodDescriptors.add(createIndexMethodDescriptor); + methodDescriptors.add(deleteIndexMethodDescriptor); + methodDescriptors.add(getIndexMethodDescriptor); + methodDescriptors.add(listIndexesMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable exportEntitiesCallable() { + return exportEntitiesCallable; + } + + @Override + public OperationCallable + exportEntitiesOperationCallable() { + return exportEntitiesOperationCallable; + } + + @Override + public UnaryCallable importEntitiesCallable() { + return importEntitiesCallable; + } + + @Override + public OperationCallable + importEntitiesOperationCallable() { + return importEntitiesOperationCallable; + } + + @Override + public UnaryCallable createIndexCallable() { + return createIndexCallable; + } + + @Override + public OperationCallable + createIndexOperationCallable() { + return createIndexOperationCallable; + } + + @Override + public UnaryCallable deleteIndexCallable() { + return deleteIndexCallable; + } + + @Override + public OperationCallable + deleteIndexOperationCallable() { + return deleteIndexOperationCallable; + } + + @Override + public UnaryCallable getIndexCallable() { + return getIndexCallable; + } + + @Override + public UnaryCallable listIndexesCallable() { + return listIndexesCallable; + } + + @Override + public UnaryCallable listIndexesPagedCallable() { + return listIndexesPagedCallable; + } + + @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-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/Aggregation.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/Aggregation.java new file mode 100644 index 000000000000..a347cdf3db72 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/Aggregation.java @@ -0,0 +1,65 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.aggregation; + +import com.google.api.core.InternalApi; +import com.google.datastore.v1.AggregationQuery; + +/** + * Represents a Google Cloud Datastore Aggregation which is used with an {@link AggregationQuery}. + */ +public abstract class Aggregation { + + private final String alias; + + public Aggregation(String alias) { + this.alias = alias; + } + + /** Returns the alias for this aggregation. */ + public String getAlias() { + return alias; + } + + @InternalApi + public abstract AggregationQuery.Aggregation toPb(); + + @InternalApi + protected AggregationQuery.Aggregation.Builder aggregationBuilder() { + AggregationQuery.Aggregation.Builder aggregationBuilder = + AggregationQuery.Aggregation.newBuilder(); + if (this.getAlias() != null) { + aggregationBuilder.setAlias(this.getAlias()); + } + return aggregationBuilder; + } + + /** Returns a {@link CountAggregation} builder. */ + public static CountAggregation.Builder count() { + return new CountAggregation.Builder(); + } + + /** Returns a {@link SumAggregation} builder. */ + public static SumAggregation.Builder sum(String propertyReference) { + return new SumAggregation.Builder().propertyReference(propertyReference); + } + + /** Returns a {@link AvgAggregation} builder. */ + public static AvgAggregation.Builder avg(String propertyReference) { + return new AvgAggregation.Builder().propertyReference(propertyReference); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/AggregationBuilder.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/AggregationBuilder.java new file mode 100644 index 000000000000..39e0dd22fa5b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/AggregationBuilder.java @@ -0,0 +1,31 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.aggregation; + +import com.google.api.core.InternalExtensionOnly; + +/** + * An interface to represent the builders which build and customize {@link Aggregation} for {@link + * com.google.cloud.datastore.AggregationQuery}. + * + *

Used by {@link + * com.google.cloud.datastore.AggregationQuery.Builder#addAggregation(AggregationBuilder)}. + */ +@InternalExtensionOnly +public interface AggregationBuilder { + A build(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/AvgAggregation.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/AvgAggregation.java new file mode 100644 index 000000000000..0e2f60d84987 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/AvgAggregation.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.aggregation; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.api.core.InternalApi; +import com.google.datastore.v1.AggregationQuery; +import com.google.datastore.v1.AggregationQuery.Aggregation.Avg; +import com.google.datastore.v1.PropertyReference; +import java.util.Objects; + +/** Represents an {@link Aggregation} which returns average of numerical values. */ +public class AvgAggregation extends Aggregation { + + private final String propertyReference; + + public AvgAggregation(String alias, String propertyReference) { + super(alias); + checkArgument(propertyReference != null, "Property reference can't be null"); + this.propertyReference = propertyReference; + } + + @InternalApi + @Override + public AggregationQuery.Aggregation toPb() { + PropertyReference reference = + PropertyReference.newBuilder().setName(this.propertyReference).build(); + Avg avg = Avg.newBuilder().setProperty(reference).build(); + return aggregationBuilder().setAvg(avg).build(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + AvgAggregation that = (AvgAggregation) o; + return Objects.equals(this.propertyReference, that.propertyReference) + && Objects.equals(getAlias(), that.getAlias()); + } + + @Override + public int hashCode() { + return Objects.hash(getAlias(), this.propertyReference); + } + + /** A builder class to create and customize a {@link AvgAggregation}. */ + public static class Builder implements AggregationBuilder { + + private String alias; + private String propertyReference; + + public AvgAggregation.Builder propertyReference(String propertyReference) { + this.propertyReference = propertyReference; + return this; + } + + public AvgAggregation.Builder as(String alias) { + this.alias = alias; + return this; + } + + @Override + public AvgAggregation build() { + return new AvgAggregation(alias, propertyReference); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/CountAggregation.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/CountAggregation.java new file mode 100644 index 000000000000..e4bd1464681a --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/CountAggregation.java @@ -0,0 +1,70 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.aggregation; + +import com.google.datastore.v1.AggregationQuery; +import com.google.datastore.v1.AggregationQuery.Aggregation.Count; +import java.util.Objects; + +/** Represents an {@link Aggregation} which returns count. */ +public class CountAggregation extends Aggregation { + + /** + * @param alias Alias to used when running this aggregation. + */ + public CountAggregation(String alias) { + super(alias); + } + + @Override + public AggregationQuery.Aggregation toPb() { + return aggregationBuilder().setCount(Count.newBuilder()).build(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CountAggregation that = (CountAggregation) o; + return Objects.equals(getAlias(), that.getAlias()); + } + + @Override + public int hashCode() { + return Objects.hash(getAlias()); + } + + /** A builder class to create and customize a {@link CountAggregation}. */ + public static class Builder implements AggregationBuilder { + + private String alias; + + public Builder as(String alias) { + this.alias = alias; + return this; + } + + @Override + public CountAggregation build() { + return new CountAggregation(alias); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/SumAggregation.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/SumAggregation.java new file mode 100644 index 000000000000..36c6f83563d8 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/aggregation/SumAggregation.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.aggregation; + +import static com.google.common.base.Preconditions.checkArgument; + +import com.google.api.core.InternalApi; +import com.google.datastore.v1.AggregationQuery; +import com.google.datastore.v1.AggregationQuery.Aggregation.Sum; +import com.google.datastore.v1.PropertyReference; +import java.util.Objects; + +/** Represents an {@link Aggregation} which returns sum of numerical values. */ +public class SumAggregation extends Aggregation { + + private final String propertyReference; + + public SumAggregation(String alias, String propertyReference) { + super(alias); + checkArgument(propertyReference != null, "Property reference can't be null"); + this.propertyReference = propertyReference; + } + + @InternalApi + @Override + public AggregationQuery.Aggregation toPb() { + PropertyReference reference = + PropertyReference.newBuilder().setName(this.propertyReference).build(); + Sum sum = Sum.newBuilder().setProperty(reference).build(); + return aggregationBuilder().setSum(sum).build(); + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SumAggregation that = (SumAggregation) o; + return Objects.equals(this.propertyReference, that.propertyReference) + && Objects.equals(getAlias(), that.getAlias()); + } + + @Override + public int hashCode() { + return Objects.hash(getAlias(), this.propertyReference); + } + + /** A builder class to create and customize a {@link SumAggregation}. */ + public static class Builder implements AggregationBuilder { + + private String alias; + private String propertyReference; + + public SumAggregation.Builder propertyReference(String propertyReference) { + this.propertyReference = propertyReference; + return this; + } + + public SumAggregation.Builder as(String alias) { + this.alias = alias; + return this; + } + + @Override + public SumAggregation build() { + return new SumAggregation(alias, propertyReference); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/AggregationQueryExecutor.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/AggregationQueryExecutor.java new file mode 100644 index 000000000000..698e6095d3ea --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/AggregationQueryExecutor.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. + */ +package com.google.cloud.datastore.execution; + +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.ReadOption.QueryConfig; +import com.google.cloud.datastore.execution.request.AggregationQueryRequestProtoPreparer; +import com.google.cloud.datastore.execution.response.AggregationQueryResponseTransformer; +import com.google.cloud.datastore.models.ExplainOptions; +import com.google.cloud.datastore.spi.v1.DatastoreRpc; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import java.util.Arrays; + +/** + * An implementation of {@link QueryExecutor} which executes {@link AggregationQuery} and returns + * {@link AggregationResults}. + */ +@InternalApi +public class AggregationQueryExecutor + implements QueryExecutor { + + private final DatastoreRpc datastoreRpc; + private final AggregationQueryRequestProtoPreparer protoPreparer; + private final AggregationQueryResponseTransformer responseTransformer; + + public AggregationQueryExecutor(DatastoreRpc datastoreRpc, DatastoreOptions datastoreOptions) { + this.datastoreRpc = datastoreRpc; + this.protoPreparer = new AggregationQueryRequestProtoPreparer(datastoreOptions); + this.responseTransformer = new AggregationQueryResponseTransformer(); + } + + @Override + public AggregationResults execute( + AggregationQuery query, ExplainOptions explainOptions, ReadOption... readOptions) { + RunAggregationQueryRequest runAggregationQueryRequest = + getRunAggregationQueryRequest( + query, explainOptions == null ? null : explainOptions.toPb(), readOptions); + RunAggregationQueryResponse runAggregationQueryResponse = + this.datastoreRpc.runAggregationQuery(runAggregationQueryRequest); + return this.responseTransformer.transform(runAggregationQueryResponse); + } + + private RunAggregationQueryRequest getRunAggregationQueryRequest( + AggregationQuery query, + com.google.datastore.v1.ExplainOptions explainOptions, + ReadOption... readOptions) { + QueryConfig queryConfig = + readOptions == null + ? QueryConfig.create(query, explainOptions) + : QueryConfig.create(query, explainOptions, Arrays.asList(readOptions)); + return this.protoPreparer.prepare(queryConfig); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/QueryExecutor.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/QueryExecutor.java new file mode 100644 index 000000000000..c6fe1b64ad6e --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/QueryExecutor.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.execution; + +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.models.ExplainOptions; + +/** + * An internal functional interface whose implementation has the responsibility to execute a {@link + * Query} and returns the result. This class will have the responsibility to orchestrate between + * {@link com.google.cloud.datastore.execution.request.ProtoPreparer}, {@link + * com.google.cloud.datastore.spi.v1.DatastoreRpc} and {@link + * com.google.cloud.datastore.execution.response.ResponseTransformer} layers. + * + * @param A {@link Query} to execute. + * @param the type of result produced by Query. + */ +@InternalApi +public interface QueryExecutor, OUTPUT> { + + /** + * @param query A {@link Query} to execute. + * @param explainOptions {@link com.google.cloud.datastore.models.ExplainOptions}s to be used when + * executing {@link Query}. + * @param readOptions Optional {@link ReadOption}s to be used when executing {@link Query}. + */ + OUTPUT execute(INPUT query, ExplainOptions explainOptions, ReadOption... readOptions); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/request/AggregationQueryRequestProtoPreparer.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/request/AggregationQueryRequestProtoPreparer.java new file mode 100644 index 000000000000..9d8120314ec8 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/request/AggregationQueryRequestProtoPreparer.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. + */ +package com.google.cloud.datastore.execution.request; + +import static com.google.cloud.datastore.AggregationQuery.Mode.GQL; + +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.GqlQueryProtoPreparer; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.ReadOption.QueryConfig; +import com.google.cloud.datastore.ReadOptionProtoPreparer; +import com.google.cloud.datastore.StructuredQueryProtoPreparer; +import com.google.cloud.datastore.aggregation.Aggregation; +import com.google.common.base.MoreObjects; +import com.google.datastore.v1.GqlQuery; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.Query; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.RunAggregationQueryRequest; +import java.util.List; +import java.util.Optional; + +@InternalApi +public class AggregationQueryRequestProtoPreparer + implements ProtoPreparer, RunAggregationQueryRequest> { + + private final DatastoreOptions datastoreOptions; + private final StructuredQueryProtoPreparer structuredQueryProtoPreparer; + private final GqlQueryProtoPreparer gqlQueryProtoPreparer; + private final ReadOptionProtoPreparer readOptionProtoPreparer; + + public AggregationQueryRequestProtoPreparer(DatastoreOptions datastoreOptions) { + this.datastoreOptions = datastoreOptions; + this.structuredQueryProtoPreparer = new StructuredQueryProtoPreparer(); + this.gqlQueryProtoPreparer = new GqlQueryProtoPreparer(); + this.readOptionProtoPreparer = new ReadOptionProtoPreparer(); + } + + @Override + public RunAggregationQueryRequest prepare(QueryConfig queryConfig) { + AggregationQuery aggregationQuery = queryConfig.getQuery(); + List readOptions = queryConfig.getReadOptions(); + PartitionId partitionId = getPartitionId(aggregationQuery); + RunAggregationQueryRequest.Builder aggregationQueryRequestBuilder = + RunAggregationQueryRequest.newBuilder() + .setPartitionId(partitionId) + .setProjectId(datastoreOptions.getProjectId()) + .setDatabaseId(datastoreOptions.getDatabaseId()); + + if (aggregationQuery.getMode() == GQL) { + aggregationQueryRequestBuilder.setGqlQuery(buildGqlQuery(aggregationQuery)); + } else { + aggregationQueryRequestBuilder.setAggregationQuery(getAggregationQuery(aggregationQuery)); + } + if (queryConfig.getExplainOptions() != null) { + aggregationQueryRequestBuilder.setExplainOptions(queryConfig.getExplainOptions()); + } + Optional readOptionsPb = readOptionProtoPreparer.prepare(readOptions); + readOptionsPb.ifPresent(aggregationQueryRequestBuilder::setReadOptions); + return aggregationQueryRequestBuilder.build(); + } + + private GqlQuery buildGqlQuery(AggregationQuery aggregationQuery) { + return gqlQueryProtoPreparer.prepare(aggregationQuery.getNestedGqlQuery()); + } + + private com.google.datastore.v1.AggregationQuery getAggregationQuery( + AggregationQuery aggregationQuery) { + Query nestedQueryProto = + structuredQueryProtoPreparer.prepare(aggregationQuery.getNestedStructuredQuery()); + + com.google.datastore.v1.AggregationQuery.Builder aggregationQueryProtoBuilder = + com.google.datastore.v1.AggregationQuery.newBuilder().setNestedQuery(nestedQueryProto); + for (Aggregation aggregation : aggregationQuery.getAggregations()) { + aggregationQueryProtoBuilder.addAggregations(aggregation.toPb()); + } + return aggregationQueryProtoBuilder.build(); + } + + private PartitionId getPartitionId(AggregationQuery aggregationQuery) { + PartitionId.Builder builder = + PartitionId.newBuilder() + .setProjectId(datastoreOptions.getProjectId()) + .setDatabaseId(datastoreOptions.getDatabaseId()); + String namespace = + MoreObjects.firstNonNull(aggregationQuery.getNamespace(), datastoreOptions.getNamespace()); + builder.setNamespaceId(namespace); + return builder.build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/request/ProtoPreparer.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/request/ProtoPreparer.java new file mode 100644 index 000000000000..946c9072457a --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/request/ProtoPreparer.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.execution.request; + +import com.google.api.core.InternalApi; + +/** + * An internal functional interface whose implementation has the responsibility to populate a Proto + * object from a domain object. + * + * @param the type of domain object. + * @param the type of proto object + */ +@InternalApi +public interface ProtoPreparer { + OUTPUT prepare(INPUT input); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/response/AggregationQueryResponseTransformer.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/response/AggregationQueryResponseTransformer.java new file mode 100644 index 000000000000..cc04a49e3b96 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/response/AggregationQueryResponseTransformer.java @@ -0,0 +1,61 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.execution.response; + +import com.google.api.core.InternalApi; +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.models.ExplainMetrics; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.Value; +import java.util.AbstractMap.SimpleEntry; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.function.Function; +import java.util.stream.Collectors; + +@InternalApi +public class AggregationQueryResponseTransformer + implements ResponseTransformer { + + @Override + public AggregationResults transform(RunAggregationQueryResponse response) { + Timestamp readTime = Timestamp.fromProto(response.getBatch().getReadTime()); + List aggregationResults = + response.getBatch().getAggregationResultsList().stream() + .map(aggregationResult -> new AggregationResult(transformValues(aggregationResult))) + .collect(Collectors.toCollection(LinkedList::new)); + ExplainMetrics explainMetrics = null; + if (response.hasExplainMetrics()) { + explainMetrics = new ExplainMetrics(response.getExplainMetrics()); + } + return new AggregationResults(aggregationResults, readTime, explainMetrics); + } + + private Map> transformValues( + com.google.datastore.v1.AggregationResult aggregationResult) { + return aggregationResult.getAggregatePropertiesMap().entrySet().stream() + .map( + (Function, Entry>>) + entry -> + new SimpleEntry<>( + entry.getKey(), com.google.cloud.datastore.Value.fromPb(entry.getValue()))) + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/response/ResponseTransformer.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/response/ResponseTransformer.java new file mode 100644 index 000000000000..d1f498d8d5b6 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/execution/response/ResponseTransformer.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.execution.response; + +import com.google.api.core.InternalApi; + +/** + * An internal functional interface whose implementation has the responsibility to populate a Domain + * object from a proto response. + * + * @param the type of proto response object. + * @param the type of domain object. + */ +@InternalApi +public interface ResponseTransformer { + OUTPUT transform(INPUT response); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java new file mode 100644 index 000000000000..d8faaa611d18 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExecutionStats.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.models; + +import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; +import com.google.cloud.Structs; +import com.google.common.base.Objects; +import java.util.Map; + +/** Model class for {@link com.google.datastore.v1.ExecutionStats} */ +@BetaApi +public class ExecutionStats { + private final long resultsReturned; + private final java.time.Duration executionDuration; + private final long readOperations; + private final Map debugStats; + + @InternalApi + public ExecutionStats(com.google.datastore.v1.ExecutionStats proto) { + this.resultsReturned = proto.getResultsReturned(); + this.executionDuration = java.time.Duration.ofNanos(proto.getExecutionDuration().getNanos()); + this.readOperations = proto.getReadOperations(); + this.debugStats = Structs.asMap(proto.getDebugStats()); + } + + /** + * Returns the total number of results returned, including documents, projections, aggregation + * results, keys. + */ + public long getResultsReturned() { + return resultsReturned; + } + + /** Returns the debugging statistics from the execution of the query. */ + public Map getDebugStats() { + return debugStats; + } + + /** This method is obsolete. Use {@link #getExecutionDurationJavaTime()} instead. */ + @ObsoleteApi("Use getExecutionDurationJavaTime() instead") + public org.threeten.bp.Duration getExecutionDuration() { + return toThreetenDuration(getExecutionDurationJavaTime()); + } + + /** Returns the total time to execute the query in the backend. */ + public java.time.Duration getExecutionDurationJavaTime() { + return executionDuration; + } + + /** Returns the total billable read operations. */ + public long getReadOperations() { + return readOperations; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ExecutionStats)) { + return false; + } + ExecutionStats that = (ExecutionStats) o; + + return Objects.equal(resultsReturned, that.resultsReturned) + && Objects.equal(executionDuration, that.executionDuration) + && Objects.equal(readOperations, that.readOperations) + && Objects.equal(debugStats, that.debugStats); + } + + @Override + public int hashCode() { + return Objects.hashCode(resultsReturned, executionDuration, readOperations, debugStats); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExplainMetrics.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExplainMetrics.java new file mode 100644 index 000000000000..a4a889ca33fa --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExplainMetrics.java @@ -0,0 +1,63 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.models; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.common.base.Objects; +import java.util.Optional; + +/** Model class for {@link com.google.datastore.v1.ExplainMetrics}. */ +@BetaApi +public class ExplainMetrics { + private final PlanSummary planSummary; + private ExecutionStats executionStats; + + @InternalApi + public ExplainMetrics(com.google.datastore.v1.ExplainMetrics proto) { + if (proto.hasExecutionStats()) { + this.executionStats = new ExecutionStats(proto.getExecutionStats()); + } + this.planSummary = new PlanSummary(proto.getPlanSummary()); + } + + /** Returns the planning phase information for the query. */ + public PlanSummary getPlanSummary() { + return planSummary; + } + + /** + * Returns the aggregated stats from the execution of the query, if present. Only present when + * 'analyze' is set to true for {@link ExplainOptions}. + */ + public Optional getExecutionStats() { + return Optional.ofNullable(executionStats); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ExplainMetrics)) return false; + ExplainMetrics that = (ExplainMetrics) o; + return Objects.equal(planSummary, that.planSummary) + && Objects.equal(executionStats, that.executionStats); + } + + @Override + public int hashCode() { + return Objects.hashCode(planSummary, executionStats); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExplainOptions.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExplainOptions.java new file mode 100644 index 000000000000..065d79c67fa4 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/ExplainOptions.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.models; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Objects; + +/** + * Model class for {@link com.google.datastore.v1.ExplainOptions}. Contains the explain options for + * the query. Analyze is set to 'false' by default. + */ +@BetaApi +public class ExplainOptions { + private final com.google.datastore.v1.ExplainOptions proto; + + private ExplainOptions(com.google.datastore.v1.ExplainOptions proto) { + this.proto = proto; + } + + public static Builder newBuilder() { + return new Builder(); + } + + /** + * Returns whether analyze is set to true or false. 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. + */ + public boolean shouldAnalyze() { + return proto.getAnalyze(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ExplainOptions)) return false; + ExplainOptions that = (ExplainOptions) o; + return proto.equals(that.proto); + } + + @Override + public int hashCode() { + return Objects.hashCode(proto); + } + + @InternalApi + @VisibleForTesting + public com.google.datastore.v1.ExplainOptions toPb() { + return this.proto; + } + + public static class Builder { + private boolean analyze = false; + + /* + * Set 'analyze' to true or false for the explain options. + * 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. + */ + public Builder setAnalyze(boolean analyze) { + this.analyze = analyze; + return this; + } + + public ExplainOptions build() { + return new ExplainOptions( + com.google.datastore.v1.ExplainOptions.newBuilder().setAnalyze(this.analyze).build()); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/PlanSummary.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/PlanSummary.java new file mode 100644 index 000000000000..620b7c3f164d --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/models/PlanSummary.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. + */ +package com.google.cloud.datastore.models; + +import com.google.api.core.BetaApi; +import com.google.api.core.InternalApi; +import com.google.cloud.Structs; +import com.google.common.base.Objects; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** Model class for {@link com.google.datastore.v1.PlanSummary} */ +@BetaApi +public class PlanSummary { + private final List> indexesUsed; + + @InternalApi + public PlanSummary(com.google.datastore.v1.PlanSummary proto) { + this.indexesUsed = + proto.getIndexesUsedList().stream().map(Structs::asMap).collect(Collectors.toList()); + } + + /** Returns the indexes selected for the query. */ + public List> getIndexesUsed() { + return indexesUsed; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof PlanSummary)) return false; + PlanSummary planSummary = (PlanSummary) o; + return Objects.equal(indexesUsed, planSummary.indexesUsed); + } + + @Override + public int hashCode() { + return Objects.hashCode(indexesUsed); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/package-info.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/package-info.java new file mode 100644 index 000000000000..f95d41fad8dc --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/package-info.java @@ -0,0 +1,63 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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. + */ + +/** + * A client for Cloud Datastore – A highly-scalable NoSQL database for web and mobile applications. + * + *

Here's a simple usage example for using google-cloud from App/Compute Engine. This example + * shows how to create a Datastore entity. For the complete source code see + * CreateEntity.java. + * + *

{@code
+ * Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
+ * KeyFactory keyFactory = datastore.newKeyFactory().setKind("keyKind");
+ * Key key = keyFactory.newKey("keyName");
+ * Entity entity = Entity.newBuilder(key)
+ *     .set("name", "John Doe")
+ *     .set("age", 30)
+ *     .set("access_time", Timestamp.now())
+ *     .build();
+ * datastore.put(entity);
+ * }
+ * + *

This second example shows how to get and update a Datastore entity if it exists. For the + * complete source code see + * UpdateEntity.java. + * + *

{@code
+ * Datastore datastore = DatastoreOptions.getDefaultInstance().getService();
+ * KeyFactory keyFactory = datastore.newKeyFactory().setKind("keyKind");
+ * Key key = keyFactory.newKey("keyName");
+ * Entity entity = datastore.get(key);
+ * if (entity != null) {
+ *   System.out.println("Updating access_time for " + entity.getString("name"));
+ *   entity = Entity.newBuilder(entity)
+ *       .set("access_time", Timestamp.now())
+ *       .build();
+ *   datastore.update(entity);
+ * }
+ * }
+ * + *

When using google-cloud from outside of App/Compute Engine, you have to specify a project + * ID and provide + * credentials. + * + * @see Google Cloud Datastore + */ +package com.google.cloud.datastore; diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/DatastoreRpcFactory.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/DatastoreRpcFactory.java new file mode 100644 index 000000000000..ca837030975e --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/DatastoreRpcFactory.java @@ -0,0 +1,28 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.spi; + +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.spi.ServiceRpcFactory; + +/** + * An interface for Datastore RPC factory. Implementation will be loaded via {@link + * java.util.ServiceLoader}. + */ +@InternalExtensionOnly +public interface DatastoreRpcFactory extends ServiceRpcFactory {} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/DatastoreRpc.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/DatastoreRpc.java new file mode 100644 index 000000000000..4f1090bd4be1 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/DatastoreRpc.java @@ -0,0 +1,120 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.spi.v1; + +import com.google.api.core.InternalExtensionOnly; +import com.google.api.gax.rpc.HeaderProvider; +import com.google.cloud.ServiceRpc; +import com.google.cloud.datastore.DatastoreException; +import com.google.cloud.datastore.v1.DatastoreSettings; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; + +/** Provides access to the remote Datastore service. */ +@InternalExtensionOnly +public interface DatastoreRpc extends ServiceRpc, AutoCloseable { + + /** + * Sends an allocate IDs request. + * + * @throws DatastoreException upon failure + */ + AllocateIdsResponse allocateIds(AllocateIdsRequest request); + + /** + * Sends a begin transaction request. + * + * @throws DatastoreException upon failure + */ + BeginTransactionResponse beginTransaction(BeginTransactionRequest request) + throws DatastoreException; + + /** + * Sends a commit request. + * + * @throws DatastoreException upon failure + */ + CommitResponse commit(CommitRequest request); + + /** + * Sends a lookup request. + * + * @throws DatastoreException upon failure + */ + LookupResponse lookup(LookupRequest request); + + /** + * Sends a reserveIds request. + * + * @throws DatastoreException upon failure + */ + ReserveIdsResponse reserveIds(ReserveIdsRequest request); + + /** + * Sends a rollback request. + * + * @throws DatastoreException upon failure + */ + RollbackResponse rollback(RollbackRequest request); + + /** + * Sends a request to run a query. + * + * @throws DatastoreException upon failure + */ + RunQueryResponse runQuery(RunQueryRequest request); + + /** + * Sends a request to run an aggregation query. + * + * @throws DatastoreException upon failure + */ + RunAggregationQueryResponse runAggregationQuery(RunAggregationQueryRequest request); + + @Override + void close() throws Exception; + + /** Returns true if this background resource has been shut down. */ + boolean isClosed(); + + // This class is needed solely to get access to protected method setInternalHeaderProvider() + class DatastoreSettingsBuilder extends DatastoreSettings.Builder { + DatastoreSettingsBuilder(DatastoreSettings settings) { + super(settings); + } + + @Override + protected DatastoreSettings.Builder setInternalHeaderProvider( + HeaderProvider internalHeaderProvider) { + return super.setInternalHeaderProvider(internalHeaderProvider); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/GrpcDatastoreRpc.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/GrpcDatastoreRpc.java new file mode 100644 index 000000000000..ce79ac346bc8 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/GrpcDatastoreRpc.java @@ -0,0 +1,201 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.spi.v1; + +import static com.google.cloud.datastore.DatastoreUtils.isEmulator; +import static com.google.cloud.datastore.DatastoreUtils.removeScheme; +import static com.google.cloud.datastore.spi.v1.RpcUtils.retrySettingSetter; +import static java.util.concurrent.TimeUnit.SECONDS; + +import com.google.api.core.InternalApi; +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.core.GaxProperties; +import com.google.api.gax.grpc.ChannelPoolSettings; +import com.google.api.gax.grpc.GrpcCallContext; +import com.google.api.gax.grpc.GrpcTransportChannel; +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.TransportChannel; +import com.google.cloud.ServiceOptions; +import com.google.cloud.datastore.DatastoreException; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.v1.DatastoreSettings; +import com.google.cloud.datastore.v1.stub.DatastoreStubSettings; +import com.google.cloud.datastore.v1.stub.GrpcDatastoreStub; +import com.google.cloud.grpc.GrpcTransportOptions; +import com.google.common.base.Strings; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import io.grpc.CallOptions; +import io.grpc.ManagedChannel; +import io.grpc.ManagedChannelBuilder; +import java.io.IOException; +import java.util.Collections; + +@InternalApi +public class GrpcDatastoreRpc implements DatastoreRpc { + + private final GrpcDatastoreStub datastoreStub; + private final ClientContext clientContext; + private boolean closed; + + public GrpcDatastoreRpc(DatastoreOptions datastoreOptions) throws IOException { + try { + clientContext = + isEmulator(datastoreOptions) + ? getClientContextForEmulator(datastoreOptions) + : getClientContext(datastoreOptions); + + /* For grpc transport options, configure default gRPC Connection pool with minChannelCount = 1 */ + DatastoreStubSettings datastoreStubSettings = + DatastoreStubSettings.newBuilder(clientContext) + .applyToAllUnaryMethods(retrySettingSetter(datastoreOptions)) + .setTransportChannelProvider( + DatastoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelPoolSettings( + ChannelPoolSettings.builder() + .setInitialChannelCount(DatastoreOptions.INIT_CHANNEL_COUNT) + .setMinChannelCount(DatastoreOptions.MIN_CHANNEL_COUNT) + .build()) + .build()) + .build(); + datastoreStub = GrpcDatastoreStub.create(datastoreStubSettings); + } catch (IOException e) { + throw new IOException(e); + } + } + + @Override + public void close() throws Exception { + if (!closed) { + datastoreStub.close(); + for (BackgroundResource resource : clientContext.getBackgroundResources()) { + resource.close(); + } + closed = true; + } + for (BackgroundResource resource : clientContext.getBackgroundResources()) { + resource.awaitTermination(1, SECONDS); + } + } + + @Override + public AllocateIdsResponse allocateIds(AllocateIdsRequest request) { + return datastoreStub.allocateIdsCallable().call(request); + } + + @Override + public BeginTransactionResponse beginTransaction(BeginTransactionRequest request) + throws DatastoreException { + return datastoreStub.beginTransactionCallable().call(request); + } + + @Override + public CommitResponse commit(CommitRequest request) { + return datastoreStub.commitCallable().call(request); + } + + @Override + public LookupResponse lookup(LookupRequest request) { + return datastoreStub.lookupCallable().call(request); + } + + @Override + public ReserveIdsResponse reserveIds(ReserveIdsRequest request) { + return datastoreStub.reserveIdsCallable().call(request); + } + + @Override + public RollbackResponse rollback(RollbackRequest request) { + return datastoreStub.rollbackCallable().call(request); + } + + @Override + public RunQueryResponse runQuery(RunQueryRequest request) { + return datastoreStub.runQueryCallable().call(request); + } + + @Override + public RunAggregationQueryResponse runAggregationQuery(RunAggregationQueryRequest request) { + return datastoreStub.runAggregationQueryCallable().call(request); + } + + @Override + public boolean isClosed() { + return closed && datastoreStub.isShutdown(); + } + + private ClientContext getClientContextForEmulator(DatastoreOptions datastoreOptions) + throws IOException { + ManagedChannel managedChannel = + ManagedChannelBuilder.forTarget(removeScheme(datastoreOptions.getHost())) + .usePlaintext() + .build(); + TransportChannel transportChannel = GrpcTransportChannel.create(managedChannel); + return ClientContext.newBuilder() + .setCredentials(null) + .setTransportChannel(transportChannel) + .setDefaultCallContext(GrpcCallContext.of(managedChannel, CallOptions.DEFAULT)) + .setBackgroundResources(Collections.singletonList(transportChannel)) + .build(); + } + + private ClientContext getClientContext(DatastoreOptions datastoreOptions) throws IOException { + HeaderProvider internalHeaderProvider = + DatastoreSettings.defaultApiClientHeaderProviderBuilder() + .setClientLibToken( + ServiceOptions.getGoogApiClientLibName(), + GaxProperties.getLibraryVersion(datastoreOptions.getClass())) + .setResourceToken(getResourceToken(datastoreOptions)) + .build(); + + DatastoreSettingsBuilder settingsBuilder = + new DatastoreSettingsBuilder(DatastoreSettings.newBuilder().build()); + settingsBuilder.setCredentialsProvider( + GrpcTransportOptions.setUpCredentialsProvider(datastoreOptions)); + settingsBuilder.setTransportChannelProvider(datastoreOptions.getTransportChannelProvider()); + settingsBuilder.setInternalHeaderProvider(internalHeaderProvider); + settingsBuilder.setHeaderProvider( + datastoreOptions.getMergedHeaderProvider(new NoHeaderProvider())); + return ClientContext.create(settingsBuilder.build()); + } + + private String getResourceToken(DatastoreOptions datastoreOptions) { + StringBuilder builder = new StringBuilder("project_id="); + builder.append(datastoreOptions.getProjectId()); + if (!Strings.isNullOrEmpty(datastoreOptions.getDatabaseId())) { + builder.append("&database_id="); + builder.append(datastoreOptions.getDatabaseId()); + } + return builder.toString(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/HttpDatastoreRpc.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/HttpDatastoreRpc.java new file mode 100644 index 000000000000..493064526d7c --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/HttpDatastoreRpc.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 + * + * 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.datastore.spi.v1; + +import com.google.api.client.http.HttpRequest; +import com.google.api.client.http.HttpRequestInitializer; +import com.google.api.client.http.HttpTransport; +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.DatastoreException; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.http.CensusHttpModule; +import com.google.cloud.http.HttpTransportOptions; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import io.opencensus.trace.Tracing; +import java.io.IOException; +import java.net.InetAddress; +import java.net.URL; + +@InternalApi +public class HttpDatastoreRpc implements DatastoreRpc { + + private final com.google.datastore.v1.client.Datastore client; + + public HttpDatastoreRpc(DatastoreOptions options) { + HttpTransportOptions httpTransportOptions = + (HttpTransportOptions) options.getTransportOptions(); + HttpTransport transport = httpTransportOptions.getHttpTransportFactory().create(); + com.google.datastore.v1.client.DatastoreOptions.Builder clientBuilder = + new com.google.datastore.v1.client.DatastoreOptions.Builder() + .projectId(options.getProjectId()) + .initializer(getHttpRequestInitializer(options, httpTransportOptions)) + .transport(transport); + String normalizedHost = options.getHost() != null ? options.getHost().toLowerCase() : ""; + + if (isLocalHost(normalizedHost)) { + clientBuilder = clientBuilder.localHost(removeScheme(normalizedHost)); + } else if (!removeScheme(com.google.datastore.v1.client.DatastoreFactory.DEFAULT_HOST) + .equals(removeScheme(normalizedHost)) + && !normalizedHost.isEmpty()) { + String fullUrl = normalizedHost; + if (fullUrl.charAt(fullUrl.length() - 1) != '/') { + fullUrl = fullUrl + '/'; + } + fullUrl = + fullUrl + + com.google.datastore.v1.client.DatastoreFactory.VERSION + + "/projects/" + + options.getProjectId(); + clientBuilder = clientBuilder.projectId(null).projectEndpoint(fullUrl); + } + client = com.google.datastore.v1.client.DatastoreFactory.get().create(clientBuilder.build()); + } + + private HttpRequestInitializer getHttpRequestInitializer( + final DatastoreOptions options, HttpTransportOptions httpTransportOptions) { + // Open Census initialization + CensusHttpModule censusHttpModule = new CensusHttpModule(Tracing.getTracer(), true); + final HttpRequestInitializer censusHttpModuleHttpRequestInitializer = + censusHttpModule.getHttpRequestInitializer( + httpTransportOptions.getHttpRequestInitializer(options)); + + final String applicationName = options.getApplicationName(); + return new HttpRequestInitializer() { + @Override + public void initialize(HttpRequest httpRequest) throws IOException { + censusHttpModuleHttpRequestInitializer.initialize(httpRequest); + httpRequest.getHeaders().setUserAgent(applicationName); + } + }; + } + + private static boolean isLocalHost(String host) { + if (!host.isEmpty()) { + try { + String normalizedHost = "http://" + removeScheme(host); + InetAddress hostAddr = InetAddress.getByName(new URL(normalizedHost).getHost()); + return hostAddr.isAnyLocalAddress() || hostAddr.isLoopbackAddress(); + } catch (Exception e) { + // ignore + } + } + return false; + } + + private static String removeScheme(String url) { + if (url != null) { + if (url.startsWith("https://")) { + return url.substring("https://".length()); + } else if (url.startsWith("http://")) { + return url.substring("http://".length()); + } + } + return url; + } + + private static DatastoreException translate( + com.google.datastore.v1.client.DatastoreException exception) { + return translate(exception, true); + } + + private static DatastoreException translate( + com.google.datastore.v1.client.DatastoreException exception, boolean idempotent) { + String reason = ""; + if (exception.getCode() != null) { + reason = exception.getCode().name(); + } + if (reason.isEmpty()) { + if (exception.getCause() instanceof IOException) { + return new DatastoreException((IOException) exception.getCause()); + } + } + return new DatastoreException( + exception.getCode().getNumber(), exception.getMessage(), reason, idempotent, exception); + } + + @Override + public AllocateIdsResponse allocateIds(AllocateIdsRequest request) { + try { + return client.allocateIds(request); + } catch (com.google.datastore.v1.client.DatastoreException ex) { + throw translate(ex); + } + } + + @Override + public BeginTransactionResponse beginTransaction(BeginTransactionRequest request) { + try { + return client.beginTransaction(request); + } catch (com.google.datastore.v1.client.DatastoreException ex) { + throw translate(ex); + } + } + + @Override + public CommitResponse commit(CommitRequest request) { + try { + return client.commit(request); + } catch (com.google.datastore.v1.client.DatastoreException ex) { + throw translate(ex, request.getMode() == CommitRequest.Mode.NON_TRANSACTIONAL); + } + } + + @Override + public LookupResponse lookup(LookupRequest request) { + try { + return client.lookup(request); + } catch (com.google.datastore.v1.client.DatastoreException ex) { + throw translate(ex); + } + } + + @Override + public ReserveIdsResponse reserveIds(ReserveIdsRequest request) { + try { + return client.reserveIds(request); + } catch (com.google.datastore.v1.client.DatastoreException ex) { + throw translate(ex); + } + } + + @Override + public RollbackResponse rollback(RollbackRequest request) { + try { + return client.rollback(request); + } catch (com.google.datastore.v1.client.DatastoreException ex) { + throw translate(ex); + } + } + + @Override + public RunQueryResponse runQuery(RunQueryRequest request) { + try { + return client.runQuery(request); + } catch (com.google.datastore.v1.client.DatastoreException ex) { + throw translate(ex); + } + } + + @Override + public RunAggregationQueryResponse runAggregationQuery(RunAggregationQueryRequest request) { + try { + return client.runAggregationQuery(request); + } catch (com.google.datastore.v1.client.DatastoreException ex) { + throw translate(ex); + } + } + + @Override + public void close() throws Exception { + throw new UnsupportedOperationException("Not implemented."); + } + + @Override + public boolean isClosed() { + throw new UnsupportedOperationException("Not implemented."); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/RpcUtils.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/RpcUtils.java new file mode 100644 index 000000000000..5649a42120f9 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/spi/v1/RpcUtils.java @@ -0,0 +1,34 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.spi.v1; + +import com.google.api.core.ApiFunction; +import com.google.api.core.InternalApi; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.datastore.DatastoreOptions; + +@InternalApi +public class RpcUtils { + @InternalApi + static ApiFunction, Void> retrySettingSetter( + DatastoreOptions datastoreOptions) { + return builder -> { + builder.setRetrySettings(datastoreOptions.getRetrySettings()); + return null; + }; + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/DisabledTraceUtil.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/DisabledTraceUtil.java new file mode 100644 index 000000000000..259048e8e059 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/DisabledTraceUtil.java @@ -0,0 +1,131 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.telemetry; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalApi; +import com.google.cloud.datastore.telemetry.TraceUtil.Context; +import io.grpc.ManagedChannelBuilder; +import io.opentelemetry.api.trace.Span; +import io.opentelemetry.api.trace.SpanBuilder; +import io.opentelemetry.api.trace.Tracer; +import io.opentelemetry.api.trace.TracerProvider; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** + * Tracing utility implementation, used to stub out tracing instrumentation when tracing is + * disabled. + */ +@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; + } + + public io.opentelemetry.api.trace.Span getSpan() { + return null; + } + + @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.Span parentSpan) { + return new Span(); + } + + public SpanBuilder addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder) { + return getTracer().spanBuilder("TRACING_DISABLED_NO_OP"); + } + + @Nonnull + @Override + public TraceUtil.Span getCurrentSpan() { + return new Span(); + } + + @Nonnull + @Override + public TraceUtil.Context getCurrentContext() { + return new Context(); + } + + @Override + public Tracer getTracer() { + return TracerProvider.noop().get(LIBRARY_NAME); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/EnabledTraceUtil.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/EnabledTraceUtil.java new file mode 100644 index 000000000000..5d0fb8c7c927 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/EnabledTraceUtil.java @@ -0,0 +1,343 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.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.datastore.DatastoreOptions; +import com.google.cloud.datastore.telemetry.TraceUtil.Context; +import com.google.cloud.datastore.telemetry.TraceUtil.Scope; +import com.google.cloud.datastore.telemetry.TraceUtil.Span; +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; + +/** + * Tracing utility implementation, used to stub out tracing instrumentation when tracing is enabled. + */ +@InternalApi +public class EnabledTraceUtil implements TraceUtil { + private final Tracer tracer; + private final OpenTelemetry openTelemetry; + private final DatastoreOptions datastoreOptions; + + EnabledTraceUtil(DatastoreOptions datastoreOptions) { + OpenTelemetry openTelemetry = datastoreOptions.getOpenTelemetryOptions().getOpenTelemetry(); + + // If tracing is enabled, but an OpenTelemetry instance is not provided, fall back + // to using GlobalOpenTelemetry. + if (openTelemetry == null) { + openTelemetry = GlobalOpenTelemetry.get(); + } + + this.datastoreOptions = datastoreOptions; + this.openTelemetry = openTelemetry; + 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(); + } + + 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; + } + + @Override + public io.opentelemetry.api.trace.Span getSpan() { + return this.span; + } + + /** 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() { + try (io.opentelemetry.context.Scope scope = span.makeCurrent()) { + return new Scope(scope); + } + } + } + + 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() { + try (io.opentelemetry.context.Scope scope = context.makeCurrent()) { + return new Scope(scope); + } + } + } + + /** Applies the current Datastore instance settings as attributes to the current Span */ + @Override + public SpanBuilder addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder) { + spanBuilder = + spanBuilder.setAllAttributes( + Attributes.builder() + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.databaseId", + datastoreOptions.getDatabaseId()) + .put(ATTRIBUTE_SERVICE_PREFIX + "settings.host", datastoreOptions.getHost()) + .build()); + + if (datastoreOptions.getCredentials() != null) { + spanBuilder = + spanBuilder.setAttribute( + ATTRIBUTE_SERVICE_PREFIX + "settings.credentials.authenticationType", + datastoreOptions.getCredentials().getAuthenticationType()); + } + + if (datastoreOptions.getRetrySettings() != null) { + spanBuilder = + spanBuilder.setAllAttributes( + Attributes.builder() + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.initialRetryDelay", + datastoreOptions.getRetrySettings().getInitialRetryDelay().toString()) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.maxRetryDelay", + datastoreOptions.getRetrySettings().getMaxRetryDelay().toString()) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.retryDelayMultiplier", + String.valueOf(datastoreOptions.getRetrySettings().getRetryDelayMultiplier())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.maxAttempts", + String.valueOf(datastoreOptions.getRetrySettings().getMaxAttempts())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.initialRpcTimeout", + datastoreOptions.getRetrySettings().getInitialRpcTimeout().toString()) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.maxRpcTimeout", + datastoreOptions.getRetrySettings().getMaxRpcTimeout().toString()) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.rpcTimeoutMultiplier", + String.valueOf(datastoreOptions.getRetrySettings().getRpcTimeoutMultiplier())) + .put( + ATTRIBUTE_SERVICE_PREFIX + "settings.retrySettings.totalTimeout", + datastoreOptions.getRetrySettings().getTotalTimeout().toString()) + .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 + "memoryUtilization", + 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.Span parentSpan) { + SpanBuilder spanBuilder = + tracer + .spanBuilder(spanName) + .setSpanKind(SpanKind.PRODUCER) + .setParent(io.opentelemetry.context.Context.current().with(parentSpan.getSpan())); + return new Span(addSettingsAttributesToCurrentSpan(spanBuilder).startSpan(), spanName); + } + + @Nonnull + @Override + public TraceUtil.Span getCurrentSpan() { + return new Span(io.opentelemetry.api.trace.Span.current(), ""); + } + + @Nonnull + @Override + public TraceUtil.Context getCurrentContext() { + return new Context(io.opentelemetry.context.Context.current()); + } + + @Override + public Tracer getTracer() { + return this.tracer; + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/TraceUtil.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/TraceUtil.java new file mode 100644 index 000000000000..7fcd935775b1 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/telemetry/TraceUtil.java @@ -0,0 +1,167 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.telemetry; + +import com.google.api.core.ApiFunction; +import com.google.api.core.ApiFuture; +import com.google.api.core.InternalExtensionOnly; +import com.google.cloud.datastore.DatastoreOptions; +import io.grpc.ManagedChannelBuilder; +import io.opentelemetry.api.trace.SpanBuilder; +import io.opentelemetry.api.trace.Tracer; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; + +/** Utility interface to manage OpenTelemetry tracing instrumentation based on the configuration. */ +@InternalExtensionOnly +public interface TraceUtil { + static final String ATTRIBUTE_SERVICE_PREFIX = "gcp.datastore."; + static final String ENABLE_TRACING_ENV_VAR = "DATASTORE_ENABLE_TRACING"; + static final String LIBRARY_NAME = "com.google.cloud.datastore"; + static final String SPAN_NAME_LOOKUP = "Lookup"; + static final String SPAN_NAME_ALLOCATE_IDS = "AllocateIds"; + static final String SPAN_NAME_RESERVE_IDS = "ReserveIds"; + static final String SPAN_NAME_COMMIT = "Commit"; + static final String SPAN_NAME_RUN_QUERY = "RunQuery"; + static final String SPAN_NAME_RUN_AGGREGATION_QUERY = "RunAggregationQuery"; + static final String SPAN_NAME_TRANSACTION_RUN = "Transaction.Run"; + static final String SPAN_NAME_BEGIN_TRANSACTION = "Transaction.Begin"; + static final String SPAN_NAME_TRANSACTION_LOOKUP = "Transaction.Lookup"; + static final String SPAN_NAME_TRANSACTION_COMMIT = "Transaction.Commit"; + static final String SPAN_NAME_TRANSACTION_RUN_QUERY = "Transaction.RunQuery"; + static final String SPAN_NAME_ROLLBACK = "Transaction.Rollback"; + static final String SPAN_NAME_TRANSACTION_RUN_AGGREGATION_QUERY = + "Transaction.RunAggregationQuery"; + static final String ATTRIBUTES_KEY_DOCUMENT_COUNT = "doc_count"; + static final String ATTRIBUTES_KEY_TRANSACTIONAL = "transactional"; + static final String ATTRIBUTES_KEY_TRANSACTION_ID = "transaction_id"; + static final String ATTRIBUTES_KEY_READ_CONSISTENCY = "read_consistency"; + static final String ATTRIBUTES_KEY_RECEIVED = "Received"; + static final String ATTRIBUTES_KEY_MISSING = "Missing"; + static final String ATTRIBUTES_KEY_DEFERRED = "Deferred"; + static final String ATTRIBUTES_KEY_MORE_RESULTS = "mor_results"; + + /** + * Creates and returns an instance of the TraceUtil class. + * + * @param datastoreOptions The DatastoreOptions object that is requesting an instance of + * TraceUtil. + * @return An instance of the TraceUtil class. + */ + static TraceUtil getInstance(@Nonnull DatastoreOptions datastoreOptions) { + boolean createEnabledInstance = datastoreOptions.getOpenTelemetryOptions().isEnabled(); + + // 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(datastoreOptions); + } 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); + + io.opentelemetry.api.trace.Span getSpan(); + + /** 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 span represented by the parentSpan as its parent, + * sets it as the current span and returns it. + */ + Span startSpan(String spanName, Span parentSpan); + + /** + * Adds common SpanAttributes to the current span, useful when hand-creating a new Span without + * using the TraceUtil.Span interface. + */ + SpanBuilder addSettingsAttributesToCurrentSpan(SpanBuilder spanBuilder); + + /** Returns the current span. */ + @Nonnull + Span getCurrentSpan(); + + /** Returns the current Context. */ + @Nonnull + Context getCurrentContext(); + + /** Returns the current OpenTelemetry Tracer when OpenTelemetry SDK is provided. */ + Tracer getTracer(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java new file mode 100644 index 000000000000..e2ec33f68615 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/LocalDatastoreHelper.java @@ -0,0 +1,413 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.testing; + +import static com.google.api.gax.util.TimeConversionUtils.toJavaTimeDuration; +import static com.google.common.base.MoreObjects.firstNonNull; + +import com.google.api.core.InternalApi; +import com.google.api.core.ObsoleteApi; +import com.google.cloud.NoCredentials; +import com.google.cloud.ServiceOptions; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.grpc.GrpcTransportOptions; +import com.google.cloud.testing.BaseEmulatorHelper; +import com.google.common.collect.ImmutableList; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.nio.file.FileVisitResult; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.SimpleFileVisitor; +import java.nio.file.attribute.BasicFileAttributes; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; +import java.util.concurrent.TimeoutException; +import java.util.logging.Logger; + +/** + * Utility to start and stop local Google Cloud Datastore emulators. + * + *

This class is unstable. + */ +@InternalApi +public class LocalDatastoreHelper extends BaseEmulatorHelper { + + private final List emulatorRunners; + private final double consistency; + private final Path gcdPath; + private boolean storeOnDisk; + private boolean firestoreInDatastoreMode; + + // Gcloud emulator settings + private static final String GCLOUD_CMD_TEXT = "gcloud beta emulators datastore start"; + private static final String GCLOUD_CMD_PORT_FLAG = "--host-port="; + private static final String VERSION_PREFIX = "cloud-datastore-emulator "; + private static final String MIN_VERSION = "2.3.1"; + + // Downloadable emulator settings + private static final String BIN_NAME = "cloud-datastore-emulator/cloud_datastore_emulator"; + private static final String FILENAME = "cloud-datastore-emulator-" + MIN_VERSION + ".zip"; + private static final String MD5_CHECKSUM = "e0d1170519cf52e2e5f9f93892cdf70c"; + private static final String BIN_CMD_PORT_FLAG = "--port="; + private static final URL EMULATOR_URL; + private static final String EMULATOR_URL_ENV_VAR = "DATASTORE_EMULATOR_URL"; + private static final String ACCESS_TOKEN = System.getenv("DATASTORE_EMULATOR_ACCESS_TOKEN"); + + // Common settings + private static final String CONSISTENCY_FLAG = "--consistency="; + private static final String PROJECT_FLAG = "--project="; + private static final double DEFAULT_CONSISTENCY = 0.9; + private static final String DEFAULT_PROJECT_ID = PROJECT_ID_PREFIX + UUID.randomUUID(); + private static final String FIRESTORE_IN_DATASTORE_MODE_FLAG = + "--use-firestore-in-datastore-mode"; + + private static final Logger LOGGER = Logger.getLogger(LocalDatastoreHelper.class.getName()); + + static { + try { + if (System.getenv(EMULATOR_URL_ENV_VAR) == null) { + EMULATOR_URL = new URL("http://storage.googleapis.com/gcd/tools/" + FILENAME); + } else { + EMULATOR_URL = new URL(System.getenv(EMULATOR_URL_ENV_VAR)); + } + } catch (MalformedURLException ex) { + throw new IllegalStateException(ex); + } + } + + private final DatastoreOptions.Builder optionsBuilder = + DatastoreOptions.newBuilder() + .setProjectId(getProjectId()) + .setHost(DEFAULT_HOST + ":" + getPort()) + .setCredentials(NoCredentials.getInstance()) + .setRetrySettings(ServiceOptions.getNoRetrySettings()); + + /** A builder for {@code LocalDatastoreHelper} objects. */ + public static class Builder { + private double consistency; + private int port; + private Path dataDir; + private boolean storeOnDisk = true; + private boolean firestoreInDatastoreMode = false; + private String projectId; + + private Builder() {} + + private Builder(LocalDatastoreHelper helper) { + this.consistency = helper.consistency; + this.dataDir = helper.gcdPath; + this.storeOnDisk = helper.storeOnDisk; + this.firestoreInDatastoreMode = helper.firestoreInDatastoreMode; + } + + public Builder setConsistency(double consistency) { + this.consistency = consistency; + return this; + } + + public Builder setPort(int port) { + this.port = port; + return this; + } + + public Builder setProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public Builder setDataDir(Path dataDir) { + this.dataDir = dataDir; + return this; + } + + public Builder setStoreOnDisk(boolean storeOnDisk) { + this.storeOnDisk = storeOnDisk; + return this; + } + + public Builder setFirestoreInDatastoreMode(boolean firestoreInDatastoreMode) { + this.firestoreInDatastoreMode = firestoreInDatastoreMode; + return this; + } + + /** Creates a {@code LocalDatastoreHelper} object. */ + public LocalDatastoreHelper build() { + return new LocalDatastoreHelper(this); + } + } + + private LocalDatastoreHelper(Builder builder) { + super( + "datastore", + builder.port > 0 ? builder.port : BaseEmulatorHelper.findAvailablePort(DEFAULT_PORT), + firstNonNull(builder.projectId, DEFAULT_PROJECT_ID)); + String projectId = firstNonNull(builder.projectId, DEFAULT_PROJECT_ID); + this.consistency = builder.consistency > 0 ? builder.consistency : DEFAULT_CONSISTENCY; + this.gcdPath = builder.dataDir; + this.storeOnDisk = builder.storeOnDisk; + this.firestoreInDatastoreMode = builder.firestoreInDatastoreMode; + String binName = BIN_NAME; + if (isWindows()) { + binName = BIN_NAME.replace("/", "\\"); + } + List gcloudCommand = new ArrayList<>(Arrays.asList(GCLOUD_CMD_TEXT.split(" "))); + gcloudCommand.add(GCLOUD_CMD_PORT_FLAG + "localhost:" + getPort()); + gcloudCommand.add(PROJECT_FLAG + projectId); + if (builder.firestoreInDatastoreMode) { + gcloudCommand.add(FIRESTORE_IN_DATASTORE_MODE_FLAG); + } else { + // At most one of --consistency | --use-firestore-in-datastore-mode can be specified. + // --consistency will be ignored with --use-firestore-in-datastore-mode. + gcloudCommand.add(CONSISTENCY_FLAG + builder.consistency); + } + if (!builder.storeOnDisk) { + gcloudCommand.add("--no-store-on-disk"); + } + if (builder.dataDir != null) { + gcloudCommand.add("--data-dir=" + getGcdPath()); + } + GcloudEmulatorRunner gcloudRunner = + new GcloudEmulatorRunner(gcloudCommand, VERSION_PREFIX, MIN_VERSION); + List binCommand = new ArrayList<>(Arrays.asList(binName, "start")); + binCommand.add("--testing"); + if (builder.firestoreInDatastoreMode) { + // Downloadable emulator runner takes the flag in a different + // format: --firestore_in_datastore_mode + binCommand.add("--firestore_in_datastore_mode"); + } else { + // At most one of --consistency | --firestore_in_datastore_mode can be specified. + // --consistency will be ignored with --firestore_in_datastore_mode. + binCommand.add(CONSISTENCY_FLAG + getConsistency()); + } + binCommand.add(BIN_CMD_PORT_FLAG + getPort()); + DownloadableEmulatorRunner downloadRunner = + new DownloadableEmulatorRunner(binCommand, EMULATOR_URL, MD5_CHECKSUM, ACCESS_TOKEN); + this.emulatorRunners = ImmutableList.of(gcloudRunner, downloadRunner); + } + + /** Returns a builder for {@code LocalDatastoreHelper} object. */ + public LocalDatastoreHelper.Builder toBuilder() { + return new Builder(this); + } + + /** Returns a builder for {@code LocalDatastoreHelper} object. */ + public static LocalDatastoreHelper.Builder newBuilder() { + return new LocalDatastoreHelper.Builder(); + } + + @Override + protected List getEmulatorRunners() { + return emulatorRunners; + } + + @Override + protected Logger getLogger() { + return LOGGER; + } + + /** + * Returns a {@link DatastoreOptions} instance that sets the host to use the Datastore emulator on + * localhost. + */ + @Override + public DatastoreOptions getOptions() { + return optionsBuilder.build(); + } + + /** + * Returns a {@link DatastoreOptions} instance that sets the host to use the Datastore emulator on + * localhost. The default namespace is set to {@code namespace}. + * + *

Please use setNamespace and then build() instead. + */ + public DatastoreOptions getOptions(String namespace) { + return optionsBuilder.setNamespace(namespace).build(); + } + + /** + * Returns a {@link DatastoreOptions} instance that sets the host to use the Datastore emulator on + * localhost. The transportOptions is set to {@code grpcTransportOptions}. + */ + public DatastoreOptions getGrpcTransportOptions(GrpcTransportOptions grpcTransportOptions) { + return optionsBuilder.setTransportOptions(grpcTransportOptions).build(); + } + + public DatastoreOptions.Builder setNamespace(String namespace) { + return optionsBuilder.setNamespace(namespace); + } + + /** Returns the consistency setting for the local Datastore emulator. */ + public double getConsistency() { + return consistency; + } + + /** Returns the data directory path of the local Datastore emulator. */ + public Path getGcdPath() { + return gcdPath; + } + + /** Returns {@code true} data persist on disk, otherwise {@code false} data not store on disk. */ + public boolean isStoreOnDisk() { + return storeOnDisk; + } + + /** + * Returns {@code true} use firestore-in-datastore-mode, otherwise {@code false} use native mode. + */ + public boolean isFirestoreInDatastoreMode() { + return firestoreInDatastoreMode; + } + + /** + * Creates a local Datastore helper with the specified settings for project ID and consistency. + * + * @param consistency the fraction of Datastore writes that are immediately visible to global + * queries, with 0.0 meaning no writes are immediately visible and 1.0 meaning all writes are + * immediately visible. Note that setting this to 1.0 may mask incorrect assumptions about the + * consistency of non-ancestor queries; non-ancestor queries are eventually consistent. + */ + public static LocalDatastoreHelper create(double consistency) { + return LocalDatastoreHelper.newBuilder().setConsistency(consistency).setPort(0).build(); + } + + /** + * Creates a local Datastore helper with the specified settings for project ID and consistency. + * + * @param consistency the fraction of Datastore writes that are immediately visible to global + * queries, with 0.0 meaning no writes are immediately visible and 1.0 meaning all writes are + * immediately visible. Note that setting this to 1.0 may mask incorrect assumptions about the + * consistency of non-ancestor queries; non-ancestor queries are eventually consistent. + * @param port the port to be used to start the emulator service. Note that setting this to 0 the + * emulator will search for a free random port. + */ + public static LocalDatastoreHelper create(double consistency, int port) { + return LocalDatastoreHelper.newBuilder().setConsistency(consistency).setPort(port).build(); + } + + /** + * Creates a local Datastore helper with a placeholder project ID and the default consistency + * setting of 0.9. + * + * @param port the port to be used to start the emulator service. Note that setting this to 0 the + * emulator will search for a free random port. + */ + public static LocalDatastoreHelper create(int port) { + return LocalDatastoreHelper.newBuilder() + .setConsistency(DEFAULT_CONSISTENCY) + .setPort(port) + .build(); + } + + /** + * Creates a local Datastore helper with a placeholder project ID and the default consistency + * setting of 0.9. Consistency refers to the fraction of Datastore writes that are immediately + * visible to global queries, with 0.0 meaning no writes are immediately visible and 1.0 meaning + * all writes are immediately visible. + */ + public static LocalDatastoreHelper create() { + return LocalDatastoreHelper.newBuilder().setConsistency(DEFAULT_CONSISTENCY).build(); + } + + /** + * Starts the local Datastore emulator through {@code gcloud}, downloads and caches the zip file + * if user does not have {@code gcloud} or a compatible emulator version installed. + * + *

Currently the emulator does not persist any state across runs. + */ + @Override + public void start() throws IOException, InterruptedException { + String blockUntilOutput = "Dev App Server is now running"; + startProcess(blockUntilOutput); + } + + /** + * Resets the internal state of the Datastore emulator. + * + *

When running tests, one might {@code reset()} before each test, so earlier tests would not + * affect later ones. + */ + @Override + public void reset() throws IOException { + sendPostRequest("/reset"); + } + + /** This method is obsolete. Use {@link #stopDuration(java.time.Duration)} instead */ + @ObsoleteApi("Use stopDuration(java.time.Duration) instead") + @Override + public void stop(org.threeten.bp.Duration timeout) + throws IOException, InterruptedException, TimeoutException { + stopDuration(toJavaTimeDuration(timeout)); + } + + /** + * Stops the Datastore emulator. + * + *

It is important to stop the emulator. Since the emulator runs in its own process, not + * stopping it might cause it to become orphan. + * + *

It is not required to call {@link #reset()} before {@code stop}. + * + * @param timeout The duration to wait for the emulator process to stop. It is recommended to set + * this value high to ensure proper shutdown, like 5 seconds or more. + */ + @Override + public void stopDuration(java.time.Duration timeout) + throws IOException, InterruptedException, TimeoutException { + sendPostRequest("/shutdown"); + waitForProcessDuration(timeout); + deleteRecursively(gcdPath); + } + + /** + * Stops the Datastore emulator. The same as {@link #stopDuration(java.time.Duration)} but with + * timeout duration of 20 seconds. + * + *

It is important to stop the emulator. Since the emulator runs in its own process, not + * stopping it might cause it to become orphan. + * + *

It is not required to call {@link #reset()} before {@code stop()}. + */ + public void stop() throws IOException, InterruptedException, TimeoutException { + stopDuration(java.time.Duration.ofSeconds(20)); + } + + static void deleteRecursively(Path path) throws IOException { + if (path == null || !Files.exists(path)) { + return; + } + Files.walkFileTree( + path, + new SimpleFileVisitor() { + @Override + public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException { + Files.delete(dir); + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) + throws IOException { + Files.delete(file); + return FileVisitResult.CONTINUE; + } + }); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/package-info.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/package-info.java new file mode 100644 index 000000000000..5a1ddef2f7e8 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/testing/package-info.java @@ -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. + */ + +/** + * A testing helper for Google Cloud Datastore. + * + *

A simple usage example: + * + *

Before the test: + * + *

{@code
+ * LocalDatastoreHelper helper = LocalDatastoreHelper.create();
+ * helper.start();
+ * Datastore localDatastore = helper.getOptions().getService();
+ * }
+ * + *

After the test: + * + *

{@code
+ * helper.stop();
+ * }
+ * + * @see + * Google Cloud Java tools for testing + */ +package com.google.cloud.datastore.testing; diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreClient.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreClient.java new file mode 100644 index 000000000000..dfbb17d18878 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreClient.java @@ -0,0 +1,1087 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.v1; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.datastore.v1.stub.DatastoreStub; +import com.google.cloud.datastore.v1.stub.DatastoreStubSettings; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.Key; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.Mutation; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.protobuf.ByteString; +import java.io.IOException; +import java.util.List; +import java.util.concurrent.TimeUnit; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Service Description: Each RPC normalizes the partition IDs of the keys in its input entities, and + * always returns entities with keys with normalized partition IDs. This applies to all keys and + * entities, including those in values, except keys with both an empty path and an empty or unset + * partition ID. Normalization of input keys sets the project ID (if not already set) to the project + * ID from the request. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ *   String projectId = "projectId-894832108";
+ *   ReadOptions readOptions = ReadOptions.newBuilder().build();
+ *   List keys = new ArrayList<>();
+ *   LookupResponse response = datastoreClient.lookup(projectId, readOptions, keys);
+ * }
+ * }
+ * + *

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

Lookup

Looks up entities by key.

+ *

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

+ *
    + *
  • lookup(LookupRequest request) + *

+ *

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

+ *
    + *
  • lookup(String projectId, ReadOptions readOptions, List<Key> keys) + *

+ *

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

+ *
    + *
  • lookupCallable() + *

+ *

RunQuery

Queries for entities.

+ *

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

+ *
    + *
  • runQuery(RunQueryRequest request) + *

+ *

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

+ *
    + *
  • runQueryCallable() + *

+ *

RunAggregationQuery

Runs an aggregation query.

+ *

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

+ *
    + *
  • runAggregationQuery(RunAggregationQueryRequest request) + *

+ *

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

+ *
    + *
  • runAggregationQueryCallable() + *

+ *

BeginTransaction

Begins 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 projectId) + *

+ *

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, optionally creating, deleting or modifying some entities.

+ *

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 projectId, CommitRequest.Mode mode, List<Mutation> mutations) + *

  • commit(String projectId, CommitRequest.Mode mode, ByteString transaction, List<Mutation> mutations) + *

+ *

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 projectId, 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() + *

+ *

AllocateIds

Allocates IDs for the given keys, which is useful for referencing an entity before it is inserted.

+ *

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

+ *
    + *
  • allocateIds(AllocateIdsRequest request) + *

+ *

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

+ *
    + *
  • allocateIds(String projectId, List<Key> keys) + *

+ *

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

+ *
    + *
  • allocateIdsCallable() + *

+ *

ReserveIds

Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore.

+ *

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

+ *
    + *
  • reserveIds(ReserveIdsRequest request) + *

+ *

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

+ *
    + *
  • reserveIds(String projectId, List<Key> keys) + *

+ *

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

+ *
    + *
  • reserveIdsCallable() + *

+ *
+ * + *

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 DatastoreSettings 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
+ * DatastoreSettings datastoreSettings =
+ *     DatastoreSettings.newBuilder()
+ *         .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ *         .build();
+ * DatastoreClient datastoreClient = DatastoreClient.create(datastoreSettings);
+ * }
+ * + *

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
+ * DatastoreSettings datastoreSettings =
+ *     DatastoreSettings.newBuilder().setEndpoint(myEndpoint).build();
+ * DatastoreClient datastoreClient = DatastoreClient.create(datastoreSettings);
+ * }
+ * + *

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
+ * DatastoreSettings datastoreSettings = DatastoreSettings.newHttpJsonBuilder().build();
+ * DatastoreClient datastoreClient = DatastoreClient.create(datastoreSettings);
+ * }
+ * + *

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

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   String projectId = "projectId-894832108";
+   *   ReadOptions readOptions = ReadOptions.newBuilder().build();
+   *   List keys = new ArrayList<>();
+   *   LookupResponse response = datastoreClient.lookup(projectId, readOptions, keys);
+   * }
+   * }
+ * + * @param projectId Required. The ID of the project against which to make the request. + * @param readOptions The options for this lookup request. + * @param keys Required. Keys of entities to look up. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final LookupResponse lookup(String projectId, ReadOptions readOptions, List keys) { + LookupRequest request = + LookupRequest.newBuilder() + .setProjectId(projectId) + .setReadOptions(readOptions) + .addAllKeys(keys) + .build(); + return lookup(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Looks up entities by key. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   LookupRequest request =
+   *       LookupRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setReadOptions(ReadOptions.newBuilder().build())
+   *           .addAllKeys(new ArrayList())
+   *           .setPropertyMask(PropertyMask.newBuilder().build())
+   *           .build();
+   *   LookupResponse response = datastoreClient.lookup(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 LookupResponse lookup(LookupRequest request) { + return lookupCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Looks up entities by key. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   LookupRequest request =
+   *       LookupRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setReadOptions(ReadOptions.newBuilder().build())
+   *           .addAllKeys(new ArrayList())
+   *           .setPropertyMask(PropertyMask.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = datastoreClient.lookupCallable().futureCall(request);
+   *   // Do something.
+   *   LookupResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable lookupCallable() { + return stub.lookupCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Queries for entities. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   RunQueryRequest request =
+   *       RunQueryRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setPartitionId(PartitionId.newBuilder().build())
+   *           .setReadOptions(ReadOptions.newBuilder().build())
+   *           .setPropertyMask(PropertyMask.newBuilder().build())
+   *           .setExplainOptions(ExplainOptions.newBuilder().build())
+   *           .build();
+   *   RunQueryResponse response = datastoreClient.runQuery(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 RunQueryResponse runQuery(RunQueryRequest request) { + return runQueryCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Queries for entities. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   RunQueryRequest request =
+   *       RunQueryRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setPartitionId(PartitionId.newBuilder().build())
+   *           .setReadOptions(ReadOptions.newBuilder().build())
+   *           .setPropertyMask(PropertyMask.newBuilder().build())
+   *           .setExplainOptions(ExplainOptions.newBuilder().build())
+   *           .build();
+   *   ApiFuture future = datastoreClient.runQueryCallable().futureCall(request);
+   *   // Do something.
+   *   RunQueryResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable runQueryCallable() { + return stub.runQueryCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Runs an aggregation 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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   RunAggregationQueryRequest request =
+   *       RunAggregationQueryRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setPartitionId(PartitionId.newBuilder().build())
+   *           .setReadOptions(ReadOptions.newBuilder().build())
+   *           .setExplainOptions(ExplainOptions.newBuilder().build())
+   *           .build();
+   *   RunAggregationQueryResponse response = datastoreClient.runAggregationQuery(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 RunAggregationQueryResponse runAggregationQuery(RunAggregationQueryRequest request) { + return runAggregationQueryCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Runs an aggregation 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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   RunAggregationQueryRequest request =
+   *       RunAggregationQueryRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setPartitionId(PartitionId.newBuilder().build())
+   *           .setReadOptions(ReadOptions.newBuilder().build())
+   *           .setExplainOptions(ExplainOptions.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       datastoreClient.runAggregationQueryCallable().futureCall(request);
+   *   // Do something.
+   *   RunAggregationQueryResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + runAggregationQueryCallable() { + return stub.runAggregationQueryCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Begins 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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   String projectId = "projectId-894832108";
+   *   BeginTransactionResponse response = datastoreClient.beginTransaction(projectId);
+   * }
+   * }
+ * + * @param projectId Required. The ID of the project against which to make the request. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BeginTransactionResponse beginTransaction(String projectId) { + BeginTransactionRequest request = + BeginTransactionRequest.newBuilder().setProjectId(projectId).build(); + return beginTransaction(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Begins 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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   BeginTransactionRequest request =
+   *       BeginTransactionRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setTransactionOptions(TransactionOptions.newBuilder().build())
+   *           .build();
+   *   BeginTransactionResponse response = datastoreClient.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. + /** + * Begins 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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   BeginTransactionRequest request =
+   *       BeginTransactionRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setTransactionOptions(TransactionOptions.newBuilder().build())
+   *           .build();
+   *   ApiFuture future =
+   *       datastoreClient.beginTransactionCallable().futureCall(request);
+   *   // Do something.
+   *   BeginTransactionResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable + beginTransactionCallable() { + return stub.beginTransactionCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Commits a transaction, optionally creating, deleting or modifying some entities. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   String projectId = "projectId-894832108";
+   *   CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0);
+   *   List mutations = new ArrayList<>();
+   *   CommitResponse response = datastoreClient.commit(projectId, mode, mutations);
+   * }
+   * }
+ * + * @param projectId Required. The ID of the project against which to make the request. + * @param mode The type of commit to perform. Defaults to `TRANSACTIONAL`. + * @param mutations The mutations to perform. + *

When mode is `TRANSACTIONAL`, mutations affecting a single entity are applied in order. + * The following sequences of mutations affecting a single entity are not permitted in a + * single `Commit` request: + *

- `insert` followed by `insert` - `update` followed by `insert` - `upsert` followed by + * `insert` - `delete` followed by `update` + *

When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single entity. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CommitResponse commit( + String projectId, CommitRequest.Mode mode, List mutations) { + CommitRequest request = + CommitRequest.newBuilder() + .setProjectId(projectId) + .setMode(mode) + .addAllMutations(mutations) + .build(); + return commit(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Commits a transaction, optionally creating, deleting or modifying some entities. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   String projectId = "projectId-894832108";
+   *   CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0);
+   *   ByteString transaction = ByteString.EMPTY;
+   *   List mutations = new ArrayList<>();
+   *   CommitResponse response = datastoreClient.commit(projectId, mode, transaction, mutations);
+   * }
+   * }
+ * + * @param projectId Required. The ID of the project against which to make the request. + * @param mode The type of commit to perform. Defaults to `TRANSACTIONAL`. + * @param transaction The identifier of the transaction associated with the commit. A transaction + * identifier is returned by a call to + * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. + * @param mutations The mutations to perform. + *

When mode is `TRANSACTIONAL`, mutations affecting a single entity are applied in order. + * The following sequences of mutations affecting a single entity are not permitted in a + * single `Commit` request: + *

- `insert` followed by `insert` - `update` followed by `insert` - `upsert` followed by + * `insert` - `delete` followed by `update` + *

When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single entity. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final CommitResponse commit( + String projectId, CommitRequest.Mode mode, ByteString transaction, List mutations) { + CommitRequest request = + CommitRequest.newBuilder() + .setProjectId(projectId) + .setMode(mode) + .setTransaction(transaction) + .addAllMutations(mutations) + .build(); + return commit(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Commits a transaction, optionally creating, deleting or modifying some entities. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   CommitRequest request =
+   *       CommitRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .addAllMutations(new ArrayList())
+   *           .build();
+   *   CommitResponse response = datastoreClient.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, optionally creating, deleting or modifying some entities. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   CommitRequest request =
+   *       CommitRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .addAllMutations(new ArrayList())
+   *           .build();
+   *   ApiFuture future = datastoreClient.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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   String projectId = "projectId-894832108";
+   *   ByteString transaction = ByteString.EMPTY;
+   *   RollbackResponse response = datastoreClient.rollback(projectId, transaction);
+   * }
+   * }
+ * + * @param projectId Required. The ID of the project against which to make the request. + * @param transaction Required. The transaction identifier, returned by a call to + * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final RollbackResponse rollback(String projectId, ByteString transaction) { + RollbackRequest request = + RollbackRequest.newBuilder().setProjectId(projectId).setTransaction(transaction).build(); + return 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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   RollbackRequest request =
+   *       RollbackRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setTransaction(ByteString.EMPTY)
+   *           .build();
+   *   RollbackResponse response = datastoreClient.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 RollbackResponse rollback(RollbackRequest request) { + return 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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   RollbackRequest request =
+   *       RollbackRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .setTransaction(ByteString.EMPTY)
+   *           .build();
+   *   ApiFuture future = datastoreClient.rollbackCallable().futureCall(request);
+   *   // Do something.
+   *   RollbackResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable rollbackCallable() { + return stub.rollbackCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Allocates IDs for the given keys, which is useful for referencing an entity before it is + * inserted. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   String projectId = "projectId-894832108";
+   *   List keys = new ArrayList<>();
+   *   AllocateIdsResponse response = datastoreClient.allocateIds(projectId, keys);
+   * }
+   * }
+ * + * @param projectId Required. The ID of the project against which to make the request. + * @param keys Required. A list of keys with incomplete key paths for which to allocate IDs. No + * key may be reserved/read-only. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final AllocateIdsResponse allocateIds(String projectId, List keys) { + AllocateIdsRequest request = + AllocateIdsRequest.newBuilder().setProjectId(projectId).addAllKeys(keys).build(); + return allocateIds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Allocates IDs for the given keys, which is useful for referencing an entity before it is + * inserted. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   AllocateIdsRequest request =
+   *       AllocateIdsRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .addAllKeys(new ArrayList())
+   *           .build();
+   *   AllocateIdsResponse response = datastoreClient.allocateIds(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 AllocateIdsResponse allocateIds(AllocateIdsRequest request) { + return allocateIdsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Allocates IDs for the given keys, which is useful for referencing an entity before it is + * inserted. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   AllocateIdsRequest request =
+   *       AllocateIdsRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .addAllKeys(new ArrayList())
+   *           .build();
+   *   ApiFuture future =
+   *       datastoreClient.allocateIdsCallable().futureCall(request);
+   *   // Do something.
+   *   AllocateIdsResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable allocateIdsCallable() { + return stub.allocateIdsCallable(); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   String projectId = "projectId-894832108";
+   *   List keys = new ArrayList<>();
+   *   ReserveIdsResponse response = datastoreClient.reserveIds(projectId, keys);
+   * }
+   * }
+ * + * @param projectId Required. The ID of the project against which to make the request. + * @param keys Required. A list of keys with complete key paths whose numeric IDs should not be + * auto-allocated. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ReserveIdsResponse reserveIds(String projectId, List keys) { + ReserveIdsRequest request = + ReserveIdsRequest.newBuilder().setProjectId(projectId).addAllKeys(keys).build(); + return reserveIds(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   ReserveIdsRequest request =
+   *       ReserveIdsRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .addAllKeys(new ArrayList())
+   *           .build();
+   *   ReserveIdsResponse response = datastoreClient.reserveIds(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 ReserveIdsResponse reserveIds(ReserveIdsRequest request) { + return reserveIdsCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Prevents the supplied keys' IDs from being auto-allocated by Cloud Datastore. + * + *

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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+   *   ReserveIdsRequest request =
+   *       ReserveIdsRequest.newBuilder()
+   *           .setProjectId("projectId-894832108")
+   *           .setDatabaseId("databaseId1688905718")
+   *           .addAllKeys(new ArrayList())
+   *           .build();
+   *   ApiFuture future =
+   *       datastoreClient.reserveIdsCallable().futureCall(request);
+   *   // Do something.
+   *   ReserveIdsResponse response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable reserveIdsCallable() { + return stub.reserveIdsCallable(); + } + + @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); + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreSettings.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreSettings.java new file mode 100644 index 000000000000..74da075c1669 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/DatastoreSettings.java @@ -0,0 +1,304 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.v1; + +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.TransportChannelProvider; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.datastore.v1.stub.DatastoreStubSettings; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +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 DatastoreClient}. + * + *

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

    + *
  • The default service address (datastore.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 lookup: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * DatastoreSettings.Builder datastoreSettingsBuilder = DatastoreSettings.newBuilder();
+ * datastoreSettingsBuilder
+ *     .lookupSettings()
+ *     .setRetrySettings(
+ *         datastoreSettingsBuilder
+ *             .lookupSettings()
+ *             .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());
+ * DatastoreSettings datastoreSettings = datastoreSettingsBuilder.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 DatastoreSettings extends ClientSettings { + + /** Returns the object with the settings used for calls to lookup. */ + public UnaryCallSettings lookupSettings() { + return ((DatastoreStubSettings) getStubSettings()).lookupSettings(); + } + + /** Returns the object with the settings used for calls to runQuery. */ + public UnaryCallSettings runQuerySettings() { + return ((DatastoreStubSettings) getStubSettings()).runQuerySettings(); + } + + /** Returns the object with the settings used for calls to runAggregationQuery. */ + public UnaryCallSettings + runAggregationQuerySettings() { + return ((DatastoreStubSettings) getStubSettings()).runAggregationQuerySettings(); + } + + /** Returns the object with the settings used for calls to beginTransaction. */ + public UnaryCallSettings + beginTransactionSettings() { + return ((DatastoreStubSettings) getStubSettings()).beginTransactionSettings(); + } + + /** Returns the object with the settings used for calls to commit. */ + public UnaryCallSettings commitSettings() { + return ((DatastoreStubSettings) getStubSettings()).commitSettings(); + } + + /** Returns the object with the settings used for calls to rollback. */ + public UnaryCallSettings rollbackSettings() { + return ((DatastoreStubSettings) getStubSettings()).rollbackSettings(); + } + + /** Returns the object with the settings used for calls to allocateIds. */ + public UnaryCallSettings allocateIdsSettings() { + return ((DatastoreStubSettings) getStubSettings()).allocateIdsSettings(); + } + + /** Returns the object with the settings used for calls to reserveIds. */ + public UnaryCallSettings reserveIdsSettings() { + return ((DatastoreStubSettings) getStubSettings()).reserveIdsSettings(); + } + + public static final DatastoreSettings create(DatastoreStubSettings stub) throws IOException { + return new DatastoreSettings.Builder(stub.toBuilder()).build(); + } + + /** Returns a builder for the default ExecutorProvider for this service. */ + public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuilder() { + return DatastoreStubSettings.defaultExecutorProviderBuilder(); + } + + /** Returns the default service endpoint. */ + public static String getDefaultEndpoint() { + return DatastoreStubSettings.getDefaultEndpoint(); + } + + /** Returns the default service scopes. */ + public static List getDefaultServiceScopes() { + return DatastoreStubSettings.getDefaultServiceScopes(); + } + + /** Returns a builder for the default credentials for this service. */ + public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilder() { + return DatastoreStubSettings.defaultCredentialsProviderBuilder(); + } + + /** Returns a builder for the default gRPC ChannelProvider for this service. */ + public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { + return DatastoreStubSettings.defaultGrpcTransportProviderBuilder(); + } + + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return DatastoreStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + + public static TransportChannelProvider defaultTransportChannelProvider() { + return DatastoreStubSettings.defaultTransportChannelProvider(); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DatastoreStubSettings.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 DatastoreSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + } + + /** Builder for DatastoreSettings. */ + public static class Builder extends ClientSettings.Builder { + + protected Builder() throws IOException { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(DatastoreStubSettings.newBuilder(clientContext)); + } + + protected Builder(DatastoreSettings settings) { + super(settings.getStubSettings().toBuilder()); + } + + protected Builder(DatastoreStubSettings.Builder stubSettings) { + super(stubSettings); + } + + private static Builder createDefault() { + return new Builder(DatastoreStubSettings.newBuilder()); + } + + private static Builder createHttpJsonDefault() { + return new Builder(DatastoreStubSettings.newHttpJsonBuilder()); + } + + public DatastoreStubSettings.Builder getStubSettingsBuilder() { + return ((DatastoreStubSettings.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 lookup. */ + public UnaryCallSettings.Builder lookupSettings() { + return getStubSettingsBuilder().lookupSettings(); + } + + /** Returns the builder for the settings used for calls to runQuery. */ + public UnaryCallSettings.Builder runQuerySettings() { + return getStubSettingsBuilder().runQuerySettings(); + } + + /** Returns the builder for the settings used for calls to runAggregationQuery. */ + public UnaryCallSettings.Builder + runAggregationQuerySettings() { + return getStubSettingsBuilder().runAggregationQuerySettings(); + } + + /** 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 allocateIds. */ + public UnaryCallSettings.Builder + allocateIdsSettings() { + return getStubSettingsBuilder().allocateIdsSettings(); + } + + /** Returns the builder for the settings used for calls to reserveIds. */ + public UnaryCallSettings.Builder reserveIdsSettings() { + return getStubSettingsBuilder().reserveIdsSettings(); + } + + @Override + public DatastoreSettings build() throws IOException { + return new DatastoreSettings(this); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/gapic_metadata.json b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/gapic_metadata.json new file mode 100644 index 000000000000..02196d36eac3 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/gapic_metadata.json @@ -0,0 +1,42 @@ +{ + "schema": "1.0", + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "java", + "protoPackage": "google.datastore.v1", + "libraryPackage": "com.google.cloud.datastore.v1", + "services": { + "Datastore": { + "clients": { + "grpc": { + "libraryClient": "DatastoreClient", + "rpcs": { + "AllocateIds": { + "methods": ["allocateIds", "allocateIds", "allocateIdsCallable"] + }, + "BeginTransaction": { + "methods": ["beginTransaction", "beginTransaction", "beginTransactionCallable"] + }, + "Commit": { + "methods": ["commit", "commit", "commit", "commitCallable"] + }, + "Lookup": { + "methods": ["lookup", "lookup", "lookupCallable"] + }, + "ReserveIds": { + "methods": ["reserveIds", "reserveIds", "reserveIdsCallable"] + }, + "Rollback": { + "methods": ["rollback", "rollback", "rollbackCallable"] + }, + "RunAggregationQuery": { + "methods": ["runAggregationQuery", "runAggregationQueryCallable"] + }, + "RunQuery": { + "methods": ["runQuery", "runQueryCallable"] + } + } + } + } + } + } +} \ No newline at end of file diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/package-info.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/package-info.java new file mode 100644 index 000000000000..a5a708ed4e79 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/package-info.java @@ -0,0 +1,49 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT 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 Datastore API + * + *

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

======================= DatastoreClient ======================= + * + *

Service Description: Each RPC normalizes the partition IDs of the keys in its input entities, + * and always returns entities with keys with normalized partition IDs. This applies to all keys and + * entities, including those in values, except keys with both an empty path and an empty or unset + * partition ID. Normalization of input keys sets the project ID (if not already set) to the project + * ID from the request. + * + *

Sample for DatastoreClient: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require 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 (DatastoreClient datastoreClient = DatastoreClient.create()) {
+ *   String projectId = "projectId-894832108";
+ *   ReadOptions readOptions = ReadOptions.newBuilder().build();
+ *   List keys = new ArrayList<>();
+ *   LookupResponse response = datastoreClient.lookup(projectId, readOptions, keys);
+ * }
+ * }
+ */ +@Generated("by gapic-generator-java") +package com.google.cloud.datastore.v1; + +import javax.annotation.Generated; diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStub.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStub.java new file mode 100644 index 000000000000..5dad98ef9579 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStub.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. + */ + +package com.google.cloud.datastore.v1.stub; + +import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * Base stub class for the Datastore service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public abstract class DatastoreStub implements BackgroundResource { + + public UnaryCallable lookupCallable() { + throw new UnsupportedOperationException("Not implemented: lookupCallable()"); + } + + public UnaryCallable runQueryCallable() { + throw new UnsupportedOperationException("Not implemented: runQueryCallable()"); + } + + public UnaryCallable + runAggregationQueryCallable() { + throw new UnsupportedOperationException("Not implemented: runAggregationQueryCallable()"); + } + + 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 UnaryCallable allocateIdsCallable() { + throw new UnsupportedOperationException("Not implemented: allocateIdsCallable()"); + } + + public UnaryCallable reserveIdsCallable() { + throw new UnsupportedOperationException("Not implemented: reserveIdsCallable()"); + } + + @Override + public abstract void close(); +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStubSettings.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStubSettings.java new file mode 100644 index 000000000000..9d7d11a7d7c8 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/DatastoreStubSettings.java @@ -0,0 +1,535 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.v1.stub; + +import com.google.api.core.ApiFunction; +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.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ClientContext; +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.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Lists; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +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 DatastoreStub}. + * + *

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

    + *
  • The default service address (datastore.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 lookup: + * + *

{@code
+ * // This snippet has been automatically generated and should be regarded as a code template only.
+ * // It will require modifications to work:
+ * // - It may require correct/in-range values for request initialization.
+ * // - It may require specifying regional endpoints when creating the service client as shown in
+ * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+ * DatastoreStubSettings.Builder datastoreSettingsBuilder = DatastoreStubSettings.newBuilder();
+ * datastoreSettingsBuilder
+ *     .lookupSettings()
+ *     .setRetrySettings(
+ *         datastoreSettingsBuilder
+ *             .lookupSettings()
+ *             .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());
+ * DatastoreStubSettings datastoreSettings = datastoreSettingsBuilder.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 DatastoreStubSettings 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 lookupSettings; + private final UnaryCallSettings runQuerySettings; + private final UnaryCallSettings + runAggregationQuerySettings; + private final UnaryCallSettings + beginTransactionSettings; + private final UnaryCallSettings commitSettings; + private final UnaryCallSettings rollbackSettings; + private final UnaryCallSettings allocateIdsSettings; + private final UnaryCallSettings reserveIdsSettings; + + /** Returns the object with the settings used for calls to lookup. */ + public UnaryCallSettings lookupSettings() { + return lookupSettings; + } + + /** Returns the object with the settings used for calls to runQuery. */ + public UnaryCallSettings runQuerySettings() { + return runQuerySettings; + } + + /** Returns the object with the settings used for calls to runAggregationQuery. */ + public UnaryCallSettings + runAggregationQuerySettings() { + return runAggregationQuerySettings; + } + + /** 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 allocateIds. */ + public UnaryCallSettings allocateIdsSettings() { + return allocateIdsSettings; + } + + /** Returns the object with the settings used for calls to reserveIds. */ + public UnaryCallSettings reserveIdsSettings() { + return reserveIdsSettings; + } + + public DatastoreStub createStub() throws IOException { + if (getTransportChannelProvider() + .getTransportName() + .equals(GrpcTransportChannel.getGrpcTransportName())) { + return GrpcDatastoreStub.create(this); + } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonDatastoreStub.create(this); + } + throw new UnsupportedOperationException( + String.format( + "Transport not supported: %s", getTransportChannelProvider().getTransportName())); + } + + /** Returns the default service name. */ + @Override + public String getServiceName() { + return "datastore"; + } + + /** 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 "datastore.googleapis.com:443"; + } + + /** Returns the default mTLS service endpoint. */ + public static String getDefaultMtlsEndpoint() { + return "datastore.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(DatastoreStubSettings.class)) + .setTransportToken( + GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken("gapic", GaxProperties.getLibraryVersion(DatastoreStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return DatastoreStubSettings.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 DatastoreStubSettings(Builder settingsBuilder) throws IOException { + super(settingsBuilder); + + lookupSettings = settingsBuilder.lookupSettings().build(); + runQuerySettings = settingsBuilder.runQuerySettings().build(); + runAggregationQuerySettings = settingsBuilder.runAggregationQuerySettings().build(); + beginTransactionSettings = settingsBuilder.beginTransactionSettings().build(); + commitSettings = settingsBuilder.commitSettings().build(); + rollbackSettings = settingsBuilder.rollbackSettings().build(); + allocateIdsSettings = settingsBuilder.allocateIdsSettings().build(); + reserveIdsSettings = settingsBuilder.reserveIdsSettings().build(); + } + + /** Builder for DatastoreStubSettings. */ + public static class Builder extends StubSettings.Builder { + private final ImmutableList> unaryMethodSettingsBuilders; + private final UnaryCallSettings.Builder lookupSettings; + private final UnaryCallSettings.Builder runQuerySettings; + private final UnaryCallSettings.Builder + runAggregationQuerySettings; + private final UnaryCallSettings.Builder + beginTransactionSettings; + private final UnaryCallSettings.Builder commitSettings; + private final UnaryCallSettings.Builder rollbackSettings; + private final UnaryCallSettings.Builder + allocateIdsSettings; + private final UnaryCallSettings.Builder + reserveIdsSettings; + private static final ImmutableMap> + RETRYABLE_CODE_DEFINITIONS; + + static { + ImmutableMap.Builder> definitions = + ImmutableMap.builder(); + definitions.put( + "retry_policy_0_codes", + ImmutableSet.copyOf( + Lists.newArrayList( + StatusCode.Code.UNAVAILABLE, StatusCode.Code.DEADLINE_EXCEEDED))); + definitions.put( + "no_retry_1_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() + .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(60000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(60000L)) + .setTotalTimeoutDuration(Duration.ofMillis(60000L)) + .build(); + definitions.put("no_retry_1_params", settings); + RETRY_PARAM_DEFINITIONS = definitions.build(); + } + + protected Builder() { + this(((ClientContext) null)); + } + + protected Builder(ClientContext clientContext) { + super(clientContext); + + lookupSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + runQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + runAggregationQuerySettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + beginTransactionSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + commitSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + rollbackSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + allocateIdsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + reserveIdsSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + lookupSettings, + runQuerySettings, + runAggregationQuerySettings, + beginTransactionSettings, + commitSettings, + rollbackSettings, + allocateIdsSettings, + reserveIdsSettings); + initDefaults(this); + } + + protected Builder(DatastoreStubSettings settings) { + super(settings); + + lookupSettings = settings.lookupSettings.toBuilder(); + runQuerySettings = settings.runQuerySettings.toBuilder(); + runAggregationQuerySettings = settings.runAggregationQuerySettings.toBuilder(); + beginTransactionSettings = settings.beginTransactionSettings.toBuilder(); + commitSettings = settings.commitSettings.toBuilder(); + rollbackSettings = settings.rollbackSettings.toBuilder(); + allocateIdsSettings = settings.allocateIdsSettings.toBuilder(); + reserveIdsSettings = settings.reserveIdsSettings.toBuilder(); + + unaryMethodSettingsBuilders = + ImmutableList.>of( + lookupSettings, + runQuerySettings, + runAggregationQuerySettings, + beginTransactionSettings, + commitSettings, + rollbackSettings, + allocateIdsSettings, + reserveIdsSettings); + } + + 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 + .lookupSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .runQuerySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .runAggregationQuerySettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .beginTransactionSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + builder + .commitSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + builder + .rollbackSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + builder + .allocateIdsSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("no_retry_1_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("no_retry_1_params")); + + builder + .reserveIdsSettings() + .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 lookup. */ + public UnaryCallSettings.Builder lookupSettings() { + return lookupSettings; + } + + /** Returns the builder for the settings used for calls to runQuery. */ + public UnaryCallSettings.Builder runQuerySettings() { + return runQuerySettings; + } + + /** Returns the builder for the settings used for calls to runAggregationQuery. */ + public UnaryCallSettings.Builder + runAggregationQuerySettings() { + return runAggregationQuerySettings; + } + + /** 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 allocateIds. */ + public UnaryCallSettings.Builder + allocateIdsSettings() { + return allocateIdsSettings; + } + + /** Returns the builder for the settings used for calls to reserveIds. */ + public UnaryCallSettings.Builder reserveIdsSettings() { + return reserveIdsSettings; + } + + @Override + public DatastoreStubSettings build() throws IOException { + return new DatastoreStubSettings(this); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreCallableFactory.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreCallableFactory.java new file mode 100644 index 000000000000..d0423c6e6f94 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreCallableFactory.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.datastore.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 Datastore service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class GrpcDatastoreCallableFactory 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-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreStub.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreStub.java new file mode 100644 index 000000000000..9efdf1e6c4c9 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/GrpcDatastoreStub.java @@ -0,0 +1,437 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.v1.stub; + +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.RequestParamsBuilder; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.longrunning.stub.GrpcOperationsStub; +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 Datastore service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class GrpcDatastoreStub extends DatastoreStub { + private static final MethodDescriptor lookupMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.v1.Datastore/Lookup") + .setRequestMarshaller(ProtoUtils.marshaller(LookupRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(LookupResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + runQueryMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.v1.Datastore/RunQuery") + .setRequestMarshaller(ProtoUtils.marshaller(RunQueryRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(RunQueryResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + runAggregationQueryMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.v1.Datastore/RunAggregationQuery") + .setRequestMarshaller( + ProtoUtils.marshaller(RunAggregationQueryRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(RunAggregationQueryResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + beginTransactionMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.v1.Datastore/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.datastore.v1.Datastore/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.datastore.v1.Datastore/Rollback") + .setRequestMarshaller(ProtoUtils.marshaller(RollbackRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(RollbackResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + allocateIdsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.v1.Datastore/AllocateIds") + .setRequestMarshaller(ProtoUtils.marshaller(AllocateIdsRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(AllocateIdsResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private static final MethodDescriptor + reserveIdsMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.datastore.v1.Datastore/ReserveIds") + .setRequestMarshaller(ProtoUtils.marshaller(ReserveIdsRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(ReserveIdsResponse.getDefaultInstance())) + .setSampledToLocalTracing(true) + .build(); + + private final UnaryCallable lookupCallable; + private final UnaryCallable runQueryCallable; + private final UnaryCallable + runAggregationQueryCallable; + private final UnaryCallable + beginTransactionCallable; + private final UnaryCallable commitCallable; + private final UnaryCallable rollbackCallable; + private final UnaryCallable allocateIdsCallable; + private final UnaryCallable reserveIdsCallable; + + private final BackgroundResource backgroundResources; + private final GrpcOperationsStub operationsStub; + private final GrpcStubCallableFactory callableFactory; + + private static final PathTemplate LOOKUP_0_PATH_TEMPLATE = PathTemplate.create("{project_id=**}"); + private static final PathTemplate LOOKUP_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate RUN_QUERY_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate RUN_QUERY_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate RUN_AGGREGATION_QUERY_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate RUN_AGGREGATION_QUERY_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate BEGIN_TRANSACTION_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate BEGIN_TRANSACTION_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate COMMIT_0_PATH_TEMPLATE = PathTemplate.create("{project_id=**}"); + private static final PathTemplate COMMIT_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate ROLLBACK_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate ROLLBACK_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate ALLOCATE_IDS_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate ALLOCATE_IDS_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate RESERVE_IDS_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate RESERVE_IDS_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + + public static final GrpcDatastoreStub create(DatastoreStubSettings settings) throws IOException { + return new GrpcDatastoreStub(settings, ClientContext.create(settings)); + } + + public static final GrpcDatastoreStub create(ClientContext clientContext) throws IOException { + return new GrpcDatastoreStub(DatastoreStubSettings.newBuilder().build(), clientContext); + } + + public static final GrpcDatastoreStub create( + ClientContext clientContext, GrpcStubCallableFactory callableFactory) throws IOException { + return new GrpcDatastoreStub( + DatastoreStubSettings.newBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of GrpcDatastoreStub, 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 GrpcDatastoreStub(DatastoreStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new GrpcDatastoreCallableFactory()); + } + + /** + * Constructs an instance of GrpcDatastoreStub, 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 GrpcDatastoreStub( + DatastoreStubSettings settings, + ClientContext clientContext, + GrpcStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.operationsStub = GrpcOperationsStub.create(clientContext, callableFactory); + + GrpcCallSettings lookupTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(lookupMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", LOOKUP_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", LOOKUP_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + GrpcCallSettings runQueryTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(runQueryMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", RUN_QUERY_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", RUN_QUERY_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + GrpcCallSettings + runAggregationQueryTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(runAggregationQueryMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + request.getProjectId(), + "project_id", + RUN_AGGREGATION_QUERY_0_PATH_TEMPLATE); + builder.add( + request.getDatabaseId(), + "database_id", + RUN_AGGREGATION_QUERY_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + GrpcCallSettings + beginTransactionTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(beginTransactionMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + request.getProjectId(), "project_id", BEGIN_TRANSACTION_0_PATH_TEMPLATE); + builder.add( + request.getDatabaseId(), + "database_id", + BEGIN_TRANSACTION_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + GrpcCallSettings commitTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(commitMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", COMMIT_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", COMMIT_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + GrpcCallSettings rollbackTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(rollbackMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", ROLLBACK_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", ROLLBACK_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + GrpcCallSettings allocateIdsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(allocateIdsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", ALLOCATE_IDS_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", ALLOCATE_IDS_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + GrpcCallSettings reserveIdsTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(reserveIdsMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", RESERVE_IDS_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", RESERVE_IDS_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + + this.lookupCallable = + callableFactory.createUnaryCallable( + lookupTransportSettings, settings.lookupSettings(), clientContext); + this.runQueryCallable = + callableFactory.createUnaryCallable( + runQueryTransportSettings, settings.runQuerySettings(), clientContext); + this.runAggregationQueryCallable = + callableFactory.createUnaryCallable( + runAggregationQueryTransportSettings, + settings.runAggregationQuerySettings(), + 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.allocateIdsCallable = + callableFactory.createUnaryCallable( + allocateIdsTransportSettings, settings.allocateIdsSettings(), clientContext); + this.reserveIdsCallable = + callableFactory.createUnaryCallable( + reserveIdsTransportSettings, settings.reserveIdsSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + public GrpcOperationsStub getOperationsStub() { + return operationsStub; + } + + @Override + public UnaryCallable lookupCallable() { + return lookupCallable; + } + + @Override + public UnaryCallable runQueryCallable() { + return runQueryCallable; + } + + @Override + public UnaryCallable + runAggregationQueryCallable() { + return runAggregationQueryCallable; + } + + @Override + public UnaryCallable + beginTransactionCallable() { + return beginTransactionCallable; + } + + @Override + public UnaryCallable commitCallable() { + return commitCallable; + } + + @Override + public UnaryCallable rollbackCallable() { + return rollbackCallable; + } + + @Override + public UnaryCallable allocateIdsCallable() { + return allocateIdsCallable; + } + + @Override + public UnaryCallable reserveIdsCallable() { + return reserveIdsCallable; + } + + @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-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreCallableFactory.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreCallableFactory.java new file mode 100644 index 000000000000..fbb23e70b585 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreCallableFactory.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.datastore.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 Datastore service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +public class HttpJsonDatastoreCallableFactory + 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-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreStub.java b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreStub.java new file mode 100644 index 000000000000..d0c7e3591863 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/java/com/google/cloud/datastore/v1/stub/HttpJsonDatastoreStub.java @@ -0,0 +1,676 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.v1.stub; + +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.ClientContext; +import com.google.api.gax.rpc.RequestParamsBuilder; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.api.pathtemplate.PathTemplate; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +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 Datastore service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +public class HttpJsonDatastoreStub extends DatastoreStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor lookupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.v1.Datastore/Lookup") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}:lookup", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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().clearProjectId().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(LookupResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + runQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.v1.Datastore/RunQuery") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}:runQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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().clearProjectId().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(RunQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + runAggregationQueryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.v1.Datastore/RunAggregationQuery") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}:runAggregationQuery", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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().clearProjectId().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(RunAggregationQueryResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + beginTransactionMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.v1.Datastore/BeginTransaction") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}:beginTransaction", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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().clearProjectId().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BeginTransactionResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor commitMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.v1.Datastore/Commit") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}:commit", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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().clearProjectId().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(CommitResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + rollbackMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.v1.Datastore/Rollback") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}:rollback", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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().clearProjectId().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(RollbackResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + allocateIdsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.v1.Datastore/AllocateIds") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}:allocateIds", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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().clearProjectId().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(AllocateIdsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + reserveIdsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.datastore.v1.Datastore/ReserveIds") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/projects/{projectId}:reserveIds", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "projectId", request.getProjectId()); + 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().clearProjectId().build(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ReserveIdsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable lookupCallable; + private final UnaryCallable runQueryCallable; + private final UnaryCallable + runAggregationQueryCallable; + private final UnaryCallable + beginTransactionCallable; + private final UnaryCallable commitCallable; + private final UnaryCallable rollbackCallable; + private final UnaryCallable allocateIdsCallable; + private final UnaryCallable reserveIdsCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + private static final PathTemplate LOOKUP_0_PATH_TEMPLATE = PathTemplate.create("{project_id=**}"); + private static final PathTemplate LOOKUP_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate RUN_QUERY_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate RUN_QUERY_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate RUN_AGGREGATION_QUERY_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate RUN_AGGREGATION_QUERY_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate BEGIN_TRANSACTION_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate BEGIN_TRANSACTION_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate COMMIT_0_PATH_TEMPLATE = PathTemplate.create("{project_id=**}"); + private static final PathTemplate COMMIT_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate ROLLBACK_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate ROLLBACK_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate ALLOCATE_IDS_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate ALLOCATE_IDS_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + private static final PathTemplate RESERVE_IDS_0_PATH_TEMPLATE = + PathTemplate.create("{project_id=**}"); + private static final PathTemplate RESERVE_IDS_1_PATH_TEMPLATE = + PathTemplate.create("{database_id=**}"); + + public static final HttpJsonDatastoreStub create(DatastoreStubSettings settings) + throws IOException { + return new HttpJsonDatastoreStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonDatastoreStub create(ClientContext clientContext) throws IOException { + return new HttpJsonDatastoreStub( + DatastoreStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonDatastoreStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonDatastoreStub( + DatastoreStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonDatastoreStub, 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 HttpJsonDatastoreStub(DatastoreStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonDatastoreCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonDatastoreStub, 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 HttpJsonDatastoreStub( + DatastoreStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings lookupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(lookupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", LOOKUP_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", LOOKUP_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + HttpJsonCallSettings runQueryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(runQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", RUN_QUERY_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", RUN_QUERY_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + runAggregationQueryTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(runAggregationQueryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + request.getProjectId(), + "project_id", + RUN_AGGREGATION_QUERY_0_PATH_TEMPLATE); + builder.add( + request.getDatabaseId(), + "database_id", + RUN_AGGREGATION_QUERY_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + beginTransactionTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(beginTransactionMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + request.getProjectId(), "project_id", BEGIN_TRANSACTION_0_PATH_TEMPLATE); + builder.add( + request.getDatabaseId(), + "database_id", + BEGIN_TRANSACTION_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + HttpJsonCallSettings commitTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(commitMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", COMMIT_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", COMMIT_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + HttpJsonCallSettings rollbackTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rollbackMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", ROLLBACK_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", ROLLBACK_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + HttpJsonCallSettings allocateIdsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(allocateIdsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", ALLOCATE_IDS_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", ALLOCATE_IDS_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + HttpJsonCallSettings reserveIdsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(reserveIdsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add(request.getProjectId(), "project_id", RESERVE_IDS_0_PATH_TEMPLATE); + builder.add(request.getDatabaseId(), "database_id", RESERVE_IDS_1_PATH_TEMPLATE); + return builder.build(); + }) + .build(); + + this.lookupCallable = + callableFactory.createUnaryCallable( + lookupTransportSettings, settings.lookupSettings(), clientContext); + this.runQueryCallable = + callableFactory.createUnaryCallable( + runQueryTransportSettings, settings.runQuerySettings(), clientContext); + this.runAggregationQueryCallable = + callableFactory.createUnaryCallable( + runAggregationQueryTransportSettings, + settings.runAggregationQuerySettings(), + 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.allocateIdsCallable = + callableFactory.createUnaryCallable( + allocateIdsTransportSettings, settings.allocateIdsSettings(), clientContext); + this.reserveIdsCallable = + callableFactory.createUnaryCallable( + reserveIdsTransportSettings, settings.reserveIdsSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(lookupMethodDescriptor); + methodDescriptors.add(runQueryMethodDescriptor); + methodDescriptors.add(runAggregationQueryMethodDescriptor); + methodDescriptors.add(beginTransactionMethodDescriptor); + methodDescriptors.add(commitMethodDescriptor); + methodDescriptors.add(rollbackMethodDescriptor); + methodDescriptors.add(allocateIdsMethodDescriptor); + methodDescriptors.add(reserveIdsMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable lookupCallable() { + return lookupCallable; + } + + @Override + public UnaryCallable runQueryCallable() { + return runQueryCallable; + } + + @Override + public UnaryCallable + runAggregationQueryCallable() { + return runAggregationQueryCallable; + } + + @Override + public UnaryCallable + beginTransactionCallable() { + return beginTransactionCallable; + } + + @Override + public UnaryCallable commitCallable() { + return commitCallable; + } + + @Override + public UnaryCallable rollbackCallable() { + return rollbackCallable; + } + + @Override + public UnaryCallable allocateIdsCallable() { + return allocateIdsCallable; + } + + @Override + public UnaryCallable reserveIdsCallable() { + return reserveIdsCallable; + } + + @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-datastore/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.admin.v1/reflect-config.json b/java-datastore/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.admin.v1/reflect-config.json new file mode 100644 index 000000000000..dfe00073075b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.admin.v1/reflect-config.json @@ -0,0 +1,1829 @@ +[ + { + "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.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.datastore.admin.v1.CommonMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.CommonMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.CommonMetadata$State", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.CreateIndexRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.CreateIndexRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.DeleteIndexRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.DeleteIndexRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.EntityFilter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.EntityFilter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ExportEntitiesMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ExportEntitiesMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ExportEntitiesRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ExportEntitiesRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ExportEntitiesResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ExportEntitiesResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.GetIndexRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.GetIndexRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ImportEntitiesMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ImportEntitiesMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ImportEntitiesRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ImportEntitiesRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.Index", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.Index$AncestorMode", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.Index$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.Index$Direction", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.Index$IndexedProperty", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.Index$IndexedProperty$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.Index$State", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.IndexOperationMetadata", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.IndexOperationMetadata$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ListIndexesRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ListIndexesRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ListIndexesResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.ListIndexesResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationProgressEvent", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationProgressEvent$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationProgressEvent$ConcurrencyMode", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationProgressEvent$PrepareStepDetails", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationProgressEvent$PrepareStepDetails$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationProgressEvent$RedirectWritesStepDetails", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationProgressEvent$RedirectWritesStepDetails$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationState", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationStateEvent", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationStateEvent$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.MigrationStep", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.OperationType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.Progress", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.admin.v1.Progress$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$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$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$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$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.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 + } +] \ No newline at end of file diff --git a/java-datastore/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.v1/reflect-config.json b/java-datastore/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.v1/reflect-config.json new file mode 100644 index 000000000000..475f7690cfcb --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/main/resources/META-INF/native-image/com.google.cloud.datastore.v1/reflect-config.json @@ -0,0 +1,2522 @@ +[ + { + "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.datastore.v1.AggregationQuery", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationQuery$Aggregation", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationQuery$Aggregation$Avg", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationQuery$Aggregation$Avg$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationQuery$Aggregation$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationQuery$Aggregation$Count", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationQuery$Aggregation$Count$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationQuery$Aggregation$Sum", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationQuery$Aggregation$Sum$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationQuery$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationResult", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationResult$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationResultBatch", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AggregationResultBatch$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AllocateIdsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AllocateIdsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AllocateIdsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.AllocateIdsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ArrayValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ArrayValue$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.BeginTransactionRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.BeginTransactionRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.BeginTransactionResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.BeginTransactionResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.CommitRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.CommitRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.CommitRequest$Mode", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.CommitResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.CommitResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.CompositeFilter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.CompositeFilter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.CompositeFilter$Operator", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Entity", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Entity$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.EntityResult", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.EntityResult$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.EntityResult$ResultType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExecutionStats", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExecutionStats$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExplainMetrics", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExplainMetrics$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExplainOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ExplainOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Filter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Filter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.FindNearest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.FindNearest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.FindNearest$DistanceMeasure", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.GqlQuery", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.GqlQuery$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.GqlQueryParameter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.GqlQueryParameter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Key", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Key$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Key$PathElement", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Key$PathElement$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.KindExpression", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.KindExpression$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.LookupRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.LookupRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.LookupResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.LookupResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Mutation", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Mutation$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Mutation$ConflictResolutionStrategy", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.MutationResult", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.MutationResult$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PartitionId", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PartitionId$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PlanSummary", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PlanSummary$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Projection", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Projection$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyFilter", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyFilter$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyFilter$Operator", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyMask", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyMask$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyOrder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyOrder$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyOrder$Direction", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyReference", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyReference$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyTransform", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyTransform$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.PropertyTransform$ServerValue", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Query", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Query$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.QueryResultBatch", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.QueryResultBatch$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.QueryResultBatch$MoreResultsType", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ReadOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ReadOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ReadOptions$ReadConsistency", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ReserveIdsRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ReserveIdsRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ReserveIdsResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.ReserveIdsResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RollbackRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RollbackRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RollbackResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RollbackResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RunAggregationQueryRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RunAggregationQueryRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RunAggregationQueryResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RunAggregationQueryResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RunQueryRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RunQueryRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RunQueryResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.RunQueryResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.TransactionOptions", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.TransactionOptions$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.TransactionOptions$ReadOnly", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.TransactionOptions$ReadOnly$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.TransactionOptions$ReadWrite", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.TransactionOptions$ReadWrite$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Value", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.datastore.v1.Value$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$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$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$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$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.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.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-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/AbstractDatastoreTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/AbstractDatastoreTest.java new file mode 100644 index 000000000000..96bb1365e86b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/AbstractDatastoreTest.java @@ -0,0 +1,1402 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.cloud.datastore.ProtoTestData.intValue; +import static com.google.cloud.datastore.TestUtils.matches; +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.common.collect.Iterables.getOnlyElement; +import static com.google.common.truth.Truth.assertThat; +import static org.easymock.EasyMock.createStrictMock; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +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.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.cloud.ServiceOptions; +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.Query.ResultType; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.cloud.datastore.spi.DatastoreRpcFactory; +import com.google.cloud.datastore.spi.v1.DatastoreRpc; +import com.google.cloud.datastore.testing.LocalDatastoreHelper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.Iterators; +import com.google.common.collect.Lists; +import com.google.datastore.v1.AggregationResultBatch; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.EntityResult; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.QueryResultBatch; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.ReadOptions.ReadConsistency; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.datastore.v1.TransactionOptions; +import com.google.protobuf.ByteString; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Predicate; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public abstract class AbstractDatastoreTest { + + private static final LocalDatastoreHelper helper = LocalDatastoreHelper.create(1.0, 9090); + protected static DatastoreOptions options = helper.getOptions(); + protected static Datastore datastore; + private static final String PROJECT_ID = options.getProjectId(); + private static final String KIND1 = "kind1"; + private static final String KIND2 = "kind2"; + private static final String KIND3 = "kind3"; + private static final NullValue NULL_VALUE = NullValue.of(); + private static final StringValue STR_VALUE = StringValue.of("str"); + private static final BooleanValue BOOL_VALUE = + BooleanValue.newBuilder(false).setExcludeFromIndexes(true).build(); + private static final IncompleteKey INCOMPLETE_KEY1 = + IncompleteKey.newBuilder(PROJECT_ID, KIND1).build(); + private static final IncompleteKey INCOMPLETE_KEY2 = + IncompleteKey.newBuilder(PROJECT_ID, KIND2).build(); + private static final Key KEY1 = Key.newBuilder(INCOMPLETE_KEY1, "name").build(); + private static final Key KEY2 = Key.newBuilder(KEY1, KIND2, 1).build(); + private static final Key KEY3 = Key.newBuilder(KEY2).setName("bla").build(); + private static final Key KEY4 = Key.newBuilder(KEY2).setName("newName1").build(); + private static final Key KEY5 = Key.newBuilder(KEY2).setName("newName2").build(); + private static final KeyValue KEY_VALUE = KeyValue.of(KEY1); + private static final ListValue LIST_VALUE1 = + ListValue.newBuilder().addValue(NULL_VALUE).addValue(STR_VALUE, BOOL_VALUE).build(); + private static final ListValue LIST_VALUE2 = ListValue.of(Collections.singletonList(KEY_VALUE)); + private static final ListValue EMPTY_LIST_VALUE = ListValue.of(Collections.>emptyList()); + private static final TimestampValue TIMESTAMP_VALUE = new TimestampValue(Timestamp.now()); + private static final LatLngValue LAT_LNG_VALUE = + new LatLngValue(new LatLng(37.422035, -122.084124)); + private static final FullEntity PARTIAL_ENTITY1 = + FullEntity.newBuilder(INCOMPLETE_KEY2) + .set("str", STR_VALUE) + .set("bool", BOOL_VALUE) + .set("list", LIST_VALUE1) + .build(); + private static final FullEntity PARTIAL_ENTITY2 = + FullEntity.newBuilder(PARTIAL_ENTITY1) + .remove("str") + .set("bool", true) + .set("list", LIST_VALUE1.get()) + .build(); + private static final FullEntity PARTIAL_ENTITY3 = + FullEntity.newBuilder(PARTIAL_ENTITY1) + .setKey(IncompleteKey.newBuilder(PROJECT_ID, KIND3).build()) + .build(); + private static final Entity ENTITY1 = + Entity.newBuilder(KEY1) + .set("str", STR_VALUE) + .set("date", TIMESTAMP_VALUE) + .set("latLng", LAT_LNG_VALUE) + .set("bool", BOOL_VALUE) + .set("partial1", EntityValue.of(PARTIAL_ENTITY1)) + .set("list", LIST_VALUE2) + .set("emptyList", EMPTY_LIST_VALUE) + .build(); + private static final Entity ENTITY2 = + Entity.newBuilder(ENTITY1) + .setKey(KEY2) + .remove("str") + .set("name", "Dan") + .setNull("null") + .set("age", 20) + .build(); + private static final Entity ENTITY3 = + Entity.newBuilder(ENTITY1) + .setKey(KEY3) + .remove("str") + .set("null", NULL_VALUE) + .set("partial1", PARTIAL_ENTITY2) + .set("partial2", ENTITY2) + .build(); + + private DatastoreOptions rpcMockOptions; + private DatastoreRpcFactory rpcFactoryMock; + private DatastoreRpc rpcMock; + + public AbstractDatastoreTest(DatastoreOptions options, Datastore datastore) { + this.options = options; + this.datastore = datastore; + } + + @Before + public void setUp() { + rpcFactoryMock = EasyMock.createStrictMock(DatastoreRpcFactory.class); + rpcMock = EasyMock.createStrictMock(DatastoreRpc.class); + DatastoreOpenTelemetryOptions.Builder otelOptionsBuilder = + DatastoreOpenTelemetryOptions.newBuilder(); + rpcMockOptions = + options.toBuilder() + .setRetrySettings(ServiceOptions.getDefaultRetrySettings()) + .setServiceRpcFactory(rpcFactoryMock) + .build(); + EasyMock.expect(rpcFactoryMock.create(rpcMockOptions)).andReturn(rpcMock); + StructuredQuery query = Query.newKeyQueryBuilder().build(); + QueryResults result = datastore.run(query); + datastore.delete(Iterators.toArray(result, Key.class)); + datastore.add(ENTITY1, ENTITY2); + } + + @Test + public void testGetOptions() { + assertSame(options, datastore.getOptions()); + } + + @Test + public void testNewTransactionCommit() { + Transaction transaction = datastore.newTransaction(); + transaction.add(ENTITY3); + Entity entity2 = Entity.newBuilder(ENTITY2).clear().setNull("bla").build(); + transaction.update(entity2); + transaction.delete(KEY1); + transaction.commit(); + + List list = datastore.fetch(KEY1, KEY2, KEY3); + assertNull(list.get(0)); + assertEquals(entity2, list.get(1)); + assertEquals(ENTITY3, list.get(2)); + assertEquals(3, list.size()); + + try { + transaction.commit(); + fail("Expecting a failure"); + } catch (DatastoreException ex) { + // expected to fail + } + + try { + transaction.rollback(); + fail("Expecting a failure"); + } catch (DatastoreException ex) { + // expected to fail + } + + verifyNotUsable(transaction); + } + + @Test + public void testTransactionWithRead() { + Transaction transaction = datastore.newTransaction(); + assertNull(transaction.get(KEY3)); + transaction.add(ENTITY3); + transaction.commit(); + assertEquals(ENTITY3, datastore.get(KEY3)); + + transaction = datastore.newTransaction(); + assertEquals(ENTITY3, transaction.get(KEY3)); + // update entity3 during the transaction + datastore.put(Entity.newBuilder(ENTITY3).clear().build()); + transaction.update(ENTITY2); + try { + transaction.commit(); + fail("Expecting a failure"); + } catch (DatastoreException expected) { + assertEquals("ABORTED", expected.getReason()); + } + } + + @Test + public void testTransactionWithQuery() { + Query query = + Query.newEntityQueryBuilder() + .setKind(KIND2) + .setFilter(PropertyFilter.hasAncestor(KEY2)) + .build(); + Transaction transaction = datastore.newTransaction(); + QueryResults results = transaction.run(query); + assertEquals(ENTITY2, results.next()); + assertFalse(results.hasNext()); + transaction.add(ENTITY3); + transaction.commit(); + assertEquals(ENTITY3, datastore.get(KEY3)); + + transaction = datastore.newTransaction(); + results = transaction.run(query); + assertEquals(ENTITY2, results.next()); + transaction.delete(ENTITY3.getKey()); + // update entity2 during the transaction + datastore.put(Entity.newBuilder(ENTITY2).clear().build()); + try { + transaction.commit(); + fail("Expecting a failure"); + } catch (DatastoreException expected) { + assertEquals("ABORTED", expected.getReason()); + } + } + + @Test + public void testNewTransactionRollback() { + Transaction transaction = datastore.newTransaction(); + transaction.add(ENTITY3); + Entity entity2 = + Entity.newBuilder(ENTITY2) + .clear() + .setNull("bla") + .set("list3", StringValue.of("bla"), StringValue.newBuilder("bla").build()) + .build(); + transaction.update(entity2); + transaction.delete(KEY1); + transaction.rollback(); + transaction.rollback(); // should be safe to repeat rollback calls + + try { + transaction.commit(); + fail("Expecting a failure"); + } catch (DatastoreException ex) { + // expected to fail + } + + verifyNotUsable(transaction); + + List list = datastore.fetch(KEY1, KEY2, KEY3); + assertEquals(ENTITY1, list.get(0)); + assertEquals(ENTITY2, list.get(1)); + assertNull(list.get(2)); + assertEquals(3, list.size()); + } + + @Test + public void testRunInTransactionWithReadWriteOption() { + + EasyMock.expect(rpcMock.beginTransaction(EasyMock.anyObject(BeginTransactionRequest.class))) + .andReturn(BeginTransactionResponse.getDefaultInstance()); + EasyMock.expect(rpcMock.rollback(EasyMock.anyObject(RollbackRequest.class))) + .andReturn(RollbackResponse.getDefaultInstance()) + .once(); + + EasyMock.expect(rpcMock.beginTransaction(EasyMock.anyObject(BeginTransactionRequest.class))) + .andReturn(BeginTransactionResponse.getDefaultInstance()); + EasyMock.expect(rpcMock.commit(EasyMock.anyObject(CommitRequest.class))) + .andReturn(CommitResponse.newBuilder().build()); + + EasyMock.replay(rpcFactoryMock, rpcMock); + + Datastore mockDatastore = rpcMockOptions.getService(); + + Datastore.TransactionCallable callable = + new Datastore.TransactionCallable() { + private Integer attempts = 1; + + @Override + public Integer run(DatastoreReaderWriter transaction) { + if (attempts < 2) { + ++attempts; + throw new DatastoreException(10, "", "ABORTED", false, null); + } + return attempts; + } + }; + + TransactionOptions options = + TransactionOptions.newBuilder() + .setReadWrite(TransactionOptions.ReadWrite.getDefaultInstance()) + .build(); + Integer result = mockDatastore.runInTransaction(callable, options); + EasyMock.verify(rpcFactoryMock, rpcMock); + assertEquals(2, result.intValue()); + } + + private void verifyNotUsable(DatastoreWriter writer) { + try { + writer.add(ENTITY3); + fail("Expecting a failure"); + } catch (DatastoreException ex) { + // expected to fail + } + + try { + writer.put(ENTITY3); + fail("Expecting a failure"); + } catch (DatastoreException ex) { + // expected to fail + } + + try { + writer.update(ENTITY3); + fail("Expecting a failure"); + } catch (DatastoreException ex) { + // expected to fail + } + + try { + writer.delete(ENTITY3.getKey()); + fail("Expecting a failure"); + } catch (DatastoreException ex) { + // expected to fail + } + } + + @Test + public void testNewBatch() { + Batch batch = datastore.newBatch(); + Entity entity1 = Entity.newBuilder(ENTITY1).clear().build(); + Entity entity2 = Entity.newBuilder(ENTITY2).clear().setNull("bla").build(); + Entity entity4 = Entity.newBuilder(KEY4).set("value", StringValue.of("value")).build(); + Entity entity5 = Entity.newBuilder(KEY5).set("value", "value").build(); + + List entities = batch.add(entity4, PARTIAL_ENTITY2, entity5); + Entity entity6 = entities.get(1); + assertSame(entity4, entities.get(0)); + assertEquals(PARTIAL_ENTITY2.getProperties(), entity6.getProperties()); + assertEquals(PARTIAL_ENTITY2.getKey().getProjectId(), entity6.getKey().getProjectId()); + assertEquals(PARTIAL_ENTITY2.getKey().getNamespace(), entity6.getKey().getNamespace()); + assertEquals(PARTIAL_ENTITY2.getKey().getAncestors(), entity6.getKey().getAncestors()); + assertEquals(PARTIAL_ENTITY2.getKey().getKind(), entity6.getKey().getKind()); + assertEquals(PARTIAL_ENTITY2.getKey(), IncompleteKey.newBuilder(entity6.getKey()).build()); + assertNotEquals(PARTIAL_ENTITY2.getKey().getPath(), entity6.getKey().getPath()); + assertNotEquals(PARTIAL_ENTITY2.getKey(), entity6.getKey()); + assertSame(entity5, entities.get(2)); + batch.addWithDeferredIdAllocation(PARTIAL_ENTITY3); + batch.put(ENTITY3, entity1, entity2); + + Batch.Response response = batch.submit(); + entities = + datastore.fetch(KEY1, KEY2, KEY3, entity4.getKey(), entity5.getKey(), entity6.getKey()); + assertEquals(entity1, entities.get(0)); + assertEquals(entity2, entities.get(1)); + assertEquals(ENTITY3, entities.get(2)); + assertEquals(entity4, entities.get(3)); + assertEquals(entity5, entities.get(4)); + assertEquals(entity6, entities.get(5)); + assertEquals(6, entities.size()); + List generatedKeys = response.getGeneratedKeys(); + assertEquals(1, generatedKeys.size()); + assertEquals( + PARTIAL_ENTITY3.getProperties(), datastore.get(generatedKeys.get(0)).getProperties()); + assertEquals(PARTIAL_ENTITY3.getKey(), IncompleteKey.newBuilder(generatedKeys.get(0)).build()); + + try { + batch.submit(); + fail("Expecting a failure"); + } catch (DatastoreException ex) { + // expected to fail + } + verifyNotUsable(batch); + + batch = datastore.newBatch(); + batch.delete(entity4.getKey(), entity5.getKey()); + batch.update(ENTITY1, ENTITY2, ENTITY3); + batch.submit(); + entities = datastore.fetch(KEY1, KEY2, KEY3, entity4.getKey(), entity5.getKey()); + assertEquals(ENTITY1, entities.get(0)); + assertEquals(ENTITY2, entities.get(1)); + assertEquals(ENTITY3, entities.get(2)); + assertNull(entities.get(3)); + assertNull(entities.get(4)); + assertEquals(5, entities.size()); + } + + @Test + public void testRunGqlQueryNoCasting() { + Query query1 = + Query.newGqlQueryBuilder(ResultType.ENTITY, "select * from " + KIND1).build(); + QueryResults results1 = datastore.run(query1); + assertTrue(results1.hasNext()); + assertEquals(ENTITY1, results1.next()); + assertFalse(results1.hasNext()); + + datastore.put(ENTITY3); + Query query2 = + Query.newGqlQueryBuilder(ResultType.ENTITY, "select * from " + KIND2 + " order by __key__") + .build(); + QueryResults results2 = datastore.run(query2); + assertTrue(results2.hasNext()); + assertEquals(ENTITY2, results2.next()); + assertTrue(results2.hasNext()); + assertEquals(ENTITY3, results2.next()); + assertFalse(results2.hasNext()); + + query1 = Query.newGqlQueryBuilder(ResultType.ENTITY, "select * from bla").build(); + results1 = datastore.run(query1); + assertFalse(results1.hasNext()); + + Query keyOnlyQuery = + Query.newGqlQueryBuilder(ResultType.KEY, "select __key__ from " + KIND1).build(); + QueryResults keyOnlyResults = datastore.run(keyOnlyQuery); + assertTrue(keyOnlyResults.hasNext()); + assertEquals(KEY1, keyOnlyResults.next()); + assertFalse(keyOnlyResults.hasNext()); + + GqlQuery keyProjectionQuery = + Query.newGqlQueryBuilder(ResultType.PROJECTION_ENTITY, "select __key__ from " + KIND1) + .build(); + QueryResults keyProjectionResult = datastore.run(keyProjectionQuery); + assertTrue(keyProjectionResult.hasNext()); + ProjectionEntity projectionEntity = keyProjectionResult.next(); + assertEquals(KEY1, projectionEntity.getKey()); + assertTrue(projectionEntity.getProperties().isEmpty()); + assertFalse(keyProjectionResult.hasNext()); + + GqlQuery projectionQuery = + Query.newGqlQueryBuilder(ResultType.PROJECTION_ENTITY, "select str, date from " + KIND1) + .build(); + + QueryResults projectionResult = datastore.run(projectionQuery); + assertTrue(projectionResult.hasNext()); + projectionEntity = projectionResult.next(); + assertEquals("str", projectionEntity.getString("str")); + assertEquals(TIMESTAMP_VALUE.get(), projectionEntity.getTimestamp("date")); + assertEquals(2, projectionEntity.getNames().size()); + assertFalse(projectionResult.hasNext()); + } + + @Test + public void testRunGqlQueryWithCasting() { + @SuppressWarnings("unchecked") + Query query1 = + (Query) Query.newGqlQueryBuilder("select * from " + KIND1).build(); + QueryResults results1 = datastore.run(query1); + assertTrue(results1.hasNext()); + assertEquals(ENTITY1, results1.next()); + assertFalse(results1.hasNext()); + + Query query2 = Query.newGqlQueryBuilder("select * from " + KIND1).build(); + QueryResults results2 = datastore.run(query2); + assertSame(Entity.class, results2.getResultClass()); + @SuppressWarnings("unchecked") + QueryResults results3 = (QueryResults) results2; + assertTrue(results3.hasNext()); + assertEquals(ENTITY1, results3.next()); + assertFalse(results3.hasNext()); + } + + @Test + public void testGqlQueryPagination() throws DatastoreException { + List responses = buildResponsesForQueryPagination(); + for (int i = 0; i < responses.size(); i++) { + EasyMock.expect(rpcMock.runQuery(EasyMock.anyObject(RunQueryRequest.class))) + .andReturn(responses.get(i)); + } + EasyMock.replay(rpcFactoryMock, rpcMock); + Datastore mockDatastore = rpcMockOptions.getService(); + QueryResults results = + mockDatastore.run( + Query.newGqlQueryBuilder(ResultType.KEY, "select __key__ from *").build()); + int count = 0; + while (results.hasNext()) { + count += 1; + results.next(); + } + assertEquals(count, 5); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testRunAggregationQuery() { + RunAggregationQueryResponse aggregationQueryResponse = placeholderAggregationQueryResponse(); + EasyMock.expect(rpcMock.runAggregationQuery(matches(aggregationQueryWithAlias("total_count")))) + .andReturn(aggregationQueryResponse); + EasyMock.replay(rpcFactoryMock, rpcMock); + + Datastore mockDatastore = rpcMockOptions.getService(); + + EntityQuery selectAllQuery = Query.newEntityQueryBuilder().build(); + AggregationQuery getCountQuery = + Query.newAggregationQueryBuilder() + .addAggregation(count().as("total_count")) + .over(selectAllQuery) + .build(); + AggregationResult result = getOnlyElement(mockDatastore.runAggregation(getCountQuery)); + + assertThat(result.getLong("total_count")).isEqualTo(209L); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testRunStructuredQuery() { + Query query = + Query.newEntityQueryBuilder().setKind(KIND1).setOrderBy(OrderBy.asc("__key__")).build(); + QueryResults results1 = datastore.run(query); + assertTrue(results1.hasNext()); + assertEquals(ENTITY1, results1.next()); + assertFalse(results1.hasNext()); + + Query keyOnlyQuery = Query.newKeyQueryBuilder().setKind(KIND1).build(); + QueryResults results2 = datastore.run(keyOnlyQuery); + assertTrue(results2.hasNext()); + assertEquals(ENTITY1.getKey(), results2.next()); + assertFalse(results2.hasNext()); + + StructuredQuery keyOnlyProjectionQuery = + Query.newProjectionEntityQueryBuilder().setKind(KIND1).setProjection("__key__").build(); + QueryResults results3 = datastore.run(keyOnlyProjectionQuery); + assertTrue(results3.hasNext()); + ProjectionEntity projectionEntity = results3.next(); + assertEquals(ENTITY1.getKey(), projectionEntity.getKey()); + assertTrue(projectionEntity.getNames().isEmpty()); + assertFalse(results2.hasNext()); + + StructuredQuery projectionQuery = + Query.newProjectionEntityQueryBuilder() + .setKind(KIND2) + .setProjection("age") + .setFilter(PropertyFilter.gt("age", 18)) + .setDistinctOn("age") + .setOrderBy(OrderBy.asc("age")) + .setLimit(10) + .build(); + + QueryResults results4 = datastore.run(projectionQuery); + assertTrue(results4.hasNext()); + ProjectionEntity entity = results4.next(); + assertEquals(ENTITY2.getKey(), entity.getKey()); + assertEquals(20, entity.getLong("age")); + assertEquals(1, entity.getProperties().size()); + assertFalse(results4.hasNext()); + } + + @Test + public void testStructuredQueryPagination() throws DatastoreException { + List responses = buildResponsesForQueryPagination(); + for (int i = 0; i < responses.size(); i++) { + EasyMock.expect(rpcMock.runQuery(EasyMock.anyObject(RunQueryRequest.class))) + .andReturn(responses.get(i)); + } + EasyMock.replay(rpcFactoryMock, rpcMock); + Datastore datastore = rpcMockOptions.getService(); + QueryResults results = datastore.run(Query.newKeyQueryBuilder().build()); + int count = 0; + while (results.hasNext()) { + count += 1; + results.next(); + } + assertEquals(count, 5); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testStructuredQueryPaginationWithMoreResults() throws DatastoreException { + List responses = buildResponsesForQueryPagination(); + for (int i = 0; i < responses.size(); i++) { + EasyMock.expect(rpcMock.runQuery(EasyMock.anyObject(RunQueryRequest.class))) + .andReturn(responses.get(i)); + } + EasyMock.replay(rpcFactoryMock, rpcMock); + Datastore datastore = rpcMockOptions.getService(); + QueryResults results = datastore.run(Query.newKeyQueryBuilder().build()); + int count = 0; + while (results.hasNext()) { + count += 1; + results.next(); + } + assertEquals(count, 5); + assertEquals(QueryResultBatch.MoreResultsType.NO_MORE_RESULTS, results.getMoreResults()); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + private List buildResponsesForQueryPagination() { + Entity entity4 = Entity.newBuilder(KEY4).set("value", StringValue.of("value")).build(); + Entity entity5 = Entity.newBuilder(KEY5).set("value", "value").build(); + datastore.add(ENTITY3, entity4, entity5); + List responses = new ArrayList<>(); + RecordQuery query = Query.newKeyQueryBuilder().build(); + RunQueryRequest.Builder requestPb = RunQueryRequest.newBuilder(); + requestPb.setProjectId(PROJECT_ID); + query.populatePb(requestPb); + QueryResultBatch queryResultBatchPb = + RunQueryResponse.newBuilder() + .mergeFrom(((DatastoreImpl) datastore).runQuery(requestPb.build())) + .getBatch(); + QueryResultBatch queryResultBatchPb1 = + QueryResultBatch.newBuilder() + .mergeFrom(queryResultBatchPb) + .setMoreResults(QueryResultBatch.MoreResultsType.NOT_FINISHED) + .clearEntityResults() + .addAllEntityResults(queryResultBatchPb.getEntityResultsList().subList(0, 1)) + .setEndCursor(queryResultBatchPb.getEntityResultsList().get(0).getCursor()) + .build(); + responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb1).build()); + QueryResultBatch queryResultBatchPb2 = + QueryResultBatch.newBuilder() + .mergeFrom(queryResultBatchPb) + .setMoreResults(QueryResultBatch.MoreResultsType.NOT_FINISHED) + .clearEntityResults() + .addAllEntityResults(queryResultBatchPb.getEntityResultsList().subList(1, 3)) + .setEndCursor(queryResultBatchPb.getEntityResultsList().get(2).getCursor()) + .build(); + responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb2).build()); + QueryResultBatch queryResultBatchPb3 = + QueryResultBatch.newBuilder() + .mergeFrom(queryResultBatchPb) + .setMoreResults(QueryResultBatch.MoreResultsType.NO_MORE_RESULTS) + .clearEntityResults() + .addAllEntityResults(queryResultBatchPb.getEntityResultsList().subList(3, 5)) + .setEndCursor(queryResultBatchPb.getEntityResultsList().get(4).getCursor()) + .build(); + responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb3).build()); + return responses; + } + + @Test + public void testQueryPaginationWithLimit() throws DatastoreException { + List responses = buildResponsesForQueryPaginationWithLimit(); + List endCursors = Lists.newArrayListWithCapacity(responses.size()); + for (RunQueryResponse response : responses) { + EasyMock.expect(rpcMock.runQuery(EasyMock.anyObject(RunQueryRequest.class))) + .andReturn(response); + if (response.getBatch().getMoreResults() != QueryResultBatch.MoreResultsType.NOT_FINISHED) { + endCursors.add(response.getBatch().getEndCursor()); + } + } + EasyMock.replay(rpcFactoryMock, rpcMock); + Datastore datastore = rpcMockOptions.getService(); + int limit = 2; + int totalCount = 0; + Iterator cursorIter = endCursors.iterator(); + StructuredQuery query = Query.newEntityQueryBuilder().setLimit(limit).build(); + while (true) { + QueryResults results = datastore.run(query); + int resultCount = 0; + while (results.hasNext()) { + results.next(); + resultCount++; + totalCount++; + } + assertTrue(cursorIter.hasNext()); + Cursor expectedEndCursor = Cursor.copyFrom(cursorIter.next().toByteArray()); + assertEquals(expectedEndCursor, results.getCursorAfter()); + if (resultCount < limit) { + break; + } + query = query.toBuilder().setStartCursor(results.getCursorAfter()).build(); + } + assertEquals(5, totalCount); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testRunKeyQueryWithOffset() { + Query query = Query.newKeyQueryBuilder().setOffset(Integer.MAX_VALUE).build(); + int numberOfEntities = datastore.run(query).getSkippedResults(); + assertEquals(2, numberOfEntities); + } + + @Test + public void testRunKeyQueryWithLimit() { + datastore.put(ENTITY1, ENTITY2); + Query keyQuery = Query.newKeyQueryBuilder().setLimit(2).build(); + QueryResults queryResults = datastore.run(keyQuery); + int resultCount = 0; + while (queryResults.hasNext()) { + queryResults.next(); + resultCount++; + } + assertEquals(2, resultCount); + + Query query = Query.newKeyQueryBuilder().setLimit(0).build(); + QueryResults results = datastore.run(query); + int count = 0; + while (results.hasNext()) { + results.next(); + count++; + } + assertEquals(0, count); + } + + private List buildResponsesForQueryPaginationWithLimit() { + Entity entity4 = Entity.newBuilder(KEY4).set("value", StringValue.of("value")).build(); + Entity entity5 = Entity.newBuilder(KEY5).set("value", "value").build(); + datastore.add(ENTITY3, entity4, entity5); + DatastoreRpc datastoreRpc = datastore.getOptions().getDatastoreRpcV1(); + List responses = new ArrayList<>(); + RecordQuery query = Query.newEntityQueryBuilder().build(); + RunQueryRequest.Builder requestPb = RunQueryRequest.newBuilder(); + requestPb.setProjectId(PROJECT_ID); + query.populatePb(requestPb); + QueryResultBatch queryResultBatchPb = + RunQueryResponse.newBuilder() + .mergeFrom(datastoreRpc.runQuery(requestPb.build())) + .getBatch(); + QueryResultBatch queryResultBatchPb1 = + QueryResultBatch.newBuilder() + .mergeFrom(queryResultBatchPb) + .setMoreResults(QueryResultBatch.MoreResultsType.NOT_FINISHED) + .clearEntityResults() + .addAllEntityResults(queryResultBatchPb.getEntityResultsList().subList(0, 1)) + .setEndCursor(ByteString.copyFromUtf8("a")) + .build(); + responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb1).build()); + QueryResultBatch queryResultBatchPb2 = + QueryResultBatch.newBuilder() + .mergeFrom(queryResultBatchPb) + .setMoreResults(QueryResultBatch.MoreResultsType.MORE_RESULTS_AFTER_LIMIT) + .clearEntityResults() + .addAllEntityResults(queryResultBatchPb.getEntityResultsList().subList(1, 2)) + .setEndCursor( + ByteString.copyFrom(new byte[] {(byte) 0x80})) // test invalid UTF-8 string + .build(); + responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb2).build()); + QueryResultBatch queryResultBatchPb3 = + QueryResultBatch.newBuilder() + .mergeFrom(queryResultBatchPb) + .setMoreResults(QueryResultBatch.MoreResultsType.MORE_RESULTS_AFTER_LIMIT) + .clearEntityResults() + .addAllEntityResults(queryResultBatchPb.getEntityResultsList().subList(2, 4)) + .setEndCursor(ByteString.copyFromUtf8("b")) + .build(); + responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb3).build()); + QueryResultBatch queryResultBatchPb4 = + QueryResultBatch.newBuilder() + .mergeFrom(queryResultBatchPb) + .setMoreResults(QueryResultBatch.MoreResultsType.NO_MORE_RESULTS) + .clearEntityResults() + .addAllEntityResults(queryResultBatchPb.getEntityResultsList().subList(4, 5)) + .setEndCursor(ByteString.copyFromUtf8("c")) + .build(); + responses.add(RunQueryResponse.newBuilder().setBatch(queryResultBatchPb4).build()); + return responses; + } + + @Test + public void testEventualConsistencyQuery() { + ReadOptions readOption = + ReadOptions.newBuilder().setReadConsistencyValue(ReadConsistency.EVENTUAL_VALUE).build(); + com.google.datastore.v1.GqlQuery query = + com.google.datastore.v1.GqlQuery.newBuilder().setQueryString("FROM * SELECT *").build(); + RunQueryRequest.Builder expectedRequest = + RunQueryRequest.newBuilder() + .setReadOptions(readOption) + .setGqlQuery(query) + .setProjectId(PROJECT_ID) + .setPartitionId(PartitionId.newBuilder().setProjectId(PROJECT_ID).build()); + EasyMock.expect(rpcMock.runQuery(expectedRequest.build())) + .andReturn(RunQueryResponse.newBuilder().build()); + EasyMock.replay(rpcFactoryMock, rpcMock); + Datastore datastore = rpcMockOptions.getService(); + datastore.run( + Query.newGqlQueryBuilder("FROM * SELECT *").build(), ReadOption.eventualConsistency()); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testReadTimeQuery() { + Timestamp timestamp = Timestamp.now(); + ReadOptions readOption = ReadOptions.newBuilder().setReadTime(timestamp.toProto()).build(); + com.google.datastore.v1.GqlQuery query = + com.google.datastore.v1.GqlQuery.newBuilder().setQueryString("FROM * SELECT *").build(); + RunQueryRequest.Builder expectedRequest = + RunQueryRequest.newBuilder() + .setReadOptions(readOption) + .setGqlQuery(query) + .setProjectId(PROJECT_ID) + .setPartitionId(PartitionId.newBuilder().setProjectId(PROJECT_ID).build()); + EasyMock.expect(rpcMock.runQuery(expectedRequest.build())) + .andReturn(RunQueryResponse.newBuilder().build()); + EasyMock.replay(rpcFactoryMock, rpcMock); + Datastore datastore = rpcMockOptions.getService(); + datastore.run( + Query.newGqlQueryBuilder("FROM * SELECT *").build(), ReadOption.readTime(timestamp)); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testToUrlSafe() { + byte[][] invalidUtf8 = + new byte[][] {{(byte) 0xfe}, {(byte) 0xc1, (byte) 0xbf}, {(byte) 0xc0}, {(byte) 0x80}}; + for (byte[] bytes : invalidUtf8) { + assertFalse(ByteString.copyFrom(bytes).isValidUtf8()); + Cursor cursor = new Cursor(ByteString.copyFrom(bytes)); + assertEquals(cursor, Cursor.fromUrlSafe(cursor.toUrlSafe())); + } + } + + @Test + public void testAllocateId() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind(KIND1); + IncompleteKey pk1 = keyFactory.newKey(); + Key key1 = datastore.allocateId(pk1); + assertEquals(key1.getProjectId(), pk1.getProjectId()); + assertEquals(key1.getNamespace(), pk1.getNamespace()); + assertEquals(key1.getAncestors(), pk1.getAncestors()); + assertEquals(key1.getKind(), pk1.getKind()); + assertTrue(key1.hasId()); + assertFalse(key1.hasName()); + assertEquals(Key.newBuilder(pk1, key1.getId()).build(), key1); + + Key key2 = datastore.allocateId(pk1); + assertNotEquals(key1, key2); + assertEquals(Key.newBuilder(pk1, key2.getId()).build(), key2); + + try { + datastore.allocateId(key1); + fail("Expecting a failure"); + } catch (IllegalArgumentException expected) { + assertEquals(expected.getMessage(), "keys must be IncompleteKey instances"); + } + } + + @Test + public void testAllocateIdArray() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind(KIND1); + IncompleteKey incompleteKey1 = keyFactory.newKey(); + IncompleteKey incompleteKey2 = + keyFactory.setKind(KIND2).addAncestor(PathElement.of(KIND1, 10)).newKey(); + Key key3 = keyFactory.newKey("name"); + List result1 = datastore.allocateId(incompleteKey1, incompleteKey2, incompleteKey1); + assertEquals(3, result1.size()); + assertEquals(Key.newBuilder(incompleteKey1, result1.get(0).getId()).build(), result1.get(0)); + assertEquals(Key.newBuilder(incompleteKey1, result1.get(2).getId()).build(), result1.get(2)); + assertEquals(Key.newBuilder(incompleteKey2, result1.get(1).getId()).build(), result1.get(1)); + + try { + datastore.allocateId(incompleteKey1, incompleteKey2, key3); + fail("expecting a failure"); + } catch (IllegalArgumentException expected) { + assertEquals(expected.getMessage(), "keys must be IncompleteKey instances"); + } + } + + @Test + public void testReserveIds() { + ReserveIdsRequest reserveIdsRequest = + ReserveIdsRequest.newBuilder().setProjectId(PROJECT_ID).addKeys(KEY1.toPb()).build(); + EasyMock.expect(rpcMock.reserveIds(reserveIdsRequest)) + .andReturn(ReserveIdsResponse.newBuilder().build()) + .times(1); + EasyMock.replay(rpcFactoryMock, rpcMock); + Datastore datastore = rpcMockOptions.getService(); + datastore.reserveIds(KEY1); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testReserveIdsWithKeys() { + Datastore datastore = createStrictMock(Datastore.class); + EasyMock.expect(datastore.reserveIds(KEY1, KEY2)).andReturn(Arrays.asList(KEY1, KEY2)); + replay(datastore); + List result = datastore.reserveIds(KEY1, KEY2); + assertEquals(KEY1, result.get(0)); + assertEquals(KEY2, result.get(1)); + verify(datastore); + } + + @Test + public void testGet() { + Entity entity = datastore.get(KEY3); + assertNull(entity); + + entity = datastore.get(KEY1); + assertEquals(ENTITY1, entity); + StringValue value1 = entity.getValue("str"); + assertEquals(STR_VALUE, value1); + BooleanValue value2 = entity.getValue("bool"); + assertEquals(BOOL_VALUE, value2); + ListValue value3 = entity.getValue("list"); + assertEquals(LIST_VALUE2, value3); + TimestampValue value4 = entity.getValue("date"); + assertEquals(TIMESTAMP_VALUE, value4); + LatLngValue value5 = entity.getValue("latLng"); + assertEquals(LAT_LNG_VALUE, value5); + FullEntity value6 = entity.getEntity("partial1"); + assertEquals(PARTIAL_ENTITY1, value6); + ListValue value7 = entity.getValue("emptyList"); + assertEquals(EMPTY_LIST_VALUE, value7); + assertEquals(7, entity.getNames().size()); + assertFalse(entity.contains("bla")); + } + + @Test + public void testLookupEventualConsistency() { + ReadOptions readOption = + ReadOptions.newBuilder().setReadConsistencyValue(ReadConsistency.EVENTUAL_VALUE).build(); + com.google.datastore.v1.Key key = + com.google.datastore.v1.Key.newBuilder() + .setPartitionId(PartitionId.newBuilder().setProjectId(PROJECT_ID).build()) + .addPath( + com.google.datastore.v1.Key.PathElement.newBuilder() + .setKind("kind1") + .setName("name") + .build()) + .build(); + LookupRequest lookupRequest = + LookupRequest.newBuilder() + .setProjectId(PROJECT_ID) + .setReadOptions(readOption) + .addKeys(key) + .build(); + EasyMock.expect(rpcMock.lookup(lookupRequest)) + .andReturn(LookupResponse.newBuilder().build()) + .times(3); + EasyMock.replay(rpcFactoryMock, rpcMock); + Datastore datastore = rpcMockOptions.getService(); + datastore.get(KEY1, ReadOption.eventualConsistency()); + datastore.get(ImmutableList.of(KEY1), ReadOption.eventualConsistency()); + datastore.fetch(ImmutableList.of(KEY1), ReadOption.eventualConsistency()); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testLookupReadTime() { + Timestamp timestamp = Timestamp.now(); + ReadOptions readOption = ReadOptions.newBuilder().setReadTime(timestamp.toProto()).build(); + com.google.datastore.v1.Key key = + com.google.datastore.v1.Key.newBuilder() + .setPartitionId(PartitionId.newBuilder().setProjectId(PROJECT_ID).build()) + .addPath( + com.google.datastore.v1.Key.PathElement.newBuilder() + .setKind("kind1") + .setName("name") + .build()) + .build(); + LookupRequest lookupRequest = + LookupRequest.newBuilder() + .setProjectId(PROJECT_ID) + .setReadOptions(readOption) + .addKeys(key) + .build(); + EasyMock.expect(rpcMock.lookup(lookupRequest)) + .andReturn(LookupResponse.newBuilder().build()) + .times(3); + EasyMock.replay(rpcFactoryMock, rpcMock); + com.google.cloud.datastore.Datastore datastore = rpcMockOptions.getService(); + datastore.get(KEY1, com.google.cloud.datastore.ReadOption.readTime(timestamp)); + datastore.get( + ImmutableList.of(KEY1), com.google.cloud.datastore.ReadOption.readTime(timestamp)); + datastore.fetch( + ImmutableList.of(KEY1), com.google.cloud.datastore.ReadOption.readTime(timestamp)); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testGetArrayNoDeferredResults() { + datastore.put(ENTITY3); + Iterator result = + datastore.fetch(KEY1, Key.newBuilder(KEY1).setName("bla").build(), KEY2, KEY3).iterator(); + assertEquals(ENTITY1, result.next()); + assertNull(result.next()); + assertEquals(ENTITY2, result.next()); + Entity entity3 = result.next(); + assertEquals(ENTITY3, entity3); + assertTrue(entity3.isNull("null")); + assertFalse(entity3.getBoolean("bool")); + assertEquals(LIST_VALUE2.get(), entity3.getList("list")); + FullEntity partial1 = entity3.getEntity("partial1"); + FullEntity partial2 = entity3.getEntity("partial2"); + assertEquals(PARTIAL_ENTITY2, partial1); + assertEquals(ENTITY2, partial2); + assertEquals(ValueType.BOOLEAN, entity3.getValue("bool").getType()); + assertEquals(LAT_LNG_VALUE, entity3.getValue("latLng")); + assertEquals(EMPTY_LIST_VALUE, entity3.getValue("emptyList")); + assertEquals(8, entity3.getNames().size()); + assertFalse(entity3.contains("bla")); + try { + entity3.getString("str"); + fail("Expecting a failure"); + } catch (DatastoreException expected) { + // expected - no such property + } + assertFalse(result.hasNext()); + } + + @Test + public void testGetArrayDeferredResults() throws DatastoreException { + Set requestedKeys = new HashSet<>(); + requestedKeys.add(KEY1); + requestedKeys.add(KEY2); + requestedKeys.add(KEY3); + requestedKeys.add(KEY4); + requestedKeys.add(KEY5); + Iterator iter = createDatastoreForDeferredLookup().get(KEY1, KEY2, KEY3, KEY4, KEY5); + Set keysOfFoundEntities = new HashSet<>(); + while (iter.hasNext()) { + keysOfFoundEntities.add(iter.next().getKey()); + } + assertEquals(requestedKeys, keysOfFoundEntities); + } + + @Test + public void testFetchArrayDeferredResults() throws DatastoreException { + List foundEntities = + createDatastoreForDeferredLookup().fetch(KEY1, KEY2, KEY3, KEY4, KEY5); + assertEquals(foundEntities.get(0).getKey(), KEY1); + assertEquals(foundEntities.get(1).getKey(), KEY2); + assertEquals(foundEntities.get(2).getKey(), KEY3); + assertEquals(foundEntities.get(3).getKey(), KEY4); + assertEquals(foundEntities.get(4).getKey(), KEY5); + assertEquals(foundEntities.size(), 5); + } + + private Datastore createDatastoreForDeferredLookup() throws DatastoreException { + List keysPb = new ArrayList<>(); + keysPb.add(KEY1.toPb()); + keysPb.add(KEY2.toPb()); + keysPb.add(KEY3.toPb()); + keysPb.add(KEY4.toPb()); + keysPb.add(KEY5.toPb()); + List lookupRequests = new ArrayList<>(); + lookupRequests.add( + LookupRequest.newBuilder().setProjectId(PROJECT_ID).addAllKeys(keysPb).build()); + lookupRequests.add( + LookupRequest.newBuilder() + .setProjectId(PROJECT_ID) + .addKeys(keysPb.get(1)) + .addKeys(keysPb.get(2)) + .addKeys(keysPb.get(4)) + .build()); + lookupRequests.add( + LookupRequest.newBuilder().setProjectId(PROJECT_ID).addKeys(keysPb.get(4)).build()); + Entity entity4 = Entity.newBuilder(KEY4).set("value", StringValue.of("value")).build(); + Entity entity5 = Entity.newBuilder(KEY5).set("value", "value").build(); + List lookupResponses = new ArrayList<>(); + lookupResponses.add( + LookupResponse.newBuilder() + .addFound(EntityResult.newBuilder().setEntity(ENTITY1.toPb())) + .addFound(EntityResult.newBuilder().setEntity(entity4.toPb())) + .addDeferred(keysPb.get(1)) + .addDeferred(keysPb.get(2)) + .addDeferred(keysPb.get(4)) + .build()); + lookupResponses.add( + LookupResponse.newBuilder() + .addFound(EntityResult.newBuilder().setEntity(ENTITY2.toPb())) + .addFound(EntityResult.newBuilder().setEntity(ENTITY3.toPb())) + .addDeferred(keysPb.get(4)) + .build()); + lookupResponses.add( + LookupResponse.newBuilder() + .addFound(EntityResult.newBuilder().setEntity(entity5.toPb())) + .build()); + for (int i = 0; i < lookupRequests.size(); i++) { + EasyMock.expect(rpcMock.lookup(lookupRequests.get(i))).andReturn(lookupResponses.get(i)); + } + EasyMock.replay(rpcFactoryMock, rpcMock); + return rpcMockOptions.getService(); + } + + @Test + public void testAddEntity() { + List keys = datastore.fetch(ENTITY1.getKey(), ENTITY3.getKey()); + assertEquals(ENTITY1, keys.get(0)); + assertNull(keys.get(1)); + assertEquals(2, keys.size()); + + try { + datastore.add(ENTITY1); + fail("Expecting a failure"); + } catch (DatastoreException expected) { + // expected; + } + + List entities = datastore.add(ENTITY3, PARTIAL_ENTITY1, PARTIAL_ENTITY2); + assertEquals(ENTITY3, datastore.get(ENTITY3.getKey())); + assertEquals(ENTITY3, entities.get(0)); + assertEquals(PARTIAL_ENTITY1.getProperties(), entities.get(1).getProperties()); + assertEquals(PARTIAL_ENTITY1.getKey().getAncestors(), entities.get(1).getKey().getAncestors()); + assertNotNull(datastore.get(entities.get(1).getKey())); + assertEquals(PARTIAL_ENTITY2.getProperties(), entities.get(2).getProperties()); + assertEquals(PARTIAL_ENTITY2.getKey().getAncestors(), entities.get(2).getKey().getAncestors()); + assertNotNull(datastore.get(entities.get(2).getKey())); + } + + @Test + public void testUpdate() { + List keys = datastore.fetch(ENTITY1.getKey(), ENTITY3.getKey()); + assertEquals(ENTITY1, keys.get(0)); + assertNull(keys.get(1)); + assertEquals(2, keys.size()); + + try { + datastore.update(ENTITY3); + fail("Expecting a failure"); + } catch (DatastoreException expected) { + // expected; + } + datastore.add(ENTITY3); + assertEquals(ENTITY3, datastore.get(ENTITY3.getKey())); + Entity entity3 = Entity.newBuilder(ENTITY3).clear().set("bla", new NullValue()).build(); + assertNotEquals(ENTITY3, entity3); + datastore.update(entity3); + assertEquals(entity3, datastore.get(ENTITY3.getKey())); + } + + @Test + public void testPut() { + Entity updatedEntity = Entity.newBuilder(ENTITY1).set("new_property", 42L).build(); + assertEquals(updatedEntity, datastore.put(updatedEntity)); + assertEquals(updatedEntity, datastore.get(updatedEntity.getKey())); + + Entity entity2 = Entity.newBuilder(ENTITY2).clear().set("bla", new NullValue()).build(); + assertNotEquals(ENTITY2, entity2); + List entities = datastore.put(ENTITY1, entity2, ENTITY3, PARTIAL_ENTITY1); + assertEquals(ENTITY1, entities.get(0)); + assertEquals(entity2, entities.get(1)); + assertEquals(ENTITY3, entities.get(2)); + assertEquals(PARTIAL_ENTITY1.getProperties(), entities.get(3).getProperties()); + assertEquals(PARTIAL_ENTITY1.getKey().getAncestors(), entities.get(3).getKey().getAncestors()); + assertEquals(ENTITY1, datastore.get(ENTITY1.getKey())); + assertEquals(entity2, datastore.get(entity2.getKey())); + assertEquals(ENTITY3, datastore.get(ENTITY3.getKey())); + Entity entity = datastore.get(entities.get(3).getKey()); + assertEquals(entities.get(3), entity); + } + + @Test + public void testDelete() { + Iterator keys = + datastore.fetch(ENTITY1.getKey(), ENTITY2.getKey(), ENTITY3.getKey()).iterator(); + assertEquals(ENTITY1, keys.next()); + assertEquals(ENTITY2, keys.next()); + assertNull(keys.next()); + assertFalse(keys.hasNext()); + datastore.delete(ENTITY1.getKey(), ENTITY2.getKey(), ENTITY3.getKey()); + keys = datastore.fetch(ENTITY1.getKey(), ENTITY2.getKey(), ENTITY3.getKey()).iterator(); + assertNull(keys.next()); + assertNull(keys.next()); + assertNull(keys.next()); + assertFalse(keys.hasNext()); + } + + @Test + public void testKeyFactory() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind(KIND1); + assertEquals(INCOMPLETE_KEY1, keyFactory.newKey()); + assertEquals( + IncompleteKey.newBuilder(INCOMPLETE_KEY1).setKind(KIND2).build(), + datastore.newKeyFactory().setKind(KIND2).newKey()); + assertEquals(KEY1, keyFactory.newKey("name")); + assertEquals(Key.newBuilder(KEY1).setId(2).build(), keyFactory.newKey(2)); + } + + @Test + public void testRetryableException() { + LookupRequest requestPb = + LookupRequest.newBuilder().setProjectId(PROJECT_ID).addKeys(KEY1.toPb()).build(); + LookupResponse responsePb = + LookupResponse.newBuilder() + .addFound(EntityResult.newBuilder().setEntity(ENTITY1.toPb())) + .build(); + EasyMock.expect(rpcMock.lookup(requestPb)) + .andThrow(new DatastoreException(14, "UNAVAILABLE", "UNAVAILABLE", null)) + .andReturn(responsePb); + EasyMock.replay(rpcFactoryMock, rpcMock); + Datastore datastore = rpcMockOptions.getService(); + Entity entity = datastore.get(KEY1); + assertEquals(ENTITY1, entity); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testRetryableExceptionForOperationWithTxn() { + ByteString txnBytes = ByteString.copyFromUtf8("txn1"); + LookupRequest requestPb = + LookupRequest.newBuilder() + .setProjectId(PROJECT_ID) + .addKeys(KEY1.toPb()) + .setReadOptions(ReadOptions.newBuilder().setTransaction(txnBytes).build()) + .build(); + LookupResponse responsePb = + LookupResponse.newBuilder() + .addFound(EntityResult.newBuilder().setEntity(ENTITY1.toPb())) + .build(); + EasyMock.expect(rpcMock.beginTransaction(EasyMock.anyObject(BeginTransactionRequest.class))) + .andReturn(BeginTransactionResponse.newBuilder().setTransaction(txnBytes).build()); + EasyMock.expect(rpcMock.lookup(requestPb)) + .andThrow(new DatastoreException(14, "UNAVAILABLE", "UNAVAILABLE", null)) + .andReturn(responsePb); + EasyMock.replay(rpcFactoryMock, rpcMock); + Datastore datastore = rpcMockOptions.getService(); + Transaction transaction = datastore.newTransaction(); + Entity entity = transaction.get(KEY1); + assertEquals(ENTITY1, entity); + EasyMock.verify(rpcFactoryMock, rpcMock); + } + + @Test + public void testNonRetryableExceptionForOperationWithTxn() { + ByteString txnBytes = ByteString.copyFromUtf8("txn1"); + LookupRequest requestPb = + LookupRequest.newBuilder() + .setProjectId(PROJECT_ID) + .addKeys(KEY1.toPb()) + .setReadOptions(ReadOptions.newBuilder().setTransaction(txnBytes).build()) + .build(); + EasyMock.expect(rpcMock.beginTransaction(EasyMock.anyObject(BeginTransactionRequest.class))) + .andReturn(BeginTransactionResponse.newBuilder().setTransaction(txnBytes).build()); + EasyMock.expect(rpcMock.lookup(requestPb)) + .andThrow(new DatastoreException(10, "ABORTED", "ABORTED", null)) + .times(1); + EasyMock.replay(rpcFactoryMock, rpcMock); + try { + Datastore datastore = rpcMockOptions.getService(); + Transaction transaction = datastore.newTransaction(); + transaction.get(KEY1); + Assert.fail(); + EasyMock.verify(rpcFactoryMock, rpcMock); + } catch (DatastoreException ex) { + assertEquals("ABORTED", ex.getMessage()); + } + } + + @Test + public void testNonRetryableException() { + LookupRequest requestPb = + LookupRequest.newBuilder().setProjectId(PROJECT_ID).addKeys(KEY1.toPb()).build(); + EasyMock.expect(rpcMock.lookup(requestPb)) + .andThrow( + new DatastoreException(DatastoreException.UNKNOWN_CODE, "denied", "PERMISSION_DENIED")) + .times(1); + EasyMock.replay(rpcFactoryMock, rpcMock); + try { + Datastore datastore = rpcMockOptions.getService(); + datastore.get(KEY1); + Assert.fail(); + EasyMock.verify(rpcFactoryMock, rpcMock); + } catch (DatastoreException ex) { + assertEquals("denied", ex.getMessage()); + } + } + + @Test + public void testRuntimeException() { + LookupRequest requestPb = + LookupRequest.newBuilder().setProjectId(PROJECT_ID).addKeys(KEY1.toPb()).build(); + String exceptionMessage = "Artificial runtime exception"; + EasyMock.expect(rpcMock.lookup(requestPb)).andThrow(new RuntimeException(exceptionMessage)); + EasyMock.replay(rpcFactoryMock, rpcMock); + try { + Datastore datastore = rpcMockOptions.getService(); + datastore.get(KEY1); + Assert.fail(); + EasyMock.verify(rpcFactoryMock, rpcMock); + } catch (DatastoreException ex) { + assertEquals(exceptionMessage, ex.getCause().getMessage()); + } + } + + @Test + public void testGqlQueryWithNullBinding() { + Query query = + Query.newGqlQueryBuilder(ResultType.ENTITY, "select * from " + KIND1) + .setNullBinding("name") + .build(); + Iterator results = datastore.run(query); + assertTrue(results.hasNext()); + assertEquals(ENTITY1, results.next()); + assertFalse(results.hasNext()); + + Query gqlQuery = + Query.newGqlQueryBuilder(ResultType.ENTITY, "select * from " + KIND1) + .setNullBinding("name") + .build(); + Iterator queryResults = datastore.run(gqlQuery); + int count = 0; + while (queryResults.hasNext()) { + queryResults.next(); + count++; + } + assertEquals(1, count); + } + + @Test + public void testQueryWithStartCursor() { + Entity entity1 = + Entity.newBuilder(Key.newBuilder(PROJECT_ID, KIND1, "name-01").build()).build(); + Entity entity2 = + Entity.newBuilder(Key.newBuilder(PROJECT_ID, KIND1, "name-02").build()).build(); + Entity entity3 = + Entity.newBuilder(Key.newBuilder(PROJECT_ID, KIND1, "name-03").build()).build(); + datastore.put(entity1, entity2, entity3); + QueryResults run1 = datastore.run(Query.newEntityQueryBuilder().setKind(KIND1).build()); + run1.next(); + Cursor cursor1 = run1.getCursorAfter(); + assertNotNull(cursor1); + QueryResults run2 = + datastore.run(Query.newEntityQueryBuilder().setKind(KIND1).setStartCursor(cursor1).build()); + Cursor cursor2 = run2.getCursorAfter(); + assertNotNull(cursor2); + assertEquals(cursor2, cursor1); + datastore.delete(entity1.getKey(), entity2.getKey(), entity3.getKey()); + } + + @Test + public void testDatabaseIdKeyFactory() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind(KIND1); + + Key key1 = keyFactory.newKey("key1"); + checkKeyProperties(key1); + + Key key2 = keyFactory.newKey(123); + checkKeyProperties(key2); + + IncompleteKey incompleteKey = keyFactory.newKey(); + checkKeyProperties(incompleteKey); + } + + private void checkKeyProperties(BaseKey key) { + assertEquals(options.getDatabaseId(), key.getDatabaseId()); + assertEquals(options.getProjectId(), key.getProjectId()); + assertEquals(options.getNamespace(), key.getNamespace()); + } + + private RunAggregationQueryResponse placeholderAggregationQueryResponse() { + Map result1 = + new HashMap<>(ImmutableMap.of("total_count", intValue(209))); + + AggregationResultBatch resultBatch = + AggregationResultBatch.newBuilder() + .addAggregationResults( + com.google.datastore.v1.AggregationResult.newBuilder() + .putAllAggregateProperties(result1) + .build()) + .build(); + return RunAggregationQueryResponse.newBuilder().setBatch(resultBatch).build(); + } + + private Predicate aggregationQueryWithAlias(String alias) { + return runAggregationQueryRequest -> + alias.equals( + runAggregationQueryRequest + .getAggregationQuery() + .getAggregationsList() + .get(0) + .getAlias()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/AggregationQueryTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/AggregationQueryTest.java new file mode 100644 index 000000000000..830c5832994e --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/AggregationQueryTest.java @@ -0,0 +1,208 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import static com.google.cloud.datastore.AggregationQuery.Mode.GQL; +import static com.google.cloud.datastore.AggregationQuery.Mode.STRUCTURED; +import static com.google.cloud.datastore.StructuredQuery.PropertyFilter.eq; +import static com.google.cloud.datastore.aggregation.Aggregation.avg; +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.cloud.datastore.aggregation.Aggregation.sum; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertThrows; + +import com.google.cloud.datastore.aggregation.AvgAggregation; +import com.google.cloud.datastore.aggregation.CountAggregation; +import com.google.cloud.datastore.aggregation.SumAggregation; +import com.google.common.collect.ImmutableSet; +import org.junit.Test; + +public class AggregationQueryTest { + + private static final String KIND = "Task"; + private static final String NAMESPACE = "ns"; + private static final EntityQuery COMPLETED_TASK_QUERY = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND) + .setFilter(eq("done", true)) + .setLimit(100) + .build(); + + @Test + public void testAggregations() { + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregation(new CountAggregation("total")) + .over(COMPLETED_TASK_QUERY) + .build(); + + assertThat(aggregationQuery.getNamespace()).isEqualTo(NAMESPACE); + assertThat(aggregationQuery.getAggregations()) + .isEqualTo(ImmutableSet.of(count().as("total").build())); + assertThat(aggregationQuery.getNestedStructuredQuery()).isEqualTo(COMPLETED_TASK_QUERY); + assertThat(aggregationQuery.getMode()).isEqualTo(STRUCTURED); + } + + @Test + public void testAggregationBuilderWithMultipleAggregationsOneByOne() { + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregation(count().as("total")) + .addAggregation(sum("marks").as("total_marks")) + .addAggregation(avg("marks").as("avg_marks")) + .over(COMPLETED_TASK_QUERY) + .build(); + + assertThat(aggregationQuery.getAggregations()) + .isEqualTo( + ImmutableSet.of( + count().as("total").build(), + sum("marks").as("total_marks").build(), + avg("marks").as("avg_marks").build())); + } + + @Test + public void testAggregationBuilderWithMultipleAggregationsTogether() { + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregations( + count().as("total"), sum("marks").as("total_marks"), avg("marks").as("avg_marks")) + .over(COMPLETED_TASK_QUERY) + .build(); + + assertThat(aggregationQuery.getAggregations()) + .isEqualTo( + ImmutableSet.of( + count().as("total").build(), + sum("marks").as("total_marks").build(), + avg("marks").as("avg_marks").build())); + } + + @Test + public void testAggregationBuilderWithMultipleAggregationsConfiguredThroughConstructor() { + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregations( + new CountAggregation("total"), + new SumAggregation("total_marks", "marks"), + new AvgAggregation("avg_marks", "marks")) + .over(COMPLETED_TASK_QUERY) + .build(); + + assertThat(aggregationQuery.getAggregations()) + .isEqualTo( + ImmutableSet.of( + count().as("total").build(), + sum("marks").as("total_marks").build(), + avg("marks").as("avg_marks").build())); + } + + @Test + public void testAggregationBuilderWithDuplicateAggregations() { + AggregationQuery aggregationQueryWithDuplicateCounts = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregation(count().as("total")) + .addAggregation(count().as("total")) + .over(COMPLETED_TASK_QUERY) + .build(); + AggregationQuery aggregationQueryWithDuplicateSum = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregation(sum("marks").as("total")) + .addAggregation(sum("marks").as("total")) + .over(COMPLETED_TASK_QUERY) + .build(); + AggregationQuery aggregationQueryWithDuplicateAvg = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregation(avg("marks").as("avg_marks")) + .addAggregation(avg("marks").as("avg_marks")) + .over(COMPLETED_TASK_QUERY) + .build(); + + assertThat(aggregationQueryWithDuplicateCounts.getAggregations()) + .isEqualTo(ImmutableSet.of(count().as("total").build())); + assertThat(aggregationQueryWithDuplicateSum.getAggregations()) + .isEqualTo(ImmutableSet.of(sum("marks").as("total").build())); + assertThat(aggregationQueryWithDuplicateAvg.getAggregations()) + .isEqualTo(ImmutableSet.of(avg("marks").as("avg_marks").build())); + } + + @Test + public void testAggregationQueryBuilderWithoutNamespace() { + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .addAggregation(count().as("total")) + .over(COMPLETED_TASK_QUERY) + .build(); + + assertNull(aggregationQuery.getNamespace()); + assertThat(aggregationQuery.getAggregations()) + .isEqualTo(ImmutableSet.of(count().as("total").build())); + assertThat(aggregationQuery.getNestedStructuredQuery()).isEqualTo(COMPLETED_TASK_QUERY); + assertThat(aggregationQuery.getMode()).isEqualTo(STRUCTURED); + } + + @Test + public void testAggregationQueryBuilderWithoutNestedQuery() { + assertThrows( + "Nested query is required for an aggregation query to run", + IllegalArgumentException.class, + () -> + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregation(count().as("total")) + .build()); + } + + @Test + public void testAggregationQueryBuilderWithoutAggregation() { + assertThrows( + "At least one aggregation is required for an aggregation query to run", + IllegalArgumentException.class, + () -> + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .over(COMPLETED_TASK_QUERY) + .build()); + } + + @Test + public void testAggregationQueryBuilderWithGqlQuery() { + GqlQuery gqlQuery = Query.newGqlQueryBuilder("SELECT * FROM Task WHERE done = true").build(); + + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder().setNamespace(NAMESPACE).over(gqlQuery).build(); + + assertThat(aggregationQuery.getNestedGqlQuery()).isEqualTo(gqlQuery); + assertThat(aggregationQuery.getMode()).isEqualTo(GQL); + } + + @Test + public void testAggregationQueryBuilderWithoutProvidingAnyNestedQuery() { + assertThrows( + "Nested query is required for an aggregation query to run", + IllegalArgumentException.class, + () -> Query.newAggregationQueryBuilder().setNamespace(NAMESPACE).build()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/AggregationResultTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/AggregationResultTest.java new file mode 100644 index 000000000000..8728cfab0b02 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/AggregationResultTest.java @@ -0,0 +1,99 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertThrows; + +import com.google.common.collect.ImmutableMap; +import org.junit.Test; + +public class AggregationResultTest { + + @Test + public void shouldGetLongAggregatedResultValueByAlias() { + AggregationResult aggregationResult = + new AggregationResult( + ImmutableMap.of( + "count", LongValue.of(45), + "property_2", LongValue.of(30))); + + assertThat(aggregationResult.getLong("count")).isEqualTo(45L); + assertThat(aggregationResult.getLong("property_2")).isEqualTo(30L); + } + + @Test + public void shouldGetDoubleAggregatedResultValueByAlias() { + AggregationResult aggregationResult = + new AggregationResult( + ImmutableMap.of( + "qty_avg", DoubleValue.of(45.9322), + "qty_sum", DoubleValue.of(783.2134))); + + assertThat(aggregationResult.getDouble("qty_avg")).isEqualTo(45.9322); + assertThat(aggregationResult.getDouble("qty_sum")).isEqualTo(783.2134); + } + + @Test + public void shouldGetLongAggregatedResultValueAsDouble() { + AggregationResult aggregationResult = + new AggregationResult(ImmutableMap.of("count", LongValue.of(45))); + + assertThat(aggregationResult.getDouble("count")).isEqualTo(45D); + } + + @Test + public void shouldGetDoubleAggregatedResultValueAsLong() { + AggregationResult aggregationResult = + new AggregationResult(ImmutableMap.of("qty_avg", DoubleValue.of(45.9322))); + + assertThat(aggregationResult.getLong("qty_avg")).isEqualTo(45L); + } + + @Test + public void shouldThrowRuntimeExceptionOnUnknownTypes() { + AggregationResult aggregationResult = + new AggregationResult( + ImmutableMap.of( + "qty_avg", BooleanValue.of(true))); // only double and long types are supported + + RuntimeException e1 = + assertThrows(RuntimeException.class, () -> aggregationResult.getLong("qty_avg")); + assertThat(e1.getMessage()).isEqualTo("Unsupported type BOOLEAN received for alias 'qty_avg'."); + + RuntimeException e2 = + assertThrows(RuntimeException.class, () -> aggregationResult.getDouble("qty_avg")); + assertThat(e2.getMessage()).isEqualTo("Unsupported type BOOLEAN received for alias 'qty_avg'."); + + RuntimeException e3 = + assertThrows(RuntimeException.class, () -> aggregationResult.getNumber("qty_avg")); + assertThat(e3.getMessage()).isEqualTo("Unsupported type BOOLEAN received for alias 'qty_avg'."); + } + + @Test + public void shouldGetDoubleAggregatedResultValueAsNumber() { + AggregationResult aggregationResult = + new AggregationResult(ImmutableMap.of("qty_avg", DoubleValue.of(45.9322))); + assertThat(aggregationResult.getNumber("qty_avg")).isEqualTo(45.9322); + } + + @Test + public void shouldGetLongAggregatedResultValueAsNumber() { + AggregationResult aggregationResult = + new AggregationResult(ImmutableMap.of("count", LongValue.of(50))); + assertThat(aggregationResult.getNumber("count")).isEqualTo(50); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BaseDatastoreBatchWriterTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BaseDatastoreBatchWriterTest.java new file mode 100644 index 000000000000..b5e2fe2e96ce --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BaseDatastoreBatchWriterTest.java @@ -0,0 +1,363 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; + +import com.google.common.collect.ImmutableList; +import java.util.LinkedList; +import java.util.List; +import org.easymock.EasyMock; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; + +public class BaseDatastoreBatchWriterTest { + + private static final Key KEY1 = Key.newBuilder("dataset1", "kind1", "name1").build(); + private static final Key KEY2 = Key.newBuilder(KEY1, 1).build(); + private static final Key KEY3 = Key.newBuilder(KEY1, 2).build(); + private static final IncompleteKey INCOMPLETE_KEY = IncompleteKey.newBuilder(KEY1).build(); + private static final Entity ENTITY1 = Entity.newBuilder(KEY1).build(); + private static final Entity ENTITY2 = Entity.newBuilder(KEY2).set("bak", true).build(); + private static final Entity ENTITY3 = Entity.newBuilder(KEY3).set("bak", true).build(); + private static final FullEntity INCOMPLETE_ENTITY_1 = + Entity.newBuilder(INCOMPLETE_KEY).build(); + private static final FullEntity INCOMPLETE_ENTITY_2 = + Entity.newBuilder(INCOMPLETE_KEY).set("name", "dan").build(); + + private DatastoreBatchWriter batchWriter; + + private class DatastoreBatchWriter extends BaseDatastoreBatchWriter { + + private final Datastore datastore; + + protected DatastoreBatchWriter() { + super("test"); + datastore = EasyMock.createMock(Datastore.class); + IncompleteKey[] expected = {INCOMPLETE_KEY, INCOMPLETE_KEY}; + List result = ImmutableList.of(KEY2, KEY3); + expect(datastore.allocateId(expected)).andReturn(result).times(0, 1); + replay(datastore); + } + + @Override + protected Datastore getDatastore() { + return datastore; + } + + void finish() { + verify(datastore); + } + } + + @Before + public void setUp() { + batchWriter = new DatastoreBatchWriter(); + } + + @After + public void tearDown() { + batchWriter.finish(); + } + + @Test + public void testAdd() { + Entity entity2 = + Entity.newBuilder(ENTITY2).setKey(Key.newBuilder(KEY1).setName("name2").build()).build(); + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setInsert(ENTITY1.toPb()).build()); + pbs.add( + com.google.datastore.v1.Mutation.newBuilder() + .setInsert(Entity.newBuilder(KEY2, INCOMPLETE_ENTITY_1).build().toPb()) + .build()); + pbs.add( + com.google.datastore.v1.Mutation.newBuilder() + .setInsert(Entity.newBuilder(KEY3, INCOMPLETE_ENTITY_2).build().toPb()) + .build()); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setInsert(entity2.toPb()).build()); + List entities = + batchWriter.add(ENTITY1, INCOMPLETE_ENTITY_1, INCOMPLETE_ENTITY_2, entity2); + assertEquals(pbs, batchWriter.toMutationPbList()); + assertEquals(ENTITY1, entities.get(0)); + assertEquals(Entity.newBuilder(KEY2, INCOMPLETE_ENTITY_1).build(), entities.get(1)); + assertEquals(Entity.newBuilder(KEY3, INCOMPLETE_ENTITY_2).build(), entities.get(2)); + assertEquals(entity2, entities.get(3)); + } + + @Test + public void testAddAfterDelete() { + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(ENTITY1.toPb()).build()); + batchWriter.delete(KEY1); + batchWriter.add(ENTITY1); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test(expected = DatastoreException.class) + public void testAddDuplicate() { + batchWriter.add(ENTITY1); + batchWriter.add(ENTITY1); + } + + @Test(expected = DatastoreException.class) + public void testAddAfterPut() { + batchWriter.put(ENTITY1); + batchWriter.add(ENTITY1); + } + + @Test(expected = DatastoreException.class) + public void testAddAfterUpdate() { + batchWriter.update(ENTITY1); + batchWriter.add(ENTITY1); + } + + @Test(expected = DatastoreException.class) + public void testAddWhenNotActive() { + batchWriter.deactivate(); + batchWriter.add(ENTITY1); + } + + @Test + public void testAddWithDeferredAllocation() { + List pbs = new LinkedList<>(); + pbs.add( + com.google.datastore.v1.Mutation.newBuilder() + .setInsert(INCOMPLETE_ENTITY_1.toPb()) + .build()); + pbs.add( + com.google.datastore.v1.Mutation.newBuilder() + .setInsert(INCOMPLETE_ENTITY_2.toPb()) + .build()); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setInsert(ENTITY1.toPb()).build()); + batchWriter.addWithDeferredIdAllocation(ENTITY1, INCOMPLETE_ENTITY_1); + batchWriter.addWithDeferredIdAllocation(INCOMPLETE_ENTITY_2); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test(expected = DatastoreException.class) + public void testAddWithDeferredAllocationWhenNotActive() { + batchWriter.deactivate(); + batchWriter.addWithDeferredIdAllocation(INCOMPLETE_ENTITY_1); + } + + @Test + public void testUpdate() { + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpdate(ENTITY1.toPb()).build()); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpdate(ENTITY2.toPb()).build()); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpdate(ENTITY3.toPb()).build()); + batchWriter.update(ENTITY1, ENTITY2); + batchWriter.update(ENTITY3); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testUpdateAfterUpdate() { + Entity entity = Entity.newBuilder(ENTITY1).set("foo", "bar").build(); + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpdate(entity.toPb()).build()); + batchWriter.update(ENTITY1); + batchWriter.update(entity); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testUpdateAfterAdd() { + Entity entity = Entity.newBuilder(ENTITY1).set("foo", "bar").build(); + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(entity.toPb()).build()); + batchWriter.add(ENTITY1); + batchWriter.update(entity); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testUpdateAfterPut() { + Entity entity = Entity.newBuilder(ENTITY1).set("foo", "bar").build(); + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(entity.toPb()).build()); + batchWriter.put(ENTITY1); + batchWriter.update(entity); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test(expected = DatastoreException.class) + public void testUpdateAfterDelete() { + batchWriter.delete(KEY1); + batchWriter.update(ENTITY1, ENTITY2); + } + + @Test(expected = DatastoreException.class) + public void testUpdateWhenNotActive() { + batchWriter.deactivate(); + batchWriter.update(ENTITY1); + } + + @Test + public void testPut() { + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(ENTITY1.toPb()).build()); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(ENTITY2.toPb()).build()); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(ENTITY3.toPb()).build()); + List putEntities = batchWriter.put(ENTITY1, ENTITY2); + Entity putEntity = batchWriter.put(ENTITY3); + assertEquals(ENTITY1, putEntities.get(0)); + assertEquals(ENTITY2, putEntities.get(1)); + assertEquals(ENTITY3, putEntity); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testPutIncompleteKey() { + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(ENTITY1.toPb()).build()); + pbs.add( + com.google.datastore.v1.Mutation.newBuilder() + .setUpsert(Entity.newBuilder(KEY2, INCOMPLETE_ENTITY_1).build().toPb()) + .build()); + pbs.add( + com.google.datastore.v1.Mutation.newBuilder() + .setUpsert(Entity.newBuilder(KEY3, INCOMPLETE_ENTITY_2).build().toPb()) + .build()); + Entity putEntity = batchWriter.put(ENTITY1); + List putEntities = batchWriter.put(INCOMPLETE_ENTITY_1, INCOMPLETE_ENTITY_2); + assertEquals(ENTITY1, putEntity); + assertEquals(Entity.newBuilder(KEY2, INCOMPLETE_ENTITY_1).build(), putEntities.get(0)); + assertEquals(Entity.newBuilder(KEY3, INCOMPLETE_ENTITY_2).build(), putEntities.get(1)); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testPutWithDeferredAllocation() { + List pbs = new LinkedList<>(); + pbs.add( + com.google.datastore.v1.Mutation.newBuilder() + .setInsert(INCOMPLETE_ENTITY_1.toPb()) + .build()); + pbs.add( + com.google.datastore.v1.Mutation.newBuilder() + .setInsert(INCOMPLETE_ENTITY_2.toPb()) + .build()); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(ENTITY1.toPb()).build()); + batchWriter.put(ENTITY1); + batchWriter.putWithDeferredIdAllocation(INCOMPLETE_ENTITY_1, INCOMPLETE_ENTITY_2); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testPutAfterPut() { + Entity entity = Entity.newBuilder(ENTITY1).set("foo", "bar").build(); + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(entity.toPb()).build()); + Entity putEntity1 = batchWriter.put(ENTITY1); + Entity putEntity2 = batchWriter.put(entity); + assertEquals(ENTITY1, putEntity1); + assertEquals(entity, putEntity2); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testPutAfterAdd() { + Entity entity = Entity.newBuilder(ENTITY1).set("foo", "bar").build(); + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(entity.toPb()).build()); + batchWriter.add(ENTITY1); + batchWriter.put(entity); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testPutAfterUpdate() { + Entity entity = Entity.newBuilder(ENTITY1).set("foo", "bar").build(); + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(entity.toPb()).build()); + batchWriter.update(ENTITY1); + Entity putEntity = batchWriter.put(entity); + assertEquals(entity, putEntity); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testPutAfterDelete() { + Entity entity = Entity.newBuilder(ENTITY1).set("foo", "bar").build(); + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setUpsert(entity.toPb()).build()); + batchWriter.delete(KEY1); + Entity putEntity = batchWriter.put(entity); + assertEquals(entity, putEntity); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test(expected = DatastoreException.class) + public void testPutWhenNotActive() { + batchWriter.deactivate(); + batchWriter.put(ENTITY1); + } + + @Test + public void testDelete() { + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setDelete(KEY1.toPb()).build()); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setDelete(KEY2.toPb()).build()); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setDelete(KEY3.toPb()).build()); + batchWriter.delete(KEY1, KEY2); + batchWriter.delete(KEY3); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testDeleteAfterAdd() { + List pbs = new LinkedList<>(); + pbs.add( + com.google.datastore.v1.Mutation.newBuilder() + .setInsert(INCOMPLETE_ENTITY_1.toPb()) + .build()); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setDelete(KEY1.toPb()).build()); + batchWriter.add(ENTITY1); + batchWriter.addWithDeferredIdAllocation(INCOMPLETE_ENTITY_1); + batchWriter.delete(KEY1); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testDeleteAfterUpdate() { + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setDelete(KEY1.toPb()).build()); + batchWriter.update(ENTITY1); + batchWriter.delete(KEY1); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test + public void testDeleteAfterPut() { + List pbs = new LinkedList<>(); + pbs.add(com.google.datastore.v1.Mutation.newBuilder().setDelete(KEY1.toPb()).build()); + batchWriter.put(ENTITY1); + batchWriter.delete(KEY1); + assertEquals(pbs, batchWriter.toMutationPbList()); + } + + @Test(expected = DatastoreException.class) + public void testDeleteWhenNotActive() { + batchWriter.deactivate(); + batchWriter.delete(KEY1); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BaseEntityTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BaseEntityTest.java new file mode 100644 index 000000000000..7f5836e0e984 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BaseEntityTest.java @@ -0,0 +1,244 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.Timestamp; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableSet; +import java.util.Calendar; +import java.util.Collections; +import java.util.List; +import java.util.Set; +import org.junit.Before; +import org.junit.Test; + +public class BaseEntityTest { + + private static final Blob BLOB = Blob.copyFrom(new byte[] {1, 2}); + private static final Timestamp TIMESTAMP = Timestamp.now(); + private static final LatLng LAT_LNG = new LatLng(37.422035, -122.084124); + private static final Key KEY = Key.newBuilder("ds1", "k1", "n1").build(); + private static final Entity ENTITY = Entity.newBuilder(KEY).set("name", "foo").build(); + private static final IncompleteKey INCOMPLETE_KEY = IncompleteKey.newBuilder("ds1", "k1").build(); + private static final FullEntity PARTIAL_ENTITY = + Entity.newBuilder(INCOMPLETE_KEY).build(); + + private Builder builder; + + private class Builder extends BaseEntity.Builder { + + @Override + public BaseEntity build() { + + return new BaseEntity(this) {}; + } + } + + @Before + public void setUp() { + builder = new Builder(); + builder.set("blob", BLOB).set("boolean", true).set("timestamp", TIMESTAMP); + builder.set("double", 1.25).set("key", KEY).set("string", "hello world"); + builder.set("long", 125).setNull("null").set("entity", ENTITY).set("latLng", LAT_LNG); + builder.set("partialEntity", PARTIAL_ENTITY).set("stringValue", StringValue.of("bla")); + builder.set("list1", NullValue.of(), StringValue.of("foo"), LatLngValue.of(LAT_LNG)); + builder.set("list2", ImmutableList.of(LongValue.of(10), DoubleValue.of(2))); + builder.set("list3", Collections.singletonList(BooleanValue.of(true))); + builder.set( + "blobList", BLOB, Blob.copyFrom(new byte[] {3, 4}), Blob.copyFrom(new byte[] {5, 6})); + builder.set("booleanList", true, false, true); + builder.set("timestampList", Timestamp.now(), Timestamp.now(), Timestamp.now()); + builder.set("doubleList", 12.3, 4.56, .789); + builder.set( + "keyList", + KEY, + Key.newBuilder("ds2", "k2", "n2").build(), + Key.newBuilder("ds3", "k3", "n3").build()); + builder.set("entityList", ENTITY, PARTIAL_ENTITY); + builder.set("stringList", "s1", "s2", "s3"); + builder.set("longList", 1, 23, 456); + builder.set("latLngList", LAT_LNG, LAT_LNG); + } + + @Test + public void testContains() { + BaseEntity entity = builder.build(); + assertTrue(entity.contains("list1")); + assertFalse(entity.contains("bla")); + entity = builder.clear().build(); + assertFalse(entity.contains("list1")); + } + + @Test + public void testGetValue() { + BaseEntity entity = builder.build(); + assertEquals(BlobValue.of(BLOB), entity.getValue("blob")); + } + + @Test(expected = DatastoreException.class) + public void testGetValueNotFound() { + BaseEntity entity = builder.clear().build(); + entity.getValue("blob"); + } + + @Test + public void testIsNull() { + BaseEntity entity = builder.build(); + assertTrue(entity.isNull("null")); + assertFalse(entity.isNull("blob")); + entity = builder.setNull("blob").build(); + assertTrue(entity.isNull("blob")); + } + + @Test(expected = DatastoreException.class) + public void testIsNullNotFound() { + BaseEntity entity = builder.clear().build(); + entity.isNull("null"); + } + + @Test + public void testGetString() { + BaseEntity entity = builder.build(); + assertEquals("hello world", entity.getString("string")); + assertEquals("bla", entity.getString("stringValue")); + entity = builder.set("string", "foo").build(); + assertEquals("foo", entity.getString("string")); + } + + @Test + public void testGetLong() { + BaseEntity entity = builder.build(); + assertEquals(125, entity.getLong("long")); + entity = builder.set("long", LongValue.of(10)).build(); + assertEquals(10, entity.getLong("long")); + } + + @Test + public void testGetDouble() { + BaseEntity entity = builder.build(); + assertEquals(1.25, entity.getDouble("double"), 0); + entity = builder.set("double", DoubleValue.of(10)).build(); + assertEquals(10, entity.getDouble("double"), 0); + } + + @Test + public void testGetBoolean() throws Exception { + BaseEntity entity = builder.build(); + assertTrue(entity.getBoolean("boolean")); + entity = builder.set("boolean", BooleanValue.of(false)).build(); + assertFalse(entity.getBoolean("boolean")); + } + + @Test + public void testGetTimestamp() { + BaseEntity entity = builder.build(); + assertEquals(TIMESTAMP, entity.getTimestamp("timestamp")); + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.DATE, -1); + Timestamp timestamp = Timestamp.of(cal.getTime()); + entity = builder.set("timestamp", TimestampValue.of(timestamp)).build(); + assertEquals(timestamp, entity.getTimestamp("timestamp")); + } + + @Test + public void testGetLatLng() { + BaseEntity entity = builder.build(); + assertEquals(LAT_LNG, entity.getLatLng("latLng")); + } + + @Test + public void testGetKey() { + BaseEntity entity = builder.build(); + assertEquals(KEY, entity.getKey("key")); + Key key = Key.newBuilder(KEY).setName("BLA").build(); + entity = builder.set("key", key).build(); + assertEquals(key, entity.getKey("key")); + } + + @Test + public void testGetEntity() { + BaseEntity entity = builder.build(); + assertEquals(ENTITY, entity.getEntity("entity")); + assertEquals(PARTIAL_ENTITY, entity.getEntity("partialEntity")); + entity = builder.set("entity", EntityValue.of(PARTIAL_ENTITY)).build(); + assertEquals(PARTIAL_ENTITY, entity.getEntity("entity")); + } + + @Test + public void testGetList() { + BaseEntity entity = builder.build(); + List> list = entity.getList("list1"); + assertEquals(3, list.size()); + assertEquals(NullValue.of(), list.get(0)); + assertEquals("foo", list.get(1).get()); + assertEquals(LAT_LNG, list.get(2).get()); + list = entity.getList("list2"); + assertEquals(2, list.size()); + assertEquals(Long.valueOf(10), list.get(0).get()); + assertEquals(Double.valueOf(2), list.get(1).get()); + list = entity.getList("list3"); + assertEquals(1, list.size()); + assertEquals(Boolean.TRUE, list.get(0).get()); + entity = builder.set("list1", ListValue.of(list)).build(); + assertEquals(list, entity.getList("list1")); + List> stringList = entity.getList("stringList"); + assertEquals( + ImmutableList.of(StringValue.of("s1"), StringValue.of("s2"), StringValue.of("s3")), + stringList); + List> doubleList = entity.getList("doubleList"); + assertEquals( + ImmutableList.of(DoubleValue.of(12.3), DoubleValue.of(4.56), DoubleValue.of(.789)), + doubleList); + List entityList = entity.getList("entityList"); + assertEquals( + ImmutableList.of(EntityValue.of(ENTITY), EntityValue.of(PARTIAL_ENTITY)), entityList); + } + + @Test + public void testGetBlob() { + BaseEntity entity = builder.build(); + assertEquals(BLOB, entity.getBlob("blob")); + Blob blob = Blob.copyFrom(new byte[] {}); + entity = builder.set("blob", BlobValue.of(blob)).build(); + assertEquals(blob, entity.getBlob("blob")); + } + + @Test + public void testNames() { + Set names = + ImmutableSet.builder() + .add("string", "stringValue", "boolean", "double", "long", "list1", "list2", "list3") + .add("entity", "partialEntity", "null", "timestamp", "blob", "key", "blobList") + .add( + "booleanList", "timestampList", "doubleList", "keyList", "entityList", "stringList") + .add("longList", "latLng", "latLngList") + .build(); + BaseEntity entity = builder.build(); + assertEquals(names, entity.getNames()); + } + + @Test + public void testKey() { + builder.setKey(KEY); + BaseEntity entity = builder.build(); + assertEquals(KEY, entity.getKey()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BaseKeyTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BaseKeyTest.java new file mode 100644 index 000000000000..332017945096 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BaseKeyTest.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 + * + * 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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import com.google.common.collect.ImmutableList; +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; + +public class BaseKeyTest { + + private class Builder extends BaseKey.Builder { + + Builder(String projectId) { + super(projectId); + } + + Builder(String projectId, String kind) { + super(projectId, kind); + } + + Builder(BaseKey copyFrom) { + super(copyFrom); + } + + @Override + protected BaseKey build() { + ImmutableList.Builder path = ImmutableList.builder(); + path.addAll(ancestors); + path.add(PathElement.of(kind)); + return new BaseKey(projectId, namespace, databaseId, path.build()) { + + @Override + protected BaseKey getParent() { + return null; + } + }; + } + } + + @Test + public void testProjectId() { + Builder builder = new Builder("ds1", "k"); + BaseKey key = builder.build(); + assertEquals("ds1", key.getProjectId()); + key = builder.setProjectId("ds2").build(); + assertEquals("ds2", key.getProjectId()); + assertEquals("", key.getDatabaseId()); + } + + @Test + public void testDatabaseId() { + Builder builder = new Builder("ds1", "k").setDatabaseId("test-db"); + BaseKey key = builder.build(); + assertEquals("ds1", key.getProjectId()); + key = builder.setProjectId("ds2").build(); + assertEquals("ds2", key.getProjectId()); + assertEquals("test-db", key.getDatabaseId()); + } + + @Test(expected = IllegalArgumentException.class) + public void testBadDatasetInConstructor() { + new Builder(" ", "k"); + } + + @Test(expected = IllegalArgumentException.class) + public void testBadDatasetInSetter() { + Builder builder = new Builder("d", "k"); + builder.setProjectId(" "); + } + + @Test + public void testNamespace() { + Builder builder = new Builder("ds", "k"); + BaseKey key = builder.build(); + assertTrue(key.getNamespace() != null); + assertTrue(key.getNamespace().isEmpty()); + key = builder.setNamespace("ns").build(); + assertEquals("ns", key.getNamespace()); + } + + @Test + public void testKind() { + Builder builder = new Builder("ds", "k1"); + BaseKey key = builder.build(); + assertEquals("k1", key.getKind()); + key = builder.setKind("k2").build(); + assertEquals("k2", key.getKind()); + } + + @Test(expected = NullPointerException.class) + public void testNoKind() throws Exception { + Builder builder = new Builder("ds"); + builder.build(); + } + + @Test(expected = IllegalArgumentException.class) + public void testBadKindInConstructor() throws Exception { + new Builder("ds", ""); + } + + @Test(expected = IllegalArgumentException.class) + public void testBadKindInSetter() throws Exception { + Builder builder = new Builder("ds", "k1"); + builder.setKind(""); + } + + @Test + public void testAncestors() throws Exception { + Builder builder = new Builder("ds", "k"); + BaseKey key = builder.build(); + assertTrue(key.getAncestors().isEmpty()); + List path = new ArrayList<>(); + path.add(PathElement.of("p1", "v1")); + key = builder.addAncestor(path.get(0)).build(); + assertEquals(path, key.getAncestors()); + path.add(PathElement.of("p2", "v2")); + key = builder.addAncestor(path.get(1)).build(); + assertEquals(path, key.getAncestors()); + } + + @Test + public void testCopyFrom() { + Builder copyFrom = new Builder("test-project", "kind").setDatabaseId("test-db"); + Builder builder = new Builder(copyFrom.build()); + BaseKey baseKey = builder.build(); + assertEquals("test-project", baseKey.getProjectId()); + assertEquals("test-db", baseKey.getDatabaseId()); + assertEquals("kind", baseKey.getKind()); + assertEquals("", baseKey.getNamespace()); + assertEquals(new ArrayList<>(), baseKey.getAncestors()); + assertEquals(PathElement.of("kind"), baseKey.getLeaf()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BlobTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BlobTest.java new file mode 100644 index 000000000000..5c6b1dedf7ab --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BlobTest.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 + * + * 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.datastore; + +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 com.google.common.testing.EqualsTester; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.ByteBuffer; +import java.util.Random; +import org.junit.Before; +import org.junit.Test; + +public class BlobTest { + + private static final byte[] bytes1 = new byte[10]; + private static final byte[] bytes2 = new byte[11]; + private Blob blob1; + private Blob blob2; + + @Before + public void setUp() { + Random rnd = new Random(); + rnd.nextBytes(bytes1); + rnd.nextBytes(bytes2); + blob1 = Blob.copyFrom(bytes1); + blob2 = Blob.copyFrom(bytes2); + } + + @Test + public void testEquals() { + EqualsTester equalsTester = new EqualsTester(); + equalsTester.addEqualityGroup(blob1, blob1).testEquals(); + assertEquals(blob1, Blob.copyFrom(bytes1)); + assertNotEquals(blob1, blob2); + } + + @Test + public void testLength() { + assertEquals(bytes1.length, blob1.getLength()); + assertEquals(bytes2.length, blob2.getLength()); + } + + @Test + public void testToByteArray() { + assertArrayEquals(bytes1, blob1.toByteArray()); + assertArrayEquals(bytes2, blob2.toByteArray()); + } + + @Test + public void testAsReadOnlyByteBuffer() { + ByteBuffer buffer = blob1.asReadOnlyByteBuffer(); + byte[] bytes = new byte[bytes1.length]; + buffer.get(bytes); + assertFalse(buffer.hasRemaining()); + assertArrayEquals(bytes1, bytes); + } + + @Test + public void testAsInputStream() throws Exception { + byte[] bytes = new byte[bytes1.length]; + InputStream in = blob1.asInputStream(); + assertEquals(bytes1.length, in.read(bytes)); + assertEquals(-1, in.read()); + assertArrayEquals(bytes1, bytes); + } + + @Test + public void testCopyTo() { + byte[] bytes = new byte[bytes1.length]; + blob1.copyTo(bytes); + assertArrayEquals(bytes1, bytes); + + ByteBuffer buffer = ByteBuffer.allocate(bytes1.length); + blob1.copyTo(buffer); + buffer.flip(); + bytes = new byte[bytes1.length]; + buffer.get(bytes); + assertFalse(buffer.hasRemaining()); + assertArrayEquals(bytes1, bytes); + } + + @Test + public void testCopyFrom() throws Exception { + Blob blob = Blob.copyFrom(ByteBuffer.wrap(bytes1)); + assertEquals(blob1, blob); + assertArrayEquals(bytes1, blob.toByteArray()); + + blob = Blob.copyFrom(new ByteArrayInputStream(bytes2)); + assertEquals(blob2, blob); + assertArrayEquals(bytes2, blob.toByteArray()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BlobValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BlobValueTest.java new file mode 100644 index 000000000000..3cb193ffbd51 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BlobValueTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class BlobValueTest { + + private static final Blob CONTENT = Blob.copyFrom(new byte[] {1, 2}); + + @Test + public void testToBuilder() { + BlobValue value = BlobValue.of(CONTENT); + assertEquals(value, value.toBuilder().build()); + } + + @Test + public void testOf() { + BlobValue value = BlobValue.of(CONTENT); + assertEquals(CONTENT, value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + BlobValue.Builder builder = BlobValue.newBuilder(CONTENT); + BlobValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertEquals(CONTENT, value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BooleanValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BooleanValueTest.java new file mode 100644 index 000000000000..bf85f74b21c0 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/BooleanValueTest.java @@ -0,0 +1,49 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class BooleanValueTest { + + @Test + public void testToBuilder() { + BooleanValue value = BooleanValue.of(true); + assertEquals(value, value.toBuilder().build()); + } + + @Test + public void testOf() { + BooleanValue value = BooleanValue.of(false); + assertFalse(value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + BooleanValue.Builder builder = BooleanValue.newBuilder(true); + BooleanValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertTrue(value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/CursorTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/CursorTest.java new file mode 100644 index 000000000000..26d634323f1a --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/CursorTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import com.google.protobuf.ByteString; +import org.junit.Before; +import org.junit.Test; + +public class CursorTest { + + private static final byte[] bytes1 = {1, 2, 3, '%', '<', '+'}; + private static final byte[] bytes2 = {10, 20, 30}; + private Cursor cursor1; + private Cursor cursor2; + + @Before + public void setUp() { + cursor1 = new Cursor(ByteString.copyFrom(bytes1)); + cursor2 = new Cursor(ByteString.copyFrom(bytes2)); + } + + @Test + public void testToFromUrlSafe() { + String urlSafe = cursor1.toUrlSafe(); + assertEquals(cursor1, Cursor.fromUrlSafe(urlSafe)); + } + + @Test + public void testCopyFrom() { + Cursor cursor = Cursor.copyFrom(bytes2); + assertEquals(cursor2, cursor); + assertNotEquals(cursor1, cursor); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreExceptionTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreExceptionTest.java new file mode 100644 index 000000000000..b83809536cee --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreExceptionTest.java @@ -0,0 +1,124 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import com.google.cloud.BaseServiceException; +import com.google.cloud.RetryHelper; +import java.io.IOException; +import java.net.SocketTimeoutException; +import org.junit.Test; + +public class DatastoreExceptionTest { + + @Test + public void testDatastoreException() { + DatastoreException exception = new DatastoreException(10, "message", "ABORTED"); + assertEquals(10, exception.getCode()); + assertEquals("ABORTED", exception.getReason()); + assertEquals("message", exception.getMessage()); + assertTrue(exception.isRetryable()); + + exception = new DatastoreException(4, "message", "DEADLINE_EXCEEDED"); + assertEquals(4, exception.getCode()); + assertEquals("DEADLINE_EXCEEDED", exception.getReason()); + assertEquals("message", exception.getMessage()); + assertTrue(exception.isRetryable()); + + exception = new DatastoreException(14, "message", "UNAVAILABLE"); + assertEquals(14, exception.getCode()); + assertEquals("UNAVAILABLE", exception.getReason()); + assertEquals("message", exception.getMessage()); + assertTrue(exception.isRetryable()); + + exception = new DatastoreException(2, "message", "INTERNAL"); + assertEquals(2, exception.getCode()); + assertEquals("INTERNAL", exception.getReason()); + assertEquals("message", exception.getMessage()); + assertFalse(exception.isRetryable()); + + IOException cause = new SocketTimeoutException("socketTimeoutMessage"); + exception = new DatastoreException(cause); + assertEquals(DatastoreException.UNKNOWN_CODE, exception.getCode()); + assertNull(exception.getReason()); + assertEquals("socketTimeoutMessage", exception.getMessage()); + assertEquals(cause, exception.getCause()); + assertTrue(exception.isRetryable()); + assertSame(cause, exception.getCause()); + + exception = new DatastoreException(2, "message", "INTERNAL", cause); + assertEquals(2, exception.getCode()); + assertEquals("INTERNAL", exception.getReason()); + assertEquals("message", exception.getMessage()); + assertFalse(exception.isRetryable()); + assertSame(cause, exception.getCause()); + } + + @Test + public void testTranslateAndThrow() { + Exception cause = new DatastoreException(14, "message", "UNAVAILABLE"); + RetryHelper.RetryHelperException exceptionMock = + createMock(RetryHelper.RetryHelperException.class); + expect(exceptionMock.getCause()).andReturn(cause).times(2); + replay(exceptionMock); + try { + DatastoreException.translateAndThrow(exceptionMock); + } catch (BaseServiceException ex) { + assertEquals(14, ex.getCode()); + assertEquals("message", ex.getMessage()); + assertTrue(ex.isRetryable()); + } finally { + verify(exceptionMock); + } + cause = new IllegalArgumentException("message"); + exceptionMock = createMock(RetryHelper.RetryHelperException.class); + expect(exceptionMock.getMessage()).andReturn("message").times(1); + expect(exceptionMock.getCause()).andReturn(cause).times(4); + replay(exceptionMock); + try { + DatastoreException.translateAndThrow(exceptionMock); + } catch (BaseServiceException ex) { + assertEquals(DatastoreException.UNKNOWN_CODE, ex.getCode()); + assertEquals("message", ex.getMessage()); + assertFalse(ex.isRetryable()); + assertSame(cause, ex.getCause()); + } finally { + verify(exceptionMock); + } + } + + @Test + public void testThrowInvalidRequest() { + try { + DatastoreException.throwInvalidRequest("message %s %d", "a", 1); + fail("Exception expected"); + } catch (DatastoreException ex) { + assertEquals("FAILED_PRECONDITION", ex.getReason()); + assertEquals("message a 1", ex.getMessage()); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreHelperTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreHelperTest.java new file mode 100644 index 000000000000..2d72339be6d5 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreHelperTest.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 + * + * 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.datastore; + +import static org.easymock.EasyMock.createMock; +import static org.easymock.EasyMock.createStrictMock; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Iterators; +import java.util.Collections; +import java.util.List; +import org.junit.Test; + +public class DatastoreHelperTest { + + @Test + public void testNewKeyFactory() { + DatastoreOptions options = createMock(DatastoreOptions.class); + expect(options.getProjectId()).andReturn("ds1").once(); + expect(options.getNamespace()).andReturn("ns1").once(); + expect(options.getDatabaseId()).andReturn("test-db").once(); + replay(options); + KeyFactory keyFactory = DatastoreHelper.newKeyFactory(options); + Key key = keyFactory.setKind("k").newKey("bla"); + assertEquals("ds1", key.getProjectId()); + assertEquals("ns1", key.getNamespace()); + assertEquals("k", key.getKind()); + assertEquals("bla", key.getName()); + assertEquals("test-db", key.getDatabaseId()); + verify(options); + } + + @Test + public void testAllocateId() { + Datastore datastore = createStrictMock(Datastore.class); + IncompleteKey pKey1 = IncompleteKey.newBuilder("ds", "k").build(); + Key key1 = Key.newBuilder(pKey1, 1).build(); + expect(datastore.allocateId(new IncompleteKey[] {pKey1})) + .andReturn(Collections.singletonList(key1)); + replay(datastore); + assertEquals(key1, DatastoreHelper.allocateId(datastore, pKey1)); + verify(datastore); + } + + @Test + public void testGetWithDatastore() throws Exception { + Datastore datastore = createStrictMock(Datastore.class); + IncompleteKey pKey1 = IncompleteKey.newBuilder("ds", "k").build(); + Key key1 = Key.newBuilder(pKey1, 1).build(); + Entity entity1 = Entity.newBuilder(key1).build(); + Key key2 = Key.newBuilder(pKey1, 2).build(); + ReadOption eventualConsistency = ReadOption.eventualConsistency(); + expect(datastore.get(Collections.singletonList(key1))) + .andReturn(Collections.singletonList(entity1).iterator()); + expect(datastore.get(Collections.singletonList(key2))) + .andReturn(Collections.emptyIterator()); + expect(datastore.get(Collections.singletonList(key1), eventualConsistency)) + .andReturn(Collections.singletonList(entity1).iterator()); + replay(datastore); + assertEquals(entity1, DatastoreHelper.get(datastore, key1)); + assertNull(DatastoreHelper.get(datastore, key2)); + assertEquals(entity1, DatastoreHelper.get(datastore, key1, eventualConsistency)); + verify(datastore); + } + + @Test + public void testGetWithTransaction() throws Exception { + Transaction transaction = createStrictMock(Transaction.class); + IncompleteKey pKey1 = IncompleteKey.newBuilder("ds", "k").build(); + Key key1 = Key.newBuilder(pKey1, 1).build(); + Entity entity1 = Entity.newBuilder(key1).build(); + Key key2 = Key.newBuilder(pKey1, 2).build(); + expect(transaction.get(new Key[] {key1})) + .andReturn(Collections.singletonList(entity1).iterator()); + expect(transaction.get(new Key[] {key2})).andReturn(Collections.emptyIterator()); + replay(transaction); + assertEquals(entity1, DatastoreHelper.get(transaction, key1)); + assertNull(DatastoreHelper.get(transaction, key2)); + verify(transaction); + } + + @Test + public void testAdd() throws Exception { + Datastore datastore = createStrictMock(Datastore.class); + IncompleteKey pKey = IncompleteKey.newBuilder("ds", "k").build(); + Key key = Key.newBuilder(pKey, 1).build(); + Entity entity = Entity.newBuilder(key).build(); + expect(datastore.add(new Entity[] {entity})).andReturn(Collections.singletonList(entity)); + replay(datastore); + assertEquals(entity, DatastoreHelper.add(datastore, entity)); + verify(datastore); + } + + @Test + public void testFetchWithDatastore() throws Exception { + Datastore datastore = createStrictMock(Datastore.class); + IncompleteKey pKey1 = IncompleteKey.newBuilder("ds", "k").build(); + Key key1 = Key.newBuilder(pKey1, 1).build(); + Key key2 = Key.newBuilder(pKey1, "a").build(); + Entity entity1 = Entity.newBuilder(key1).build(); + Entity entity2 = Entity.newBuilder(key2).build(); + ReadOption eventualConsistency = ReadOption.eventualConsistency(); + expect(datastore.get(ImmutableList.of(key1, key2))) + .andReturn(Iterators.forArray(entity1, entity2)) + .once(); + expect(datastore.get(ImmutableList.of(key1, key2), eventualConsistency)) + .andReturn(Iterators.forArray(entity1, entity2)) + .once(); + replay(datastore); + List values = DatastoreHelper.fetch(datastore, new Key[] {key1, key2}); + assertEquals(2, values.size()); + assertEquals(entity1, values.get(0)); + assertEquals(entity2, values.get(1)); + values = DatastoreHelper.fetch(datastore, new Key[] {key1, key2}, eventualConsistency); + assertEquals(2, values.size()); + assertEquals(entity1, values.get(0)); + assertEquals(entity2, values.get(1)); + verify(datastore); + } + + @Test + public void testFetchWithTransaction() throws Exception { + Transaction transaction = createStrictMock(Transaction.class); + IncompleteKey pKey1 = IncompleteKey.newBuilder("ds", "k").build(); + Key key1 = Key.newBuilder(pKey1, 1).build(); + Key key2 = Key.newBuilder(pKey1, "a").build(); + Entity entity1 = Entity.newBuilder(key1).build(); + Entity entity2 = Entity.newBuilder(key2).build(); + expect(transaction.get(new Key[] {key1, key2})) + .andReturn(Iterators.forArray(entity1, entity2)) + .once(); + replay(transaction); + List values = DatastoreHelper.fetch(transaction, new Key[] {key1, key2}); + assertEquals(2, values.size()); + assertEquals(entity1, values.get(0)); + assertEquals(entity2, values.get(1)); + verify(transaction); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreOptionsTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreOptionsTest.java new file mode 100644 index 000000000000..fd9b71f93be1 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreOptionsTest.java @@ -0,0 +1,241 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +import com.google.api.gax.grpc.ChannelPoolSettings; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.cloud.NoCredentials; +import com.google.cloud.datastore.spi.DatastoreRpcFactory; +import com.google.cloud.datastore.spi.v1.DatastoreRpc; +import com.google.cloud.datastore.v1.DatastoreSettings; +import com.google.cloud.grpc.GrpcTransportOptions; +import com.google.cloud.http.HttpTransportOptions; +import com.google.datastore.v1.client.DatastoreFactory; +import org.easymock.EasyMock; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; + +public class DatastoreOptionsTest { + + private static final String PROJECT_ID = "project-id"; + private static final String DATABASE_ID = "database-id"; + private static final int PORT = 8080; + private static final int DEFAULT_MAX_CHANNEL_COUNT = 200; + private DatastoreRpcFactory datastoreRpcFactory; + private DatastoreRpc datastoreRpc; + private DatastoreOptions.Builder options; + + @Before + public void setUp() { + datastoreRpcFactory = EasyMock.createMock(DatastoreRpcFactory.class); + datastoreRpc = EasyMock.createMock(DatastoreRpc.class); + options = + DatastoreOptions.newBuilder() + .setServiceRpcFactory(datastoreRpcFactory) + .setProjectId(PROJECT_ID) + .setDatabaseId(DATABASE_ID) + .setCredentials(NoCredentials.getInstance()) + .setHost("http://localhost:" + PORT); + + EasyMock.expect(datastoreRpcFactory.create(EasyMock.anyObject(DatastoreOptions.class))) + .andReturn(datastoreRpc) + .anyTimes(); + EasyMock.replay(datastoreRpcFactory, datastoreRpc); + } + + @Test + public void testProjectId() { + assertEquals(PROJECT_ID, options.build().getProjectId()); + } + + @Test + public void testDatabaseId() { + assertEquals(DATABASE_ID, options.build().getDatabaseId()); + } + + @Test + public void testHost() { + assertEquals("http://localhost:" + PORT, options.build().getHost()); + } + + @Test + public void testOpenTelemetryOptionsEnabled() { + options.setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(true).build()); + assertTrue(options.build().getOpenTelemetryOptions().isEnabled()); + } + + @Test + public void testOpenTelemetryOptionsDisabled() { + options.setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(false).build()); + assertTrue(!options.build().getOpenTelemetryOptions().isEnabled()); + } + + @Test + public void testNamespace() { + assertTrue(options.build().getNamespace().isEmpty()); + assertEquals("ns1", options.setNamespace("ns1").build().getNamespace()); + } + + @Test + public void testDatastore() { + assertSame(datastoreRpc, options.build().getRpc()); + } + + @Test + public void testGrpcDefaultChannelConfigurations() { + DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setServiceRpcFactory(datastoreRpcFactory) + .setProjectId(PROJECT_ID) + .setDatabaseId(DATABASE_ID) + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .setCredentials(NoCredentials.getInstance()) + .setHost("http://localhost:" + PORT) + .build(); + ChannelPoolSettings channelPoolSettings = + ((InstantiatingGrpcChannelProvider) datastoreOptions.getTransportChannelProvider()) + .getChannelPoolSettings(); + assertEquals(channelPoolSettings.getInitialChannelCount(), DatastoreOptions.INIT_CHANNEL_COUNT); + assertEquals(channelPoolSettings.getMinChannelCount(), DatastoreOptions.MIN_CHANNEL_COUNT); + assertEquals(channelPoolSettings.getMaxChannelCount(), DEFAULT_MAX_CHANNEL_COUNT); + } + + @Test + public void testCustomChannelAndCredentials() { + InstantiatingGrpcChannelProvider channelProvider = + DatastoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelPoolSettings( + ChannelPoolSettings.builder() + .setInitialChannelCount(10) + .setMaxChannelCount(20) + .build()) + .build(); + DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setServiceRpcFactory(datastoreRpcFactory) + .setProjectId(PROJECT_ID) + .setDatabaseId(DATABASE_ID) + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .setChannelProvider(channelProvider) + .setCredentials(NoCredentials.getInstance()) + .setHost("http://localhost:" + PORT) + .build(); + assertEquals(datastoreOptions.getTransportChannelProvider(), channelProvider); + } + + @Test + public void testInvalidConfigForHttp() { + DatastoreOptions.Builder options = + DatastoreOptions.newBuilder() + .setServiceRpcFactory(datastoreRpcFactory) + .setProjectId(PROJECT_ID) + .setDatabaseId(DATABASE_ID) + .setTransportOptions(HttpTransportOptions.newBuilder().build()) + .setChannelProvider( + DatastoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelPoolSettings( + ChannelPoolSettings.builder() + .setInitialChannelCount(10) + .setMaxChannelCount(20) + .build()) + .build()) + .setCredentials(NoCredentials.getInstance()) + .setHost("http://localhost:" + PORT); + Assert.assertThrows(IllegalArgumentException.class, options::build); + } + + @Test + public void testTransport() { + // default http transport + assertThat(options.build().getTransportOptions()).isInstanceOf(HttpTransportOptions.class); + + // custom grpc transport + DatastoreOptions grpcTransportOptions = + DatastoreOptions.newBuilder() + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .setProjectId(PROJECT_ID) + .setCredentials(NoCredentials.getInstance()) + .build(); + assertThat(grpcTransportOptions.getTransportOptions()).isInstanceOf(GrpcTransportOptions.class); + assertThat(grpcTransportOptions.getTransportChannelProvider()) + .isInstanceOf(InstantiatingGrpcChannelProvider.class); + } + + @Test + public void testHostWithGrpcAndHttp() { + DatastoreOptions grpcTransportOptions = + DatastoreOptions.newBuilder() + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .setProjectId(PROJECT_ID) + .setCredentials(NoCredentials.getInstance()) + .build(); + assertThat(grpcTransportOptions.getHost()).isEqualTo(DatastoreSettings.getDefaultEndpoint()); + assertThat(grpcTransportOptions.getHost()).isEqualTo("datastore.googleapis.com:443"); + + String customHost = "http://localhost:" + PORT; + DatastoreOptions grpcTransportOptionsCustomHost = + DatastoreOptions.newBuilder() + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .setHost(customHost) + .setProjectId(PROJECT_ID) + .setCredentials(NoCredentials.getInstance()) + .build(); + assertThat(grpcTransportOptionsCustomHost.getHost()).isEqualTo(customHost); + + DatastoreOptions httpTransportOptions = + DatastoreOptions.newBuilder() + .setProjectId(PROJECT_ID) + .setCredentials(NoCredentials.getInstance()) + .build(); + assertThat(httpTransportOptions.getHost()).isEqualTo(DatastoreFactory.DEFAULT_HOST); + + DatastoreOptions httpTransportOptionsCustomHost = + DatastoreOptions.newBuilder() + .setHost(customHost) + .setProjectId(PROJECT_ID) + .setCredentials(NoCredentials.getInstance()) + .build(); + assertThat(httpTransportOptionsCustomHost.getHost()).isEqualTo(customHost); + } + + @Test + public void testToBuilder() { + DatastoreOptions original = options.setNamespace("ns1").build(); + DatastoreOptions copy = original.toBuilder().build(); + assertEquals(original.getProjectId(), copy.getProjectId()); + assertEquals(original.getNamespace(), copy.getNamespace()); + assertEquals(original.getDatabaseId(), copy.getDatabaseId()); + assertEquals(original.getHost(), copy.getHost()); + assertEquals(original.getRetrySettings(), copy.getRetrySettings()); + assertEquals(original.getCredentials(), copy.getCredentials()); + assertEquals(original, copy); + assertEquals(original.hashCode(), copy.hashCode()); + + DatastoreOptions newOptions = options.setDatabaseId("new-database-id").build(); + assertNotEquals(original, newOptions); + assertNotEquals(original.hashCode(), newOptions.hashCode()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTestGrpc.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTestGrpc.java new file mode 100644 index 000000000000..4d0f4fb5a0ca --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTestGrpc.java @@ -0,0 +1,61 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.google.cloud.datastore.testing.LocalDatastoreHelper; +import com.google.cloud.grpc.GrpcTransportOptions; +import com.google.common.truth.Truth; +import java.io.IOException; +import java.time.Duration; +import java.util.Arrays; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class DatastoreTestGrpc extends AbstractDatastoreTest { + + private static final LocalDatastoreHelper helper = LocalDatastoreHelper.create(1.0, 9090); + + private static DatastoreOptions options = + helper.getGrpcTransportOptions(GrpcTransportOptions.newBuilder().build()); + private static Datastore datastore = options.getService(); + + public DatastoreTestGrpc(DatastoreOptions options, Datastore datastore) { + super(options, datastore); + } + + @Parameterized.Parameters(name = "data options: {0}") + public static Iterable data() { + return Arrays.asList(new Object[][] {{options, datastore}}); + } + + @BeforeClass + public static void beforeClass() throws IOException, InterruptedException { + helper.start(); + options = helper.getGrpcTransportOptions(GrpcTransportOptions.newBuilder().build()); + datastore = options.getService(); + } + + @AfterClass + public static void afterClass() throws Exception { + datastore.close(); + Truth.assertThat(datastore.isClosed()).isTrue(); + helper.stopDuration(Duration.ofMinutes(1)); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTestHttp.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTestHttp.java new file mode 100644 index 000000000000..346b722cd496 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreTestHttp.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 + * + * 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.datastore; + +import com.google.cloud.datastore.testing.LocalDatastoreHelper; +import com.google.cloud.grpc.GrpcTransportOptions; +import java.io.IOException; +import java.time.Duration; +import java.util.Arrays; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class DatastoreTestHttp extends AbstractDatastoreTest { + + private static final LocalDatastoreHelper helper = LocalDatastoreHelper.create(1.0, 9090); + + private static DatastoreOptions options = helper.getOptions(); + private static Datastore datastore = options.getService(); + + public DatastoreTestHttp(DatastoreOptions options, Datastore datastore) { + super(options, datastore); + } + + @Parameterized.Parameters(name = "data options: {0}") + public static Iterable data() { + return Arrays.asList(new Object[][] {{options, datastore}}); + } + + @BeforeClass + public static void beforeClass() throws IOException, InterruptedException { + helper.start(); + options = helper.getGrpcTransportOptions(GrpcTransportOptions.newBuilder().build()); + datastore = options.getService(); + } + + @AfterClass + public static void afterClass() throws Exception { + helper.stopDuration(Duration.ofMinutes(1)); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreUtilsTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreUtilsTest.java new file mode 100644 index 000000000000..3a4f7b80ccd8 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DatastoreUtilsTest.java @@ -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. + */ + +package com.google.cloud.datastore; + +import static com.google.cloud.datastore.DatastoreUtils.isLocalHost; +import static com.google.cloud.datastore.DatastoreUtils.removeScheme; +import static com.google.common.truth.Truth.assertThat; + +import org.junit.Test; + +public class DatastoreUtilsTest { + + @Test + public void testIsLocalHost() { + assertThat(isLocalHost(null)).isFalse(); + assertThat(isLocalHost("")).isFalse(); + assertThat(isLocalHost("http://localhost:9090")).isTrue(); + assertThat(isLocalHost("https://localhost:9090")).isTrue(); + assertThat(isLocalHost("10.10.10.10:9090")).isFalse(); + } + + @Test + public void testRemoveScheme() { + assertThat(removeScheme("http://localhost:9090")).isEqualTo("localhost:9090"); + assertThat(removeScheme("https://localhost:9090")).isEqualTo("localhost:9090"); + assertThat(removeScheme("https://localhost:9090")).isEqualTo("localhost:9090"); + assertThat(removeScheme("Https://localhost:9090")).isEqualTo("localhost:9090"); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DoubleValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DoubleValueTest.java new file mode 100644 index 000000000000..b686106f7a46 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/DoubleValueTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class DoubleValueTest { + + private static final Double CONTENT = 1.25; + + @Test + public void testToBuilder() { + DoubleValue value = DoubleValue.of(CONTENT); + assertEquals(value, value.toBuilder().build()); + } + + @SuppressWarnings("deprecation") + @Test + public void testOf() { + DoubleValue value = DoubleValue.of(CONTENT); + assertEquals(CONTENT, value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + DoubleValue.Builder builder = DoubleValue.newBuilder(CONTENT); + DoubleValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertEquals(CONTENT, value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/EntityTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/EntityTest.java new file mode 100644 index 000000000000..588b27520db1 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/EntityTest.java @@ -0,0 +1,63 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class EntityTest { + + private static final Key KEY1 = Key.newBuilder("ds1", "k1", "n1").build(); + private static final Key KEY2 = Key.newBuilder("ds1", "k2", 1).build(); + private static final IncompleteKey INCOMPLETE_KEY = IncompleteKey.newBuilder("ds1", "k2").build(); + private static final Entity ENTITY = Entity.newBuilder(KEY1).set("foo", "bar").build(); + private static final FullEntity INCOMPLETE_ENTITY = + Entity.newBuilder(INCOMPLETE_KEY).set("a", "b").build(); + + @Test + public void testEntity() { + assertTrue(ENTITY.hasKey()); + assertEquals(KEY1, ENTITY.getKey()); + assertEquals("bar", ENTITY.getString("foo")); + } + + @Test + public void testCopyFrom() { + Entity.Builder builder = Entity.newBuilder(ENTITY); + assertEquals(ENTITY, builder.build()); + Entity entity = builder.setKey(KEY2).build(); + assertNotEquals(ENTITY, entity); + assertEquals(KEY2, entity.getKey()); + assertEquals(ENTITY.getProperties(), entity.getProperties()); + } + + @Test + public void testCopyFromIncompleteEntity() { + Entity.Builder builder = Entity.newBuilder(KEY2, INCOMPLETE_ENTITY); + Entity entity = builder.build(); + assertNotEquals(INCOMPLETE_ENTITY, entity); + assertEquals(INCOMPLETE_ENTITY.getProperties(), entity.getProperties()); + } + + @Test + public void testEntitySize() { + assertEquals(ENTITY.toPb().getSerializedSize(), Entity.calculateSerializedSize(ENTITY)); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/EntityValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/EntityValueTest.java new file mode 100644 index 000000000000..b582937ca611 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/EntityValueTest.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 + * + * 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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class EntityValueTest { + + private static final Key KEY = Key.newBuilder("ds", "kind", 1).build(); + private static final Entity CONTENT = Entity.newBuilder(KEY).set("FOO", "BAR").build(); + + @Test + public void testToBuilder() { + EntityValue value = EntityValue.of(CONTENT); + assertEquals(value, value.toBuilder().build()); + } + + @SuppressWarnings("deprecation") + @Test + public void testOf() { + EntityValue value = EntityValue.of(CONTENT); + assertEquals(CONTENT, value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + EntityValue.Builder builder = EntityValue.newBuilder(CONTENT); + EntityValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertEquals(CONTENT, value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/FullEntityTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/FullEntityTest.java new file mode 100644 index 000000000000..cd1c9ad4c328 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/FullEntityTest.java @@ -0,0 +1,72 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +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 org.junit.Test; + +public class FullEntityTest { + + private static final Key KEY1 = Key.newBuilder("ds1", "k1", "n1").build(); + private static final Key KEY2 = Key.newBuilder("ds1", "k2", 1).build(); + private static final IncompleteKey INCOMPLETE_KEY = IncompleteKey.newBuilder("ds1", "k2").build(); + private static final Entity ENTITY = Entity.newBuilder(KEY1).set("foo", "bar").build(); + private static final FullEntity COMPLETE_ENTITY1 = ENTITY; + private static final FullEntity COMPLETE_ENTITY2 = + FullEntity.newBuilder(KEY2).set("foo", "bar").build(); + private static final FullEntity INCOMPLETE_ENTITY = + Entity.newBuilder(INCOMPLETE_KEY).set("a", "b").build(); + + @Test + public void testFullEntity() { + assertTrue(COMPLETE_ENTITY1.hasKey()); + assertEquals(KEY1, COMPLETE_ENTITY1.getKey()); + assertEquals("bar", COMPLETE_ENTITY1.getString("foo")); + + assertTrue(COMPLETE_ENTITY2.hasKey()); + assertEquals(KEY2, COMPLETE_ENTITY2.getKey()); + assertEquals("bar", COMPLETE_ENTITY2.getString("foo")); + } + + @Test + public void testNoKey() { + FullEntity entity = FullEntity.newBuilder().set("foo", "bar").build(); + assertFalse(entity.hasKey()); + assertNull(entity.getKey()); + assertEquals("bar", entity.getString("foo")); + + entity = FullEntity.newBuilder((IncompleteKey) null).build(); + assertFalse(entity.hasKey()); + assertNull(entity.getKey()); + } + + @Test + public void testCopyFrom() { + FullEntity.Builder builder1 = FullEntity.newBuilder(ENTITY); + assertEquals(ENTITY, builder1.build()); + + builder1 = FullEntity.newBuilder(COMPLETE_ENTITY1); + assertEquals(COMPLETE_ENTITY1, builder1.build()); + + FullEntity.Builder builder2 = FullEntity.newBuilder(INCOMPLETE_ENTITY); + assertEquals(INCOMPLETE_ENTITY, builder2.build()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/GqlQueryProtoPreparerTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/GqlQueryProtoPreparerTest.java new file mode 100644 index 000000000000..06088cde6db6 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/GqlQueryProtoPreparerTest.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. + */ +package com.google.cloud.datastore; + +import static com.google.cloud.datastore.ProtoTestData.gqlQueryParameter; +import static com.google.cloud.datastore.ProtoTestData.intValue; +import static com.google.cloud.datastore.ProtoTestData.stringValue; +import static com.google.cloud.datastore.Query.newGqlQueryBuilder; +import static com.google.common.truth.Truth.assertThat; +import static java.util.Arrays.asList; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import com.google.common.collect.ImmutableMap; +import java.util.HashMap; +import org.junit.Test; + +public class GqlQueryProtoPreparerTest { + + private final GqlQueryProtoPreparer protoPreparer = new GqlQueryProtoPreparer(); + private final GqlQuery.Builder gqlQueryBuilder = newGqlQueryBuilder("SELECT * from Character"); + + @Test + public void testQueryString() { + com.google.datastore.v1.GqlQuery gqlQuery = protoPreparer.prepare(gqlQueryBuilder.build()); + + assertThat(gqlQuery.getQueryString()).isEqualTo("SELECT * from Character"); + } + + @Test + public void testAllowLiteral() { + assertTrue( + protoPreparer.prepare(gqlQueryBuilder.setAllowLiteral(true).build()).getAllowLiterals()); + assertFalse( + protoPreparer.prepare(gqlQueryBuilder.setAllowLiteral(false).build()).getAllowLiterals()); + } + + @Test + public void testNamedBinding() { + com.google.datastore.v1.GqlQuery gqlQuery = + protoPreparer.prepare( + gqlQueryBuilder.setBinding("name", "John Doe").setBinding("age", 27).build()); + + assertThat(gqlQuery.getNamedBindingsMap()) + .isEqualTo( + new HashMap<>( + ImmutableMap.of( + "name", gqlQueryParameter(stringValue("John Doe")), + "age", gqlQueryParameter(intValue(27))))); + } + + @Test + public void testPositionalBinding() { + com.google.datastore.v1.GqlQuery gqlQuery = + protoPreparer.prepare(gqlQueryBuilder.addBinding("John Doe").addBinding(27).build()); + + assertThat(gqlQuery.getPositionalBindingsList()) + .isEqualTo( + asList(gqlQueryParameter(stringValue("John Doe")), gqlQueryParameter(intValue(27)))); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/GrpcToDatastoreCodeTranslationTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/GrpcToDatastoreCodeTranslationTest.java new file mode 100644 index 000000000000..327a0436ae30 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/GrpcToDatastoreCodeTranslationTest.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 + * + * 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.datastore; + +import static com.google.common.truth.Truth.assertThat; + +import io.grpc.Status.Code; +import java.util.EnumMap; +import org.junit.Test; + +public class GrpcToDatastoreCodeTranslationTest { + @Test + public void grpcCodeToDatastoreCode_expectedMapping() { + EnumMap expected = new EnumMap<>(Code.class); + expected.put(Code.OK, com.google.rpc.Code.OK.getNumber()); + expected.put(Code.INVALID_ARGUMENT, com.google.rpc.Code.INVALID_ARGUMENT.getNumber()); + expected.put(Code.OUT_OF_RANGE, com.google.rpc.Code.OUT_OF_RANGE.getNumber()); + expected.put(Code.UNAUTHENTICATED, com.google.rpc.Code.UNAUTHENTICATED.getNumber()); + expected.put(Code.PERMISSION_DENIED, com.google.rpc.Code.PERMISSION_DENIED.getNumber()); + expected.put(Code.NOT_FOUND, com.google.rpc.Code.NOT_FOUND.getNumber()); + expected.put(Code.FAILED_PRECONDITION, com.google.rpc.Code.FAILED_PRECONDITION.getNumber()); + expected.put(Code.ALREADY_EXISTS, com.google.rpc.Code.ALREADY_EXISTS.getNumber()); + expected.put(Code.RESOURCE_EXHAUSTED, com.google.rpc.Code.RESOURCE_EXHAUSTED.getNumber()); + expected.put(Code.INTERNAL, com.google.rpc.Code.INTERNAL.getNumber()); + expected.put(Code.UNIMPLEMENTED, com.google.rpc.Code.UNIMPLEMENTED.getNumber()); + expected.put(Code.UNAVAILABLE, com.google.rpc.Code.UNAVAILABLE.getNumber()); + expected.put(Code.ABORTED, com.google.rpc.Code.ABORTED.getNumber()); + expected.put(Code.CANCELLED, com.google.rpc.Code.CANCELLED.getNumber()); + expected.put(Code.UNKNOWN, com.google.rpc.Code.UNKNOWN.getNumber()); + expected.put(Code.DEADLINE_EXCEEDED, com.google.rpc.Code.DEADLINE_EXCEEDED.getNumber()); + expected.put(Code.DATA_LOSS, com.google.rpc.Code.DATA_LOSS.getNumber()); + + EnumMap actual = new EnumMap<>(Code.class); + for (Code c : Code.values()) { + actual.put(c, GrpcToDatastoreCodeTranslation.grpcCodeToDatastoreStatusCode(c)); + } + + assertThat(actual).isEqualTo(expected); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/IncompleteKeyTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/IncompleteKeyTest.java new file mode 100644 index 000000000000..3d9ec96e7e98 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/IncompleteKeyTest.java @@ -0,0 +1,80 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + +import org.junit.Before; +import org.junit.Test; + +public class IncompleteKeyTest { + + private static IncompleteKey pk1, pk2, pk4, pk5; + private static Key parent1, parent2; + + @Before + public void setUp() { + pk1 = IncompleteKey.newBuilder("ds", "kind1").build(); + parent1 = Key.newBuilder("ds", "kind2", 10).setNamespace("ns").build(); + parent2 = Key.newBuilder("ds", "kind2", 10, "test-db").setNamespace("ns").build(); + pk2 = IncompleteKey.newBuilder(parent1, "kind3").build(); + pk4 = IncompleteKey.newBuilderWithDatabaseId("ds", "kind3", "test-db").build(); + pk5 = IncompleteKey.newBuilder(parent2, "kind4").build(); + } + + @Test + public void testBuilders() { + assertEquals("ds", pk1.getProjectId()); + assertEquals("", pk1.getDatabaseId()); + assertEquals("kind1", pk1.getKind()); + assertTrue(pk1.getAncestors().isEmpty()); + + assertEquals("ds", pk2.getProjectId()); + assertEquals("", pk2.getDatabaseId()); + assertEquals("kind3", pk2.getKind()); + assertEquals(parent1.getPath(), pk2.getAncestors()); + + assertEquals(pk2, IncompleteKey.newBuilder(pk2).build()); + IncompleteKey pk3 = IncompleteKey.newBuilder(pk2).setKind("kind4").build(); + assertEquals("ds", pk3.getProjectId()); + assertEquals("", pk3.getDatabaseId()); + assertEquals("kind4", pk3.getKind()); + assertEquals(parent1.getPath(), pk3.getAncestors()); + + assertEquals("ds", pk4.getProjectId()); + assertEquals("test-db", pk4.getDatabaseId()); + assertEquals("kind3", pk4.getKind()); + assertTrue(pk4.getAncestors().isEmpty()); + + assertEquals("ds", pk5.getProjectId()); + assertEquals("test-db", pk5.getDatabaseId()); + assertEquals("kind4", pk5.getKind()); + assertEquals(parent2.getPath(), pk5.getAncestors()); + } + + @Test + public void testParent() { + assertNull(pk1.getParent()); + assertEquals(parent1, pk2.getParent()); + assertEquals(parent2, pk5.getParent()); + Key parent2 = Key.newBuilder("ds", "kind3", "name").setNamespace("ns").build(); + IncompleteKey pk3 = IncompleteKey.newBuilder(parent2, "kind3").build(); + assertEquals(parent2, pk3.getParent()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/KeyFactoryTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/KeyFactoryTest.java new file mode 100644 index 000000000000..6afbf8ec1c9f --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/KeyFactoryTest.java @@ -0,0 +1,175 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.Iterator; +import org.junit.Before; +import org.junit.Test; + +public class KeyFactoryTest { + + private static final String PROJECT_ID = "projectid"; + private static final String DATABASE_ID = "database-id"; + + private KeyFactory keyFactory; + + @Before + public void setUp() { + keyFactory = new KeyFactory(PROJECT_ID).setDatabaseId(DATABASE_ID).setKind("k"); + } + + @Test + public void testReset() { + IncompleteKey key = + keyFactory + .setProjectId("ds1") + .setDatabaseId("db") + .setNamespace("ns1") + .addAncestor(PathElement.of("p", 1)) + .build(); + assertEquals("k", key.getKind()); + assertEquals("ds1", key.getProjectId()); + assertEquals("db", key.getDatabaseId()); + assertEquals("ns1", key.getNamespace()); + assertEquals(1, key.getAncestors().size()); + + keyFactory.reset(); + try { + keyFactory.newKey(1); + } catch (NullPointerException ex) { + assertEquals("kind must not be null", ex.getMessage()); + } + keyFactory.setKind("k1"); + key = keyFactory.newKey(); + assertEquals("k1", key.getKind()); + assertEquals(PROJECT_ID, key.getProjectId()); + assertEquals("", key.getDatabaseId()); + assertTrue(key.getNamespace().isEmpty()); + assertTrue(key.getAncestors().isEmpty()); + + keyFactory = new KeyFactory(PROJECT_ID, "ns1").setKind("k"); + key = keyFactory.newKey(); + assertEquals(PROJECT_ID, key.getProjectId()); + assertEquals("", key.getDatabaseId()); + assertEquals("ns1", key.getNamespace()); + key = keyFactory.setProjectId("bla1").setNamespace("bla2").build(); + assertEquals("bla1", key.getProjectId()); + assertEquals("bla2", key.getNamespace()); + keyFactory.reset().setKind("kind"); + key = keyFactory.newKey(); + assertEquals(PROJECT_ID, key.getProjectId()); + assertEquals("ns1", key.getNamespace()); + assertEquals("kind", key.getKind()); + } + + @Test + public void testCreatedWithDbId() { + KeyFactory keyFactory = new KeyFactory(PROJECT_ID, "namespace", DATABASE_ID).setKind("k"); + IncompleteKey key = + keyFactory + .setProjectId("ds1") + .setDatabaseId("db") + .setNamespace("ns1") + .addAncestor(PathElement.of("p", 1)) + .build(); + assertEquals("k", key.getKind()); + assertEquals("ds1", key.getProjectId()); + assertEquals("db", key.getDatabaseId()); + assertEquals("ns1", key.getNamespace()); + assertEquals(1, key.getAncestors().size()); + + keyFactory.reset(); + try { + keyFactory.newKey(1); + } catch (NullPointerException ex) { + assertEquals("kind must not be null", ex.getMessage()); + } + keyFactory.setKind("k1"); + key = keyFactory.newKey(); + assertEquals("k1", key.getKind()); + assertEquals(PROJECT_ID, key.getProjectId()); + assertEquals(DATABASE_ID, key.getDatabaseId()); + assertEquals("namespace", key.getNamespace()); + assertTrue(key.getAncestors().isEmpty()); + + keyFactory = new KeyFactory(PROJECT_ID, "ns1").setKind("k"); + key = keyFactory.newKey(); + assertEquals(PROJECT_ID, key.getProjectId()); + assertEquals("", key.getDatabaseId()); + assertEquals("ns1", key.getNamespace()); + key = keyFactory.setProjectId("bla1").setNamespace("bla2").build(); + assertEquals("bla1", key.getProjectId()); + assertEquals("bla2", key.getNamespace()); + keyFactory.reset().setKind("kind"); + key = keyFactory.newKey(); + assertEquals(PROJECT_ID, key.getProjectId()); + assertEquals("ns1", key.getNamespace()); + assertEquals("kind", key.getKind()); + } + + @Test + public void testNewKey() { + Key key = keyFactory.newKey(1); + verifyKey(key, 1L, ""); + key = keyFactory.newKey("n"); + verifyKey(key, "n", ""); + PathElement p1 = PathElement.of("k1", "n"); + PathElement p2 = PathElement.of("k2", 10); + key = keyFactory.setNamespace("ns").addAncestors(p1, p2).newKey("k3"); + verifyKey(key, "k3", "ns", p1, p2); + } + + @Test + public void testNewIncompleteKey() { + IncompleteKey key = keyFactory.newKey(); + verifyIncompleteKey(key, ""); + PathElement p1 = PathElement.of("k1", "n"); + PathElement p2 = PathElement.of("k2", 10); + key = keyFactory.setNamespace("ns").addAncestors(p1, p2).newKey(); + verifyIncompleteKey(key, "ns", p1, p2); + } + + @Test(expected = NullPointerException.class) + public void testNewIncompleteWithNoKind() { + new KeyFactory(PROJECT_ID).build(); + } + + private void verifyKey(Key key, String name, String namespace, PathElement... ancestors) { + assertEquals(name, key.getName()); + verifyIncompleteKey(key, namespace, ancestors); + } + + private void verifyKey(Key key, Long id, String namespace, PathElement... ancestors) { + assertEquals(id, key.getId()); + verifyIncompleteKey(key, namespace, ancestors); + } + + private void verifyIncompleteKey(IncompleteKey key, String namespace, PathElement... ancestors) { + assertEquals("k", key.getKind()); + assertEquals(PROJECT_ID, key.getProjectId()); + assertEquals(DATABASE_ID, key.getDatabaseId()); + assertEquals(namespace, key.getNamespace()); + assertEquals(ancestors.length, key.getAncestors().size()); + Iterator iter = key.getAncestors().iterator(); + for (PathElement ancestor : ancestors) { + assertEquals(ancestor, iter.next()); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/KeyTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/KeyTest.java new file mode 100644 index 000000000000..3f2fbe0e0b2b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/KeyTest.java @@ -0,0 +1,89 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class KeyTest { + + @Test + public void testHasId() { + Key.Builder builder = Key.newBuilder("d", "k", 10); + Key key = builder.build(); + assertTrue(key.hasId()); + key = builder.setName("bla").build(); + assertFalse(key.hasId()); + } + + @Test + public void testId() { + Key.Builder builder = Key.newBuilder("d", "k", 10); + Key key = builder.build(); + assertEquals(Long.valueOf(10), key.getId()); + key = builder.setId(100).build(); + assertEquals(Long.valueOf(100), key.getId()); + } + + @Test + public void testHasName() { + Key.Builder builder = Key.newBuilder("d", "k", "n"); + Key key = builder.build(); + assertTrue(key.hasName()); + key = builder.setId(1).build(); + assertFalse(key.hasName()); + } + + @Test + public void testName() { + Key.Builder builder = Key.newBuilder("d", "k", "n"); + Key key = builder.build(); + assertEquals("n", key.getName()); + key = builder.setName("o").build(); + assertEquals("o", key.getName()); + } + + @Test + public void testNameOrId() { + Key.Builder builder = Key.newBuilder("d", "k", "n"); + Key key = builder.build(); + assertEquals("n", key.getNameOrId()); + key = builder.setId(1).build(); + assertEquals(Long.valueOf(1), key.getNameOrId()); + } + + @Test + public void testToAndFromUrlSafe() { + Key key = Key.newBuilder("d", "k", "n").build(); + String urlSafe = key.toUrlSafe(); + Key copy = Key.fromUrlSafe(urlSafe); + assertEquals(key, copy); + } + + @Test + public void testDatabaseId() { + Key.Builder builder = Key.newBuilder("project-id", "kind", "name", "database-id"); + Key key = builder.build(); + assertEquals("database-id", key.getDatabaseId()); + assertEquals("project-id", key.getProjectId()); + assertEquals("name", key.getName()); + assertEquals("kind", key.getKind()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/KeyValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/KeyValueTest.java new file mode 100644 index 000000000000..a35a15262b77 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/KeyValueTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class KeyValueTest { + + private static final Key CONTENT = Key.newBuilder("ds", "kind", 1).build(); + + @Test + public void testToBuilder() { + KeyValue value = KeyValue.of(CONTENT); + assertEquals(value, value.toBuilder().build()); + } + + @SuppressWarnings("deprecation") + @Test + public void testOf() { + KeyValue value = KeyValue.of(CONTENT); + assertEquals(CONTENT, value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + KeyValue.Builder builder = KeyValue.newBuilder(CONTENT); + KeyValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertEquals(CONTENT, value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/LatLngTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/LatLngTest.java new file mode 100644 index 000000000000..7c4c0a6e6dae --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/LatLngTest.java @@ -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. + */ + +package com.google.cloud.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +import com.google.common.testing.EqualsTester; +import org.junit.Assert; +import org.junit.Test; + +public class LatLngTest { + + private static LatLng gp1 = new LatLng(37.422035, -122.084124); + private static LatLng gp2 = new LatLng(0.0, 0.0); + + private static final String INVALID_LAT_MESSAGE = + "latitude must be in the range [-90, 90] degrees"; + private static final String INVALID_LNG_MESSAGE = + "latitude must be in the range [-180, 180] degrees"; + + @Test + public void testLatLng() { + assertEquals(37.422035, gp1.getLatitude(), 0); + assertEquals(-122.084124, gp1.getLongitude(), 0); + } + + @Test + public void testEquals() { + EqualsTester equalsTester = new EqualsTester(); + equalsTester.addEqualityGroup(gp1, gp1).testEquals(); + assertNotEquals(gp1, gp2); + } + + @Test + public void testUpperLatRange() { + try { + new LatLng(90, 0); + new LatLng(91, 0); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertEquals(INVALID_LAT_MESSAGE, ex.getMessage()); + } + } + + @Test + public void testLowerLatRange() { + try { + new LatLng(-90, 0); + new LatLng(-91, 0); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertEquals(INVALID_LAT_MESSAGE, ex.getMessage()); + } + } + + @Test + public void testUpperLngRange() { + try { + new LatLng(0, 180); + new LatLng(0, 181); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertEquals(INVALID_LNG_MESSAGE, ex.getMessage()); + } + } + + @Test + public void testLowerLngRange() { + try { + new LatLng(0, 180); + new LatLng(0, -181); + Assert.fail(); + } catch (IllegalArgumentException ex) { + assertEquals(INVALID_LNG_MESSAGE, ex.getMessage()); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/LatLngValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/LatLngValueTest.java new file mode 100644 index 000000000000..04874dc0c7db --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/LatLngValueTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class LatLngValueTest { + + private static final LatLng CONTENT = new LatLng(37.4, -122.1); + + @Test + public void testToBuilder() { + LatLngValue value = LatLngValue.of(CONTENT); + assertEquals(value, value.toBuilder().build()); + } + + @SuppressWarnings("deprecation") + @Test + public void testOf() { + LatLngValue value = LatLngValue.of(CONTENT); + assertEquals(CONTENT, value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + LatLngValue.Builder builder = LatLngValue.newBuilder(CONTENT); + LatLngValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertEquals(CONTENT, value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ListValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ListValueTest.java new file mode 100644 index 000000000000..ecbb6f34b9c8 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ListValueTest.java @@ -0,0 +1,204 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.Timestamp; +import com.google.common.collect.ImmutableList; +import java.util.Collections; +import java.util.List; +import org.junit.Test; + +public class ListValueTest { + + private static final List> CONTENT = + ImmutableList.of(NullValue.of(), StringValue.of("foo")); + private static final String STRING1 = "string1"; + private static final String STRING2 = "string2"; + private static final long LONG1 = 1L; + private static final long LONG2 = 2L; + private static final double DOUBLE1 = 1.0; + private static final double DOUBLE2 = 2.0; + private static final boolean BOOLEAN1 = true; + private static final boolean BOOLEAN2 = false; + private static final Timestamp TIMESTAMP1 = Timestamp.ofTimeMicroseconds(1); + private static final Timestamp TIMESTAMP2 = Timestamp.ofTimeMicroseconds(2); + private static final LatLng LATLNG1 = LatLng.of(DOUBLE1, DOUBLE2); + private static final LatLng LATLNG2 = LatLng.of(DOUBLE2, DOUBLE1); + private static final Key KEY1 = Key.newBuilder("project", "kind", "name1").build(); + private static final Key KEY2 = Key.newBuilder("project", "kind", "name2").build(); + private static final FullEntity ENTITY1 = FullEntity.newBuilder(KEY1).build(); + private static final FullEntity ENTITY2 = FullEntity.newBuilder(KEY2).build(); + private static final Blob BLOB1 = Blob.copyFrom(new byte[] {0xD, 0xE, 0xA, 0xD}); + private static final Blob BLOB2 = Blob.copyFrom(new byte[] {0xB, 0x0, 0x0, 0x0}); + + @Test + public void testToBuilder() { + ListValue value = ListValue.of(CONTENT); + assertEquals(value, value.toBuilder().build()); + } + + @Test + public void testOf() { + ListValue value = ListValue.of(CONTENT); + assertEquals(CONTENT, value.get()); + assertFalse(value.excludeFromIndexes()); + value = ListValue.of(Collections.>emptyList()); + assertEquals(Collections.>emptyList(), value.get()); + assertFalse(value.excludeFromIndexes()); + value = ListValue.of(STRING1); + assertEquals(ImmutableList.of(StringValue.of(STRING1)), value.get()); + value = ListValue.of(STRING1, STRING2); + assertEquals(ImmutableList.of(StringValue.of(STRING1), StringValue.of(STRING2)), value.get()); + value = ListValue.of(LONG1); + assertEquals(ImmutableList.of(LongValue.of(LONG1)), value.get()); + value = ListValue.of(LONG1, LONG2); + assertEquals(ImmutableList.of(LongValue.of(LONG1), LongValue.of(LONG2)), value.get()); + value = ListValue.of(DOUBLE1); + assertEquals(ImmutableList.of(DoubleValue.of(DOUBLE1)), value.get()); + value = ListValue.of(DOUBLE1, DOUBLE2); + assertEquals(ImmutableList.of(DoubleValue.of(DOUBLE1), DoubleValue.of(DOUBLE2)), value.get()); + value = ListValue.of(BOOLEAN1); + assertEquals(ImmutableList.of(BooleanValue.of(BOOLEAN1)), value.get()); + value = ListValue.of(BOOLEAN1, BOOLEAN2); + assertEquals( + ImmutableList.of(BooleanValue.of(BOOLEAN1), BooleanValue.of(BOOLEAN2)), value.get()); + value = ListValue.of(TIMESTAMP1); + assertEquals(ImmutableList.of(TimestampValue.of(TIMESTAMP1)), value.get()); + value = ListValue.of(TIMESTAMP1, TIMESTAMP2); + assertEquals( + ImmutableList.of(TimestampValue.of(TIMESTAMP1), TimestampValue.of(TIMESTAMP2)), + value.get()); + value = ListValue.of(LATLNG1); + assertEquals(ImmutableList.of(LatLngValue.of(LATLNG1)), value.get()); + value = ListValue.of(LATLNG1, LATLNG2); + assertEquals(ImmutableList.of(LatLngValue.of(LATLNG1), LatLngValue.of(LATLNG2)), value.get()); + value = ListValue.of(KEY1); + assertEquals(ImmutableList.of(KeyValue.of(KEY1)), value.get()); + value = ListValue.of(KEY1, KEY2); + assertEquals(ImmutableList.of(KeyValue.of(KEY1), KeyValue.of(KEY2)), value.get()); + value = ListValue.of(ENTITY1); + assertEquals(ImmutableList.of(EntityValue.of(ENTITY1)), value.get()); + value = ListValue.of(ENTITY1, ENTITY2); + assertEquals(ImmutableList.of(EntityValue.of(ENTITY1), EntityValue.of(ENTITY2)), value.get()); + value = ListValue.of(BLOB1); + assertEquals(ImmutableList.of(BlobValue.of(BLOB1)), value.get()); + value = ListValue.of(BLOB1, BLOB2); + assertEquals(ImmutableList.of(BlobValue.of(BLOB1), BlobValue.of(BLOB2)), value.get()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + ListValue.Builder builder = ListValue.newBuilder().set(CONTENT); + ListValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertEquals(CONTENT, value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + + builder = ListValue.newBuilder(); + for (Value v : CONTENT) { + builder.addValue(v); + } + assertEquals(CONTENT, builder.build().get()); + + builder = builder.set(Collections.>emptyList()); + assertEquals(Collections.>emptyList(), builder.build().get()); + + builder = builder.addValue(STRING1); + assertEquals(ImmutableList.of(StringValue.of(STRING1)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(STRING1, STRING2); + assertEquals( + ImmutableList.of(StringValue.of(STRING1), StringValue.of(STRING2)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(LONG1); + assertEquals(ImmutableList.of(LongValue.of(LONG1)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(LONG1, LONG2); + assertEquals(ImmutableList.of(LongValue.of(LONG1), LongValue.of(LONG2)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(DOUBLE1); + assertEquals(ImmutableList.of(DoubleValue.of(DOUBLE1)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(DOUBLE1, DOUBLE2); + assertEquals( + ImmutableList.of(DoubleValue.of(DOUBLE1), DoubleValue.of(DOUBLE2)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(BOOLEAN1); + assertEquals(ImmutableList.of(BooleanValue.of(BOOLEAN1)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(BOOLEAN1, BOOLEAN2); + assertEquals( + ImmutableList.of(BooleanValue.of(BOOLEAN1), BooleanValue.of(BOOLEAN2)), + builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(TIMESTAMP1); + assertEquals(ImmutableList.of(TimestampValue.of(TIMESTAMP1)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(TIMESTAMP1, TIMESTAMP2); + assertEquals( + ImmutableList.of(TimestampValue.of(TIMESTAMP1), TimestampValue.of(TIMESTAMP2)), + builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(LATLNG1); + assertEquals(ImmutableList.of(LatLngValue.of(LATLNG1)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(LATLNG1, LATLNG2); + assertEquals( + ImmutableList.of(LatLngValue.of(LATLNG1), LatLngValue.of(LATLNG2)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(KEY1); + assertEquals(ImmutableList.of(KeyValue.of(KEY1)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(KEY1, KEY2); + assertEquals(ImmutableList.of(KeyValue.of(KEY1), KeyValue.of(KEY2)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(ENTITY1); + assertEquals(ImmutableList.of(EntityValue.of(ENTITY1)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(ENTITY1, ENTITY2); + assertEquals( + ImmutableList.of(EntityValue.of(ENTITY1), EntityValue.of(ENTITY2)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(BLOB1); + assertEquals(ImmutableList.of(BlobValue.of(BLOB1)), builder.build().get()); + builder = builder.set(Collections.>emptyList()); + + builder = builder.addValue(BLOB1, BLOB2); + assertEquals(ImmutableList.of(BlobValue.of(BLOB1), BlobValue.of(BLOB2)), builder.build().get()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/LongValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/LongValueTest.java new file mode 100644 index 000000000000..92b3dd9e2abb --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/LongValueTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class LongValueTest { + + private static final Long CONTENT = 125L; + + @Test + public void testToBuilder() { + LongValue value = LongValue.of(CONTENT); + assertEquals(value, value.toBuilder().build()); + } + + @SuppressWarnings("deprecation") + @Test + public void testOf() { + LongValue value = LongValue.of(CONTENT); + assertEquals(CONTENT, value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + LongValue.Builder builder = LongValue.newBuilder(CONTENT); + LongValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertEquals(CONTENT, value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/NullValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/NullValueTest.java new file mode 100644 index 000000000000..1978dd5ad5e6 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/NullValueTest.java @@ -0,0 +1,50 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +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 org.junit.Test; + +public class NullValueTest { + + @Test + public void testToBuilder() { + NullValue value = NullValue.of(); + assertEquals(value, value.toBuilder().build()); + } + + @Test + public void testOf() { + NullValue value = NullValue.of(); + assertNull(value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + NullValue.Builder builder = NullValue.newBuilder(); + NullValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertNull(value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/PathElementTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/PathElementTest.java new file mode 100644 index 000000000000..8832013d23c2 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/PathElementTest.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 + * + * 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.datastore; + +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 org.junit.Test; + +public class PathElementTest { + + private static final PathElement PE_1 = PathElement.of("k1"); + private static final PathElement PE_2 = PathElement.of("k2", "n"); + private static final PathElement PE_3 = PathElement.of("k3", 1); + + @Test + public void testKind() { + assertEquals("k1", PE_1.getKind()); + assertEquals("k2", PE_2.getKind()); + assertEquals("k3", PE_3.getKind()); + } + + @Test + public void testHasId() { + assertFalse(PE_1.hasId()); + assertFalse(PE_2.hasId()); + assertTrue(PE_3.hasId()); + } + + @Test + public void testId() { + assertNull(PE_1.getId()); + assertNull(PE_2.getId()); + assertEquals(Long.valueOf(1), PE_3.getId()); + } + + @Test + public void testHasName() { + assertFalse(PE_1.hasName()); + assertTrue(PE_2.hasName()); + assertFalse(PE_3.hasName()); + } + + @Test + public void testName() { + assertNull(PE_1.getName()); + assertEquals("n", PE_2.getName()); + assertNull(PE_3.getName()); + } + + @Test + public void testNameOrId() { + assertNull(PE_1.getNameOrId()); + assertEquals("n", PE_2.getNameOrId()); + assertEquals(Long.valueOf(1), PE_3.getNameOrId()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ProjectionEntityTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ProjectionEntityTest.java new file mode 100644 index 000000000000..1172b1106ad5 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ProjectionEntityTest.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 + * + * 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.datastore; + +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 com.google.cloud.Timestamp; +import org.junit.Test; + +public class ProjectionEntityTest { + + private static final Key KEY = Key.newBuilder("ds1", "k1", "n1").build(); + private static final StringValue STRING_INDEX_VALUE = + StringValue.newBuilder("foo").setMeaning(18).build(); + private static final BlobValue BLOB_VALUE = BlobValue.of(Blob.copyFrom(new byte[] {1})); + private static final TimestampValue TIMESTAMP_VALUE = TimestampValue.of(Timestamp.now()); + private static final LongValue LONG_INDEX_VALUE = + LongValue.newBuilder( + TIMESTAMP_VALUE.get().getSeconds() * 1000000 + + TIMESTAMP_VALUE.get().getNanos() / 1000) + .setMeaning(18) + .build(); + private static final ProjectionEntity ENTITY1 = + new ProjectionEntity.Builder().setKey(KEY).set("a", "b").build(); + private static final ProjectionEntity ENTITY2 = + new ProjectionEntity.Builder() + .set("a", STRING_INDEX_VALUE) + .set("b", BLOB_VALUE) + .set("c", TIMESTAMP_VALUE) + .set("d", LONG_INDEX_VALUE) + .build(); + + @Test + public void testHasKey() { + assertTrue(ENTITY1.hasKey()); + assertFalse(ENTITY2.hasKey()); + } + + @Test + public void testKey() { + assertEquals(KEY, ENTITY1.getKey()); + assertNull(ENTITY2.getKey()); + } + + @Test + public void testGetBlob() { + assertArrayEquals(STRING_INDEX_VALUE.get().getBytes(), ENTITY2.getBlob("a").toByteArray()); + assertEquals(BLOB_VALUE.get(), ENTITY2.getBlob("b")); + } + + @Test + public void testGetTimestamp() { + assertEquals(TIMESTAMP_VALUE.get(), ENTITY2.getTimestamp("c")); + assertEquals(TIMESTAMP_VALUE.get(), ENTITY2.getTimestamp("d")); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ProtoTestData.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ProtoTestData.java new file mode 100644 index 000000000000..6b44d7a08dd5 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ProtoTestData.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import static com.google.datastore.v1.PropertyOrder.Direction.ASCENDING; + +import com.google.datastore.v1.AggregationQuery.Aggregation; +import com.google.datastore.v1.AggregationQuery.Aggregation.Count; +import com.google.datastore.v1.Filter; +import com.google.datastore.v1.GqlQueryParameter; +import com.google.datastore.v1.KindExpression; +import com.google.datastore.v1.Projection; +import com.google.datastore.v1.PropertyFilter.Operator; +import com.google.datastore.v1.PropertyOrder; +import com.google.datastore.v1.PropertyReference; +import com.google.datastore.v1.Value; + +public class ProtoTestData { + + public static Value booleanValue(boolean value) { + return Value.newBuilder().setBooleanValue(value).build(); + } + + public static Value stringValue(String value) { + return Value.newBuilder().setStringValue(value).build(); + } + + public static Value intValue(long value) { + return Value.newBuilder().setIntegerValue(value).build(); + } + + public static Value doubleValue(double value) { + return Value.newBuilder().setDoubleValue(value).build(); + } + + public static GqlQueryParameter gqlQueryParameter(Value value) { + return GqlQueryParameter.newBuilder().setValue(value).build(); + } + + public static KindExpression kind(String kind) { + return KindExpression.newBuilder().setName(kind).build(); + } + + public static Filter propertyFilter(String propertyName, Operator operator, Value value) { + return Filter.newBuilder() + .setPropertyFilter( + com.google.datastore.v1.PropertyFilter.newBuilder() + .setProperty(propertyReference(propertyName)) + .setOp(operator) + .setValue(value) + .build()) + .build(); + } + + public static PropertyReference propertyReference(String value) { + return PropertyReference.newBuilder().setName(value).build(); + } + + public static Aggregation countAggregation(String alias) { + return Aggregation.newBuilder().setAlias(alias).setCount(Count.newBuilder().build()).build(); + } + + public static PropertyOrder propertyOrder(String value) { + return PropertyOrder.newBuilder() + .setProperty(propertyReference(value)) + .setDirection(ASCENDING) + .build(); + } + + public static Projection projection(String value) { + return Projection.newBuilder().setProperty(propertyReference(value)).build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/RawValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/RawValueTest.java new file mode 100644 index 000000000000..249ef74ec76c --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/RawValueTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class RawValueTest { + + private static final com.google.datastore.v1.Value CONTENT = StringValue.of("hello").toPb(); + + @Test + public void testToBuilder() { + RawValue value = RawValue.of(CONTENT); + assertEquals(value, value.toBuilder().build()); + } + + @Test + public void testOf() { + RawValue value = RawValue.of(CONTENT); + assertEquals(CONTENT, value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + RawValue.Builder builder = RawValue.newBuilder(CONTENT); + RawValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertEquals(CONTENT, value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ReadOptionProtoPreparerTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ReadOptionProtoPreparerTest.java new file mode 100644 index 000000000000..bd7f7ee437e1 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ReadOptionProtoPreparerTest.java @@ -0,0 +1,97 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import static com.google.cloud.datastore.ReadOption.eventualConsistency; +import static com.google.cloud.datastore.ReadOption.readTime; +import static com.google.cloud.datastore.ReadOption.transactionId; +import static com.google.common.truth.Truth.assertThat; +import static com.google.datastore.v1.ReadOptions.ReadConsistency.EVENTUAL; +import static java.util.Collections.singletonList; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertThrows; + +import com.google.cloud.Timestamp; +import com.google.common.collect.ImmutableList; +import com.google.datastore.v1.ReadOptions; +import java.util.Arrays; +import java.util.Optional; +import org.junit.Test; + +public class ReadOptionProtoPreparerTest { + + private final ReadOptionProtoPreparer protoPreparer = new ReadOptionProtoPreparer(); + + @Test + public void shouldThrowErrorWhenUsingMultipleReadOptions() { + assertThrows( + DatastoreException.class, + () -> + protoPreparer.prepare(Arrays.asList(eventualConsistency(), readTime(Timestamp.now())))); + assertThrows( + DatastoreException.class, + () -> + protoPreparer.prepare( + Arrays.asList(eventualConsistency(), transactionId("transaction-id")))); + assertThrows( + DatastoreException.class, + () -> + protoPreparer.prepare( + Arrays.asList(transactionId("transaction-id"), readTime(Timestamp.now())))); + assertThrows( + DatastoreException.class, + () -> + protoPreparer.prepare( + Arrays.asList( + eventualConsistency(), + readTime(Timestamp.now()), + transactionId("transaction-id")))); + } + + @Test + public void shouldPrepareReadOptionsWithEventualConsistency() { + Optional readOptions = protoPreparer.prepare(singletonList(eventualConsistency())); + + assertThat(readOptions.get().getReadConsistency()).isEqualTo(EVENTUAL); + } + + @Test + public void shouldPrepareReadOptionsWithReadTime() { + Timestamp timestamp = Timestamp.now(); + Optional readOptions = protoPreparer.prepare(singletonList(readTime(timestamp))); + + assertThat(Timestamp.fromProto(readOptions.get().getReadTime())).isEqualTo(timestamp); + } + + @Test + public void shouldPrepareReadOptionsWithTransactionId() { + String transactionId = "transaction-id"; + Optional readOptions = + protoPreparer.prepare(singletonList(transactionId(transactionId))); + + assertThat(readOptions.get().getTransaction().toStringUtf8()).isEqualTo(transactionId); + } + + @Test + public void shouldReturnNullWhenReadOptionsIsNull() { + assertFalse(protoPreparer.prepare(null).isPresent()); + } + + @Test + public void shouldReturnNullWhenReadOptionsIsAnEmptyList() { + assertFalse(protoPreparer.prepare(ImmutableList.of()).isPresent()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/SerializationTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/SerializationTest.java new file mode 100644 index 000000000000..52baa7d80bf2 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/SerializationTest.java @@ -0,0 +1,177 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static java.nio.charset.StandardCharsets.UTF_8; + +import com.google.cloud.BaseSerializationTest; +import com.google.cloud.NoCredentials; +import com.google.cloud.Restorable; +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.StructuredQuery.CompositeFilter; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; + +public class SerializationTest extends BaseSerializationTest { + + private static final IncompleteKey INCOMPLETE_KEY1 = + IncompleteKey.newBuilder("ds", "k").addAncestor(PathElement.of("p", 1)).build(); + private static final Key KEY1 = Key.newBuilder("ds", "k", "n").build(); + private static final IncompleteKey INCOMPLETE_KEY2 = + IncompleteKey.newBuilder(KEY1, "v").addAncestor(PathElement.of("p", 1)).build(); + private static final Key KEY2 = Key.newBuilder(KEY1, "v", 2).build(); + private static final Timestamp TIMESTAMP = Timestamp.now(); + private static final LatLng LAT_LNG = new LatLng(37.422035, -122.084124); + private static final Blob BLOB1 = Blob.copyFrom(UTF_8.encode("hello world")); + private static final Cursor CURSOR1 = Cursor.copyFrom(new byte[] {1, 2}); + private static final Cursor CURSOR2 = Cursor.copyFrom(new byte[] {10}); + private static final Query GQL1 = + Query.newGqlQueryBuilder("select * from kind1 where name = @name and age > @1") + .setBinding("name", "name1") + .addBinding(20) + .setNamespace("ns1") + .build(); + private static final Query GQL2 = + Query.newGqlQueryBuilder( + Query.ResultType.ENTITY, "select * from kind1 where name = @name and age > @1") + .setBinding("name", "name1") + .addBinding(20) + .setNamespace("ns1") + .build(); + private static final Query QUERY1 = + Query.newEntityQueryBuilder().setKind("kind1").build(); + private static final Query QUERY2 = + Query.newKeyQueryBuilder().setKind("k").setFilter(PropertyFilter.eq("p1", "hello")).build(); + private static final Query QUERY3 = + Query.newProjectionEntityQueryBuilder() + .setKind("k") + .setNamespace("ns1") + .addProjection("p") + .setLimit(100) + .setOffset(5) + .setStartCursor(CURSOR1) + .setEndCursor(CURSOR2) + .setFilter(CompositeFilter.and(PropertyFilter.gt("p1", 10), PropertyFilter.eq("a", "v"))) + .addDistinctOn("p") + .addOrderBy(OrderBy.asc("p")) + .build(); + private static final Query QUERY4 = + Query.newProjectionEntityQueryBuilder() + .setKind("k") + .setNamespace("ns1") + .addProjection("p") + .setLimit(100) + .setOffset(5) + .setStartCursor(CURSOR1) + .setEndCursor(CURSOR2) + .setFilter(CompositeFilter.or(PropertyFilter.gt("p1", 10), PropertyFilter.eq("a", "v"))) + .addDistinctOn("p") + .addOrderBy(OrderBy.asc("p")) + .build(); + private static final KeyValue KEY_VALUE = KeyValue.of(KEY1); + private static final NullValue NULL_VALUE = + NullValue.newBuilder().setExcludeFromIndexes(true).build(); + private static final StringValue STRING_VALUE = StringValue.of("hello"); + private static final LongValue LONG_VALUE = LongValue.of(123); + private static final DoubleValue DOUBLE_VALUE = DoubleValue.of(12.34); + private static final BooleanValue BOOLEAN_VALUE = BooleanValue.of(true); + private static final TimestampValue TIMESTAMP_VALUE = TimestampValue.of(Timestamp.now()); + private static final BlobValue BLOB_VALUE = BlobValue.of(BLOB1); + private static final RawValue RAW_VALUE = + RawValue.of(com.google.datastore.v1.Value.newBuilder().setMeaning(18).build()); + private static final LatLngValue LAT_LNG_VALUE = LatLngValue.of(LAT_LNG); + private static final Entity ENTITY1 = Entity.newBuilder(KEY1).build(); + private static final Entity ENTITY2 = Entity.newBuilder(KEY2).set("null", NullValue.of()).build(); + private static final Entity ENTITY3 = + Entity.newBuilder(KEY2) + .set("p1", StringValue.newBuilder("hi1").setMeaning(10).build()) + .set( + "p2", + StringValue.newBuilder("hi2").setMeaning(11).setExcludeFromIndexes(true).build()) + .set("p3", LongValue.newBuilder(100).setExcludeFromIndexes(true).setMeaning(100).build()) + .set("blob", BLOB1) + .build(); + private static final FullEntity EMBEDDED_ENTITY = + Entity.newBuilder(INCOMPLETE_KEY1) + .set("p1", STRING_VALUE) + .set("p2", LongValue.newBuilder(100).setExcludeFromIndexes(true).setMeaning(100).build()) + .build(); + private static final EntityValue EMBEDDED_ENTITY_VALUE1 = EntityValue.of(ENTITY1); + private static final EntityValue EMBEDDED_ENTITY_VALUE2 = EntityValue.of(ENTITY2); + private static final EntityValue EMBEDDED_ENTITY_VALUE3 = EntityValue.of(EMBEDDED_ENTITY); + private static final ListValue LIST_VALUE = + ListValue.newBuilder() + .addValue(NULL_VALUE) + .addValue(STRING_VALUE) + .addValue(new NullValue()) + .build(); + private static final ProjectionEntity PROJECTION_ENTITY = ProjectionEntity.fromPb(ENTITY1.toPb()); + private static final DatastoreException DATASTORE_EXCEPTION = + new DatastoreException(42, "message", "reason"); + + @Override + protected java.io.Serializable[] serializableObjects() { + DatastoreOptions options = + DatastoreOptions.newBuilder() + .setCredentials(NoCredentials.getInstance()) + .setProjectId("ds1") + .build(); + DatastoreOptions otherOptions = options.toBuilder().setNamespace("ns1").build(); + return new java.io.Serializable[] { + KEY1, + KEY2, + INCOMPLETE_KEY1, + INCOMPLETE_KEY2, + ENTITY1, + ENTITY2, + ENTITY3, + EMBEDDED_ENTITY, + PROJECTION_ENTITY, + TIMESTAMP, + BLOB1, + CURSOR1, + GQL1, + GQL2, + QUERY1, + QUERY2, + QUERY3, + QUERY4, + NULL_VALUE, + KEY_VALUE, + STRING_VALUE, + EMBEDDED_ENTITY_VALUE1, + EMBEDDED_ENTITY_VALUE2, + EMBEDDED_ENTITY_VALUE3, + LIST_VALUE, + LONG_VALUE, + DOUBLE_VALUE, + BOOLEAN_VALUE, + TIMESTAMP_VALUE, + BLOB_VALUE, + RAW_VALUE, + LAT_LNG_VALUE, + DATASTORE_EXCEPTION, + options, + otherOptions + }; + } + + @Override + protected Restorable[] restorableObjects() { + return null; + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/StringValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/StringValueTest.java new file mode 100644 index 000000000000..d97c5ef9ae57 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/StringValueTest.java @@ -0,0 +1,51 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.junit.Test; + +public class StringValueTest { + + private static final String CONTENT = "hello world"; + + @Test + public void testToBuilder() { + StringValue value = StringValue.of(CONTENT); + assertEquals(value, value.toBuilder().build()); + } + + @Test + public void testOf() { + StringValue value = StringValue.of(CONTENT); + assertEquals(CONTENT, value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + StringValue.Builder builder = StringValue.newBuilder(CONTENT); + StringValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertEquals(CONTENT, value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/StructuredQueryProtoPreparerTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/StructuredQueryProtoPreparerTest.java new file mode 100644 index 000000000000..52ec9226baa5 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/StructuredQueryProtoPreparerTest.java @@ -0,0 +1,118 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import static com.google.cloud.datastore.ProtoTestData.booleanValue; +import static com.google.cloud.datastore.ProtoTestData.projection; +import static com.google.cloud.datastore.ProtoTestData.propertyFilter; +import static com.google.cloud.datastore.ProtoTestData.propertyOrder; +import static com.google.cloud.datastore.ProtoTestData.propertyReference; +import static com.google.cloud.datastore.Query.newEntityQueryBuilder; +import static com.google.common.truth.Truth.assertThat; +import static com.google.datastore.v1.PropertyFilter.Operator.EQUAL; + +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.datastore.v1.KindExpression; +import com.google.datastore.v1.Query; +import com.google.protobuf.ByteString; +import com.google.protobuf.Int32Value; +import org.junit.Test; + +public class StructuredQueryProtoPreparerTest { + + private final StructuredQueryProtoPreparer protoPreparer = new StructuredQueryProtoPreparer(); + + @Test + public void testKind() { + Query queryProto = protoPreparer.prepare(newEntityQueryBuilder().setKind("kind").build()); + + assertThat(queryProto.getKind(0)) + .isEqualTo(KindExpression.newBuilder().setName("kind").build()); + } + + @Test + public void testStartCursor() { + byte[] bytes = {1, 2}; + Query queryProto = + protoPreparer.prepare( + newEntityQueryBuilder().setStartCursor(Cursor.copyFrom(bytes)).build()); + + assertThat(queryProto.getStartCursor()).isEqualTo(ByteString.copyFrom(bytes)); + } + + @Test + public void testEndCursor() { + byte[] bytes = {1, 2}; + Query queryProto = + protoPreparer.prepare(newEntityQueryBuilder().setEndCursor(Cursor.copyFrom(bytes)).build()); + + assertThat(queryProto.getEndCursor()).isEqualTo(ByteString.copyFrom(bytes)); + } + + @Test + public void testOffset() { + Query queryProto = protoPreparer.prepare(newEntityQueryBuilder().setOffset(5).build()); + + assertThat(queryProto.getOffset()).isEqualTo(5); + } + + @Test + public void testLimit() { + Query queryProto = protoPreparer.prepare(newEntityQueryBuilder().setLimit(5).build()); + + assertThat(queryProto.getLimit()).isEqualTo(Int32Value.of(5)); + } + + @Test + public void testFilter() { + Query queryProto = + protoPreparer.prepare( + newEntityQueryBuilder().setFilter(PropertyFilter.eq("done", true)).build()); + + assertThat(queryProto.getFilter()).isEqualTo(propertyFilter("done", EQUAL, booleanValue(true))); + } + + @Test + public void testOrderBy() { + Query queryProto = + protoPreparer.prepare( + newEntityQueryBuilder() + .setOrderBy(OrderBy.asc("dept-id"), OrderBy.asc("rank")) + .build()); + + assertThat(queryProto.getOrder(0)).isEqualTo(propertyOrder("dept-id")); + assertThat(queryProto.getOrder(1)).isEqualTo(propertyOrder("rank")); + } + + @Test + public void testDistinctOn() { + Query queryProto = + protoPreparer.prepare(newEntityQueryBuilder().setDistinctOn("dept-id", "rank").build()); + + assertThat(queryProto.getDistinctOn(0)).isEqualTo(propertyReference("dept-id")); + assertThat(queryProto.getDistinctOn(1)).isEqualTo(propertyReference("rank")); + } + + @Test + public void testProjections() { + Query queryProto = + protoPreparer.prepare(newEntityQueryBuilder().setProjection("dept-id", "rank").build()); + + assertThat(queryProto.getProjection(0)).isEqualTo(projection("dept-id")); + assertThat(queryProto.getProjection(1)).isEqualTo(projection("rank")); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/StructuredQueryTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/StructuredQueryTest.java new file mode 100644 index 000000000000..adfb6b8784aa --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/StructuredQueryTest.java @@ -0,0 +1,182 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.datastore.Query.ResultType; +import com.google.cloud.datastore.StructuredQuery.CompositeFilter; +import com.google.cloud.datastore.StructuredQuery.Filter; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.common.collect.ImmutableList; +import java.util.List; +import org.junit.Test; + +public class StructuredQueryTest { + + private static final String NAMESPACE = "ns"; + private static final String KIND = "k"; + private static final Cursor START_CURSOR = Cursor.copyFrom(new byte[] {1, 2}); + private static final Cursor END_CURSOR = Cursor.copyFrom(new byte[] {10}); + private static final int OFFSET = 42; + private static final Integer LIMIT = 43; + private static final Filter AND_FILTER = + CompositeFilter.and(PropertyFilter.gt("p1", 10), PropertyFilter.eq("a", "v")); + private static final Filter OR_FILTER = + CompositeFilter.or(PropertyFilter.gt("p1", 10), PropertyFilter.eq("a", "v")); + private static final OrderBy ORDER_BY_1 = OrderBy.asc("p2"); + private static final OrderBy ORDER_BY_2 = OrderBy.desc("p3"); + private static final List ORDER_BY = ImmutableList.of(ORDER_BY_1, ORDER_BY_2); + private static final String PROJECTION1 = "p4"; + private static final String PROJECTION2 = "p5"; + private static final List PROJECTION = ImmutableList.of(PROJECTION1, PROJECTION2); + private static final String DISTINCT_ON1 = "p6"; + private static final String DISTINCT_ON2 = "p7"; + private static final List DISTINCT_ON = ImmutableList.of(DISTINCT_ON1, DISTINCT_ON2); + private static final EntityQuery ENTITY_QUERY = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND) + .setStartCursor(START_CURSOR) + .setEndCursor(END_CURSOR) + .setOffset(OFFSET) + .setLimit(LIMIT) + .setFilter(AND_FILTER) + .setOrderBy(ORDER_BY_1, ORDER_BY_2) + .build(); + private static final KeyQuery KEY_QUERY = + Query.newKeyQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND) + .setStartCursor(START_CURSOR) + .setEndCursor(END_CURSOR) + .setOffset(OFFSET) + .setLimit(LIMIT) + .setFilter(OR_FILTER) + .setOrderBy(ORDER_BY_1, ORDER_BY_2) + .build(); + private static final ProjectionEntityQuery PROJECTION_QUERY = + Query.newProjectionEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND) + .setStartCursor(START_CURSOR) + .setEndCursor(END_CURSOR) + .setOffset(OFFSET) + .setLimit(LIMIT) + .setFilter(AND_FILTER) + .setOrderBy(ORDER_BY_1, ORDER_BY_2) + .setProjection(PROJECTION1, PROJECTION2) + .setDistinctOn(DISTINCT_ON1, DISTINCT_ON2) + .build(); + + @Test + public void testEntityQueryBuilder() { + compareBaseBuilderFields(ENTITY_QUERY); + assertTrue(ENTITY_QUERY.getProjection().isEmpty()); + assertTrue(ENTITY_QUERY.getDistinctOn().isEmpty()); + } + + @Test + public void testKeyQueryBuilder() { + assertEquals(NAMESPACE, KEY_QUERY.getNamespace()); + assertEquals(KIND, KEY_QUERY.getKind()); + assertEquals(START_CURSOR, KEY_QUERY.getStartCursor()); + assertEquals(END_CURSOR, KEY_QUERY.getEndCursor()); + assertEquals(OFFSET, KEY_QUERY.getOffset()); + assertEquals(LIMIT, KEY_QUERY.getLimit()); + assertEquals(OR_FILTER, KEY_QUERY.getFilter()); + assertEquals(ORDER_BY, KEY_QUERY.getOrderBy()); + assertEquals(ImmutableList.of(StructuredQuery.KEY_PROPERTY_NAME), KEY_QUERY.getProjection()); + assertTrue(KEY_QUERY.getDistinctOn().isEmpty()); + } + + @Test + public void testProjectionEntityQueryBuilder() { + compareBaseBuilderFields(PROJECTION_QUERY); + assertEquals(PROJECTION, PROJECTION_QUERY.getProjection()); + assertEquals(DISTINCT_ON, PROJECTION_QUERY.getDistinctOn()); + } + + private void compareBaseBuilderFields(StructuredQuery query) { + assertEquals(NAMESPACE, query.getNamespace()); + assertEquals(KIND, query.getKind()); + assertEquals(START_CURSOR, query.getStartCursor()); + assertEquals(END_CURSOR, query.getEndCursor()); + assertEquals(OFFSET, query.getOffset()); + assertEquals(LIMIT, query.getLimit()); + assertEquals(AND_FILTER, query.getFilter()); + assertEquals(ORDER_BY, query.getOrderBy()); + } + + @Test + public void mergeFrom() { + compareMergedQuery( + ENTITY_QUERY, new EntityQuery.Builder().mergeFrom(ENTITY_QUERY.toPb()).build()); + compareMergedQuery(KEY_QUERY, new KeyQuery.Builder().mergeFrom(KEY_QUERY.toPb()).build()); + compareMergedQuery( + PROJECTION_QUERY, + new ProjectionEntityQuery.Builder().mergeFrom(PROJECTION_QUERY.toPb()).build()); + } + + private void compareMergedQuery(StructuredQuery expected, StructuredQuery actual) { + assertEquals(expected.getKind(), actual.getKind()); + assertEquals(expected.getStartCursor(), actual.getStartCursor()); + assertEquals(expected.getEndCursor(), actual.getEndCursor()); + assertEquals(expected.getOffset(), actual.getOffset()); + assertEquals(expected.getLimit(), actual.getLimit()); + assertEquals(expected.getFilter(), actual.getFilter()); + assertEquals(expected.getOrderBy(), actual.getOrderBy()); + assertEquals(expected.getProjection(), actual.getProjection()); + assertEquals(expected.getDistinctOn(), actual.getDistinctOn()); + } + + @Test + public void testToAndFromPb() { + assertEquals( + ENTITY_QUERY, + StructuredQuery.fromPb( + ResultType.ENTITY, ENTITY_QUERY.getNamespace(), ENTITY_QUERY.toPb())); + assertEquals( + KEY_QUERY, + StructuredQuery.fromPb(ResultType.KEY, KEY_QUERY.getNamespace(), KEY_QUERY.toPb())); + assertEquals( + PROJECTION_QUERY, + StructuredQuery.fromPb( + ResultType.PROJECTION_ENTITY, + PROJECTION_QUERY.getNamespace(), + PROJECTION_QUERY.toPb())); + } + + @Test + public void testToBuilder() { + List> queries = + ImmutableList.>of(ENTITY_QUERY, KEY_QUERY, PROJECTION_QUERY); + for (StructuredQuery query : queries) { + assertEquals(query, query.toBuilder().build()); + } + } + + @Test + public void testKeyOnly() { + assertTrue(KEY_QUERY.isKeyOnly()); + assertFalse(ENTITY_QUERY.isKeyOnly()); + assertFalse(PROJECTION_QUERY.isKeyOnly()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/TestUtils.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/TestUtils.java new file mode 100644 index 000000000000..c90d6ce22a9d --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/TestUtils.java @@ -0,0 +1,39 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore; + +import java.util.function.Predicate; +import org.easymock.EasyMock; +import org.easymock.IArgumentMatcher; + +public class TestUtils { + + public static T matches(Predicate predicate) { + EasyMock.reportMatcher( + new IArgumentMatcher() { + @Override + public boolean matches(Object argument) { + return predicate.test(((T) argument)); + } + + @Override + public void appendTo(StringBuffer buffer) { + buffer.append("matches(\"").append(predicate).append("\")"); + } + }); + return null; + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/TimestampValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/TimestampValueTest.java new file mode 100644 index 000000000000..ce5b9f0ac44f --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/TimestampValueTest.java @@ -0,0 +1,52 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.Timestamp; +import org.junit.Test; + +public class TimestampValueTest { + + private static final Timestamp CONTENT = Timestamp.now(); + + @Test + public void testToBuilder() { + TimestampValue value = TimestampValue.of(CONTENT); + assertEquals(value, value.toBuilder().build()); + } + + @Test + public void testOf() { + TimestampValue value = TimestampValue.of(CONTENT); + assertEquals(CONTENT, value.get()); + assertFalse(value.excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testBuilder() { + TimestampValue.Builder builder = TimestampValue.newBuilder(CONTENT); + TimestampValue value = builder.setMeaning(1).setExcludeFromIndexes(true).build(); + assertEquals(CONTENT, value.get()); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/TransactionExceptionHandlerTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/TransactionExceptionHandlerTest.java new file mode 100644 index 000000000000..e08ede692e7d --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/TransactionExceptionHandlerTest.java @@ -0,0 +1,67 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import static junit.framework.TestCase.assertFalse; +import static junit.framework.TestCase.assertTrue; + +import com.google.cloud.BaseServiceException; +import com.google.cloud.ExceptionHandler; +import org.junit.Test; + +/** Tests for {@link TransactionExceptionHandler}. */ +public class TransactionExceptionHandlerTest { + + @Test + public void testShouldTry() { + ExceptionHandler handler = + ExceptionHandler.newBuilder() + .abortOn(RuntimeException.class) + .addInterceptors(DatastoreImpl.EXCEPTION_HANDLER_INTERCEPTOR) + .build(); + ExceptionHandler transactionHandler = TransactionExceptionHandler.build(); + + assertFalse(handler.shouldRetry(new DatastoreException(10, "", "ABORTED", false, null), null)); + assertFalse(handler.shouldRetry(new DatastoreException(10, "", "", false, null), null)); + assertFalse(handler.shouldRetry(new DatastoreException(0, "", "", false, null), null)); + + assertTrue( + transactionHandler.shouldRetry( + new DatastoreException(10, "", "ABORTED", false, null), null)); + assertTrue( + transactionHandler.shouldRetry(new DatastoreException(10, "", "", false, null), null)); + assertFalse( + transactionHandler.shouldRetry(new DatastoreException(0, "", "", false, null), null)); + + DatastoreException nestedDatastoreException = + new DatastoreException( + BaseServiceException.UNKNOWN_CODE, + "", + null, + new DatastoreException(10, "", "ABORTED", false, null)); + + assertTrue(transactionHandler.shouldRetry(nestedDatastoreException, null)); + assertFalse(handler.shouldRetry(nestedDatastoreException, null)); + + DatastoreException nestedUserException = + new DatastoreException( + BaseServiceException.UNKNOWN_CODE, "", null, new RuntimeException("")); + + assertFalse(transactionHandler.shouldRetry(nestedUserException, null)); + assertFalse(handler.shouldRetry(nestedDatastoreException, null)); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ValueTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ValueTest.java new file mode 100644 index 000000000000..72e193a7dc55 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/ValueTest.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 + * + * 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.datastore; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.Timestamp; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.primitives.Primitives; +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.Map; +import java.util.Set; +import org.junit.Before; +import org.junit.Test; + +public class ValueTest { + + private static final Key KEY = Key.newBuilder("ds", "kind", 1).build(); + private static final Blob BLOB = Blob.copyFrom(new byte[] {}); + private static final Timestamp TIMESTAMP = Timestamp.now(); + private static final Entity ENTITY = Entity.newBuilder(KEY).set("FOO", "BAR").build(); + private static final NullValue NULL_VALUE = NullValue.of(); + private static final StringValue STRING_VALUE = StringValue.of("hello"); + private static final RawValue RAW_VALUE = RawValue.of(STRING_VALUE.toPb()); + private static final LatLngValue LAT_LNG_VALUE = + LatLngValue.of(new LatLng(37.422035, -122.084124)); + private static final ImmutableMap TYPES = + ImmutableMap.builder() + .put(ValueType.NULL, new Object[] {NullValue.class, NULL_VALUE.get()}) + .put(ValueType.KEY, new Object[] {KeyValue.class, KEY}) + .put(ValueType.BLOB, new Object[] {BlobValue.class, BLOB}) + .put(ValueType.BOOLEAN, new Object[] {BooleanValue.class, Boolean.TRUE}) + .put(ValueType.TIMESTAMP, new Object[] {TimestampValue.class, TIMESTAMP}) + .put(ValueType.DOUBLE, new Object[] {DoubleValue.class, 1.25D}) + .put(ValueType.ENTITY, new Object[] {EntityValue.class, ENTITY}) + .put( + ValueType.LIST, + new Object[] {ListValue.class, ImmutableList.of(NULL_VALUE, STRING_VALUE, RAW_VALUE)}) + .put(ValueType.LONG, new Object[] {LongValue.class, 123L}) + .put(ValueType.RAW_VALUE, new Object[] {RawValue.class, RAW_VALUE.get()}) + .put(ValueType.LAT_LNG, new Object[] {LatLngValue.class, LAT_LNG_VALUE.get()}) + .put(ValueType.STRING, new Object[] {StringValue.class, STRING_VALUE.get()}) + .buildOrThrow(); + + private ImmutableMap> typeToValue; + + @SuppressWarnings("rawtypes") + private class TestBuilder extends Value.BaseBuilder, TestBuilder> { + TestBuilder() { + super(ValueType.LIST); + } + + @SuppressWarnings({"unchecked"}) + @Override + public Value build() { + return new Value(this) { + + @Override + public TestBuilder toBuilder() { + return new TestBuilder().mergeFrom(this); + } + }; + } + } + + @Before + public void setUp() throws Exception { + ImmutableMap.Builder> builder = ImmutableMap.builder(); + for (ValueType valueType : ValueType.values()) { + Object[] values = TYPES.get(valueType); + @SuppressWarnings("unchecked") + Class> valueClass = (Class>) values[0]; + Object value = values[1]; + if (value == null) { + Method method = valueClass.getMethod("of"); + builder.put(valueType, (Value) method.invoke(null)); + } else { + boolean found = false; + for (Method method : valueClass.getDeclaredMethods()) { + if (method.getName().equals("of")) { + Class paramType = method.getParameterTypes()[0]; + if (paramType.isPrimitive()) { + paramType = Primitives.wrap(paramType); + } + if (paramType.isAssignableFrom(value.getClass())) { + builder.put(valueType, (Value) method.invoke(null, value)); + found = true; + break; + } + } + } + assertTrue("Could not find an of method for " + valueClass, found); + } + } + typeToValue = builder.buildOrThrow(); + } + + @Test + public void testType() { + for (Map.Entry> entry : typeToValue.entrySet()) { + assertEquals(entry.getKey(), entry.getValue().getType()); + } + } + + @Test + public void testExcludeFromIndexes() { + for (Map.Entry> entry : typeToValue.entrySet()) { + assertFalse(entry.getValue().excludeFromIndexes()); + } + TestBuilder builder = new TestBuilder(); + assertFalse(builder.build().excludeFromIndexes()); + assertTrue(builder.setExcludeFromIndexes(true).build().excludeFromIndexes()); + assertFalse(builder.setExcludeFromIndexes(false).build().excludeFromIndexes()); + } + + @SuppressWarnings("deprecation") + @Test + public void testMeaning() { + TestBuilder builder = new TestBuilder(); + assertEquals(10, builder.setMeaning(10).build().getMeaning()); + } + + @Test + public void testGet() { + for (Map.Entry> entry : typeToValue.entrySet()) { + ValueType valueType = entry.getKey(); + Value value = entry.getValue(); + assertEquals(TYPES.get(valueType)[1], value.get()); + } + + TestBuilder builder = new TestBuilder(); + Set value = Collections.singleton("bla"); + assertEquals(value, builder.set(value).build().get()); + } + + @SuppressWarnings({"unchecked", "deprecation"}) + @Test + public void testToBuilder() { + Set content = Collections.singleton("bla"); + @SuppressWarnings("rawtypes") + ValueBuilder builder = new TestBuilder(); + builder.setMeaning(1).set(content).setExcludeFromIndexes(true); + Value value = builder.build(); + builder = value.toBuilder(); + assertEquals(1, value.getMeaning()); + assertTrue(value.excludeFromIndexes()); + assertEquals(ValueType.LIST, value.getType()); + assertEquals(content, value.get()); + assertEquals(value, builder.build()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClientHttpJsonTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClientHttpJsonTest.java new file mode 100644 index 000000000000..61105dee8a7a --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClientHttpJsonTest.java @@ -0,0 +1,434 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.admin.v1; + +import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.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.datastore.admin.v1.stub.HttpJsonDatastoreAdminStub; +import com.google.common.collect.Lists; +import com.google.datastore.admin.v1.CreateIndexRequest; +import com.google.datastore.admin.v1.DeleteIndexRequest; +import com.google.datastore.admin.v1.EntityFilter; +import com.google.datastore.admin.v1.ExportEntitiesResponse; +import com.google.datastore.admin.v1.GetIndexRequest; +import com.google.datastore.admin.v1.Index; +import com.google.datastore.admin.v1.ListIndexesRequest; +import com.google.datastore.admin.v1.ListIndexesResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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 DatastoreAdminClientHttpJsonTest { + private static MockHttpService mockService; + private static DatastoreAdminClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDatastoreAdminStub.getMethodDescriptors(), + DatastoreAdminSettings.getDefaultEndpoint()); + DatastoreAdminSettings settings = + DatastoreAdminSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DatastoreAdminSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DatastoreAdminClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void exportEntitiesTest() throws Exception { + ExportEntitiesResponse expectedResponse = + ExportEntitiesResponse.newBuilder().setOutputUrl("outputUrl-2119300946").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String projectId = "projectId-1530"; + Map labels = new HashMap<>(); + EntityFilter entityFilter = EntityFilter.newBuilder().build(); + String outputUrlPrefix = "outputUrlPrefix-1132598048"; + + ExportEntitiesResponse actualResponse = + client.exportEntitiesAsync(projectId, labels, entityFilter, outputUrlPrefix).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 exportEntitiesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String projectId = "projectId-1530"; + Map labels = new HashMap<>(); + EntityFilter entityFilter = EntityFilter.newBuilder().build(); + String outputUrlPrefix = "outputUrlPrefix-1132598048"; + client.exportEntitiesAsync(projectId, labels, entityFilter, outputUrlPrefix).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void importEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String projectId = "projectId-1530"; + Map labels = new HashMap<>(); + String inputUrl = "inputUrl470706501"; + EntityFilter entityFilter = EntityFilter.newBuilder().build(); + + client.importEntitiesAsync(projectId, labels, inputUrl, entityFilter).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 importEntitiesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String projectId = "projectId-1530"; + Map labels = new HashMap<>(); + String inputUrl = "inputUrl470706501"; + EntityFilter entityFilter = EntityFilter.newBuilder().build(); + client.importEntitiesAsync(projectId, labels, inputUrl, entityFilter).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setProjectId("projectId-894832108") + .setIndexId("indexId1943291277") + .setKind("kind3292052") + .addAllProperties(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + CreateIndexRequest request = + CreateIndexRequest.newBuilder() + .setProjectId("projectId-1530") + .setIndex(Index.newBuilder().build()) + .build(); + + Index actualResponse = client.createIndexAsync(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 createIndexExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateIndexRequest request = + CreateIndexRequest.newBuilder() + .setProjectId("projectId-1530") + .setIndex(Index.newBuilder().build()) + .build(); + client.createIndexAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setProjectId("projectId-894832108") + .setIndexId("indexId1943291277") + .setKind("kind3292052") + .addAllProperties(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DeleteIndexRequest request = + DeleteIndexRequest.newBuilder() + .setProjectId("projectId-1530") + .setIndexId("indexId-7485") + .build(); + + Index actualResponse = client.deleteIndexAsync(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 deleteIndexExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteIndexRequest request = + DeleteIndexRequest.newBuilder() + .setProjectId("projectId-1530") + .setIndexId("indexId-7485") + .build(); + client.deleteIndexAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setProjectId("projectId-894832108") + .setIndexId("indexId1943291277") + .setKind("kind3292052") + .addAllProperties(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + GetIndexRequest request = + GetIndexRequest.newBuilder() + .setProjectId("projectId-1530") + .setIndexId("indexId-7485") + .build(); + + Index actualResponse = client.getIndex(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 getIndexExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetIndexRequest request = + GetIndexRequest.newBuilder() + .setProjectId("projectId-1530") + .setIndexId("indexId-7485") + .build(); + client.getIndex(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIndexesTest() throws Exception { + Index responsesElement = Index.newBuilder().build(); + ListIndexesResponse expectedResponse = + ListIndexesResponse.newBuilder() + .setNextPageToken("") + .addAllIndexes(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListIndexesRequest request = + ListIndexesRequest.newBuilder() + .setProjectId("projectId-1530") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListIndexesPagedResponse pagedListResponse = client.listIndexes(request); + + 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 { + ListIndexesRequest request = + ListIndexesRequest.newBuilder() + .setProjectId("projectId-1530") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listIndexes(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClientTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClientTest.java new file mode 100644 index 000000000000..a4c32d7c7a5b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/DatastoreAdminClientTest.java @@ -0,0 +1,428 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.admin.v1; + +import static com.google.cloud.datastore.admin.v1.DatastoreAdminClient.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.datastore.admin.v1.CreateIndexRequest; +import com.google.datastore.admin.v1.DeleteIndexRequest; +import com.google.datastore.admin.v1.EntityFilter; +import com.google.datastore.admin.v1.ExportEntitiesRequest; +import com.google.datastore.admin.v1.ExportEntitiesResponse; +import com.google.datastore.admin.v1.GetIndexRequest; +import com.google.datastore.admin.v1.ImportEntitiesRequest; +import com.google.datastore.admin.v1.Index; +import com.google.datastore.admin.v1.ListIndexesRequest; +import com.google.datastore.admin.v1.ListIndexesResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +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.Map; +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 DatastoreAdminClientTest { + private static MockDatastoreAdmin mockDatastoreAdmin; + private static MockServiceHelper mockServiceHelper; + private LocalChannelProvider channelProvider; + private DatastoreAdminClient client; + + @BeforeClass + public static void startStaticServer() { + mockDatastoreAdmin = new MockDatastoreAdmin(); + mockServiceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), Arrays.asList(mockDatastoreAdmin)); + mockServiceHelper.start(); + } + + @AfterClass + public static void stopServer() { + mockServiceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); + DatastoreAdminSettings settings = + DatastoreAdminSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DatastoreAdminClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + public void exportEntitiesTest() throws Exception { + ExportEntitiesResponse expectedResponse = + ExportEntitiesResponse.newBuilder().setOutputUrl("outputUrl-2119300946").build(); + Operation resultOperation = + Operation.newBuilder() + .setName("exportEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDatastoreAdmin.addResponse(resultOperation); + + String projectId = "projectId-894832108"; + Map labels = new HashMap<>(); + EntityFilter entityFilter = EntityFilter.newBuilder().build(); + String outputUrlPrefix = "outputUrlPrefix-1132598048"; + + ExportEntitiesResponse actualResponse = + client.exportEntitiesAsync(projectId, labels, entityFilter, outputUrlPrefix).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ExportEntitiesRequest actualRequest = ((ExportEntitiesRequest) actualRequests.get(0)); + + Assert.assertEquals(projectId, actualRequest.getProjectId()); + Assert.assertEquals(labels, actualRequest.getLabelsMap()); + Assert.assertEquals(entityFilter, actualRequest.getEntityFilter()); + Assert.assertEquals(outputUrlPrefix, actualRequest.getOutputUrlPrefix()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void exportEntitiesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastoreAdmin.addException(exception); + + try { + String projectId = "projectId-894832108"; + Map labels = new HashMap<>(); + EntityFilter entityFilter = EntityFilter.newBuilder().build(); + String outputUrlPrefix = "outputUrlPrefix-1132598048"; + client.exportEntitiesAsync(projectId, labels, entityFilter, outputUrlPrefix).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 importEntitiesTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("importEntitiesTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDatastoreAdmin.addResponse(resultOperation); + + String projectId = "projectId-894832108"; + Map labels = new HashMap<>(); + String inputUrl = "inputUrl470706501"; + EntityFilter entityFilter = EntityFilter.newBuilder().build(); + + client.importEntitiesAsync(projectId, labels, inputUrl, entityFilter).get(); + + List actualRequests = mockDatastoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ImportEntitiesRequest actualRequest = ((ImportEntitiesRequest) actualRequests.get(0)); + + Assert.assertEquals(projectId, actualRequest.getProjectId()); + Assert.assertEquals(labels, actualRequest.getLabelsMap()); + Assert.assertEquals(inputUrl, actualRequest.getInputUrl()); + Assert.assertEquals(entityFilter, actualRequest.getEntityFilter()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void importEntitiesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastoreAdmin.addException(exception); + + try { + String projectId = "projectId-894832108"; + Map labels = new HashMap<>(); + String inputUrl = "inputUrl470706501"; + EntityFilter entityFilter = EntityFilter.newBuilder().build(); + client.importEntitiesAsync(projectId, labels, inputUrl, entityFilter).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 createIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setProjectId("projectId-894832108") + .setIndexId("indexId1943291277") + .setKind("kind3292052") + .addAllProperties(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDatastoreAdmin.addResponse(resultOperation); + + CreateIndexRequest request = + CreateIndexRequest.newBuilder() + .setProjectId("projectId-894832108") + .setIndex(Index.newBuilder().build()) + .build(); + + Index actualResponse = client.createIndexAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateIndexRequest actualRequest = ((CreateIndexRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId()); + Assert.assertEquals(request.getIndex(), 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); + mockDatastoreAdmin.addException(exception); + + try { + CreateIndexRequest request = + CreateIndexRequest.newBuilder() + .setProjectId("projectId-894832108") + .setIndex(Index.newBuilder().build()) + .build(); + client.createIndexAsync(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 deleteIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setProjectId("projectId-894832108") + .setIndexId("indexId1943291277") + .setKind("kind3292052") + .addAllProperties(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteIndexTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockDatastoreAdmin.addResponse(resultOperation); + + DeleteIndexRequest request = + DeleteIndexRequest.newBuilder() + .setProjectId("projectId-894832108") + .setIndexId("indexId1943291277") + .build(); + + Index actualResponse = client.deleteIndexAsync(request).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteIndexRequest actualRequest = ((DeleteIndexRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId()); + Assert.assertEquals(request.getIndexId(), actualRequest.getIndexId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteIndexExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastoreAdmin.addException(exception); + + try { + DeleteIndexRequest request = + DeleteIndexRequest.newBuilder() + .setProjectId("projectId-894832108") + .setIndexId("indexId1943291277") + .build(); + client.deleteIndexAsync(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 getIndexTest() throws Exception { + Index expectedResponse = + Index.newBuilder() + .setProjectId("projectId-894832108") + .setIndexId("indexId1943291277") + .setKind("kind3292052") + .addAllProperties(new ArrayList()) + .build(); + mockDatastoreAdmin.addResponse(expectedResponse); + + GetIndexRequest request = + GetIndexRequest.newBuilder() + .setProjectId("projectId-894832108") + .setIndexId("indexId1943291277") + .build(); + + Index actualResponse = client.getIndex(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetIndexRequest actualRequest = ((GetIndexRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId()); + Assert.assertEquals(request.getIndexId(), actualRequest.getIndexId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getIndexExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastoreAdmin.addException(exception); + + try { + GetIndexRequest request = + GetIndexRequest.newBuilder() + .setProjectId("projectId-894832108") + .setIndexId("indexId1943291277") + .build(); + client.getIndex(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listIndexesTest() throws Exception { + Index responsesElement = Index.newBuilder().build(); + ListIndexesResponse expectedResponse = + ListIndexesResponse.newBuilder() + .setNextPageToken("") + .addAllIndexes(Arrays.asList(responsesElement)) + .build(); + mockDatastoreAdmin.addResponse(expectedResponse); + + ListIndexesRequest request = + ListIndexesRequest.newBuilder() + .setProjectId("projectId-894832108") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListIndexesPagedResponse pagedListResponse = client.listIndexes(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getIndexesList().get(0), resources.get(0)); + + List actualRequests = mockDatastoreAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListIndexesRequest actualRequest = ((ListIndexesRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId()); + Assert.assertEquals(request.getFilter(), actualRequest.getFilter()); + Assert.assertEquals(request.getPageSize(), actualRequest.getPageSize()); + Assert.assertEquals(request.getPageToken(), actualRequest.getPageToken()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listIndexesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastoreAdmin.addException(exception); + + try { + ListIndexesRequest request = + ListIndexesRequest.newBuilder() + .setProjectId("projectId-894832108") + .setFilter("filter-1274492040") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listIndexes(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdmin.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdmin.java new file mode 100644 index 000000000000..0e0d17e4f5c0 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdmin.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.datastore.admin.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 MockDatastoreAdmin implements MockGrpcService { + private final MockDatastoreAdminImpl serviceImpl; + + public MockDatastoreAdmin() { + serviceImpl = new MockDatastoreAdminImpl(); + } + + @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-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdminImpl.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdminImpl.java new file mode 100644 index 000000000000..d9be1ba4d056 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/admin/v1/MockDatastoreAdminImpl.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.cloud.datastore.admin.v1; + +import com.google.api.core.BetaApi; +import com.google.datastore.admin.v1.CreateIndexRequest; +import com.google.datastore.admin.v1.DatastoreAdminGrpc.DatastoreAdminImplBase; +import com.google.datastore.admin.v1.DeleteIndexRequest; +import com.google.datastore.admin.v1.ExportEntitiesRequest; +import com.google.datastore.admin.v1.GetIndexRequest; +import com.google.datastore.admin.v1.ImportEntitiesRequest; +import com.google.datastore.admin.v1.Index; +import com.google.datastore.admin.v1.ListIndexesRequest; +import com.google.datastore.admin.v1.ListIndexesResponse; +import com.google.longrunning.Operation; +import com.google.protobuf.AbstractMessage; +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 MockDatastoreAdminImpl extends DatastoreAdminImplBase { + private List requests; + private Queue responses; + + public MockDatastoreAdminImpl() { + 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 exportEntities( + ExportEntitiesRequest 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 ExportEntities, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void importEntities( + ImportEntitiesRequest 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 ImportEntities, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.class.getName(), + Exception.class.getName()))); + } + } + + @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 deleteIndex(DeleteIndexRequest 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 DeleteIndex, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Operation.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 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()))); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/aggregation/AvgAggregationTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/aggregation/AvgAggregationTest.java new file mode 100644 index 000000000000..f00652137fc7 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/aggregation/AvgAggregationTest.java @@ -0,0 +1,88 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.aggregation; + +import static com.google.cloud.datastore.aggregation.Aggregation.avg; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertThrows; + +import com.google.datastore.v1.AggregationQuery; +import org.junit.Test; + +public class AvgAggregationTest { + + @Test + public void shouldThrowExceptionWhenPropertyReferenceIsNull() { + assertThrows(IllegalArgumentException.class, () -> avg(null).build()); + } + + @Test + public void testAvgAggregationWithDefaultValues() { + AggregationQuery.Aggregation avgAggregation = avg("marks").build().toPb(); + + assertThat(avgAggregation.getAvg().getProperty().getName()).isEqualTo("marks"); + assertThat(avgAggregation.getAlias()).isEqualTo(""); + } + + @Test + public void testCountAggregationWithAlias() { + AggregationQuery.Aggregation avgAggregation = avg("marks").as("total_marks").build().toPb(); + + assertThat(avgAggregation.getAvg().getProperty().getName()).isEqualTo("marks"); + assertThat(avgAggregation.getAlias()).isEqualTo("total_marks"); + } + + @Test + public void testEqualsWithAliasVariations() { + AvgAggregation.Builder aggregationWithAlias1 = avg("marks").as("total"); + AvgAggregation.Builder aggregationWithAlias2 = avg("marks").as("total"); + AvgAggregation.Builder aggregationWithoutAlias1 = avg("marks"); + AvgAggregation.Builder aggregationWithoutAlias2 = avg("marks"); + + // same aliases + assertThat(aggregationWithAlias1.build()).isEqualTo(aggregationWithAlias2.build()); + assertThat(aggregationWithAlias2.build()).isEqualTo(aggregationWithAlias1.build()); + + // with and without aliases + assertThat(aggregationWithAlias1.build()).isNotEqualTo(aggregationWithoutAlias1.build()); + assertThat(aggregationWithoutAlias1.build()).isNotEqualTo(aggregationWithAlias1.build()); + + // no aliases + assertThat(aggregationWithoutAlias1.build()).isEqualTo(aggregationWithoutAlias2.build()); + assertThat(aggregationWithoutAlias2.build()).isEqualTo(aggregationWithoutAlias1.build()); + + // different aliases + assertThat(aggregationWithAlias1.as("new-alias").build()) + .isNotEqualTo(aggregationWithAlias2.build()); + assertThat(aggregationWithAlias2.build()) + .isNotEqualTo(aggregationWithAlias1.as("new-alias").build()); + } + + @Test + public void testEqualsWithPropertyReferenceVariations() { + AvgAggregation totalMarks1 = avg("marks").build(); + AvgAggregation totalMarks2 = avg("marks").build(); + + AvgAggregation totalQuantities = avg("quantity").build(); + + assertThat(totalMarks1).isEqualTo(totalMarks2); + assertThat(totalMarks2).isEqualTo(totalMarks1); + + assertThat(totalMarks1).isNotEqualTo(totalQuantities); + assertThat(totalQuantities).isNotEqualTo(totalMarks1); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/aggregation/CountAggregationTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/aggregation/CountAggregationTest.java new file mode 100644 index 000000000000..9fbe94a860db --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/aggregation/CountAggregationTest.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. + */ + +package com.google.cloud.datastore.aggregation; + +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.common.truth.Truth.assertThat; + +import com.google.datastore.v1.AggregationQuery; +import org.junit.Test; + +public class CountAggregationTest { + + @Test + public void testCountAggregationWithDefaultValues() { + AggregationQuery.Aggregation countAggregationPb = count().build().toPb(); + + assertThat(countAggregationPb.getCount().getUpTo().getValue()).isEqualTo(0L); + assertThat(countAggregationPb.getAlias()).isEqualTo(""); + } + + @Test + public void testCountAggregationWithAlias() { + AggregationQuery.Aggregation countAggregationPb = count().as("column_1").build().toPb(); + + assertThat(countAggregationPb.getCount().getUpTo().getValue()).isEqualTo(0L); + assertThat(countAggregationPb.getAlias()).isEqualTo("column_1"); + } + + @Test + public void testEquals() { + CountAggregation.Builder aggregationWithAlias1 = count().as("total"); + CountAggregation.Builder aggregationWithAlias2 = count().as("total"); + CountAggregation.Builder aggregationWithoutAlias1 = count(); + CountAggregation.Builder aggregationWithoutAlias2 = count(); + + // same aliases + assertThat(aggregationWithAlias1.build()).isEqualTo(aggregationWithAlias2.build()); + assertThat(aggregationWithAlias2.build()).isEqualTo(aggregationWithAlias1.build()); + + // with and without aliases + assertThat(aggregationWithAlias1.build()).isNotEqualTo(aggregationWithoutAlias1.build()); + assertThat(aggregationWithoutAlias1.build()).isNotEqualTo(aggregationWithAlias1.build()); + + // no aliases + assertThat(aggregationWithoutAlias1.build()).isEqualTo(aggregationWithoutAlias2.build()); + assertThat(aggregationWithoutAlias2.build()).isEqualTo(aggregationWithoutAlias1.build()); + + // different aliases + assertThat(aggregationWithAlias1.as("new-alias").build()) + .isNotEqualTo(aggregationWithAlias2.build()); + assertThat(aggregationWithAlias2.build()) + .isNotEqualTo(aggregationWithAlias1.as("new-alias").build()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/aggregation/SumAggregationTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/aggregation/SumAggregationTest.java new file mode 100644 index 000000000000..53f550bdeb74 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/aggregation/SumAggregationTest.java @@ -0,0 +1,88 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.aggregation; + +import static com.google.cloud.datastore.aggregation.Aggregation.sum; +import static com.google.common.truth.Truth.assertThat; +import static org.junit.Assert.assertThrows; + +import com.google.datastore.v1.AggregationQuery; +import org.junit.Test; + +public class SumAggregationTest { + + @Test + public void shouldThrowExceptionWhenPropertyReferenceIsNull() { + assertThrows(IllegalArgumentException.class, () -> sum(null).build()); + } + + @Test + public void testSumAggregationWithDefaultValues() { + AggregationQuery.Aggregation sumAggregation = sum("marks").build().toPb(); + + assertThat(sumAggregation.getSum().getProperty().getName()).isEqualTo("marks"); + assertThat(sumAggregation.getAlias()).isEqualTo(""); + } + + @Test + public void testCountAggregationWithAlias() { + AggregationQuery.Aggregation sumAggregation = sum("marks").as("total_marks").build().toPb(); + + assertThat(sumAggregation.getSum().getProperty().getName()).isEqualTo("marks"); + assertThat(sumAggregation.getAlias()).isEqualTo("total_marks"); + } + + @Test + public void testEqualsWithAliasVariations() { + SumAggregation.Builder aggregationWithAlias1 = sum("marks").as("total"); + SumAggregation.Builder aggregationWithAlias2 = sum("marks").as("total"); + SumAggregation.Builder aggregationWithoutAlias1 = sum("marks"); + SumAggregation.Builder aggregationWithoutAlias2 = sum("marks"); + + // same aliases + assertThat(aggregationWithAlias1.build()).isEqualTo(aggregationWithAlias2.build()); + assertThat(aggregationWithAlias2.build()).isEqualTo(aggregationWithAlias1.build()); + + // with and without aliases + assertThat(aggregationWithAlias1.build()).isNotEqualTo(aggregationWithoutAlias1.build()); + assertThat(aggregationWithoutAlias1.build()).isNotEqualTo(aggregationWithAlias1.build()); + + // no aliases + assertThat(aggregationWithoutAlias1.build()).isEqualTo(aggregationWithoutAlias2.build()); + assertThat(aggregationWithoutAlias2.build()).isEqualTo(aggregationWithoutAlias1.build()); + + // different aliases + assertThat(aggregationWithAlias1.as("new-alias").build()) + .isNotEqualTo(aggregationWithAlias2.build()); + assertThat(aggregationWithAlias2.build()) + .isNotEqualTo(aggregationWithAlias1.as("new-alias").build()); + } + + @Test + public void testEqualsWithPropertyReferenceVariations() { + SumAggregation totalMarks1 = sum("marks").build(); + SumAggregation totalMarks2 = sum("marks").build(); + + SumAggregation totalQuantities = sum("quantity").build(); + + assertThat(totalMarks1).isEqualTo(totalMarks2); + assertThat(totalMarks2).isEqualTo(totalMarks1); + + assertThat(totalMarks1).isNotEqualTo(totalQuantities); + assertThat(totalQuantities).isNotEqualTo(totalMarks1); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/execution/AggregationQueryExecutorTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/execution/AggregationQueryExecutorTest.java new file mode 100644 index 000000000000..2ab8b790aa4a --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/execution/AggregationQueryExecutorTest.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. + */ +package com.google.cloud.datastore.execution; + +import static com.google.cloud.datastore.ProtoTestData.intValue; +import static com.google.cloud.datastore.ReadOption.eventualConsistency; +import static com.google.cloud.datastore.StructuredQuery.PropertyFilter.eq; +import static com.google.cloud.datastore.TestUtils.matches; +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.common.truth.Truth.assertThat; +import static com.google.datastore.v1.ReadOptions.ReadConsistency.EVENTUAL; +import static java.util.Arrays.asList; +import static org.easymock.EasyMock.anyObject; +import static org.easymock.EasyMock.expect; +import static org.easymock.EasyMock.replay; +import static org.easymock.EasyMock.verify; + +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.LongValue; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.spi.v1.DatastoreRpc; +import com.google.common.collect.ImmutableMap; +import com.google.datastore.v1.AggregationResultBatch; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.Value; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Predicate; +import org.easymock.EasyMock; +import org.junit.Before; +import org.junit.Test; + +public class AggregationQueryExecutorTest { + + private static final String KIND = "Task"; + private static final String NAMESPACE = "ns"; + + private DatastoreRpc mockRpc; + private AggregationQueryExecutor queryExecutor; + private DatastoreOptions datastoreOptions; + + @Before + public void setUp() throws Exception { + mockRpc = EasyMock.createStrictMock(DatastoreRpc.class); + datastoreOptions = + DatastoreOptions.newBuilder().setProjectId("project-id").setNamespace(NAMESPACE).build(); + queryExecutor = new AggregationQueryExecutor(mockRpc, datastoreOptions); + } + + @Test + public void shouldExecuteAggregationQuery() { + EntityQuery nestedQuery = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND) + .setFilter(eq("done", true)) + .build(); + + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregation(count().as("total")) + .over(nestedQuery) + .build(); + + RunAggregationQueryResponse runAggregationQueryResponse = placeholderAggregationQueryResponse(); + expect(mockRpc.runAggregationQuery(anyObject(RunAggregationQueryRequest.class))) + .andReturn(runAggregationQueryResponse); + + replay(mockRpc); + + AggregationResults aggregationResults = queryExecutor.execute(aggregationQuery, null); + + verify(mockRpc); + assertThat(aggregationResults) + .isEqualTo( + new AggregationResults( + asList( + new AggregationResult( + ImmutableMap.of( + "count", LongValue.of(209), "property_2", LongValue.of(100))), + new AggregationResult( + ImmutableMap.of( + "count", LongValue.of(509), "property_2", LongValue.of(100)))), + Timestamp.fromProto(runAggregationQueryResponse.getBatch().getReadTime()), + null)); + } + + @Test + public void shouldExecuteAggregationQueryWithReadOptions() { + EntityQuery nestedQuery = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND) + .setFilter(eq("done", true)) + .build(); + + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregation(count().as("total")) + .over(nestedQuery) + .build(); + + RunAggregationQueryResponse runAggregationQueryResponse = placeholderAggregationQueryResponse(); + expect(mockRpc.runAggregationQuery(matches(runAggregationRequestWithEventualConsistency()))) + .andReturn(runAggregationQueryResponse); + + replay(mockRpc); + + AggregationResults aggregationResults = + queryExecutor.execute(aggregationQuery, null, eventualConsistency()); + + verify(mockRpc); + assertThat(aggregationResults) + .isEqualTo( + new AggregationResults( + asList( + new AggregationResult( + ImmutableMap.of( + "count", LongValue.of(209), "property_2", LongValue.of(100))), + new AggregationResult( + ImmutableMap.of( + "count", LongValue.of(509), "property_2", LongValue.of(100)))), + Timestamp.fromProto(runAggregationQueryResponse.getBatch().getReadTime()), + null)); + } + + private RunAggregationQueryResponse placeholderAggregationQueryResponse() { + Map result1 = + new HashMap<>( + ImmutableMap.of( + "count", intValue(209), + "property_2", intValue(100))); + + Map result2 = + new HashMap<>( + ImmutableMap.of( + "count", intValue(509), + "property_2", intValue(100))); + + AggregationResultBatch resultBatch = + AggregationResultBatch.newBuilder() + .addAggregationResults( + com.google.datastore.v1.AggregationResult.newBuilder() + .putAllAggregateProperties(result1) + .build()) + .addAggregationResults( + com.google.datastore.v1.AggregationResult.newBuilder() + .putAllAggregateProperties(result2) + .build()) + .build(); + return RunAggregationQueryResponse.newBuilder().setBatch(resultBatch).build(); + } + + private Predicate runAggregationRequestWithEventualConsistency() { + return runAggregationQueryRequest -> + runAggregationQueryRequest.getReadOptions().getReadConsistency() == EVENTUAL; + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/execution/request/AggregationQueryRequestProtoPreparerTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/execution/request/AggregationQueryRequestProtoPreparerTest.java new file mode 100644 index 000000000000..8a6cc16e3b9b --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/execution/request/AggregationQueryRequestProtoPreparerTest.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. + */ +package com.google.cloud.datastore.execution.request; + +import static com.google.cloud.datastore.ProtoTestData.booleanValue; +import static com.google.cloud.datastore.ProtoTestData.countAggregation; +import static com.google.cloud.datastore.ProtoTestData.gqlQueryParameter; +import static com.google.cloud.datastore.ProtoTestData.intValue; +import static com.google.cloud.datastore.ProtoTestData.kind; +import static com.google.cloud.datastore.ProtoTestData.propertyFilter; +import static com.google.cloud.datastore.ProtoTestData.stringValue; +import static com.google.cloud.datastore.ReadOption.eventualConsistency; +import static com.google.cloud.datastore.StructuredQuery.PropertyFilter.eq; +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.common.truth.Truth.assertThat; +import static com.google.datastore.v1.PropertyFilter.Operator.EQUAL; +import static com.google.datastore.v1.ReadOptions.ReadConsistency.EVENTUAL; +import static java.util.Arrays.asList; +import static java.util.Collections.singletonList; + +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.GqlQuery; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.ReadOption.QueryConfig; +import com.google.common.collect.ImmutableMap; +import com.google.datastore.v1.ExplainOptions; +import com.google.datastore.v1.RunAggregationQueryRequest; +import java.util.HashMap; +import org.junit.Test; + +public class AggregationQueryRequestProtoPreparerTest { + + private static final String KIND = "Task"; + private static final String NAMESPACE = "ns"; + private static final String PROJECT_ID = "project-id"; + private static final String DATABASE_ID = "database-id"; + private static final DatastoreOptions DATASTORE_OPTIONS = + DatastoreOptions.newBuilder() + .setProjectId(PROJECT_ID) + .setDatabaseId(DATABASE_ID) + .setNamespace(NAMESPACE) + .build(); + private static final EntityQuery COMPLETED_TASK_STRUCTURED_QUERY = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND) + .setFilter(eq("done", true)) + .build(); + + private static final GqlQuery COMPLETED_TASK_GQL_QUERY = + Query.newGqlQueryBuilder( + "AGGREGATE COUNT AS total_characters OVER (" + + "SELECT * FROM Character WHERE name = @name and age > @1" + + ")") + .setBinding("name", "John Doe") + .addBinding(27) + .build(); + + private final AggregationQuery AGGREGATION_OVER_STRUCTURED_QUERY = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .addAggregation(count().as("total")) + .over(COMPLETED_TASK_STRUCTURED_QUERY) + .build(); + + private final AggregationQuery AGGREGATION_OVER_GQL_QUERY = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .over(COMPLETED_TASK_GQL_QUERY) + .build(); + + private final AggregationQueryRequestProtoPreparer protoPreparer = + new AggregationQueryRequestProtoPreparer(DATASTORE_OPTIONS); + + @Test + public void shouldPrepareAggregationQueryRequestWithGivenStructuredQuery() { + RunAggregationQueryRequest runAggregationQueryRequest = + protoPreparer.prepare(QueryConfig.create(AGGREGATION_OVER_STRUCTURED_QUERY, null)); + + assertThat(runAggregationQueryRequest.getProjectId()).isEqualTo(PROJECT_ID); + assertThat(runAggregationQueryRequest.getDatabaseId()).isEqualTo(DATABASE_ID); + + assertThat(runAggregationQueryRequest.getPartitionId().getProjectId()).isEqualTo(PROJECT_ID); + assertThat(runAggregationQueryRequest.getPartitionId().getNamespaceId()).isEqualTo(NAMESPACE); + assertThat(runAggregationQueryRequest.hasExplainOptions()).isFalse(); + + com.google.datastore.v1.AggregationQuery aggregationQueryProto = + runAggregationQueryRequest.getAggregationQuery(); + assertThat(aggregationQueryProto.getNestedQuery()) + .isEqualTo( + com.google.datastore.v1.Query.newBuilder() + .addKind(kind(KIND)) + .setFilter(propertyFilter("done", EQUAL, booleanValue(true))) + .build()); + assertThat(aggregationQueryProto.getAggregationsList()) + .isEqualTo(singletonList(countAggregation("total"))); + } + + @Test + public void shouldPrepareAggregationQueryRequestWithGivenGqlQuery() { + RunAggregationQueryRequest runAggregationQueryRequest = + protoPreparer.prepare(QueryConfig.create(AGGREGATION_OVER_GQL_QUERY, null)); + + assertThat(runAggregationQueryRequest.getProjectId()).isEqualTo(PROJECT_ID); + assertThat(runAggregationQueryRequest.getDatabaseId()).isEqualTo(DATABASE_ID); + + assertThat(runAggregationQueryRequest.getPartitionId().getProjectId()).isEqualTo(PROJECT_ID); + assertThat(runAggregationQueryRequest.getPartitionId().getDatabaseId()).isEqualTo(DATABASE_ID); + assertThat(runAggregationQueryRequest.getPartitionId().getNamespaceId()).isEqualTo(NAMESPACE); + assertThat(runAggregationQueryRequest.hasExplainOptions()).isFalse(); + + com.google.datastore.v1.GqlQuery gqlQueryProto = runAggregationQueryRequest.getGqlQuery(); + + assertThat(gqlQueryProto.getQueryString()).isEqualTo(COMPLETED_TASK_GQL_QUERY.getQueryString()); + assertThat(gqlQueryProto.getNamedBindingsMap()) + .isEqualTo( + new HashMap<>(ImmutableMap.of("name", gqlQueryParameter(stringValue("John Doe"))))); + assertThat(gqlQueryProto.getPositionalBindingsList()) + .isEqualTo(asList(gqlQueryParameter(intValue(27)))); + } + + @Test + public void shouldPrepareReadOptionsWithGivenStructuredQuery() { + RunAggregationQueryRequest eventualConsistencyAggregationRequest = + prepareQuery(AGGREGATION_OVER_STRUCTURED_QUERY, eventualConsistency()); + assertThat(eventualConsistencyAggregationRequest.getReadOptions().getReadConsistency()) + .isEqualTo(EVENTUAL); + + Timestamp now = Timestamp.now(); + RunAggregationQueryRequest readTimeAggregationRequest = + prepareQuery(AGGREGATION_OVER_STRUCTURED_QUERY, ReadOption.readTime(now)); + assertThat(Timestamp.fromProto(readTimeAggregationRequest.getReadOptions().getReadTime())) + .isEqualTo(now); + } + + @Test + public void shouldPrepareReadOptionsWithGivenGqlQuery() { + RunAggregationQueryRequest eventualConsistencyAggregationRequest = + prepareQuery(AGGREGATION_OVER_GQL_QUERY, eventualConsistency()); + assertThat(eventualConsistencyAggregationRequest.getReadOptions().getReadConsistency()) + .isEqualTo(EVENTUAL); + + Timestamp now = Timestamp.now(); + RunAggregationQueryRequest readTimeAggregationRequest = + prepareQuery(AGGREGATION_OVER_GQL_QUERY, ReadOption.readTime(now)); + assertThat(Timestamp.fromProto(readTimeAggregationRequest.getReadOptions().getReadTime())) + .isEqualTo(now); + } + + @Test + public void shouldPrepareAggregationQueryWithNamespaceFromDatastoreOptions() { + AggregationQuery structuredQueryWithoutNamespace = + Query.newAggregationQueryBuilder() + .addAggregation(count().as("total")) + .over(COMPLETED_TASK_STRUCTURED_QUERY) + .build(); + AggregationQuery gqlQueryWithoutNamespace = + Query.newAggregationQueryBuilder().over(COMPLETED_TASK_GQL_QUERY).build(); + + RunAggregationQueryRequest runAggregationQueryFromStructuredQuery = + protoPreparer.prepare(QueryConfig.create(structuredQueryWithoutNamespace, null)); + RunAggregationQueryRequest runAggregationQueryFromGqlQuery = + protoPreparer.prepare(QueryConfig.create(gqlQueryWithoutNamespace, null)); + + assertThat(runAggregationQueryFromStructuredQuery.getPartitionId().getNamespaceId()) + .isEqualTo(NAMESPACE); + assertThat(runAggregationQueryFromGqlQuery.getPartitionId().getNamespaceId()) + .isEqualTo(NAMESPACE); + assertThat(runAggregationQueryFromStructuredQuery.hasExplainOptions()).isEqualTo(false); + } + + @Test + public void shouldPrepareAggregationQueryWithDifferentModes() { + AggregationQuery structuredQueryWithoutNamespace = + Query.newAggregationQueryBuilder() + .addAggregation(count().as("total")) + .over(COMPLETED_TASK_STRUCTURED_QUERY) + .build(); + + ExplainOptions explainOptions = ExplainOptions.newBuilder().build(); + RunAggregationQueryRequest runAggregationQueryFromStructuredQuery = + protoPreparer.prepare(QueryConfig.create(structuredQueryWithoutNamespace, explainOptions)); + assertThat(runAggregationQueryFromStructuredQuery.getPartitionId().getNamespaceId()) + .isEqualTo(NAMESPACE); + assertThat(runAggregationQueryFromStructuredQuery.getExplainOptions()) + .isEqualTo(explainOptions); + + RunAggregationQueryRequest runAggregationQueryFromStructuredQuery2 = + protoPreparer.prepare(QueryConfig.create(structuredQueryWithoutNamespace, explainOptions)); + assertThat(runAggregationQueryFromStructuredQuery2.getPartitionId().getNamespaceId()) + .isEqualTo(NAMESPACE); + assertThat(runAggregationQueryFromStructuredQuery2.getExplainOptions()) + .isEqualTo(explainOptions); + } + + private RunAggregationQueryRequest prepareQuery(AggregationQuery query, ReadOption readOption) { + return protoPreparer.prepare(QueryConfig.create(query, null, singletonList(readOption))); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/execution/response/AggregationQueryResponseTransformerTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/execution/response/AggregationQueryResponseTransformerTest.java new file mode 100644 index 000000000000..156a46a73c7f --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/execution/response/AggregationQueryResponseTransformerTest.java @@ -0,0 +1,211 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.execution.response; + +import static com.google.cloud.datastore.ProtoTestData.doubleValue; +import static com.google.cloud.datastore.ProtoTestData.intValue; +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.models.ExplainMetrics; +import com.google.common.collect.ImmutableMap; +import com.google.datastore.v1.AggregationResultBatch; +import com.google.datastore.v1.ExecutionStats; +import com.google.datastore.v1.PlanSummary; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.Value; +import com.google.protobuf.Duration; +import com.google.protobuf.Struct; +import java.util.AbstractMap.SimpleEntry; +import java.util.HashMap; +import java.util.Map; +import java.util.Map.Entry; +import java.util.function.Function; +import java.util.stream.Collectors; +import org.junit.Test; + +public class AggregationQueryResponseTransformerTest { + + private final AggregationQueryResponseTransformer responseTransformer = + new AggregationQueryResponseTransformer(); + + @Test + public void shouldTransformAggregationQueryResponseWithIntValues() { + Map result1 = + new HashMap<>( + ImmutableMap.of( + "count", intValue(209), + "property_2", intValue(100))); + + Map result2 = + new HashMap<>( + ImmutableMap.of( + "count", intValue(509), + "property_2", intValue((100)))); + Timestamp readTime = Timestamp.now(); + + AggregationResultBatch resultBatch = + AggregationResultBatch.newBuilder() + .addAggregationResults( + com.google.datastore.v1.AggregationResult.newBuilder() + .putAllAggregateProperties(result1) + .build()) + .addAggregationResults( + com.google.datastore.v1.AggregationResult.newBuilder() + .putAllAggregateProperties(result2) + .build()) + .setReadTime(readTime.toProto()) + .build(); + RunAggregationQueryResponse runAggregationQueryResponse = + RunAggregationQueryResponse.newBuilder().setBatch(resultBatch).build(); + + AggregationResults aggregationResults = + responseTransformer.transform(runAggregationQueryResponse); + + assertThat(aggregationResults.size()).isEqualTo(2); + assertThat(aggregationResults.get(0)).isEqualTo(new AggregationResult(toDomainValues(result1))); + assertThat(aggregationResults.get(1)).isEqualTo(new AggregationResult(toDomainValues(result2))); + assertThat(aggregationResults.getReadTime()).isEqualTo(readTime); + assertThat(aggregationResults.getExplainMetrics().isPresent()).isFalse(); + } + + @Test + public void shouldTransformAggregationQueryResponseWithIntValuesWithStats() { + Map result1 = + new HashMap<>( + ImmutableMap.of( + "count", intValue(209), + "property_2", intValue(100))); + + Map result2 = + new HashMap<>( + ImmutableMap.of( + "count", intValue(509), + "property_2", intValue((100)))); + Timestamp readTime = Timestamp.now(); + + AggregationResultBatch resultBatch = + AggregationResultBatch.newBuilder() + .addAggregationResults( + com.google.datastore.v1.AggregationResult.newBuilder() + .putAllAggregateProperties(result1) + .build()) + .addAggregationResults( + com.google.datastore.v1.AggregationResult.newBuilder() + .putAllAggregateProperties(result2) + .build()) + .setReadTime(readTime.toProto()) + .build(); + + ExecutionStats executionStats = + ExecutionStats.newBuilder() + .setDebugStats( + Struct.newBuilder() + .putFields( + "field", + com.google.protobuf.Value.newBuilder().setStringValue("val").build()) + .build()) + .setExecutionDuration(Duration.newBuilder().setSeconds(1).build()) + .setReadOperations(1) + .setResultsReturned(2) + .build(); + + PlanSummary planSummary = + PlanSummary.newBuilder() + .addIndexesUsed( + Struct.newBuilder() + .putFields( + "field2", + com.google.protobuf.Value.newBuilder().setStringValue("val2").build()) + .build()) + .build(); + + com.google.datastore.v1.ExplainMetrics explainMetrics = + com.google.datastore.v1.ExplainMetrics.newBuilder() + .setExecutionStats(executionStats) + .setPlanSummary(planSummary) + .build(); + + RunAggregationQueryResponse runAggregationQueryResponse = + RunAggregationQueryResponse.newBuilder() + .setBatch(resultBatch) + .setExplainMetrics(explainMetrics) + .build(); + + AggregationResults aggregationResults = + responseTransformer.transform(runAggregationQueryResponse); + + assertThat(aggregationResults.size()).isEqualTo(2); + assertThat(aggregationResults.get(0)).isEqualTo(new AggregationResult(toDomainValues(result1))); + assertThat(aggregationResults.get(1)).isEqualTo(new AggregationResult(toDomainValues(result2))); + assertThat(aggregationResults.getReadTime()).isEqualTo(readTime); + assertThat(aggregationResults.getExplainMetrics().get()) + .isEqualTo(new ExplainMetrics(explainMetrics)); + } + + @Test + public void shouldTransformAggregationQueryResponseWithDoubleValues() { + Map result1 = + new HashMap<>( + ImmutableMap.of( + "count", doubleValue(209.678), + "property_2", doubleValue(100.678))); + + Map result2 = + new HashMap<>( + ImmutableMap.of( + "count", doubleValue(509.678), + "property_2", doubleValue((100.678)))); + Timestamp readTime = Timestamp.now(); + + AggregationResultBatch resultBatch = + AggregationResultBatch.newBuilder() + .addAggregationResults( + com.google.datastore.v1.AggregationResult.newBuilder() + .putAllAggregateProperties(result1) + .build()) + .addAggregationResults( + com.google.datastore.v1.AggregationResult.newBuilder() + .putAllAggregateProperties(result2) + .build()) + .setReadTime(readTime.toProto()) + .build(); + RunAggregationQueryResponse runAggregationQueryResponse = + RunAggregationQueryResponse.newBuilder().setBatch(resultBatch).build(); + + AggregationResults aggregationResults = + responseTransformer.transform(runAggregationQueryResponse); + + assertThat(aggregationResults.size()).isEqualTo(2); + assertThat(aggregationResults.get(0)).isEqualTo(new AggregationResult(toDomainValues(result1))); + assertThat(aggregationResults.get(1)).isEqualTo(new AggregationResult(toDomainValues(result2))); + assertThat(aggregationResults.getReadTime()).isEqualTo(readTime); + } + + private Map> toDomainValues( + Map map) { + + return map.entrySet().stream() + .map( + (Function, Entry>>) + entry -> + new SimpleEntry<>( + entry.getKey(), com.google.cloud.datastore.Value.fromPb(entry.getValue()))) + .collect(Collectors.toMap(Entry::getKey, Entry::getValue)); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/AbstractITDatastoreTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/AbstractITDatastoreTest.java new file mode 100644 index 000000000000..6fe624e562dc --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/AbstractITDatastoreTest.java @@ -0,0 +1,2132 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.it; + +import static com.google.api.gax.rpc.StatusCode.Code.ALREADY_EXISTS; +import static com.google.api.gax.rpc.StatusCode.Code.DEADLINE_EXCEEDED; +import static com.google.api.gax.rpc.StatusCode.Code.FAILED_PRECONDITION; +import static com.google.api.gax.rpc.StatusCode.Code.INVALID_ARGUMENT; +import static com.google.api.gax.rpc.StatusCode.Code.NOT_FOUND; +import static com.google.cloud.datastore.aggregation.Aggregation.avg; +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.cloud.datastore.aggregation.Aggregation.sum; +import static com.google.common.collect.Iterables.getOnlyElement; +import static com.google.common.truth.Truth.assertThat; +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.assertSame; +import static org.junit.Assert.assertThrows; +import static org.junit.Assert.assertTrue; + +import com.google.cloud.Timestamp; +import com.google.cloud.Tuple; +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.Batch; +import com.google.cloud.datastore.BooleanValue; +import com.google.cloud.datastore.Cursor; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.Datastore.TransactionCallable; +import com.google.cloud.datastore.DatastoreException; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.DatastoreReaderWriter; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.EntityValue; +import com.google.cloud.datastore.FullEntity; +import com.google.cloud.datastore.GqlQuery; +import com.google.cloud.datastore.IncompleteKey; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +import com.google.cloud.datastore.KeyValue; +import com.google.cloud.datastore.LatLng; +import com.google.cloud.datastore.LatLngValue; +import com.google.cloud.datastore.ListValue; +import com.google.cloud.datastore.NullValue; +import com.google.cloud.datastore.PathElement; +import com.google.cloud.datastore.ProjectionEntity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.Query.ResultType; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.StringValue; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.datastore.StructuredQuery.CompositeFilter; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.cloud.datastore.TimestampValue; +import com.google.cloud.datastore.Transaction; +import com.google.cloud.datastore.ValueType; +import com.google.cloud.datastore.models.ExecutionStats; +import com.google.cloud.datastore.models.ExplainMetrics; +import com.google.cloud.datastore.models.ExplainOptions; +import com.google.cloud.datastore.models.PlanSummary; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.Range; +import com.google.common.truth.Truth; +import com.google.datastore.v1.TransactionOptions; +import com.google.datastore.v1.TransactionOptions.ReadOnly; +import java.time.Duration; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.function.BiConsumer; +import java.util.function.Consumer; +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.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public abstract class AbstractITDatastoreTest { + protected static final String CUSTOM_DB_ID = "test-db"; + + protected DatastoreOptions options; + protected Datastore datastore; + + private static String PROJECT_ID; + private static String NAMESPACE; + private static final String KIND1 = "kind1"; + private static final String KIND2 = "kind2"; + private static final String KIND3 = "kind3"; + private static final NullValue NULL_VALUE = NullValue.of(); + private static final StringValue STR_VALUE = StringValue.of("str"); + private static final BooleanValue BOOL_VALUE = + BooleanValue.newBuilder(false).setExcludeFromIndexes(true).build(); + private static final ListValue EMPTY_LIST_VALUE = ListValue.of(Collections.emptyList()); + private static final ListValue LIST_VALUE1 = + ListValue.newBuilder().addValue(NULL_VALUE).addValue(STR_VALUE, BOOL_VALUE).build(); + private static final TimestampValue TIMESTAMP_VALUE = new TimestampValue(Timestamp.now()); + private static final LatLngValue LAT_LNG_VALUE = + new LatLngValue(LatLng.of(37.422035, -122.084124)); + + private static Key ROOT_KEY; + private static IncompleteKey INCOMPLETE_KEY1; + private static ListValue LIST_VALUE2; + private static Key KEY1; + private static Key KEY2; + private static Key KEY3; + private static Key KEY4; + private static Key KEY5; + private static Key KEY6; + private static final String MARKS_KIND = "Marks"; + private static FullEntity PARTIAL_ENTITY1; + private static FullEntity PARTIAL_ENTITY2; + private static FullEntity PARTIAL_ENTITY3; + private static Entity ENTITY1; + private static Entity ENTITY2; + private static Entity ENTITY3; + + private static Entity AGGREGATION_ENTITY_1; + private static Entity AGGREGATION_ENTITY_2; + private static Entity AGGREGATION_ENTITY_3; + + @Rule public Timeout globalTimeout = Timeout.seconds(100); + + @Rule public MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(3); + + @Before + public void setUp() { + datastore.put(ENTITY1, ENTITY2); + } + + @After + public void tearDown() { + EntityQuery allEntitiesQuery = Query.newEntityQueryBuilder().build(); + QueryResults allEntities = datastore.run(allEntitiesQuery); + Key[] keysToDelete = + ImmutableList.copyOf(allEntities).stream().map(Entity::getKey).toArray(Key[]::new); + datastore.delete(keysToDelete); + } + + public AbstractITDatastoreTest( + DatastoreOptions options, + Datastore datastore, + // databaseType is unused as a variable, but used as a parameterized label when running tests + String databaseType) { + this.options = options; + this.datastore = datastore; + + PROJECT_ID = this.options.getProjectId(); + NAMESPACE = this.options.getNamespace(); + + ROOT_KEY = + Key.newBuilder(PROJECT_ID, "rootkey", "default", options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build(); + INCOMPLETE_KEY1 = IncompleteKey.newBuilder(ROOT_KEY, KIND1).setNamespace(NAMESPACE).build(); + + IncompleteKey INCOMPLETE_KEY2 = + IncompleteKey.newBuilder(PROJECT_ID, KIND2) + .setDatabaseId(options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build(); + + KEY1 = Key.newBuilder(INCOMPLETE_KEY1, "name").build(); + KEY2 = Key.newBuilder(KEY1, KIND2, 1).build(); + KEY3 = Key.newBuilder(KEY2).setName("bla").setNamespace(NAMESPACE).build(); + KEY4 = Key.newBuilder(KEY2).setName("newName1").setNamespace(NAMESPACE).build(); + KEY5 = Key.newBuilder(KEY2).setName("newName2").setNamespace(NAMESPACE).build(); + KEY6 = + Key.newBuilder(options.getProjectId(), KIND2, 100, options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build(); + + LIST_VALUE2 = ListValue.of(Collections.singletonList(KeyValue.of(KEY1))); + + PARTIAL_ENTITY1 = + FullEntity.newBuilder(INCOMPLETE_KEY2) + .set("str", STR_VALUE) + .set("bool", BOOL_VALUE) + .set("list", LIST_VALUE1) + .build(); + PARTIAL_ENTITY2 = + FullEntity.newBuilder(PARTIAL_ENTITY1) + .remove("str") + .set("bool", true) + .set("list", LIST_VALUE1.get()) + .build(); + PARTIAL_ENTITY3 = + FullEntity.newBuilder(PARTIAL_ENTITY1) + .setKey( + IncompleteKey.newBuilder(PROJECT_ID, KIND3) + .setNamespace(NAMESPACE) + .setDatabaseId(options.getDatabaseId()) + .build()) + .build(); + ENTITY1 = + Entity.newBuilder(KEY1) + .set("str", STR_VALUE) + .set("date", TIMESTAMP_VALUE) + .set("latLng", LAT_LNG_VALUE) + .set("bool", BOOL_VALUE) + .set("partial1", EntityValue.of(PARTIAL_ENTITY1)) + .set("list", LIST_VALUE2) + .set("emptyList", EMPTY_LIST_VALUE) + .build(); + ENTITY2 = + Entity.newBuilder(ENTITY1) + .setKey(KEY2) + .remove("str") + .set("name", "Dan") + .setNull("null") + .set("age", 20) + .build(); + ENTITY3 = + Entity.newBuilder(ENTITY1) + .setKey(KEY3) + .remove("str") + .set("null", NULL_VALUE) + .set("partial1", PARTIAL_ENTITY2) + .set("partial2", ENTITY2) + .build(); + + Key aggregationKey1 = datastore.newKeyFactory().setKind(MARKS_KIND).newKey(1); + Key aggregationKey2 = datastore.newKeyFactory().setKind(MARKS_KIND).newKey(2); + Key aggregationKey3 = datastore.newKeyFactory().setKind(MARKS_KIND).newKey(3); + + AGGREGATION_ENTITY_1 = + Entity.newBuilder(aggregationKey1) + .set("name", "Person1") + .set("marks", 89) + .set("cgpa", 7.34) + .build(); + AGGREGATION_ENTITY_2 = + Entity.newBuilder(aggregationKey2) + .set("name", "Person2") + .set("marks", 95) + .set("cgpa", 9.27) + .build(); + AGGREGATION_ENTITY_3 = + Entity.newBuilder(aggregationKey3) + .set("name", "Person3") + .set("marks", 55) + .set("cgpa", 5.16) + .build(); + } + + private Iterator getStronglyConsistentResults(Query scQuery, Query query) + throws InterruptedException { + // scQuery is equivalent to query, but with an ancestor filter in it + // this makes scQuery strongly consistent + QueryResults scResults = datastore.run(scQuery); + List scResultsCopy = makeResultsCopy(scResults); + Set scResultsSet = new HashSet<>(scResultsCopy); + int maxAttempts = 20; + + while (maxAttempts > 0) { + --maxAttempts; + QueryResults results = datastore.run(query); + List resultsCopy = makeResultsCopy(results); + Set resultsSet = new HashSet<>(resultsCopy); + if (scResultsSet.size() == resultsSet.size() && scResultsSet.containsAll(resultsSet)) { + return resultsCopy.iterator(); + } + Thread.sleep(500); + } + + throw new RuntimeException( + "reached max number of attempts to get strongly consistent results."); + } + + private List makeResultsCopy(QueryResults scResults) { + Preconditions.checkNotNull(scResults); + List results = new ArrayList<>(); + while (scResults.hasNext()) { + results.add(scResults.next()); + } + return results; + } + + @Test + public void orQuery() { + Key key = Key.newBuilder(KEY1, KIND2, 2).build(); + Entity entity3 = + Entity.newBuilder(ENTITY1) + .setKey(key) + .remove("str") + .set("name", "Dan") + .setNull("null") + .set("age", 19) + .build(); + datastore.put(entity3); + + // age == 19 || age == 20 + CompositeFilter orFilter = + CompositeFilter.or(PropertyFilter.eq("age", 19), PropertyFilter.eq("age", 20)); + Query simpleOrQuery = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND2) + .setFilter(orFilter) + .build(); + QueryResults results = datastore.run(simpleOrQuery); + assertTrue(results.hasNext()); + assertEquals(ENTITY2, results.next()); + assertTrue(results.hasNext()); + assertEquals(entity3, results.next()); + assertFalse(results.hasNext()); + + // age == 19 || age == 20 with limit of 1 + Query simpleOrQueryLimit = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND2) + .setFilter(orFilter) + .setLimit(1) + .build(); + QueryResults results2 = datastore.run(simpleOrQueryLimit); + assertTrue(results2.hasNext()); + assertEquals(ENTITY2, results2.next()); + assertFalse(results2.hasNext()); + + // (age == 18 && name == Dan) || (age == 20 && name == Dan) + CompositeFilter nestedOr = + CompositeFilter.or( + CompositeFilter.and(PropertyFilter.eq("age", 18), PropertyFilter.eq("name", "Dan")), + CompositeFilter.and(PropertyFilter.eq("age", 20), PropertyFilter.eq("name", "Dan"))); + CompositeFilter compositeFilter = + CompositeFilter.and(PropertyFilter.hasAncestor(ROOT_KEY), nestedOr); + Query orQueryNested = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND2) + .setFilter(compositeFilter) + .build(); + QueryResults results3 = datastore.run(orQueryNested); + assertTrue(results3.hasNext()); + assertEquals(ENTITY2, results3.next()); + assertFalse(results3.hasNext()); + + // age == 20 && (name == Bob || name == Dan) + CompositeFilter nestedOr2 = + CompositeFilter.or(PropertyFilter.eq("name", "Dan"), PropertyFilter.eq("name", "Bob")); + CompositeFilter andFilter = CompositeFilter.and(PropertyFilter.eq("age", 20), nestedOr2); + CompositeFilter ancestorAndFilter = + CompositeFilter.and(PropertyFilter.hasAncestor(ROOT_KEY), andFilter); + Query orQueryNested2 = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND2) + .setFilter(ancestorAndFilter) + .setLimit(1) + .build(); + QueryResults results4 = datastore.run(orQueryNested2); + assertTrue(results4.hasNext()); + assertEquals(ENTITY2, results4.next()); + assertFalse(results4.hasNext()); + } + + @Test + public void testQueryProfile() { + Key key = Key.newBuilder(KEY1, KIND2, 2).build(); + Entity entity3 = + Entity.newBuilder(ENTITY1) + .setKey(key) + .remove("str") + .set("name", "Dan") + .setNull("null") + .set("age", 19) + .build(); + datastore.put(entity3); + + // age == 19 || age == 20 + CompositeFilter orFilter = + CompositeFilter.or(PropertyFilter.eq("age", 19), PropertyFilter.eq("age", 20)); + StructuredQuery simpleOrQuery = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND2) + .setFilter(orFilter) + .build(); + QueryResults results = + datastore.run(simpleOrQuery, ExplainOptions.newBuilder().setAnalyze(true).build()); + Truth.assertThat(results.hasNext()).isTrue(); + Truth.assertThat(results.getExplainMetrics().isPresent()).isTrue(); + assertPlanSummary(results.getExplainMetrics().get().getPlanSummary()); + assertExecutionStats(results.getExplainMetrics().get().getExecutionStats().get(), 2, 2, "2"); + + QueryResults results2 = + datastore.run(simpleOrQuery, ExplainOptions.newBuilder().build()); + Truth.assertThat(results2.hasNext()).isFalse(); + assertPlanSummary(results2.getExplainMetrics().get().getPlanSummary()); + Truth.assertThat(results2.getExplainMetrics().get().getExecutionStats().isPresent()).isFalse(); + + QueryResults results3 = datastore.run(simpleOrQuery); + Truth.assertThat(results3.hasNext()).isTrue(); + Truth.assertThat(results3.getExplainMetrics().isPresent()).isFalse(); + + QueryResults results4 = + datastore.run(simpleOrQuery, ExplainOptions.newBuilder().setAnalyze(false).build()); + Truth.assertThat(results4.hasNext()).isFalse(); + assertPlanSummary(results4.getExplainMetrics().get().getPlanSummary()); + Truth.assertThat(results4.getExplainMetrics().get().getExecutionStats().isPresent()).isFalse(); + + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder().over(simpleOrQuery).addAggregation(count()).build(); + AggregationResults resultsAggregation = + datastore.runAggregation( + aggregationQuery, ExplainOptions.newBuilder().setAnalyze(true).build()); + + Truth.assertThat(resultsAggregation.size() > 0).isTrue(); + + assertPlanSummary(resultsAggregation.getExplainMetrics().get().getPlanSummary()); + assertExecutionStats( + resultsAggregation.getExplainMetrics().get().getExecutionStats().get(), 1, 1, "2"); + + AggregationQuery aggregationQuery2 = + Query.newAggregationQueryBuilder().over(simpleOrQuery).addAggregation(count()).build(); + AggregationResults resultsAggregation2 = + datastore.runAggregation(aggregationQuery2, ExplainOptions.newBuilder().build()); + + Truth.assertThat(resultsAggregation2.size() > 0).isFalse(); + + assertPlanSummary(resultsAggregation2.getExplainMetrics().get().getPlanSummary()); + Truth.assertThat(resultsAggregation2.getExplainMetrics().get().getExecutionStats().isPresent()) + .isFalse(); + + AggregationQuery aggregationQuery3 = + Query.newAggregationQueryBuilder().over(simpleOrQuery).addAggregation(count()).build(); + AggregationResults resultsAggregation3 = datastore.runAggregation(aggregationQuery3); + + Truth.assertThat(resultsAggregation3.size() > 0).isTrue(); + Truth.assertThat(resultsAggregation3.getExplainMetrics().isPresent()).isFalse(); + } + + @Test + public void testNewTransactionCommit() { + Transaction transaction = datastore.newTransaction(); + transaction.add(ENTITY3); + Entity entity2 = Entity.newBuilder(ENTITY2).clear().setNull("bla").build(); + transaction.update(entity2); + transaction.delete(KEY1); + transaction.commit(); + assertFalse(transaction.isActive()); + + List list = datastore.fetch(KEY1, KEY2, KEY3); + assertNull(list.get(0)); + assertEquals(entity2, list.get(1)); + assertEquals(ENTITY3, list.get(2)); + assertEquals(3, list.size()); + + DatastoreException expected = assertThrows(DatastoreException.class, transaction::commit); + assertDatastoreException(expected, FAILED_PRECONDITION.name(), 0); + + DatastoreException expected2 = assertThrows(DatastoreException.class, transaction::rollback); + assertDatastoreException(expected2, FAILED_PRECONDITION.name(), 0); + } + + @Test + public void testTransactionWithRead() throws Exception { + StatementExecutor statementExecutor = new StatementExecutor(); + Transaction baseTransaction = datastore.newTransaction(); + assertNull(baseTransaction.get(KEY3)); + baseTransaction.add(ENTITY3); + baseTransaction.commit(); + assertEquals(ENTITY3, datastore.get(KEY3)); + + Transaction transaction = datastore.newTransaction(); + statementExecutor.execute( + Tuple.of("T1", () -> assertEquals(ENTITY3, transaction.get(KEY3))), + // update entity3 during the transaction, will be blocked in case of pessimistic concurrency + Tuple.of( + "T2", + () -> + datastore.put(Entity.newBuilder(ENTITY3).clear().set("from", "datastore").build())), + Tuple.of( + "T1", + () -> + transaction.update( + Entity.newBuilder(ENTITY3).clear().set("from", "transaction").build())), + Tuple.of("T1", transaction::commit) // T1 will throw error in case of optimistic concurrency + ); + + boolean t1AllPassed = statementExecutor.didAllPass("T1"); + boolean t2AllPassed = statementExecutor.didAllPass("T2"); + // If two transactions conflict with each other, the database guarantees that only + // one can commit successfully at a time. Please refer to StatementExecutor class for more info. + // Using XOR to ensure that only one of transaction group is successful, + boolean onlyOneTransactionIsSuccessful = t1AllPassed ^ t2AllPassed; + + assertThat(onlyOneTransactionIsSuccessful).isTrue(); + } + + @Test + public void testTransactionWithQuery() throws Exception { + StatementExecutor statementExecutor = new StatementExecutor(); + Query query = + Query.newEntityQueryBuilder() + .setKind(KIND2) + .setFilter(PropertyFilter.hasAncestor(KEY2)) + .setNamespace(NAMESPACE) + .build(); + Transaction baseTransaction = datastore.newTransaction(); + QueryResults baseResults = baseTransaction.run(query); + assertTrue(baseResults.hasNext()); + assertEquals(ENTITY2, baseResults.next()); + assertFalse(baseResults.hasNext()); + baseTransaction.add(ENTITY3); + baseTransaction.commit(); + assertEquals(ENTITY3, datastore.get(KEY3)); + + Transaction transaction = datastore.newTransaction(); + statementExecutor.execute( + Tuple.of( + "T1", + () -> { + QueryResults results = transaction.run(query); + assertTrue(results.hasNext()); + assertEquals(ENTITY2, results.next()); + assertFalse(results.hasNext()); + }), + Tuple.of("T1", () -> transaction.delete(ENTITY3.getKey())), + // update entity2 during the transaction, will be blocked in case of pessimistic concurrency + Tuple.of("T2", () -> datastore.put(Entity.newBuilder(ENTITY2).clear().build())), + Tuple.of("T1", transaction::commit) // T1 will throw error in case of optimistic concurrency + ); + + boolean t1AllPassed = statementExecutor.didAllPass("T1"); + boolean t2AllPassed = statementExecutor.didAllPass("T2"); + // If two transactions conflict with each other, the database guarantees that only + // one can commit successfully at a time. Please refer to StatementExecutor class for more info. + // Using XOR to ensure that only one of transaction group is successful, + boolean onlyOneTransactionIsSuccessful = t1AllPassed ^ t2AllPassed; + + assertThat(onlyOneTransactionIsSuccessful).isTrue(); + } + + @Test + public void testTransactionExplainOptionsAnalyze() { + StructuredQuery query = + Query.newEntityQueryBuilder() + .setKind(KIND2) + .setFilter(PropertyFilter.hasAncestor(KEY2)) + .setNamespace(NAMESPACE) + .build(); + Transaction baseTransaction = datastore.newTransaction(); + QueryResults baseResults = + baseTransaction.run(query, ExplainOptions.newBuilder().setAnalyze(true).build()); + assertTrue(baseResults.hasNext()); + assertEquals(ENTITY2, baseResults.next()); + assertFalse(baseResults.hasNext()); + + ExplainMetrics explainMetrics = baseResults.getExplainMetrics().get(); + assertPlanSummary(explainMetrics.getPlanSummary()); + assertExecutionStats(explainMetrics.getExecutionStats().get(), 1, 1, "1"); + + baseTransaction.add(ENTITY3); + baseTransaction.commit(); + assertEquals(ENTITY3, datastore.get(KEY3)); + + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder().addAggregation(count()).over(query).build(); + + Transaction aggregationTransaction = datastore.newTransaction(); + AggregationResults results = + aggregationTransaction.runAggregation( + aggregationQuery, ExplainOptions.newBuilder().setAnalyze(true).build()); + assertTrue(results.size() > 0); + + assertPlanSummary(results.getExplainMetrics().get().getPlanSummary()); + assertExecutionStats(results.getExplainMetrics().get().getExecutionStats().get(), 1, 1, "1"); + aggregationTransaction.commit(); + } + + @Test + public void testTransactionExplainOptions() { + StructuredQuery query = + Query.newEntityQueryBuilder() + .setKind(KIND2) + .setFilter(PropertyFilter.hasAncestor(KEY2)) + .setNamespace(NAMESPACE) + .build(); + Transaction baseTransaction = datastore.newTransaction(); + QueryResults baseResults = + baseTransaction.run(query, ExplainOptions.newBuilder().build()); + assertFalse(baseResults.hasNext()); + + ExplainMetrics explainMetrics = baseResults.getExplainMetrics().get(); + assertPlanSummary(explainMetrics.getPlanSummary()); + Truth.assertThat(explainMetrics.getExecutionStats().isPresent()).isFalse(); + + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder().addAggregation(count()).over(query).build(); + + Transaction aggregationTransaction = datastore.newTransaction(); + AggregationResults results = + aggregationTransaction.runAggregation( + aggregationQuery, ExplainOptions.newBuilder().build()); + assertFalse(results.size() > 0); + + assertPlanSummary(results.getExplainMetrics().get().getPlanSummary()); + assertThat(results.getExplainMetrics().get().getExecutionStats().isPresent()).isFalse(); + } + + private void assertPlanSummary(PlanSummary planSummary) { + List> indexesUsed = planSummary.getIndexesUsed(); + indexesUsed.forEach( + each -> Truth.assertThat(each.keySet()).containsAtLeast("properties", "query_scope")); + } + + private void assertExecutionStats( + ExecutionStats executionStats, + long expectedReadOps, + long expectedResultsReturned, + String expectedIndexEntriesScanned) { + Map debugStats = executionStats.getDebugStats(); + Truth.assertThat(debugStats.keySet()) + .containsAtLeast("billing_details", "documents_scanned", "index_entries_scanned"); + Truth.assertThat(debugStats.get("index_entries_scanned")) + .isEqualTo(expectedIndexEntriesScanned); + + Duration executionDuration = executionStats.getExecutionDurationJavaTime(); + Truth.assertThat(executionDuration).isIn(Range.greaterThan(Duration.ofMillis(0))); + + long readOperations = executionStats.getReadOperations(); + Truth.assertThat(readOperations).isEqualTo(expectedReadOps); + + long resultsReturned = executionStats.getResultsReturned(); + Truth.assertThat(resultsReturned).isEqualTo(expectedResultsReturned); + } + + @Test + public void testNewTransactionRollback() { + Transaction transaction = datastore.newTransaction(); + transaction.add(ENTITY3); + Entity entity2 = + Entity.newBuilder(ENTITY2) + .clear() + .setNull("bla") + .set("list3", StringValue.of("bla"), StringValue.newBuilder("bla").build()) + .build(); + transaction.update(entity2); + transaction.delete(KEY1); + transaction.rollback(); + transaction.rollback(); // should be safe to repeat rollback calls + + DatastoreException expected = assertThrows(DatastoreException.class, transaction::commit); + assertDatastoreException(expected, FAILED_PRECONDITION.name(), 0); + + List list = datastore.fetch(KEY1, KEY2, KEY3); + assertEquals(ENTITY1, list.get(0)); + assertEquals(ENTITY2, list.get(1)); + assertNull(list.get(2)); + assertEquals(3, list.size()); + } + + @Test + public void testNewBatch() { + Batch batch = datastore.newBatch(); + Entity entity1 = Entity.newBuilder(ENTITY1).clear().build(); + Entity entity2 = Entity.newBuilder(ENTITY2).clear().setNull("bla").build(); + Entity entity4 = Entity.newBuilder(KEY4).set("value", StringValue.of("value")).build(); + Entity entity5 = Entity.newBuilder(KEY5).set("value", "value").build(); + + List entities = batch.add(entity4, PARTIAL_ENTITY2, entity5); + Entity entity6 = entities.get(1); + assertSame(entity4, entities.get(0)); + assertEquals(PARTIAL_ENTITY2.getNames(), entity6.getNames()); + assertEquals(PARTIAL_ENTITY2.getKey().getProjectId(), entity6.getKey().getProjectId()); + assertEquals(PARTIAL_ENTITY2.getKey().getNamespace(), entity6.getKey().getNamespace()); + assertEquals(PARTIAL_ENTITY2.getKey().getAncestors(), entity6.getKey().getAncestors()); + assertEquals(PARTIAL_ENTITY2.getKey().getKind(), entity6.getKey().getKind()); + assertEquals(PARTIAL_ENTITY2.getKey(), IncompleteKey.newBuilder(entity6.getKey()).build()); + assertEquals(PARTIAL_ENTITY2.getKey().getAncestors(), entity6.getKey().getAncestors()); + assertNotEquals(PARTIAL_ENTITY2.getKey(), entity6.getKey()); + assertSame(entity5, entities.get(2)); + batch.addWithDeferredIdAllocation(PARTIAL_ENTITY3); + batch.put(ENTITY3, entity1, entity2); + + Batch.Response response = batch.submit(); + entities = + datastore.fetch(KEY1, KEY2, KEY3, entity4.getKey(), entity5.getKey(), entity6.getKey()); + assertEquals(entity1, entities.get(0)); + assertEquals(entity2, entities.get(1)); + assertEquals(ENTITY3, entities.get(2)); + assertEquals(entity4, entities.get(3)); + assertEquals(entity5, entities.get(4)); + assertEquals(entity6, entities.get(5)); + assertEquals(6, entities.size()); + List generatedKeys = response.getGeneratedKeys(); + assertEquals(1, generatedKeys.size()); + assertEquals(PARTIAL_ENTITY3.getNames(), datastore.get(generatedKeys.get(0)).getNames()); + assertEquals(PARTIAL_ENTITY3.getKey(), IncompleteKey.newBuilder(generatedKeys.get(0)).build()); + + DatastoreException expected = assertThrows(DatastoreException.class, batch::submit); + assertDatastoreException(expected, FAILED_PRECONDITION.name(), 0); + + batch = datastore.newBatch(); + batch.delete(entity4.getKey(), entity5.getKey(), entity6.getKey()); + batch.update(ENTITY1, ENTITY2, ENTITY3); + batch.submit(); + entities = + datastore.fetch(KEY1, KEY2, KEY3, entity4.getKey(), entity5.getKey(), entity6.getKey()); + assertEquals(ENTITY1, entities.get(0)); + assertEquals(ENTITY2, entities.get(1)); + assertEquals(ENTITY3, entities.get(2)); + assertNull(entities.get(3)); + assertNull(entities.get(4)); + assertNull(entities.get(5)); + assertEquals(6, entities.size()); + } + + @Test + public void testRunGqlQueryNoCasting() throws InterruptedException { + Query query1 = + Query.newGqlQueryBuilder(ResultType.ENTITY, "select * from " + KIND1) + .setNamespace(NAMESPACE) + .build(); + Query scQuery1 = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND1) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .build(); + + Iterator results1 = getStronglyConsistentResults(scQuery1, query1); + + assertTrue(results1.hasNext()); + assertEquals(ENTITY1, results1.next()); + assertFalse(results1.hasNext()); + + datastore.put(ENTITY3); + Query query2 = + Query.newGqlQueryBuilder(ResultType.ENTITY, "select * from " + KIND2 + " order by __key__") + .setNamespace(NAMESPACE) + .build(); + Query scQuery2 = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND2) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .setOrderBy(OrderBy.asc("__key__")) + .build(); + + Iterator results2 = getStronglyConsistentResults(scQuery2, query2); + assertTrue(results2.hasNext()); + assertEquals(ENTITY2, results2.next()); + assertTrue(results2.hasNext()); + assertEquals(ENTITY3, results2.next()); + assertFalse(results2.hasNext()); + + query1 = + Query.newGqlQueryBuilder(ResultType.ENTITY, "select * from bla") + .setNamespace(NAMESPACE) + .build(); + scQuery1 = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .setKind("bla") + .build(); + results1 = getStronglyConsistentResults(scQuery1, query1); + assertFalse(results1.hasNext()); + + Query keyOnlyQuery = + Query.newGqlQueryBuilder(ResultType.KEY, "select __key__ from " + KIND1) + .setNamespace(NAMESPACE) + .build(); + Query scKeyOnlyQuery = + Query.newKeyQueryBuilder() + .setNamespace(NAMESPACE) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .setKind(KIND1) + .build(); + Iterator keyOnlyResults = getStronglyConsistentResults(scKeyOnlyQuery, keyOnlyQuery); + assertTrue(keyOnlyResults.hasNext()); + assertEquals(KEY1, keyOnlyResults.next()); + assertFalse(keyOnlyResults.hasNext()); + + GqlQuery keyProjectionQuery = + Query.newGqlQueryBuilder(ResultType.PROJECTION_ENTITY, "select __key__ from " + KIND1) + .setNamespace(NAMESPACE) + .build(); + Query scKeyProjectionQuery = + Query.newProjectionEntityQueryBuilder() + .addProjection("__key__") + .setNamespace(NAMESPACE) + .setKind(KIND1) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .build(); + + Iterator keyProjectionResult = + getStronglyConsistentResults(scKeyProjectionQuery, keyProjectionQuery); + assertTrue(keyProjectionResult.hasNext()); + ProjectionEntity projectionEntity = keyProjectionResult.next(); + assertEquals(KEY1, projectionEntity.getKey()); + assertTrue(projectionEntity.getNames().isEmpty()); + assertFalse(keyProjectionResult.hasNext()); + datastore.delete(ENTITY3.getKey()); + } + + @Test + public void testRunGqlQueryWithCasting() throws InterruptedException { + @SuppressWarnings("unchecked") + Query query1 = + (Query) + Query.newGqlQueryBuilder("select * from " + KIND1).setNamespace(NAMESPACE).build(); + Query scQuery1 = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND1) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .build(); + Iterator results1 = getStronglyConsistentResults(scQuery1, query1); + assertTrue(results1.hasNext()); + assertEquals(ENTITY1, results1.next()); + assertFalse(results1.hasNext()); + + Query query2 = + Query.newGqlQueryBuilder("select * from " + KIND1).setNamespace(NAMESPACE).build(); + + QueryResults results2 = datastore.run(query2); + + assertSame(Entity.class, results2.getResultClass()); + + Query scQuery2 = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND1) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .build(); + + Iterator results3 = getStronglyConsistentResults(scQuery2, query2); + assertTrue(results3.hasNext()); + assertEquals(ENTITY1, results3.next()); + assertFalse(results3.hasNext()); + } + + @Test + public void testRunAggregationQuery() { + // verifying aggregation with an entity query + testCountAggregationWith( + builder -> + builder + .addAggregation(count().as("total_count")) + .over( + Query.newEntityQueryBuilder().setNamespace(NAMESPACE).setKind(KIND1).build())); + + // verifying aggregation with a projection query + testCountAggregationWith( + builder -> + builder + .addAggregation(count().as("total_count")) + .over( + Query.newProjectionEntityQueryBuilder() + .setProjection("str") + .setNamespace(NAMESPACE) + .setKind(KIND1) + .build())); + + // verifying aggregation with a key query + testCountAggregationWith( + builder -> + builder + .addAggregation(count().as("total_count")) + .over(Query.newKeyQueryBuilder().setNamespace(NAMESPACE).setKind(KIND1).build())); + + // verifying aggregation with a GQL query + testCountAggregationWith( + builder -> + builder.over( + Query.newGqlQueryBuilder( + "AGGREGATE COUNT(*) AS total_count OVER (SELECT * FROM kind1)") + .setNamespace(NAMESPACE) + .build())); + } + + @Test + public void testRunAggregationQueryWithLimit() { + // verifying aggregation with an entity query + testCountAggregationWithLimit( + builder -> + builder + .addAggregation(count().as("total_count")) + .over(Query.newEntityQueryBuilder().setNamespace(NAMESPACE).setKind(KIND1).build()), + ((builder, limit) -> + builder + .addAggregation(count().as("total_count")) + .over( + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND1) + .setLimit(limit.intValue()) + .build()))); + + // verifying aggregation with a projection query + testCountAggregationWithLimit( + builder -> + builder + .addAggregation(count().as("total_count")) + .over( + Query.newProjectionEntityQueryBuilder() + .setProjection("str") + .setNamespace(NAMESPACE) + .setKind(KIND1) + .build()), + ((builder, limit) -> + builder + .addAggregation(count().as("total_count")) + .over( + Query.newProjectionEntityQueryBuilder() + .setProjection("str") + .setNamespace(NAMESPACE) + .setKind(KIND1) + .setLimit(limit.intValue()) + .build()))); + + // verifying aggregation with a key query + testCountAggregationWithLimit( + builder -> + builder + .addAggregation(count().as("total_count")) + .over(Query.newKeyQueryBuilder().setNamespace(NAMESPACE).setKind(KIND1).build()), + (builder, limit) -> + builder + .addAggregation(count().as("total_count")) + .over( + Query.newKeyQueryBuilder() + .setNamespace(NAMESPACE) + .setKind(KIND1) + .setLimit(limit.intValue()) + .build())); + + // verifying aggregation with a GQL query + testCountAggregationWithLimit( + builder -> + builder.over( + Query.newGqlQueryBuilder( + "AGGREGATE COUNT(*) AS total_count OVER (SELECT * FROM kind1)") + .setNamespace(NAMESPACE) + .build()), + (builder, limit) -> + builder.over( + Query.newGqlQueryBuilder( + "AGGREGATE COUNT(*) AS total_count OVER (SELECT * FROM kind1 LIMIT @limit)") + .setNamespace(NAMESPACE) + .setBinding("limit", limit) + .build())); + } + + @Test + public void testSumAggregation() { + datastore.put(AGGREGATION_ENTITY_1, AGGREGATION_ENTITY_2); + + EntityQuery baseQuery = Query.newEntityQueryBuilder().setKind(MARKS_KIND).build(); + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .over(baseQuery) + .addAggregations(sum("marks").as("total_marks")) + .setNamespace(NAMESPACE) + .build(); + + // sum of 2 entities + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("total_marks")) + .isEqualTo(184L); + + // sum of 3 entities + datastore.put(AGGREGATION_ENTITY_3); + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("total_marks")) + .isEqualTo(239L); + } + + @Test + public void testSumAggregationWithAutoGeneratedAlias() { + datastore.put(AGGREGATION_ENTITY_1, AGGREGATION_ENTITY_2); + + EntityQuery baseQuery = Query.newEntityQueryBuilder().setKind(MARKS_KIND).build(); + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .over(baseQuery) + .addAggregations(sum("marks")) + .setNamespace(NAMESPACE) + .build(); + + // sum of 2 entities + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("property_1")) + .isEqualTo(184L); + + // sum of 3 entities + datastore.put(AGGREGATION_ENTITY_3); + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("property_1")) + .isEqualTo(239L); + } + + @Test + public void testSumAggregationInGqlQuery() { + datastore.put(AGGREGATION_ENTITY_1, AGGREGATION_ENTITY_2); + + GqlQuery gqlQuery = + GqlQuery.newGqlQueryBuilder( + "AGGREGATE SUM(marks) AS total_marks OVER (SELECT * FROM Marks)") + .build(); + + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder().over(gqlQuery).setNamespace(NAMESPACE).build(); + + // sum of 2 entities + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("total_marks")) + .isEqualTo(184L); + + // sum of 3 entities + datastore.put(AGGREGATION_ENTITY_3); + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("total_marks")) + .isEqualTo(239L); + } + + @Test + public void testSumAggregationWithResultOfDoubleType() { + datastore.put(AGGREGATION_ENTITY_1, AGGREGATION_ENTITY_2); + + EntityQuery baseQuery = Query.newEntityQueryBuilder().setKind(MARKS_KIND).build(); + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .over(baseQuery) + .addAggregations(sum("cgpa").as("total_cgpa")) + .setNamespace(NAMESPACE) + .build(); + + // sum of 2 entities + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getDouble("total_cgpa")) + .isEqualTo(16.61); + + // sum of 3 entities + datastore.put(AGGREGATION_ENTITY_3); + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getDouble("total_cgpa")) + .isEqualTo(21.77); + } + + @Test + public void testAvgAggregation() { + datastore.put(AGGREGATION_ENTITY_1, AGGREGATION_ENTITY_2); + + EntityQuery baseQuery = Query.newEntityQueryBuilder().setKind(MARKS_KIND).build(); + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .over(baseQuery) + .addAggregations(avg("marks").as("avg_marks")) + .setNamespace(NAMESPACE) + .build(); + + // avg of 2 entities + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getDouble("avg_marks")) + .isEqualTo(92D); + + // avg of 3 entities + datastore.put(AGGREGATION_ENTITY_3); + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getDouble("avg_marks")) + .isEqualTo(79.66666666666667); + } + + @Test + public void testAvgAggregationWithAutoGeneratedAlias() { + datastore.put(AGGREGATION_ENTITY_1, AGGREGATION_ENTITY_2); + + EntityQuery baseQuery = Query.newEntityQueryBuilder().setKind(MARKS_KIND).build(); + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .over(baseQuery) + .addAggregations(avg("marks")) + .setNamespace(NAMESPACE) + .build(); + + // avg of 2 entities + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getDouble("property_1")) + .isEqualTo(92D); + + // avg of 3 entities + datastore.put(AGGREGATION_ENTITY_3); + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getDouble("property_1")) + .isEqualTo(79.66666666666667); + } + + @Test + public void testAvgAggregationInGqlQuery() { + datastore.put(AGGREGATION_ENTITY_1, AGGREGATION_ENTITY_2); + + GqlQuery gqlQuery = + Query.newGqlQueryBuilder("AGGREGATE AVG(marks) AS avg_marks OVER (SELECT * FROM Marks)") + .build(); + + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder().over(gqlQuery).setNamespace(NAMESPACE).build(); + + // avg of 2 entities + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getDouble("avg_marks")) + .isEqualTo(92D); + + // avg of 3 entities + datastore.put(AGGREGATION_ENTITY_3); + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getDouble("avg_marks")) + .isEqualTo(79.66666666666667); + } + + @Test + public void testSumAndAvgAggregationTogether() { + datastore.put(AGGREGATION_ENTITY_1, AGGREGATION_ENTITY_2); + + EntityQuery baseQuery = Query.newEntityQueryBuilder().setKind(MARKS_KIND).build(); + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .over(baseQuery) + .addAggregations(sum("marks").as("total_marks")) + .addAggregations(avg("marks").as("avg_marks")) + .setNamespace(NAMESPACE) + .build(); + + // sum of 2 entities + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("total_marks")) + .isEqualTo(184L); + // avg of 2 entities + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getDouble("avg_marks")) + .isEqualTo(92D); + } + + @Test + public void testTransactionShouldReturnAConsistentSnapshot() { + datastore.put(AGGREGATION_ENTITY_1, AGGREGATION_ENTITY_2); + + EntityQuery baseQuery = Query.newEntityQueryBuilder().setKind(MARKS_KIND).build(); + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .over(baseQuery) + .addAggregation(count().as("count")) + .addAggregations(sum("marks").as("total_marks")) + .addAggregations(avg("marks").as("avg_marks")) + .setNamespace(NAMESPACE) + .build(); + + // original entity count is 2 + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(2L); + + // FIRST TRANSACTION + datastore.runInTransaction( + (TransactionCallable) + inFirstTransaction -> { + // creating a new entity + inFirstTransaction.put(AGGREGATION_ENTITY_3); + + // aggregation result consistently being produced for original 2 entities + AggregationResult aggregationResult = + getOnlyElement(inFirstTransaction.runAggregation(aggregationQuery)); + assertThat(aggregationResult.getLong("count")).isEqualTo(2L); + assertThat(aggregationResult.getLong("total_marks")).isEqualTo(184L); + assertThat(aggregationResult.getDouble("avg_marks")).isEqualTo(92D); + return null; + }); + + // after first transaction is committed, we have 3 entities now. + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(3L); + + // SECOND TRANSACTION + datastore.runInTransaction( + (TransactionCallable) + inSecondTransaction -> { + // deleting ENTITY3 + inSecondTransaction.delete(AGGREGATION_ENTITY_3.getKey()); + + // aggregation result still coming for 3 entities + AggregationResult aggregationResult = + getOnlyElement(inSecondTransaction.runAggregation(aggregationQuery)); + assertThat(aggregationResult.getLong("count")).isEqualTo(3L); + assertThat(aggregationResult.getLong("total_marks")).isEqualTo(239L); + assertThat(aggregationResult.getDouble("avg_marks")).isEqualTo(79.66666666666667); + return null; + }); + + // after second transaction is committed, we are back to 2 entities now. + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(2L); + } + + @Test + public void testReadOnlyTransactionShouldNotLockTheDocuments() + throws ExecutionException, InterruptedException { + ExecutorService executor = Executors.newSingleThreadExecutor(); + datastore.put(AGGREGATION_ENTITY_1, AGGREGATION_ENTITY_2); + + EntityQuery baseQuery = Query.newEntityQueryBuilder().setKind(MARKS_KIND).build(); + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .over(baseQuery) + .addAggregation(count().as("count")) + .addAggregations(sum("marks").as("total_marks")) + .addAggregations(avg("marks").as("avg_marks")) + .setNamespace(NAMESPACE) + .build(); + + TransactionOptions transactionOptions = + TransactionOptions.newBuilder().setReadOnly(ReadOnly.newBuilder().build()).build(); + Transaction readOnlyTransaction = datastore.newTransaction(transactionOptions); + + // Executing query in transaction, results for original 2 entities + AggregationResult aggregationResult = + getOnlyElement(readOnlyTransaction.runAggregation(aggregationQuery)); + assertThat(aggregationResult.getLong("count")).isEqualTo(2L); + assertThat(aggregationResult.getLong("total_marks")).isEqualTo(184L); + assertThat(aggregationResult.getDouble("avg_marks")).isEqualTo(92D); + + // Concurrent write task. + Future addNewEntityTaskOutsideTransaction = + executor.submit( + () -> { + datastore.put(AGGREGATION_ENTITY_3); + return null; + }); + + // should not throw exception and complete successfully as the ongoing transaction is read-only. + addNewEntityTaskOutsideTransaction.get(); + + // cleanup + readOnlyTransaction.commit(); + executor.shutdownNow(); + + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(3L); + } + + private void testCountAggregationWith(Consumer configurer) { + AggregationQuery.Builder builder = Query.newAggregationQueryBuilder().setNamespace(NAMESPACE); + configurer.accept(builder); + AggregationQuery aggregationQuery = builder.build(); + String alias = "total_count"; + + Long countBeforeAdd = getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong(alias); + long expectedCount = countBeforeAdd + 1; + + Entity newEntity = + Entity.newBuilder(ENTITY1) + .setKey(Key.newBuilder(KEY3, KIND1, 1).build()) + .set("null", NULL_VALUE) + .set("partial1", PARTIAL_ENTITY2) + .set("partial2", ENTITY2) + .build(); + datastore.put(newEntity); + + Long countAfterAdd = getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong(alias); + assertThat(countAfterAdd).isEqualTo(expectedCount); + + datastore.delete(newEntity.getKey()); + } + + private void testCountAggregationWithLimit( + Consumer withoutLimitConfigurer, + BiConsumer withLimitConfigurer) { + String alias = "total_count"; + + AggregationQuery.Builder withoutLimitBuilder = + Query.newAggregationQueryBuilder().setNamespace(NAMESPACE); + withoutLimitConfigurer.accept(withoutLimitBuilder); + + Long currentCount = + getOnlyElement(datastore.runAggregation(withoutLimitBuilder.build())).getLong(alias); + long limit = currentCount - 1; + + AggregationQuery.Builder withLimitBuilder = + Query.newAggregationQueryBuilder().setNamespace(NAMESPACE); + withLimitConfigurer.accept(withLimitBuilder, limit); + + Long countWithLimit = + getOnlyElement(datastore.runAggregation(withLimitBuilder.build())).getLong(alias); + assertThat(countWithLimit).isEqualTo(limit); + } + + private void testCountAggregationReadTimeWith(Consumer configurer) + throws InterruptedException { + Entity entity1 = + Entity.newBuilder( + Key.newBuilder(PROJECT_ID, "new_kind", "name-01") + .setDatabaseId(options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build()) + .set("name", "name01") + .build(); + Entity entity2 = + Entity.newBuilder( + Key.newBuilder(PROJECT_ID, "new_kind", "name-02") + .setDatabaseId(options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build()) + .set("name", "name02") + .build(); + Entity entity3 = + Entity.newBuilder( + Key.newBuilder(PROJECT_ID, "new_kind", "name-03") + .setDatabaseId(options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build()) + .set("name", "name03") + .build(); + + datastore.put(entity1, entity2); + Thread.sleep(1000); + Timestamp now = Timestamp.now(); + Thread.sleep(1000); + datastore.put(entity3); + + try { + AggregationQuery.Builder builder = Query.newAggregationQueryBuilder().setNamespace(NAMESPACE); + configurer.accept(builder); + AggregationQuery countAggregationQuery = builder.build(); + + Long latestCount = + getOnlyElement(datastore.runAggregation(countAggregationQuery)).getLong("total_count"); + assertThat(latestCount).isEqualTo(3L); + + ExplainOptions explainOptions = ExplainOptions.newBuilder().setAnalyze(true).build(); + AggregationResults results = + datastore.runAggregation(countAggregationQuery, explainOptions, ReadOption.readTime(now)); + Long oldCount = getOnlyElement(results).getLong("total_count"); + assertThat(oldCount).isEqualTo(2L); + assertPlanSummary(results.getExplainMetrics().get().getPlanSummary()); + assertExecutionStats(results.getExplainMetrics().get().getExecutionStats().get(), 1, 1, "2"); + } finally { + datastore.delete(entity1.getKey(), entity2.getKey(), entity3.getKey()); + } + } + + /** + * if an entity is modified or deleted within a transaction, a query or lookup returns the + * original version of the entity as of the beginning of the transaction, or nothing if the entity + * did not exist then. + * + * @see + * Source + */ + @Test + public void testRunAggregationQueryInTransactionShouldReturnAConsistentSnapshot() { + Key newEntityKey = Key.newBuilder(KEY1, "newKind", "name-01").build(); + EntityQuery entityQuery = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setFilter(PropertyFilter.hasAncestor(KEY1)) + .build(); + + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .over(entityQuery) + .addAggregation(count().as("count")) + .build(); + + // original entity count is 2 + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(2L); + + // FIRST TRANSACTION + datastore.runInTransaction( + (TransactionCallable) + inFirstTransaction -> { + // creating a new entity + Entity aNewEntity = + Entity.newBuilder(ENTITY2).setKey(newEntityKey).set("v_int", 10).build(); + inFirstTransaction.put(aNewEntity); + + // count remains 2 + assertThat( + getOnlyElement(inFirstTransaction.runAggregation(aggregationQuery)) + .getLong("count")) + .isEqualTo(2L); + assertThat( + getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(2L); + return null; + }); + // after first transaction is committed, count is updated to 3 now. + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(3L); + + // SECOND TRANSACTION + datastore.runInTransaction( + (TransactionCallable) + inSecondTransaction -> { + // deleting ENTITY2 + inSecondTransaction.delete(ENTITY2.getKey()); + + // count remains 3 + assertThat( + getOnlyElement(inSecondTransaction.runAggregation(aggregationQuery)) + .getLong("count")) + .isEqualTo(3L); + assertThat( + getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(3L); + return null; + }); + // after second transaction is committed, count is updated to 2 now. + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(2L); + datastore.delete(newEntityKey); + } + + @Test + public void testRunAggregationQueryInAReadOnlyTransactionShouldNotLockTheCountedDocuments() + throws Exception { + ExecutorService executor = Executors.newSingleThreadExecutor(); + EntityQuery entityQuery = + Query.newEntityQueryBuilder() + .setNamespace(NAMESPACE) + .setFilter(PropertyFilter.hasAncestor(KEY1)) + .build(); + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .setNamespace(NAMESPACE) + .over(entityQuery) + .addAggregation(count().as("count")) + .build(); + + TransactionOptions transactionOptions = + TransactionOptions.newBuilder().setReadOnly(ReadOnly.newBuilder().build()).build(); + Transaction readOnlyTransaction = datastore.newTransaction(transactionOptions); + + // Executing query in transaction + assertThat( + getOnlyElement(readOnlyTransaction.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(2L); + + // Concurrent write task. + Future addNewEntityTaskOutsideTransaction = + executor.submit( + () -> { + Entity aNewEntity = + Entity.newBuilder(ENTITY2) + .setKey(Key.newBuilder(KEY1, "newKind", "name-01").build()) + .set("v_int", 10) + .build(); + datastore.put(aNewEntity); + return null; + }); + + // should not throw exception and complete successfully as the ongoing transaction is read-only. + addNewEntityTaskOutsideTransaction.get(); + + // cleanup + readOnlyTransaction.commit(); + executor.shutdownNow(); + + assertThat(getOnlyElement(datastore.runAggregation(aggregationQuery)).getLong("count")) + .isEqualTo(3L); + } + + @Test + public void testRunAggregationQueryWithReadTime() throws InterruptedException { + String alias = "total_count"; + + // verifying aggregation readTime with an entity query + testCountAggregationReadTimeWith( + builder -> + builder + .over(Query.newEntityQueryBuilder().setKind("new_kind").build()) + .addAggregation(count().as(alias))); + + // verifying aggregation readTime with a projection query + testCountAggregationReadTimeWith( + builder -> + builder + .over( + Query.newProjectionEntityQueryBuilder() + .setProjection("name") + .setKind("new_kind") + .build()) + .addAggregation(count().as(alias))); + + // verifying aggregation readTime with a key query + testCountAggregationReadTimeWith( + builder -> + builder + .over(Query.newKeyQueryBuilder().setKind("new_kind").build()) + .addAggregation(count().as(alias))); + + // verifying aggregation readTime with a GQL query + testCountAggregationReadTimeWith( + builder -> + builder + .over( + Query.newGqlQueryBuilder( + "AGGREGATE COUNT(*) AS total_count OVER (SELECT * FROM new_kind)") + .build()) + .addAggregation(count().as(alias))); + } + + @Test + public void testRunStructuredQuery() throws InterruptedException { + Query query = + Query.newEntityQueryBuilder().setKind(KIND1).setOrderBy(OrderBy.asc("__key__")).build(); + + Query scQuery = + Query.newEntityQueryBuilder() + .setKind(KIND1) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .setOrderBy(OrderBy.asc("__key__")) + .build(); + + Iterator results1 = getStronglyConsistentResults(scQuery, query); + + assertTrue(results1.hasNext()); + assertEquals(ENTITY1, results1.next()); + assertFalse(results1.hasNext()); + + Query keyOnlyQuery = Query.newKeyQueryBuilder().setKind(KIND1).build(); + Query scKeyOnlyQuery = + Query.newKeyQueryBuilder() + .setKind(KIND1) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .build(); + + Iterator results2 = getStronglyConsistentResults(scKeyOnlyQuery, keyOnlyQuery); + assertTrue(results2.hasNext()); + assertEquals(ENTITY1.getKey(), results2.next()); + assertFalse(results2.hasNext()); + + StructuredQuery keyOnlyProjectionQuery = + Query.newProjectionEntityQueryBuilder().setKind(KIND1).setProjection("__key__").build(); + StructuredQuery scKeyOnlyProjectionQuery = + Query.newProjectionEntityQueryBuilder() + .setKind(KIND1) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .setProjection("__key__") + .build(); + Iterator results3 = + getStronglyConsistentResults(scKeyOnlyProjectionQuery, keyOnlyProjectionQuery); + assertTrue(results3.hasNext()); + ProjectionEntity projectionEntity = results3.next(); + assertEquals(ENTITY1.getKey(), projectionEntity.getKey()); + assertTrue(projectionEntity.getNames().isEmpty()); + assertFalse(results3.hasNext()); + + StructuredQuery projectionQuery = + Query.newProjectionEntityQueryBuilder() + .setKind(KIND2) + .setProjection("age") + .setFilter(PropertyFilter.gt("age", 18)) + .setDistinctOn("age") + .setOrderBy(OrderBy.asc("age")) + .setLimit(10) + .build(); + + StructuredQuery scProjectionQuery = + Query.newProjectionEntityQueryBuilder() + .setKind(KIND2) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .setProjection("age") + .setFilter(PropertyFilter.gt("age", 18)) + .setDistinctOn("age") + .setOrderBy(OrderBy.asc("age")) + .setLimit(10) + .build(); + + Iterator results4 = + getStronglyConsistentResults(scProjectionQuery, projectionQuery); + assertTrue(results4.hasNext()); + ProjectionEntity entity = results4.next(); + assertEquals(ENTITY2.getKey(), entity.getKey()); + assertEquals(20, entity.getLong("age")); + assertEquals(1, entity.getNames().size()); + assertFalse(results4.hasNext()); + } + + @Test + public void testInNotInNeqFilters() throws InterruptedException { + Entity e1 = + Entity.newBuilder(ENTITY1) + .setKey(Key.newBuilder(INCOMPLETE_KEY1, "e1").build()) + .set("v_int", 10) + .build(); + Entity e2 = + Entity.newBuilder(ENTITY1) + .setKey(Key.newBuilder(INCOMPLETE_KEY1, "e2").build()) + .set("v_int", 20) + .build(); + datastore.put(e1, e2); + + Query queryIn = + Query.newEntityQueryBuilder() + .setKind(KIND1) + .setFilter(PropertyFilter.in("v_int", ListValue.of(10, 20))) + .build(); + + Query scQueryIn = + Query.newEntityQueryBuilder() + .setKind(KIND1) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .setFilter(PropertyFilter.in("v_int", ListValue.of(10, 20))) + .build(); + + Iterator resultIn = getStronglyConsistentResults(scQueryIn, queryIn); + + assertTrue(resultIn.hasNext()); + assertEquals(e1, resultIn.next()); + assertTrue(resultIn.hasNext()); + assertEquals(e2, resultIn.next()); + assertFalse(resultIn.hasNext()); + + Query queryNotIn = + Query.newEntityQueryBuilder() + .setKind(KIND1) + .setFilter(PropertyFilter.not_in("v_int", ListValue.of(20, 30))) + .build(); + + Query scQueryNotIn = + Query.newEntityQueryBuilder() + .setKind(KIND1) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .setFilter(PropertyFilter.not_in("v_int", ListValue.of(20, 30))) + .build(); + + Iterator resultNotIn = getStronglyConsistentResults(scQueryNotIn, queryNotIn); + + assertTrue(resultNotIn.hasNext()); + assertEquals(e1, resultNotIn.next()); + assertFalse(resultNotIn.hasNext()); + + Query queryNeq = + Query.newEntityQueryBuilder() + .setKind(KIND1) + .setFilter(PropertyFilter.neq("v_int", 10)) + .build(); + + Query scQueryNeq = + Query.newEntityQueryBuilder() + .setKind(KIND1) + .setFilter(PropertyFilter.hasAncestor(ROOT_KEY)) + .setFilter(PropertyFilter.neq("v_int", 10)) + .build(); + + Iterator resultNeq = getStronglyConsistentResults(scQueryNeq, queryNeq); + + assertTrue(resultNeq.hasNext()); + assertEquals(e2, resultNeq.next()); + assertFalse(resultNeq.hasNext()); + + Query scQueryInEqOr = + Query.newEntityQueryBuilder() + .setKind(KIND1) + .setFilter( + CompositeFilter.or( + PropertyFilter.in("v_int", ListValue.of(10, 50000)), + PropertyFilter.eq("v_int", 10000))) + .build(); + + QueryResults run = datastore.run(scQueryInEqOr); + + assertTrue(run.hasNext()); + assertEquals(e1, run.next()); + assertFalse(run.hasNext()); + + datastore.delete(e1.getKey()); + datastore.delete(e2.getKey()); + } + + @Test + public void testAllocateId() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind(KIND1); + IncompleteKey pk1 = keyFactory.newKey(); + Key key1 = datastore.allocateId(pk1); + assertEquals(key1.getProjectId(), pk1.getProjectId()); + assertEquals(key1.getNamespace(), pk1.getNamespace()); + assertEquals(key1.getAncestors(), pk1.getAncestors()); + assertEquals(key1.getKind(), pk1.getKind()); + assertTrue(key1.hasId()); + assertFalse(key1.hasName()); + assertEquals(Key.newBuilder(pk1, key1.getId()).build(), key1); + + Key key2 = datastore.allocateId(pk1); + assertNotEquals(key1, key2); + assertEquals(Key.newBuilder(pk1, key2.getId()).build(), key2); + } + + @Test + public void testReserveIds() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind"); + Key key1 = keyFactory.newKey(10); + Key key2 = keyFactory.newKey("name"); + List keyList = datastore.reserveIds(key1, key2); + assertEquals(2, keyList.size()); + } + + @Test + public void testAllocateIdArray() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind(KIND1); + IncompleteKey incompleteKey1 = keyFactory.newKey(); + IncompleteKey incompleteKey2 = + keyFactory + .setKind(KIND2) + .setDatabaseId(options.getDatabaseId()) + .addAncestors(PathElement.of(KIND1, 10)) + .newKey(); + List result = datastore.allocateId(incompleteKey1, incompleteKey2, incompleteKey1); + assertEquals(3, result.size()); + assertEquals(Key.newBuilder(incompleteKey1, result.get(0).getId()).build(), result.get(0)); + assertEquals(Key.newBuilder(incompleteKey1, result.get(2).getId()).build(), result.get(2)); + assertEquals(Key.newBuilder(incompleteKey2, result.get(1).getId()).build(), result.get(1)); + } + + @Test + public void testGet() { + Entity entity = datastore.get(KEY3); + assertNull(entity); + + entity = datastore.get(KEY1); + assertEquals(ENTITY1, entity); + StringValue value1 = entity.getValue("str"); + assertEquals(STR_VALUE, value1); + BooleanValue value2 = entity.getValue("bool"); + assertEquals(BOOL_VALUE, value2); + ListValue value3 = entity.getValue("list"); + assertEquals(LIST_VALUE2, value3); + TimestampValue value4 = entity.getValue("date"); + assertEquals(TIMESTAMP_VALUE, value4); + LatLngValue value5 = entity.getValue("latLng"); + assertEquals(LAT_LNG_VALUE, value5); + FullEntity value6 = entity.getEntity("partial1"); + assertEquals(PARTIAL_ENTITY1, value6); + ListValue value7 = entity.getValue("emptyList"); + assertEquals(EMPTY_LIST_VALUE, value7); + assertEquals(7, entity.getNames().size()); + assertFalse(entity.contains("bla")); + } + + @Test + public void testIncompleteKey() { + Key parentKey = null; + try { + IncompleteKey incompleteKey = IncompleteKey.newBuilder(KEY6, KIND1).build(); + parentKey = incompleteKey.getParent(); + Entity entity = Entity.newBuilder(parentKey).set("name", "val").build(); + datastore.put(entity); + Entity retrievedEntity = datastore.get(parentKey); + assertThat(retrievedEntity).isEqualTo(entity); + } finally { + datastore.delete(parentKey); + } + } + + @Test + public void testGetWithReadTime() throws InterruptedException { + Key key = + Key.newBuilder(PROJECT_ID, "new_kind", "name", options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build(); + + try { + datastore.put(Entity.newBuilder(key).set("str", "old_str_value").build()); + + Thread.sleep(1000); + Timestamp now = Timestamp.now(); + Thread.sleep(1000); + + datastore.put(Entity.newBuilder(key).set("str", "new_str_value").build()); + + Entity entity = datastore.get(key); + StringValue value1 = entity.getValue("str"); + assertEquals(StringValue.of("new_str_value"), value1); + + entity = datastore.get(key, ReadOption.readTime(now)); + value1 = entity.getValue("str"); + assertEquals(StringValue.of("old_str_value"), value1); + } finally { + datastore.delete(key); + } + } + + @Test + public void testGetArrayNoDeferredResults() { + datastore.put(ENTITY3); + Iterator result = + datastore.fetch(KEY1, Key.newBuilder(KEY1).setName("bla").build(), KEY2, KEY3).iterator(); + assertEquals(ENTITY1, result.next()); + assertNull(result.next()); + assertEquals(ENTITY2, result.next()); + Entity entity3 = result.next(); + assertEquals(ENTITY3, entity3); + assertTrue(entity3.isNull("null")); + assertFalse(entity3.getBoolean("bool")); + assertEquals(LIST_VALUE2.get(), entity3.getList("list")); + FullEntity partial1 = entity3.getEntity("partial1"); + FullEntity partial2 = entity3.getEntity("partial2"); + assertEquals(PARTIAL_ENTITY2, partial1); + assertEquals(ENTITY2, partial2); + assertEquals(ValueType.BOOLEAN, entity3.getValue("bool").getType()); + assertEquals(LAT_LNG_VALUE, entity3.getValue("latLng")); + assertEquals(EMPTY_LIST_VALUE, entity3.getValue("emptyList")); + assertEquals(8, entity3.getNames().size()); + assertFalse(entity3.contains("bla")); + + DatastoreException expected = + assertThrows(DatastoreException.class, () -> entity3.getString("str")); + assertDatastoreException(expected, FAILED_PRECONDITION.name(), 0); + + assertFalse(result.hasNext()); + datastore.delete(ENTITY3.getKey()); + } + + @Test + public void testAddEntity() { + List keys = datastore.fetch(ENTITY1.getKey(), ENTITY3.getKey()); + assertEquals(ENTITY1, keys.get(0)); + assertNull(keys.get(1)); + assertEquals(2, keys.size()); + + DatastoreException expected = + assertThrows(DatastoreException.class, () -> datastore.add(ENTITY1)); + assertDatastoreException(expected, ALREADY_EXISTS.name(), 6); + + List entities = datastore.add(ENTITY3, PARTIAL_ENTITY1, PARTIAL_ENTITY2); + assertEquals(ENTITY3, datastore.get(ENTITY3.getKey())); + assertEquals(ENTITY3, entities.get(0)); + assertEquals(PARTIAL_ENTITY1.getNames(), entities.get(1).getNames()); + assertEquals(PARTIAL_ENTITY1.getKey().getAncestors(), entities.get(1).getKey().getAncestors()); + assertNotNull(datastore.get(entities.get(1).getKey())); + assertEquals(PARTIAL_ENTITY2.getNames(), entities.get(2).getNames()); + assertEquals(PARTIAL_ENTITY2.getKey().getAncestors(), entities.get(2).getKey().getAncestors()); + assertNotNull(datastore.get(entities.get(2).getKey())); + for (Entity entity : entities) { + datastore.delete(entity.getKey()); + } + } + + @Test + public void testUpdate() { + List keys = datastore.fetch(ENTITY1.getKey(), ENTITY3.getKey()); + assertEquals(ENTITY1, keys.get(0)); + assertNull(keys.get(1)); + assertEquals(2, keys.size()); + + DatastoreException expected = + assertThrows(DatastoreException.class, () -> datastore.update(ENTITY3)); + assertDatastoreException(expected, NOT_FOUND.name(), 5); + + datastore.add(ENTITY3); + assertEquals(ENTITY3, datastore.get(ENTITY3.getKey())); + Entity entity3 = Entity.newBuilder(ENTITY3).clear().set("bla", new NullValue()).build(); + assertNotEquals(ENTITY3, entity3); + datastore.update(entity3); + assertEquals(entity3, datastore.get(ENTITY3.getKey())); + datastore.delete(ENTITY3.getKey()); + } + + private void assertDatastoreException( + DatastoreException expected, String reason, int datastoreStatusCode) { + Truth.assertThat(expected.getReason()).isEqualTo(reason); + Truth.assertThat(expected.getCode()).isEqualTo(datastoreStatusCode); + } + + @Test + public void testPut() { + Entity updatedEntity = Entity.newBuilder(ENTITY1).set("new_property", 42L).build(); + assertEquals(updatedEntity, datastore.put(updatedEntity)); + assertEquals(updatedEntity, datastore.get(updatedEntity.getKey())); + + Entity entity2 = Entity.newBuilder(ENTITY2).clear().set("bla", new NullValue()).build(); + assertNotEquals(ENTITY2, entity2); + List entities = datastore.put(ENTITY1, entity2, ENTITY3, PARTIAL_ENTITY1); + assertEquals(ENTITY1, entities.get(0)); + assertEquals(entity2, entities.get(1)); + assertEquals(ENTITY3, entities.get(2)); + assertEquals(PARTIAL_ENTITY1.getNames(), entities.get(3).getNames()); + assertEquals(PARTIAL_ENTITY1.getKey().getAncestors(), entities.get(3).getKey().getAncestors()); + assertEquals(ENTITY1, datastore.get(ENTITY1.getKey())); + assertEquals(entity2, datastore.get(entity2.getKey())); + assertEquals(ENTITY3, datastore.get(ENTITY3.getKey())); + Entity entity = datastore.get(entities.get(3).getKey()); + assertEquals(entities.get(3), entity); + for (Entity entityToDelete : entities) { + datastore.delete(entityToDelete.getKey()); + } + } + + @Test + public void testDelete() { + Iterator keys = + datastore.fetch(ENTITY1.getKey(), ENTITY2.getKey(), ENTITY3.getKey()).iterator(); + assertEquals(ENTITY1, keys.next()); + assertEquals(ENTITY2, keys.next()); + assertNull(keys.next()); + assertFalse(keys.hasNext()); + datastore.delete(ENTITY1.getKey(), ENTITY2.getKey(), ENTITY3.getKey()); + keys = datastore.fetch(ENTITY1.getKey(), ENTITY2.getKey(), ENTITY3.getKey()).iterator(); + assertNull(keys.next()); + assertNull(keys.next()); + assertNull(keys.next()); + assertFalse(keys.hasNext()); + } + + @Test + public void testRunInTransaction() { + Datastore.TransactionCallable callable1 = + new Datastore.TransactionCallable() { + private Integer attempts = 1; + + @Override + public Integer run(DatastoreReaderWriter transaction) { + transaction.get(KEY1); + if (attempts < 2) { + ++attempts; + throw new DatastoreException(10, "", "ABORTED", false, null); + } + + return attempts; + } + }; + + int result = datastore.runInTransaction(callable1); + assertEquals(result, 2); + + Datastore.TransactionCallable callable2 = + new Datastore.TransactionCallable() { + private Integer attempts = 1; + + @Override + public Integer run(DatastoreReaderWriter transaction) { + transaction.get(KEY1); + if (attempts < 2) { + ++attempts; + throw new DatastoreException(4, "", "DEADLINE_EXCEEDED", false, null); + } + return attempts; + } + }; + + DatastoreException expected = + assertThrows(DatastoreException.class, () -> datastore.runInTransaction(callable2)); + assertDatastoreException((DatastoreException) expected.getCause(), DEADLINE_EXCEEDED.name(), 4); + } + + @Test + public void testRunInTransactionReadWrite() { + + final Entity entity1 = Entity.newBuilder(ENTITY1).clear().setNull("bla").build(); + + Datastore.TransactionCallable callable1 = + new Datastore.TransactionCallable() { + private Integer attempts = 1; + + @Override + public Integer run(DatastoreReaderWriter transaction) { + transaction.update(entity1); + if (attempts < 2) { + ++attempts; + throw new DatastoreException(10, "", "ABORTED", false, null); + } + + return attempts; + } + }; + + int result = datastore.runInTransaction(callable1); + assertEquals(result, 2); + + final Entity entity2 = Entity.newBuilder(ENTITY2).clear().setNull("bla").build(); + Datastore.TransactionCallable callable2 = + new Datastore.TransactionCallable() { + private Integer attempts = 1; + + @Override + public Integer run(DatastoreReaderWriter transaction) { + transaction.update(entity2); + if (attempts < 2) { + ++attempts; + throw new DatastoreException(10, "", "ABORTED", false, null); + } + + return attempts; + } + }; + + TransactionOptions readOnlyOptions = + TransactionOptions.newBuilder() + .setReadOnly(TransactionOptions.ReadOnly.getDefaultInstance()) + .build(); + + DatastoreException expected = + assertThrows( + DatastoreException.class, () -> datastore.runInTransaction(callable2, readOnlyOptions)); + assertDatastoreException((DatastoreException) expected.getCause(), INVALID_ARGUMENT.name(), 3); + } + + @Test + public void testSkippedResults() { + Query query = Query.newKeyQueryBuilder().setOffset(Integer.MAX_VALUE).build(); + int numberOfEntities = datastore.run(query).getSkippedResults(); + assertEquals(2, numberOfEntities); + } + + @Test + public void testSetLimit() { + datastore.put(ENTITY1); + Query keyQuery = Query.newKeyQueryBuilder().setLimit(1).build(); + QueryResults queryResults = datastore.run(keyQuery); + assertTrue(queryResults.hasNext()); + assertEquals(KEY1, queryResults.next()); + + Query query = Query.newEntityQueryBuilder().setLimit(0).build(); + QueryResults results = datastore.run(query); + assertFalse(results.hasNext()); + } + + @Test + public void testGqlQueryWithNullBinding() { + Query query = + Query.newGqlQueryBuilder(ResultType.ENTITY, "select * from " + KIND1) + .setNamespace(NAMESPACE) + .setNullBinding("name") + .build(); + Iterator results = datastore.run(query); + assertTrue(results.hasNext()); + assertEquals(ENTITY1, results.next()); + assertFalse(results.hasNext()); + } + + @Test + public void testQueryWithStartCursor() { + Entity entity1 = + Entity.newBuilder( + Key.newBuilder(PROJECT_ID, KIND1, "name-01", options.getDatabaseId()).build()) + .build(); + Entity entity2 = + Entity.newBuilder( + Key.newBuilder(PROJECT_ID, KIND1, "name-02", options.getDatabaseId()).build()) + .build(); + Entity entity3 = + Entity.newBuilder( + Key.newBuilder(PROJECT_ID, KIND1, "name-03", options.getDatabaseId()).build()) + .build(); + datastore.put(entity1, entity2, entity3); + QueryResults run1 = datastore.run(Query.newEntityQueryBuilder().setKind(KIND1).build()); + run1.next(); + Cursor cursor1 = run1.getCursorAfter(); + assertNotNull(cursor1); + QueryResults run2 = + datastore.run(Query.newEntityQueryBuilder().setKind(KIND1).setStartCursor(cursor1).build()); + Cursor cursor2 = run2.getCursorAfter(); + assertNotNull(cursor2); + assertEquals(cursor2, cursor1); + datastore.delete(entity1.getKey(), entity2.getKey(), entity3.getKey()); + } + + @Test + public void testQueryWithReadTime() throws InterruptedException { + Entity entity1 = + Entity.newBuilder( + Key.newBuilder(PROJECT_ID, "new_kind", "name-01") + .setDatabaseId(options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build()) + .build(); + Entity entity2 = + Entity.newBuilder( + Key.newBuilder(PROJECT_ID, "new_kind", "name-02") + .setDatabaseId(options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build()) + .build(); + Entity entity3 = + Entity.newBuilder( + Key.newBuilder(PROJECT_ID, "new_kind", "name-03") + .setDatabaseId(options.getDatabaseId()) + .setNamespace(NAMESPACE) + .build()) + .build(); + + datastore.put(entity1, entity2); + Thread.sleep(1000); + Timestamp now = Timestamp.now(); + Thread.sleep(1000); + datastore.put(entity3); + + try { + Query query = Query.newEntityQueryBuilder().setKind("new_kind").build(); + + QueryResults withoutReadTime = datastore.run(query); + assertTrue(withoutReadTime.hasNext()); + assertEquals(entity1, withoutReadTime.next()); + assertTrue(withoutReadTime.hasNext()); + assertEquals(entity2, withoutReadTime.next()); + assertTrue(withoutReadTime.hasNext()); + assertEquals(entity3, withoutReadTime.next()); + assertFalse(withoutReadTime.hasNext()); + + QueryResults withReadTime = datastore.run(query, ReadOption.readTime(now)); + assertTrue(withReadTime.hasNext()); + assertEquals(entity1, withReadTime.next()); + assertTrue(withReadTime.hasNext()); + assertEquals(entity2, withReadTime.next()); + assertFalse(withReadTime.hasNext()); + } finally { + datastore.delete(entity1.getKey(), entity2.getKey(), entity3.getKey()); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreConceptsTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreConceptsTest.java new file mode 100644 index 000000000000..097c0c90d326 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreConceptsTest.java @@ -0,0 +1,999 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.it; + +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.Assert.fail; + +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.Cursor; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreException; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.FullEntity; +import com.google.cloud.datastore.IncompleteKey; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +import com.google.cloud.datastore.KeyQuery; +import com.google.cloud.datastore.ListValue; +import com.google.cloud.datastore.PathElement; +import com.google.cloud.datastore.ProjectionEntity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.StringValue; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.datastore.StructuredQuery.CompositeFilter; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.cloud.datastore.Transaction; +import com.google.cloud.datastore.testing.RemoteDatastoreHelper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; +import com.google.datastore.v1.TransactionOptions; +import com.google.datastore.v1.TransactionOptions.ReadOnly; +import java.time.LocalDateTime; +import java.time.Month; +import java.time.ZoneOffset; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import org.junit.After; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +/* + * Test created based on ConceptsTest to run against GraalVM checks + */ +public class ITDatastoreConceptsTest { + private static final RemoteDatastoreHelper HELPER = RemoteDatastoreHelper.create(); + private static final DatastoreOptions OPTIONS = HELPER.getOptions(); + private static final FullEntity TEST_FULL_ENTITY = FullEntity.newBuilder().build(); + private static Datastore datastore; + private KeyFactory keyFactory; + private Key taskKey; + private Entity testEntity; + private Timestamp startDate; + private Timestamp endDate; + private Timestamp includedDate; + + private static final String TASK_CONCEPTS = "TaskConcepts"; + + /** Initializes Datastore for testing. */ + @BeforeClass + public static void beforeClass() throws Exception { + datastore = OPTIONS.getService(); + } + + /** Cleans out any residual values. Also initializes global variables used for testing. */ + @Before + public void setUp() { + StructuredQuery query = Query.newKeyQueryBuilder().build(); + QueryResults result = datastore.run(query); + datastore.delete(Iterators.toArray(result, Key.class)); + keyFactory = datastore.newKeyFactory().setKind(TASK_CONCEPTS); + taskKey = keyFactory.newKey("some-arbitrary-key"); + testEntity = Entity.newBuilder(taskKey, TEST_FULL_ENTITY).build(); + startDate = + Timestamp.ofTimeSecondsAndNanos( + LocalDateTime.of(1990, Month.JANUARY, 1, 1, 1, 1) + .toInstant(ZoneOffset.UTC) + .getEpochSecond(), + 0); + endDate = + Timestamp.ofTimeSecondsAndNanos( + LocalDateTime.of(2000, Month.JANUARY, 1, 1, 1, 1) + .toInstant(ZoneOffset.UTC) + .getEpochSecond(), + 0); + includedDate = + Timestamp.ofTimeSecondsAndNanos( + LocalDateTime.of(1999, Month.DECEMBER, 31, 1, 1, 1) + .toInstant(ZoneOffset.UTC) + .getEpochSecond(), + 0); + setUpQueryTests(); + } + + @After + public void tearDown() { + KeyQuery taskQuery = Query.newKeyQueryBuilder().setKind(TASK_CONCEPTS).build(); + Key[] taskKeysToDelete = Iterators.toArray(datastore.run(taskQuery), Key.class); + datastore.delete(taskKeysToDelete); + } + + private void assertValidKey(Key taskKey) { + datastore.put(Entity.newBuilder(taskKey, TEST_FULL_ENTITY).build()); + } + + private void assertValidEntity(Entity original) { + datastore.put(original); + assertEquals(original, datastore.get(original.getKey())); + } + + private List setUpBatchTests(Key taskKey1, Key taskKey2) { + Entity task1 = + Entity.newBuilder(taskKey1) + .set("category", "Personal") + .set("done", false) + .set("priority", 4) + .set("description", "Learn Cloud Datastore") + .build(); + Entity task2 = + Entity.newBuilder(taskKey2) + .set("category", "Personal") + .set("done", false) + .set("priority", 5) + .set("description", "Integrate Cloud Datastore") + .build(); + datastore.put(task1, task2); + return ImmutableList.of(task1, task2); + } + + private void setUpQueryTests() { + Key taskKey = + datastore + .newKeyFactory() + .setKind(TASK_CONCEPTS) + .addAncestors(PathElement.of("TaskList", "default")) + .newKey("someTask"); + datastore.put( + Entity.newBuilder(taskKey) + .set("category", "Personal") + .set("done", false) + .set("completed", false) + .set("priority", 4) + .set("created", includedDate) + .set("percent_complete", 10.0) + .set( + "description", + StringValue.newBuilder("Learn Cloud Datastore").setExcludeFromIndexes(true).build()) + .set("tag", "fun", "l", "programming", "learn") + .build()); + } + + private void assertValidQuery(Query query) { + QueryResults results = datastore.run(query); + assertTrue(results.hasNext()); + results.next(); + assertFalse(results.hasNext()); + } + + private void assertInvalidQuery(Query query) { + try { + datastore.run(query); + fail("should not reach here"); + } catch (DatastoreException ignored) { + } + } + + private List setUpTransferTests() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind("People"); + Key from = keyFactory.newKey("from"); + Key to = keyFactory.newKey("to"); + datastore.put(Entity.newBuilder(from).set("balance", 100).build()); + datastore.put(Entity.newBuilder(to).set("balance", 0).build()); + return ImmutableList.of(from, to); + } + + private void assertSuccessfulTransfer(Key from, Key to) { + assertEquals(90, datastore.get(from).getLong("balance")); + assertEquals(10, datastore.get(to).getLong("balance")); + } + + @Test + public void testIncompleteKey() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind(TASK_CONCEPTS); + Key taskKey = datastore.allocateId(keyFactory.newKey()); + assertValidKey(taskKey); + } + + @Test + public void testNamedKey() { + Key taskKey = datastore.newKeyFactory().setKind(TASK_CONCEPTS).newKey("sampleTask"); + assertValidKey(taskKey); + } + + @Test + public void testKeyWithParent() { + Key taskKey = + datastore + .newKeyFactory() + .addAncestors(PathElement.of("TaskList", "default")) + .setKind(TASK_CONCEPTS) + .newKey("sampleTask"); + assertValidKey(taskKey); + } + + @Test + public void testKeyWithMultilevelParent() { + KeyFactory keyFactory = + datastore + .newKeyFactory() + .addAncestors(PathElement.of("User", "Alice"), PathElement.of("TaskList", "default")) + .setKind(TASK_CONCEPTS); + Key taskKey = keyFactory.newKey("sampleTask"); + assertValidKey(taskKey); + } + + @Test + public void testEntityWithParent() { + Key taskKey = + datastore + .newKeyFactory() + .addAncestors(PathElement.of("TaskList", "default")) + .setKind(TASK_CONCEPTS) + .newKey("sampleTask"); + Entity task = + Entity.newBuilder(taskKey) + .set("category", "Personal") + .set("done", false) + .set("priority", 4) + .set("description", "Learn Cloud Datastore") + .build(); + assertValidEntity(task); + } + + @Test + public void testProperties() { + Entity task = + Entity.newBuilder(taskKey) + .set("category", "Personal") + .set("created", Timestamp.now()) + .set("done", false) + .set("priority", 4) + .set("percent_complete", 10.0) + .set( + "description", + StringValue.newBuilder("Learn Cloud Datastore").setExcludeFromIndexes(true).build()) + .build(); + assertValidEntity(task); + } + + @Test + public void testArrayValue() { + Entity task = + Entity.newBuilder(taskKey) + .set("tags", "fun", "programming") + .set("collaborators", ListValue.of("alice", "bob")) + .build(); + assertValidEntity(task); + } + + @Test + public void testBasicEntity() { + Key taskKey = datastore.newKeyFactory().setKind(TASK_CONCEPTS).newKey("sampleTask"); + Entity task = + Entity.newBuilder(taskKey) + .set("category", "Personal") + .set("done", false) + .set("priority", 4) + .set("description", "Learn Cloud Datastore") + .build(); + assertValidEntity(task); + } + + @Test + public void testUpsert() { + Entity task = Entity.newBuilder(keyFactory.newKey("sampleTask")).build(); + datastore.put(task); + assertEquals(task, datastore.get(task.getKey())); + } + + @Test + public void testInsert() { + Key taskKey = datastore.add(FullEntity.newBuilder(keyFactory.newKey()).build()).getKey(); + assertEquals(FullEntity.newBuilder(taskKey).build(), datastore.get(taskKey)); + } + + @Test + public void testLookup() { + datastore.put(testEntity); + Entity task = datastore.get(taskKey); + assertEquals(testEntity, task); + } + + @Test + public void testUpdate() { + datastore.put(testEntity); + Entity task = Entity.newBuilder(datastore.get(taskKey)).set("priority", 5).build(); + datastore.update(task); + assertEquals(task, datastore.get(taskKey)); + } + + @Test + public void testDelete() { + datastore.put(testEntity); + datastore.delete(taskKey); + assertNull(datastore.get(taskKey)); + } + + @Test + public void testBatchUpsert() { + FullEntity task1 = + FullEntity.newBuilder(keyFactory.newKey()) + .set("category", "Personal") + .set("done", false) + .set("priority", 4) + .set("description", "Learn Cloud Datastore") + .build(); + FullEntity task2 = + Entity.newBuilder(keyFactory.newKey()) + .set("category", "Personal") + .set("done", false) + .set("priority", 5) + .set("description", "Integrate Cloud Datastore") + .build(); + List tasks = datastore.add(task1, task2); + Key taskKey1 = tasks.get(0).getKey(); + Key taskKey2 = tasks.get(1).getKey(); + assertEquals(Entity.newBuilder(taskKey1, task1).build(), datastore.get(taskKey1)); + assertEquals(Entity.newBuilder(taskKey2, task2).build(), datastore.get(taskKey2)); + } + + @Test + public void testBatchLookup() { + Key taskKey1 = keyFactory.newKey(1); + Key taskKey2 = keyFactory.newKey(2); + List expectedTasks = setUpBatchTests(taskKey1, taskKey2); + Iterator tasks = datastore.get(taskKey1, taskKey2); + assertEquals(expectedTasks.get(0), tasks.next()); + assertEquals(expectedTasks.get(1), tasks.next()); + } + + @Test + public void testBatchDelete() { + Key taskKey1 = keyFactory.newKey(1); + Key taskKey2 = keyFactory.newKey(2); + setUpBatchTests(taskKey1, taskKey2); + datastore.delete(taskKey1, taskKey2); + assertNull(datastore.get(taskKey1)); + assertNull(datastore.get(taskKey2)); + } + + @Test + public void testBasicQuery() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter( + CompositeFilter.and( + PropertyFilter.eq("done", false), PropertyFilter.ge("priority", 4))) + .setOrderBy(OrderBy.desc("priority")) + .build(); + assertValidQuery(query); + } + + @Test + public void testRunQuery() { + Query query = Query.newEntityQueryBuilder().setKind(TASK_CONCEPTS).build(); + QueryResults tasks = datastore.run(query); + assertNotNull(tasks.next()); + assertFalse(tasks.hasNext()); + } + + @Test + public void testPropertyFilter() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.eq("done", false)) + .build(); + assertValidQuery(query); + } + + @Test + public void testCompositeFilter() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter( + CompositeFilter.and( + PropertyFilter.eq("done", false), PropertyFilter.eq("priority", 4))) + .build(); + assertValidQuery(query); + } + + @Test + public void testKeyFilter() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(StructuredQuery.PropertyFilter.gt("__key__", keyFactory.newKey("someTask"))) + .build(); + assertValidQuery(query); + } + + @Test + public void testAscendingSort() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setOrderBy(OrderBy.asc("created")) + .build(); + assertValidQuery(query); + } + + @Test + public void testDescendingSort() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setOrderBy(OrderBy.desc("created")) + .build(); + assertValidQuery(query); + } + + @Test + public void testMultiSort() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setOrderBy(OrderBy.desc("priority"), OrderBy.asc("created")) + .build(); + assertValidQuery(query); + } + + @Test + public void testKindlessQuery() { + Key lastSeenKey = keyFactory.newKey("a"); + + Query query = + Query.newEntityQueryBuilder().setFilter(PropertyFilter.gt("__key__", lastSeenKey)).build(); + assertValidQuery(query); + } + + @Test + public void testAncestorQuery() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter( + PropertyFilter.hasAncestor( + datastore.newKeyFactory().setKind("TaskList").newKey("default"))) + .build(); + assertValidQuery(query); + } + + @Test + public void testProjectionQuery() { + Query query = + Query.newProjectionEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setProjection("priority", "percent_complete") + .build(); + assertValidQuery(query); + } + + @Test + public void testRunProjectionQuery() { + Query query = + Query.newProjectionEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setProjection("priority", "percent_complete") + .build(); + List priorities = new LinkedList<>(); + List percentCompletes = new LinkedList<>(); + QueryResults tasks = datastore.run(query); + while (tasks.hasNext()) { + ProjectionEntity task = tasks.next(); + priorities.add(task.getLong("priority")); + percentCompletes.add(task.getDouble("percent_complete")); + } + assertEquals(ImmutableList.of(4L), priorities); + assertEquals(ImmutableList.of(10.0), percentCompletes); + } + + @Test + public void testKeysOnlyQuery() { + Query query = Query.newKeyQueryBuilder().setKind(TASK_CONCEPTS).build(); + assertValidQuery(query); + } + + @Test + public void testDistinctOnQuery() { + Query query = + Query.newProjectionEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setProjection("category", "priority") + .setDistinctOn("category") + .setOrderBy(OrderBy.asc("category"), OrderBy.asc("priority")) + .build(); + assertValidQuery(query); + } + + @Test + public void testArrayValueInequalityRange() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter( + CompositeFilter.and( + PropertyFilter.gt("tag", "learn"), PropertyFilter.lt("tag", "math"))) + .build(); + QueryResults results = datastore.run(query); + assertFalse(results.hasNext()); + } + + @Test + public void testArrayValueEquality() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter( + CompositeFilter.and( + PropertyFilter.eq("tag", "fun"), PropertyFilter.eq("tag", "programming"))) + .build(); + assertValidQuery(query); + } + + @Test + public void testInequalityRange() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter( + CompositeFilter.and( + PropertyFilter.gt("created", startDate), PropertyFilter.lt("created", endDate))) + .build(); + assertValidQuery(query); + } + + @Test + public void testInequalityValid() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter( + CompositeFilter.and( + PropertyFilter.gt("created", startDate), PropertyFilter.gt("priority", 3))) + .build(); + assertValidQuery(query); + } + + @Test + public void testEqualAndInequalityRange() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter( + CompositeFilter.and( + PropertyFilter.eq("priority", 4), + PropertyFilter.gt("created", startDate), + PropertyFilter.lt("created", endDate))) + .build(); + assertValidQuery(query); + } + + @Test + public void testInequalitySort() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.gt("priority", 3)) + .setOrderBy(OrderBy.asc("priority"), OrderBy.asc("created")) + .build(); + assertValidQuery(query); + } + + @Test + public void testInequalitySortInvalidNotSame() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.gt("priority", 3)) + .setOrderBy(OrderBy.asc("created")) + .build(); + assertInvalidQuery(query); + } + + @Test + public void testInequalitySortInvalidNotFirst() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.gt("priority", 3)) + .setOrderBy(OrderBy.asc("created"), OrderBy.asc("priority")) + .build(); + assertInvalidQuery(query); + } + + @Test + public void testLimit() { + Query query = Query.newEntityQueryBuilder().setKind(TASK_CONCEPTS).setLimit(5).build(); + assertValidQuery(query); + } + + @Test + public void testCursorPaging() { + datastore.put(testEntity); + Cursor nextPageCursor = cursorPaging(1, null); + assertNotNull(nextPageCursor); + nextPageCursor = cursorPaging(1, nextPageCursor); + assertNotNull(nextPageCursor); + } + + private Cursor cursorPaging(int pageSize, Cursor pageCursor) { + EntityQuery.Builder queryBuilder = + Query.newEntityQueryBuilder().setKind(TASK_CONCEPTS).setLimit(pageSize); + if (pageCursor != null) { + queryBuilder.setStartCursor(pageCursor); + } + QueryResults tasks = datastore.run(queryBuilder.build()); + while (tasks.hasNext()) { + Entity task = tasks.next(); + // do something with the task + } + Cursor nextPageCursor = tasks.getCursorAfter(); + return nextPageCursor; + } + + @Test + public void testEventualConsistentQuery() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter( + PropertyFilter.hasAncestor( + datastore.newKeyFactory().setKind("TaskList").newKey("default"))) + .build(); + datastore.run(query, ReadOption.eventualConsistency()); + assertValidQuery(query); + } + + @Test + public void testUnindexedPropertyQuery() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.eq("description", "A task description")) + .build(); + QueryResults results = datastore.run(query); + assertFalse(results.hasNext()); + } + + @Test + public void testExplodingProperties() { + Entity task = + Entity.newBuilder(taskKey) + .set("tags", "fun", "programming", "learn") + .set("collaborators", "alice", "bob", "charlie") + .set("created", Timestamp.now()) + .build(); + assertValidEntity(task); + } + + @Test + public void testTransactionalUpdate() { + List keys = setUpTransferTests(); + transferFunds(keys.get(0), keys.get(1), 10); + assertSuccessfulTransfer(keys.get(0), keys.get(1)); + } + + void transferFunds(Key fromKey, Key toKey, long amount) { + Transaction txn = datastore.newTransaction(); + try { + List entities = txn.fetch(fromKey, toKey); + Entity from = entities.get(0); + Entity updatedFrom = + Entity.newBuilder(from).set("balance", from.getLong("balance") - amount).build(); + Entity to = entities.get(1); + Entity updatedTo = + Entity.newBuilder(to).set("balance", to.getLong("balance") + amount).build(); + txn.put(updatedFrom, updatedTo); + txn.commit(); + } finally { + if (txn.isActive()) { + txn.rollback(); + } + } + } + + @Test + public void testTransactionalRetry() { + List keys = setUpTransferTests(); + Key fromKey = keys.get(0); + Key toKey = keys.get(1); + int retries = 5; + while (true) { + try { + transferFunds(fromKey, toKey, 10); + break; + } catch (DatastoreException e) { + if (retries == 0) { + throw e; + } + --retries; + } + } + assertSuccessfulTransfer(keys.get(0), keys.get(1)); + } + + @Test + public void testTransactionalGetOrCreate() { + Entity task; + Transaction txn = datastore.newTransaction(); + try { + task = txn.get(taskKey); + if (task == null) { + task = Entity.newBuilder(taskKey).build(); + txn.put(task); + txn.commit(); + } + } finally { + if (txn.isActive()) { + txn.rollback(); + } + } + assertEquals(task, datastore.get(taskKey)); + } + + @Test + public void testTransactionalSingleEntityGroupReadOnly() { + + Key taskListKey = datastore.newKeyFactory().setKind("TaskList").newKey("default"); + Entity taskListEntity = Entity.newBuilder(taskListKey).build(); + datastore.put(taskListEntity); + Entity taskList; + QueryResults tasks; + Transaction txn = + datastore.newTransaction( + TransactionOptions.newBuilder().setReadOnly(ReadOnly.newBuilder().build()).build()); + try { + taskList = txn.get(taskListKey); + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.hasAncestor(taskListKey)) + .build(); + tasks = txn.run(query); + txn.commit(); + } finally { + if (txn.isActive()) { + txn.rollback(); + } + } + assertEquals(taskListEntity, taskList); + assertNotNull(tasks.next()); + assertFalse(tasks.hasNext()); + } + + @Test + public void testNamespaceRunQuery() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind("__namespace__"); + Key namespaceKey = keyFactory.newKey(OPTIONS.getNamespace()); + Query query = + Query.newKeyQueryBuilder() + .setKind("__namespace__") + .setFilter(CompositeFilter.and(PropertyFilter.eq("__key__", namespaceKey))) + .build(); + List namespaces = new ArrayList<>(); + QueryResults results = datastore.run(query); + while (results.hasNext()) { + namespaces.add(results.next().getName()); + } + assertEquals(ImmutableList.of(OPTIONS.getNamespace()), namespaces); + } + + @Test + public void testKindRunQuery() { + Query query = Query.newKeyQueryBuilder().setKind("__kind__").build(); + List kinds = new ArrayList<>(); + QueryResults results = datastore.run(query); + while (results.hasNext()) { + kinds.add(results.next().getName()); + } + assertEquals(ImmutableList.of(TASK_CONCEPTS), kinds); + } + + @Test + public void testPropertyRunQuery() { + Query query = Query.newKeyQueryBuilder().setKind("__property__").build(); + QueryResults keys = datastore.run(query); + Map> propertiesByKind = new HashMap<>(); + while (keys.hasNext()) { + Key key = keys.next(); + String kind = key.getParent().getName(); + String propertyName = key.getName(); + Collection properties = propertiesByKind.computeIfAbsent(kind, k -> new HashSet<>()); + properties.add(propertyName); + } + Map> expected = + ImmutableMap.of( + TASK_CONCEPTS, + ImmutableSet.of( + "done", "category", "completed", "priority", "created", "percent_complete", "tag")); + assertEquals(expected, propertiesByKind); + } + + @Test + public void testPropertyByKindRunQuery() { + Key key = datastore.newKeyFactory().setKind("__kind__").newKey(TASK_CONCEPTS); + Query query = + Query.newEntityQueryBuilder() + .setKind("__property__") + .setFilter(PropertyFilter.hasAncestor(key)) + .build(); + QueryResults results = datastore.run(query); + Map> representationsByProperty = new HashMap<>(); + while (results.hasNext()) { + Entity result = results.next(); + String propertyName = result.getKey().getName(); + List representations = result.getList("property_representation"); + Collection currentRepresentations = + representationsByProperty.computeIfAbsent(propertyName, k -> new HashSet<>()); + for (StringValue value : representations) { + currentRepresentations.add(value.get()); + } + } + Map> expected = + ImmutableMap.>builder() + .put("category", Collections.singleton("STRING")) + .put("done", Collections.singleton("BOOLEAN")) + .put("completed", Collections.singleton("BOOLEAN")) + .put("priority", Collections.singleton("INT64")) + .put("created", Collections.singleton("INT64")) + .put("percent_complete", Collections.singleton("DOUBLE")) + .put("tag", Collections.singleton("STRING")) + .build(); + assertEquals(expected, representationsByProperty); + } + + @Test + public void testPropertyFilteringRunQuery() { + Key startKey = + datastore + .newKeyFactory() + .setKind("__property__") + .addAncestors(PathElement.of("__kind__", TASK_CONCEPTS)) + .newKey("priority"); + Query query = + Query.newKeyQueryBuilder() + .setKind("__property__") + .setFilter(PropertyFilter.ge("__key__", startKey)) + .build(); + Map> propertiesByKind = new HashMap<>(); + QueryResults keys = datastore.run(query); + while (keys.hasNext()) { + Key key = keys.next(); + String kind = key.getParent().getName(); + String propertyName = key.getName(); + Collection properties = propertiesByKind.computeIfAbsent(kind, k -> new HashSet<>()); + properties.add(propertyName); + } + Map> expected = + ImmutableMap.of(TASK_CONCEPTS, ImmutableSet.of("priority", "tag")); + assertEquals(expected, propertiesByKind); + } + + @Test + public void testEqQuerySorted() { + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.eq("tag", "learn")) + .setOrderBy(OrderBy.asc("tag")) + .build(); + assertValidQuery(query); + } + + private void setUpQueryTestsRealBackend() { + Key taskKey = + datastore + .newKeyFactory() + .setKind(TASK_CONCEPTS) + .addAncestors(PathElement.of("TaskList", "default")) + .newKey("someTask"); + datastore.put( + Entity.newBuilder(taskKey) + .set("category", "Personal") + .set("done", false) + .set("completed", false) + .set("priority", 4) + .set("created", includedDate) + .set("percent_complete", 10.0) + .set( + "description", + StringValue.newBuilder("Learn Cloud Datastore").setExcludeFromIndexes(true).build()) + .set("tag", "fun", "l", "programming", "learn") + .build()); + } + + @Test + public void testInQuery() { + setUpQueryTestsRealBackend(); + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.in("tag", ListValue.of("learn", "study"))) + .build(); + assertValidQuery(query); + } + + @Test + public void testNotEqualsQuery() { + setUpQueryTestsRealBackend(); + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.neq("category", "Work")) + .build(); + assertValidQuery(query); + } + + @Test + public void testNotInQuery() { + setUpQueryTestsRealBackend(); + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.not_in("category", ListValue.of("Work", "Chores", "School"))) + .build(); + assertValidQuery(query); + } + + @Test + public void testInQuerySorted() { + setUpQueryTestsRealBackend(); + Query query = + Query.newEntityQueryBuilder() + .setKind(TASK_CONCEPTS) + .setFilter(PropertyFilter.in("tag", ListValue.of("learn", "study"))) + .setOrderBy(OrderBy.asc("tag")) + .build(); + assertValidQuery(query); + } + + @Test + public void testStaleReads() throws InterruptedException { + setUpQueryTestsRealBackend(); + // waiting for 6 seconds, so that we can query with read time of 5 seconds ago + TimeUnit.SECONDS.sleep(6); + Key taskKey = + datastore + .newKeyFactory() + .setKind(TASK_CONCEPTS) + .addAncestors(PathElement.of("TaskList", "default")) + .newKey("someTask"); + + Timestamp fiveSecondsAgo = + Timestamp.ofTimeSecondsAndNanos(Timestamp.now().getSeconds() - 5L, 0); + // Create a readOption with read time fiveSecondsAgo + ReadOption readOption = ReadOption.readTime(fiveSecondsAgo); + // Use the readOption to Fetch entity + Entity entity = datastore.get(taskKey, readOption); + + // Use the readOption to Query kind Task + Query query = Query.newEntityQueryBuilder().setKind(TASK_CONCEPTS).setLimit(10).build(); + assertValidQuery(query); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTestGrpc.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTestGrpc.java new file mode 100644 index 000000000000..5002c5973e71 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTestGrpc.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 + * + * 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.datastore.it; + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.testing.RemoteDatastoreHelper; +import com.google.cloud.grpc.GrpcTransportOptions; +import com.google.common.truth.Truth; +import java.util.Arrays; +import org.junit.AfterClass; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class ITDatastoreTestGrpc extends AbstractITDatastoreTest { + // setup for default db, grpc transport + protected static final RemoteDatastoreHelper HELPER_DEFAULT_GRPC = + RemoteDatastoreHelper.create(GrpcTransportOptions.newBuilder().build()); + private static final DatastoreOptions OPTIONS_DEFAULT_GRPC = HELPER_DEFAULT_GRPC.getOptions(); + private static final Datastore DATASTORE_DEFAULT_GRPC = OPTIONS_DEFAULT_GRPC.getService(); + + // setup for custom db, grpc transport + private static final RemoteDatastoreHelper HELPER_CUSTOM_DB_GRPC = + RemoteDatastoreHelper.create(CUSTOM_DB_ID, GrpcTransportOptions.newBuilder().build()); + private static final DatastoreOptions OPTIONS_CUSTOM_DB_GRPC = HELPER_CUSTOM_DB_GRPC.getOptions(); + private static final Datastore DATASTORE_CUSTOM_DB_GRPC = OPTIONS_CUSTOM_DB_GRPC.getService(); + + public ITDatastoreTestGrpc(DatastoreOptions options, Datastore datastore, String databaseType) { + super(options, datastore, databaseType); + } + + @Parameterized.Parameters(name = "database: {2}") + public static Iterable data() { + return Arrays.asList( + new Object[][] { + {OPTIONS_DEFAULT_GRPC, DATASTORE_DEFAULT_GRPC, "default"}, + {OPTIONS_CUSTOM_DB_GRPC, DATASTORE_CUSTOM_DB_GRPC, CUSTOM_DB_ID}, + }); + } + + @AfterClass + public static void afterClass() throws Exception { + HELPER_DEFAULT_GRPC.deleteNamespace(); + HELPER_CUSTOM_DB_GRPC.deleteNamespace(); + DATASTORE_DEFAULT_GRPC.close(); + DATASTORE_CUSTOM_DB_GRPC.close(); + Truth.assertThat(DATASTORE_DEFAULT_GRPC.isClosed()).isTrue(); + Truth.assertThat(DATASTORE_CUSTOM_DB_GRPC.isClosed()).isTrue(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTestHttp.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTestHttp.java new file mode 100644 index 000000000000..f343dabc2ce6 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITDatastoreTestHttp.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 + * + * 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.datastore.it; + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.testing.RemoteDatastoreHelper; +import java.util.Arrays; +import org.junit.AfterClass; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class ITDatastoreTestHttp extends AbstractITDatastoreTest { + // setup for default db, http transport + private static final RemoteDatastoreHelper HELPER_DEFAULT_HTTP = RemoteDatastoreHelper.create(); + + private static final DatastoreOptions OPTIONS_DEFAULT_HTTP = HELPER_DEFAULT_HTTP.getOptions(); + private static final Datastore DATASTORE_DEFAULT_HTTP = OPTIONS_DEFAULT_HTTP.getService(); + + // setup for custom db, http transport + private static final RemoteDatastoreHelper HELPER_CUSTOM_DB_HTTP = + RemoteDatastoreHelper.create(CUSTOM_DB_ID); + private static final DatastoreOptions OPTIONS_CUSTOM_DB_HTTP = HELPER_CUSTOM_DB_HTTP.getOptions(); + private static final Datastore DATASTORE_CUSTOM_DB_HTTP = OPTIONS_CUSTOM_DB_HTTP.getService(); + + public ITDatastoreTestHttp(DatastoreOptions options, Datastore datastore, String databaseType) { + super(options, datastore, databaseType); + } + + @Parameterized.Parameters(name = "database: {2}") + public static Iterable data() { + return Arrays.asList( + new Object[][] { + {OPTIONS_DEFAULT_HTTP, DATASTORE_DEFAULT_HTTP, "default"}, + {OPTIONS_CUSTOM_DB_HTTP, DATASTORE_CUSTOM_DB_HTTP, CUSTOM_DB_ID}, + }); + } + + @AfterClass + public static void afterClass() throws Exception { + HELPER_DEFAULT_HTTP.deleteNamespace(); + HELPER_CUSTOM_DB_HTTP.deleteNamespace(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITE2ETracingTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITE2ETracingTest.java new file mode 100644 index 000000000000..a61bb54358c1 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITE2ETracingTest.java @@ -0,0 +1,1009 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.it; + +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_ALLOCATE_IDS; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_BEGIN_TRANSACTION; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_COMMIT; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_LOOKUP; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RESERVE_IDS; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_ROLLBACK; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RUN_AGGREGATION_QUERY; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_RUN_QUERY; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_COMMIT; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_LOOKUP; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_RUN; +import static com.google.cloud.datastore.telemetry.TraceUtil.SPAN_NAME_TRANSACTION_RUN_QUERY; +import static com.google.common.truth.Truth.assertThat; +import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME; +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 com.google.api.gax.rpc.NotFoundException; +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.IncompleteKey; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.cloud.datastore.Transaction; +import com.google.cloud.datastore.testing.RemoteDatastoreHelper; +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 com.google.testing.junit.testparameterinjector.TestParameter; +import com.google.testing.junit.testparameterinjector.TestParameterInjector; +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.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.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; +import org.junit.runner.RunWith; + +// 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, Datastore client is provided the OpenTelemetry SDK object from (1) +// 3. A custom TraceID is generated and injected using a custom SpanContext +// 4. Datastore 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. +@RunWith(TestParameterInjector.class) +public class ITE2ETracingTest { + + protected boolean isUsingGlobalOpenTelemetrySDK() { + return useGlobalOpenTelemetrySDK; + } + + protected String datastoreNamedDatabase() { + return datastoreNamedDatabase; + } + + // 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 expectedCallStack.size() <= 1; + } 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 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 = 5000; + + private static final int TRACE_PROVIDER_SHUTDOWN_MILLIS = 1000; + + private static Key KEY1; + + private static Key KEY2; + + private static Key KEY3; + + private static Key KEY4; + + // Random int generator for trace ID and span ID + private static Random random; + + private static TraceExporter 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 String projectId; + + private static DatastoreOptions options; + + private static Datastore datastore; + + private static RemoteDatastoreHelper remoteDatastoreHelper; + + @TestParameter boolean useGlobalOpenTelemetrySDK; + + @TestParameter({ + /*(default)*/ + "", + "test-db" + }) + String datastoreNamedDatabase; + + @BeforeClass + public static void setup() throws IOException { + projectId = DatastoreOptions.getDefaultProjectId(); + 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().merge(Resource.builder().put(SERVICE_NAME, "Sparky").build()); + + if (isUsingGlobalOpenTelemetrySDK()) { + 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 Datastore DB w/ the OTel SDK. Ideally we'd do this is the @BeforeAll method + // but because gRPC traces need to be deterministically force-flushed for every test + String namedDb = datastoreNamedDatabase(); + logger.log(Level.INFO, "Integration test using named database " + namedDb); + remoteDatastoreHelper = RemoteDatastoreHelper.create(namedDb, openTelemetrySdk); + options = remoteDatastoreHelper.getOptions(); + datastore = options.getService(); + + Preconditions.checkNotNull( + datastore, + "Error instantiating Datastore. Check that the service account credentials " + + "were properly set."); + + String projectId = options.getProjectId(); + String kind1 = "kind1"; + KEY1 = + Key.newBuilder(projectId, kind1, "key1", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY2 = + Key.newBuilder(projectId, kind1, "key2", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY3 = + Key.newBuilder(projectId, kind1, "key3", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY4 = + Key.newBuilder(projectId, kind1, "key4", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + // 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 = + datastore + .getOptions() + .getOpenTelemetryOptions() + .getOpenTelemetry() + .getTracer(rootSpanName); + } + + // Get up a new SpanContext (ergo TraceId) for each test + customSpanContext = getNewSpanContext(); + assertNotNull(customSpanContext); + assertNull(retrievedTrace); + } + + @After + public void after() throws Exception { + if (isUsingGlobalOpenTelemetrySDK()) { + GlobalOpenTelemetry.resetForTest(); + } + remoteDatastoreHelper.deleteNamespace(); + rootSpanName = null; + tracer = null; + retrievedTrace = null; + customSpanContext = null; + openTelemetrySdk = null; + } + + @AfterClass + public static void teardown() throws Exception { + traceClient_v1.close(); + } + + // Generates a random hex string of length `numBytes` + private String generateRandomHexString(int numBytes) { + StringBuilder newTraceId = new StringBuilder(); + 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 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: " + + Arrays.toString(expectedCallList) + + ", 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()) { + Entity entity = datastore.get(KEY1); + assertNull(entity); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + Trace traceResp = null; + int expectedSpanCount = 2; + + 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, SPAN_NAME_LOOKUP)); + + // Top-level mismatch + assertFalse(traceCont.containsCallStack(SPAN_NAME_LOOKUP, RUN_QUERY_RPC_NAME)); + + // Leaf-level mismatch/missing + assertFalse( + traceCont.containsCallStack( + rootSpanName, SPAN_NAME_LOOKUP, RUN_AGGREGATION_QUERY_RPC_NAME)); + } + + @Test + public void lookupTraceTest() 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()) { + Entity entity = datastore.get(KEY1); + assertNull(entity); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_LOOKUP); + } + + @Test + public void allocateIdsTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + String kind1 = "kind1"; + KeyFactory keyFactory = datastore.newKeyFactory().setKind(kind1); + IncompleteKey pk1 = keyFactory.newKey(); + Key key1 = datastore.allocateId(pk1); + assertEquals(key1.getProjectId(), pk1.getProjectId()); + assertEquals(key1.getNamespace(), pk1.getNamespace()); + assertEquals(key1.getAncestors(), pk1.getAncestors()); + assertEquals(key1.getKind(), pk1.getKind()); + assertTrue(key1.hasId()); + assertFalse(key1.hasName()); + assertEquals(Key.newBuilder(pk1, key1.getId()).build(), key1); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_ALLOCATE_IDS); + } + + @Test + public void reserveIdsTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind"); + Key key1 = keyFactory.newKey(10); + Key key2 = keyFactory.newKey("name"); + List keyList = datastore.reserveIds(key1, key2); + assertEquals(2, keyList.size()); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_RESERVE_IDS); + } + + @Test + public void commitTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + try (Scope ignored = rootSpan.makeCurrent()) { + Entity response = datastore.add(entity1); + assertEquals(entity1, response); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_COMMIT); + } + + @Test + public void putTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + try (Scope ignored = rootSpan.makeCurrent()) { + Entity response = datastore.put(entity1); + assertEquals(entity1, response); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_COMMIT); + } + + @Test + public void updateTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Entity entity1_update = + Entity.newBuilder(entity1).set("test_field", "new_test_value1").build(); + Entity entity2_update = + Entity.newBuilder(entity2).set("test_field", "new_test_value1").build(); + datastore.update(entity1_update, entity2_update); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_COMMIT); + } + + @Test + public void deleteTraceTest() throws Exception { + assertNotNull(customSpanContext); + + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + Entity response = datastore.put(entity1); + assertEquals(entity1, response); + + Span rootSpan = getNewRootSpanWithContext(); + + try (Scope ignored = rootSpan.makeCurrent()) { + datastore.delete(entity1.getKey()); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_COMMIT); + } + + @Test + public void runQueryTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + QueryResults queryResults = datastore.run(query); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_RUN_QUERY); + } + + @Test + public void runAggregationQueryTraceTest() throws Exception { + Entity entity1 = + Entity.newBuilder(KEY1) + .set("pepper_name", "jalapeno") + .set("max_scoville_level", 10000) + .build(); + Entity entity2 = + Entity.newBuilder(KEY2) + .set("pepper_name", "serrano") + .set("max_scoville_level", 25000) + .build(); + Entity entity3 = + Entity.newBuilder(KEY3) + .set("pepper_name", "habanero") + .set("max_scoville_level", 350000) + .build(); + Entity entity4 = + Entity.newBuilder(KEY4) + .set("pepper_name", "ghost") + .set("max_scoville_level", 1500000) + .build(); + + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + entityList.add(entity3); + entityList.add(entity4); + + List response = datastore.add(entity1, entity2, entity3, entity4); + assertEquals(entityList, response); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + PropertyFilter mediumSpicyFilters = PropertyFilter.lt("max_scoville_level", 100000); + StructuredQuery mediumSpicyQuery = + Query.newEntityQueryBuilder() + .setKind(KEY1.getKind()) + .setFilter(mediumSpicyFilters) + .build(); + AggregationQuery countSpicyPeppers = + Query.newAggregationQueryBuilder() + .addAggregation(count().as("count")) + .over(mediumSpicyQuery) + .build(); + AggregationResults results = datastore.runAggregation(countSpicyPeppers); + assertThat(results.size()).isEqualTo(1); + AggregationResult result = results.get(0); + assertThat(result.getLong("count")).isEqualTo(2L); + } finally { + rootSpan.end(); + } + + waitForTracesToComplete(); + + fetchAndValidateTrace(customSpanContext.getTraceId(), SPAN_NAME_RUN_AGGREGATION_QUERY); + } + + @Test + public void newTransactionReadTest() throws Exception { + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Transaction transaction = datastore.newTransaction(); + Entity entity = datastore.get(KEY1, ReadOption.transactionId(transaction.getTransactionId())); + transaction.commit(); + assertNull(entity); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /* numExpectedSpans= */ 3, + Arrays.asList( + Collections.singletonList(SPAN_NAME_BEGIN_TRANSACTION), + Collections.singletonList(SPAN_NAME_TRANSACTION_LOOKUP), + Collections.singletonList(SPAN_NAME_TRANSACTION_COMMIT))); + } + + @Test + public void newTransactionQueryTest() throws Exception { + // Set up + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + assertNotNull(customSpanContext); + + // Test + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Transaction transaction = datastore.newTransaction(); + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + QueryResults queryResults = transaction.run(query); + transaction.commit(); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /* numExpectedSpans= */ 3, + Arrays.asList( + Collections.singletonList(SPAN_NAME_BEGIN_TRANSACTION), + Collections.singletonList(SPAN_NAME_TRANSACTION_RUN_QUERY), + Collections.singletonList(SPAN_NAME_TRANSACTION_COMMIT))); + } + + @Test + public void newTransactionReadWriteTraceTest() throws Exception { + // Set up + Entity entity1 = Entity.newBuilder(KEY1).set("pepper_type", "jalapeno").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("pepper_type", "habanero").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + String simplified_spice_level = "not_spicy"; + Entity entity1update = + Entity.newBuilder(entity1).set("spice_level", simplified_spice_level).build(); + + assertNotNull(customSpanContext); + + // Test + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Transaction transaction = datastore.newTransaction(); + entity1 = transaction.get(KEY1); + switch (entity1.getString("pepper_type")) { + case "jalapeno": + simplified_spice_level = "mild"; + break; + + case "habanero": + simplified_spice_level = "hot"; + break; + } + transaction.update(entity1update); + transaction.delete(KEY2); + transaction.commit(); + assertFalse(transaction.isActive()); + } finally { + rootSpan.end(); + } + + waitForTracesToComplete(); + + List list = datastore.fetch(KEY1, KEY2); + assertEquals(list.get(0), entity1update); + assertNull(list.get(1)); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /* numExpectedSpans= */ 3, + Arrays.asList( + Collections.singletonList(SPAN_NAME_BEGIN_TRANSACTION), + Collections.singletonList(SPAN_NAME_TRANSACTION_LOOKUP), + Collections.singletonList(SPAN_NAME_TRANSACTION_COMMIT))); + } + + @Test + public void newTransactionRollbackTest() throws Exception { + // Set up + Entity entity1 = Entity.newBuilder(KEY1).set("pepper_type", "jalapeno").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("pepper_type", "habanero").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + String simplified_spice_level = "not_spicy"; + Entity entity1update = + Entity.newBuilder(entity1).set("spice_level", simplified_spice_level).build(); + + assertNotNull(customSpanContext); + + // Test + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + Transaction transaction = datastore.newTransaction(); + entity1 = transaction.get(KEY1); + switch (entity1.getString("pepper_type")) { + case "jalapeno": + simplified_spice_level = "mild"; + break; + + case "habanero": + simplified_spice_level = "hot"; + break; + } + transaction.update(entity1update); + transaction.delete(KEY2); + transaction.rollback(); + assertFalse(transaction.isActive()); + } finally { + rootSpan.end(); + } + + waitForTracesToComplete(); + + List list = datastore.fetch(KEY1, KEY2); + assertEquals(list.get(0), entity1); + assertEquals(list.get(1), entity2); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /* numExpectedSpans= */ 3, + Arrays.asList( + Collections.singletonList(SPAN_NAME_BEGIN_TRANSACTION), + Collections.singletonList(SPAN_NAME_TRANSACTION_LOOKUP), + Collections.singletonList(SPAN_NAME_ROLLBACK))); + } + + @Test + public void runInTransactionQueryTest() throws Exception { + // Set up + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + assertNotNull(customSpanContext); + + Span rootSpan = getNewRootSpanWithContext(); + try (Scope ignored = rootSpan.makeCurrent()) { + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + Datastore.TransactionCallable callable = + transaction -> { + QueryResults queryResults = datastore.run(query); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + return true; + }; + datastore.runInTransaction(callable); + } finally { + rootSpan.end(); + } + waitForTracesToComplete(); + + fetchAndValidateTrace( + customSpanContext.getTraceId(), + /* numExpectedSpans= */ 4, + Arrays.asList( + Arrays.asList(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_BEGIN_TRANSACTION), + Arrays.asList(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_RUN_QUERY), + Arrays.asList(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_TRANSACTION_COMMIT))); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITTracingTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITTracingTest.java new file mode 100644 index 000000000000..a09c8998a629 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/ITTracingTest.java @@ -0,0 +1,849 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.it; + +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.cloud.datastore.telemetry.TraceUtil.*; +import static com.google.common.truth.Truth.assertThat; +import static io.opentelemetry.semconv.resource.attributes.ResourceAttributes.SERVICE_NAME; +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 com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOpenTelemetryOptions; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.IncompleteKey; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.cloud.datastore.Transaction; +import com.google.cloud.datastore.testing.RemoteDatastoreHelper; +import com.google.common.base.Preconditions; +import com.google.testing.junit.testparameterinjector.TestParameter; +import com.google.testing.junit.testparameterinjector.TestParameterInjector; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.api.common.AttributeKey; +import io.opentelemetry.api.common.Attributes; +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.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +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; +import org.junit.runner.RunWith; + +@RunWith(TestParameterInjector.class) +public class ITTracingTest { + protected boolean isUsingGlobalOpenTelemetrySDK() { + return useGlobalOpenTelemetrySDK; + } + + protected String datastoreNamedDatabase() { + return datastoreNamedDatabase; + } + + private static final Logger logger = + Logger.getLogger(com.google.cloud.datastore.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.datastore.v1.Datastore/"; + + private static Key KEY1; + + private static Key KEY2; + + private static Key KEY3; + + private static Key KEY4; + + 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; + private static DatastoreOptions options; + + protected Datastore datastore; + private static RemoteDatastoreHelper remoteDatastoreHelper; + + @TestParameter boolean useGlobalOpenTelemetrySDK; + + @TestParameter({ + /*(default)*/ + "", + "test-db" + }) + String datastoreNamedDatabase; + + 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().merge(Resource.builder().put(SERVICE_NAME, "Sparky").build()); + SpanProcessor inMemorySpanProcessor = SimpleSpanProcessor.create(inMemorySpanExporter); + DatastoreOptions.Builder optionsBuilder = DatastoreOptions.newBuilder(); + DatastoreOpenTelemetryOptions.Builder otelOptionsBuilder = + DatastoreOpenTelemetryOptions.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.setTracingEnabled(true).build()); + } else { + openTelemetrySdk = openTelemetrySdkBuilder.build(); + optionsBuilder.setOpenTelemetryOptions( + otelOptionsBuilder.setTracingEnabled(true).setOpenTelemetry(openTelemetrySdk).build()); + } + + String namedDb = datastoreNamedDatabase(); + logger.log(Level.INFO, "Integration test using named database " + namedDb); + remoteDatastoreHelper = RemoteDatastoreHelper.create(namedDb, openTelemetrySdk); + options = remoteDatastoreHelper.getOptions(); + datastore = options.getService(); + + Preconditions.checkNotNull( + datastore, + "Error instantiating Datastore. Check that the service account credentials " + + "were properly set."); + + String projectId = options.getProjectId(); + String kind1 = "kind1"; + KEY1 = + Key.newBuilder(projectId, kind1, "key1", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY2 = + Key.newBuilder(projectId, kind1, "key2", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY3 = + Key.newBuilder(projectId, kind1, "key3", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + KEY4 = + Key.newBuilder(projectId, kind1, "key4", options.getDatabaseId()) + .setNamespace(options.getNamespace()) + .build(); + cleanupTestSpanContext(); + } + + @After + public void after() throws Exception { + if (isUsingGlobalOpenTelemetrySDK()) { + GlobalOpenTelemetry.resetForTest(); + } + remoteDatastoreHelper.deleteNamespace(); + inMemorySpanExporter.reset(); + CompletableResultCode completableResultCode = + openTelemetrySdk.getSdkTracerProvider().shutdown(); + completableResultCode.join(TRACE_PROVIDER_SHUTDOWN_MILLIS, TimeUnit.MILLISECONDS); + openTelemetrySdk = null; + } + + @AfterClass + public static void teardown() {} + + void waitForTracesToComplete() throws Exception { + // 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 datastore-generated spans contain the expected datastore 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 datastore attributes. + if (!parentSpanName.startsWith(SERVICE)) { + assertHasExpectedAttributes(parentSpan); + } + if (!childSpanName.startsWith(SERVICE)) { + assertHasExpectedAttributes(childSpan); + } + } + } + + void assertHasExpectedAttributes(SpanData spanData, String... additionalExpectedAttributes) { + // All datastore-generated spans have the settings attributes. + List expectedAttributes = + Arrays.asList( + "gcp.datastore.memoryUtilization", + "gcp.datastore.settings.host", + "gcp.datastore.settings.databaseId", + "gcp.datastore.settings.retrySettings.maxRpcTimeout", + "gcp.datastore.settings.retrySettings.retryDelayMultiplier", + "gcp.datastore.settings.retrySettings.initialRetryDelay", + "gcp.datastore.settings.credentials.authenticationType", + "gcp.datastore.settings.retrySettings.maxAttempts", + "gcp.datastore.settings.retrySettings.maxRetryDelay", + "gcp.datastore.settings.retrySettings.rpcTimeoutMultiplier", + "gcp.datastore.settings.retrySettings.totalTimeout", + "gcp.datastore.settings.retrySettings.initialRpcTimeout"); + + 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; + } + + void cleanupTestSpanContext() { + inMemorySpanExporter.reset(); + spanNameToSpanId.clear(); + spanIdToParentSpanId.clear(); + spanNameToSpanData.clear(); + } + + // 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 lookupTraceTest() throws Exception { + Entity entity = datastore.get(KEY1); + assertNull(entity); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_LOOKUP); + SpanData span = getSpanByName(SPAN_NAME_LOOKUP); + assertTrue( + hasEvent( + span, + SPAN_NAME_LOOKUP + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_RECEIVED, 0) + .put(ATTRIBUTES_KEY_MISSING, 1) + .put(ATTRIBUTES_KEY_DEFERRED, 0) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, false) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, "") + .build())); + } + + @Test + public void allocateIdsTraceTest() throws Exception { + String kind1 = "kind1"; + KeyFactory keyFactory = datastore.newKeyFactory().setKind(kind1); + IncompleteKey pk1 = keyFactory.newKey(); + Key key1 = datastore.allocateId(pk1); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_ALLOCATE_IDS); + } + + @Test + public void reserveIdsTraceTest() throws Exception { + KeyFactory keyFactory = datastore.newKeyFactory().setKind("MyKind"); + Key key1 = keyFactory.newKey(10); + Key key2 = keyFactory.newKey("name"); + List keyList = datastore.reserveIds(key1, key2); + assertEquals(2, keyList.size()); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_RESERVE_IDS); + } + + @Test + public void commitTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + Entity response = datastore.add(entity1); + assertEquals(entity1, response); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + } + + @Test + public void putTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + Entity response = datastore.put(entity1); + assertEquals(entity1, response); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + } + + @Test + public void updateTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + + SpanData spanData = getSpanByName(SPAN_NAME_COMMIT); + assertTrue( + hasEvent( + spanData, + SPAN_NAME_COMMIT + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, response.size()) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, false) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, "") + .build())); + + // Clean Up test span context to verify update spans + cleanupTestSpanContext(); + + Entity entity1_update = Entity.newBuilder(entity1).set("test_field", "new_test_value1").build(); + Entity entity2_update = Entity.newBuilder(entity2).set("test_field", "new_test_value1").build(); + datastore.update(entity1_update, entity2_update); + + waitForTracesToComplete(); + + spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + } + + @Test + public void deleteTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_key", "test_value").build(); + Entity response = datastore.put(entity1); + assertEquals(entity1, response); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + + SpanData spanData = getSpanByName(SPAN_NAME_COMMIT); + assertTrue( + hasEvent( + spanData, + SPAN_NAME_COMMIT + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, false) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, "") + .build())); + + // Clean Up test span context to verify update spans + cleanupTestSpanContext(); + + datastore.delete(entity1.getKey()); + + waitForTracesToComplete(); + + spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_COMMIT); + + spanData = getSpanByName(SPAN_NAME_COMMIT); + assertTrue( + hasEvent( + spanData, + SPAN_NAME_COMMIT + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, false) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, "") + .build())); + } + + @Test + public void runQueryTraceTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + // Clean Up test span context to verify RunQuery spans + cleanupTestSpanContext(); + + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + QueryResults queryResults = datastore.run(query); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_RUN_QUERY); + + SpanData span = getSpanByName(SPAN_NAME_RUN_QUERY); + assertTrue( + hasEvent( + span, + SPAN_NAME_RUN_QUERY + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, false) + .put(ATTRIBUTES_KEY_READ_CONSISTENCY, "READ_CONSISTENCY_UNSPECIFIED") + .put(ATTRIBUTES_KEY_MORE_RESULTS, "NO_MORE_RESULTS") + .put(ATTRIBUTES_KEY_TRANSACTION_ID, "") + .build())); + } + + @Test + public void runAggregationQueryTraceTest() throws Exception { + Entity entity1 = + Entity.newBuilder(KEY1) + .set("pepper_name", "jalapeno") + .set("max_scoville_level", 10000) + .build(); + Entity entity2 = + Entity.newBuilder(KEY2) + .set("pepper_name", "serrano") + .set("max_scoville_level", 25000) + .build(); + Entity entity3 = + Entity.newBuilder(KEY3) + .set("pepper_name", "habanero") + .set("max_scoville_level", 350000) + .build(); + Entity entity4 = + Entity.newBuilder(KEY4) + .set("pepper_name", "ghost") + .set("max_scoville_level", 1500000) + .build(); + + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + entityList.add(entity3); + entityList.add(entity4); + + List response = datastore.add(entity1, entity2, entity3, entity4); + assertEquals(entityList, response); + + // Clean Up test span context to verify RunAggregationQuery spans + cleanupTestSpanContext(); + + PropertyFilter mediumSpicyFilters = PropertyFilter.lt("max_scoville_level", 100000); + StructuredQuery mediumSpicyQuery = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(mediumSpicyFilters).build(); + AggregationQuery countSpicyPeppers = + Query.newAggregationQueryBuilder() + .addAggregation(count().as("count")) + .over(mediumSpicyQuery) + .build(); + AggregationResults results = datastore.runAggregation(countSpicyPeppers); + assertThat(results.size()).isEqualTo(1); + AggregationResult result = results.get(0); + assertThat(result.getLong("count")).isEqualTo(2L); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(1, spans.size()); + assertSpanHierarchy(SPAN_NAME_RUN_AGGREGATION_QUERY); + } + + @Test + public void newTransactionReadWriteTraceTest() throws Exception { + // Transaction.Begin + Transaction transaction = datastore.newTransaction(); + + // Transaction.Lookup + Entity entity = datastore.get(KEY1, ReadOption.transactionId(transaction.getTransactionId())); + assertNull(entity); + + Entity updatedEntity = Entity.newBuilder(KEY1).set("test_field", "new_test_value1").build(); + transaction.put(updatedEntity); + + // Transaction.Commit + transaction.commit(); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + + assertSpanHierarchy(SPAN_NAME_BEGIN_TRANSACTION); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_LOOKUP); + SpanData span = getSpanByName(SPAN_NAME_TRANSACTION_LOOKUP); + assertTrue( + hasEvent( + span, + SPAN_NAME_TRANSACTION_LOOKUP + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DEFERRED, 0) + .put(ATTRIBUTES_KEY_MISSING, 1) + .put(ATTRIBUTES_KEY_RECEIVED, 0) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, true) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, transaction.getTransactionId().toStringUtf8()) + .build())); + + assertSpanHierarchy(SPAN_NAME_TRANSACTION_COMMIT); + span = getSpanByName(SPAN_NAME_TRANSACTION_COMMIT); + assertTrue( + hasEvent( + span, + SPAN_NAME_TRANSACTION_COMMIT + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, true) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, transaction.getTransactionId().toStringUtf8()) + .build())); + } + + @Test + public void newTransactionQueryTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + // Clean Up test span context to verify Transaction RunQuery spans + cleanupTestSpanContext(); + + Transaction transaction = datastore.newTransaction(); + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + QueryResults queryResults = transaction.run(query); + transaction.commit(); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + + assertSpanHierarchy(SPAN_NAME_BEGIN_TRANSACTION); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_RUN_QUERY); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_COMMIT); + SpanData span = getSpanByName(SPAN_NAME_TRANSACTION_RUN_QUERY); + assertTrue( + hasEvent( + span, + SPAN_NAME_TRANSACTION_RUN_QUERY + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DOCUMENT_COUNT, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, true) + .put(ATTRIBUTES_KEY_READ_CONSISTENCY, "READ_CONSISTENCY_UNSPECIFIED") + .put(ATTRIBUTES_KEY_MORE_RESULTS, "NO_MORE_RESULTS") + .put(ATTRIBUTES_KEY_TRANSACTION_ID, transaction.getTransactionId().toStringUtf8()) + .build())); + } + + @Test + public void newTransactionRollbackTest() throws Exception { + Entity entity1 = Entity.newBuilder(KEY1).set("pepper_type", "jalapeno").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("pepper_type", "habanero").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + // Clean Up test span context to verify Transaction Rollback spans + cleanupTestSpanContext(); + + String simplified_spice_level = "not_spicy"; + Entity entity1update = + Entity.newBuilder(entity1).set("spice_level", simplified_spice_level).build(); + Transaction transaction = datastore.newTransaction(); + entity1 = transaction.get(KEY1); + switch (entity1.getString("pepper_type")) { + case "jalapeno": + simplified_spice_level = "mild"; + break; + + case "habanero": + simplified_spice_level = "hot"; + break; + } + transaction.update(entity1update); + transaction.delete(KEY2); + transaction.rollback(); + assertFalse(transaction.isActive()); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(3, spans.size()); + + assertSpanHierarchy(SPAN_NAME_BEGIN_TRANSACTION); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_LOOKUP); + SpanData span = getSpanByName(SPAN_NAME_TRANSACTION_LOOKUP); + assertTrue( + hasEvent( + span, + SPAN_NAME_TRANSACTION_LOOKUP + " complete.", + Attributes.builder() + .put(ATTRIBUTES_KEY_DEFERRED, 0) + .put(ATTRIBUTES_KEY_MISSING, 0) + .put(ATTRIBUTES_KEY_RECEIVED, 1) + .put(ATTRIBUTES_KEY_TRANSACTIONAL, true) + .put(ATTRIBUTES_KEY_TRANSACTION_ID, transaction.getTransactionId().toStringUtf8()) + .build())); + + assertSpanHierarchy(SPAN_NAME_ROLLBACK); + span = getSpanByName(SPAN_NAME_ROLLBACK); + assertTrue( + hasEvent( + span, + SPAN_NAME_ROLLBACK, + Attributes.builder() + .put(ATTRIBUTES_KEY_TRANSACTION_ID, transaction.getTransactionId().toStringUtf8()) + .build())); + } + + @Test + public void runInTransactionQueryTest() throws Exception { + // Set up + Entity entity1 = Entity.newBuilder(KEY1).set("test_field", "test_value1").build(); + Entity entity2 = Entity.newBuilder(KEY2).set("test_field", "test_value2").build(); + List entityList = new ArrayList<>(); + entityList.add(entity1); + entityList.add(entity2); + + List response = datastore.add(entity1, entity2); + assertEquals(entityList, response); + + // Clean Up test span context to verify Transaction Rollback spans + cleanupTestSpanContext(); + + PropertyFilter filter = PropertyFilter.eq("test_field", entity1.getValue("test_field")); + Query query = + Query.newEntityQueryBuilder().setKind(KEY1.getKind()).setFilter(filter).build(); + Datastore.TransactionCallable callable = + transaction -> { + QueryResults queryResults = datastore.run(query); + assertTrue(queryResults.hasNext()); + assertEquals(entity1, queryResults.next()); + assertFalse(queryResults.hasNext()); + return true; + }; + datastore.runInTransaction(callable); + + waitForTracesToComplete(); + + List spans = prepareSpans(); + assertEquals(4, spans.size()); + + // Since the runInTransaction method runs the TransactionCallable opaquely in a transaction + // there is no way for the API user to know the transaction ID, so we will not validate it here. + assertSpanHierarchy(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_BEGIN_TRANSACTION); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_RUN_QUERY); + assertSpanHierarchy(SPAN_NAME_TRANSACTION_RUN, SPAN_NAME_TRANSACTION_COMMIT); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/MultipleAttemptsRule.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/MultipleAttemptsRule.java new file mode 100644 index 000000000000..5d55d26facaa --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/MultipleAttemptsRule.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 + * + * 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.datastore.it; + +import static com.google.common.base.Preconditions.checkState; + +import java.util.ArrayList; +import java.util.List; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.MultipleFailureException; +import org.junit.runners.model.Statement; + +/** + * A JUnit rule that allows us to allow multiple attempts of a test execution before it is + * ultimately failed. When it fails, all failures will be propagated as the result of the test. + */ +public final class MultipleAttemptsRule implements TestRule { + private final long initialBackoffMillis; + private final int attemptCount; + + MultipleAttemptsRule(int attemptCount) { + this(attemptCount, 1000L); + } + + public MultipleAttemptsRule(int attemptCount, long initialBackoffMillis) { + checkState(attemptCount > 0, "attemptCount must be > 0"); + checkState(initialBackoffMillis > 0, "initialBackoffMillis must be > 0"); + this.initialBackoffMillis = initialBackoffMillis; + this.attemptCount = attemptCount; + } + + @Override + public Statement apply(final Statement base, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + List failures = new ArrayList<>(); + + long retryIntervalMillis = initialBackoffMillis; + + for (int i = 1; i <= attemptCount; i++) { + try { + base.evaluate(); + return; + } catch (Throwable t) { + failures.add(t); + Thread.sleep(retryIntervalMillis); + retryIntervalMillis *= 1.5f; + } + } + + MultipleFailureException.assertEmpty(failures); + } + }; + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/MultipleAttemptsRuleTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/MultipleAttemptsRuleTest.java new file mode 100644 index 000000000000..8fc7350bec23 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/MultipleAttemptsRuleTest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.it; + +import static org.junit.Assert.assertEquals; + +import org.junit.Rule; +import org.junit.Test; + +public final class MultipleAttemptsRuleTest { + + private static final int NUMBER_OF_ATTEMPTS = 5; + + @Rule public MultipleAttemptsRule rr = new MultipleAttemptsRule(NUMBER_OF_ATTEMPTS, 10); + + private int numberAttempted = 0; + + @Test + public void wontPassUntil5() { + numberAttempted += 1; + assertEquals(NUMBER_OF_ATTEMPTS, numberAttempted); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/StatementExecutor.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/StatementExecutor.java new file mode 100644 index 000000000000..3d8392017a27 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/it/StatementExecutor.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.it; + +import static java.util.concurrent.TimeUnit.SECONDS; + +import com.google.cloud.Tuple; +import com.google.cloud.datastore.DatastoreException; +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.Future; +import java.util.concurrent.TimeoutException; + +/** + * An executor class to handle interleaved transactions. + * + *

It executes statements (under multiple transactions) and record their failures under a groupId + * provided by users. + */ +class StatementExecutor { + + private final Multimap failures = ArrayListMultimap.create(); + + /** + * Executes a list of {@link Statement} one by one and record their failures under the groupId. In + * case of pessimistic concurrency, a statement will be blocked and cause delay until another + * transaction which was started earlier is committed. In case of optimistic concurrency, both + * transaction can perform their operation simultaneously, but the one which commits first will be + * a winner and other one will get an error on commit operation indicating a need for retry. + * + * @param tuples A {@link Statement(String, String) Tuple(<String, Statement>)} has a + * groupId of {@link String} type and a {@link Statement} to execute. + */ + @SafeVarargs + final void execute(Tuple... tuples) throws Exception { + ExecutorService executorService = Executors.newSingleThreadExecutor(); + for (Tuple tuple : tuples) { + String groupId = tuple.x(); + Statement statement = tuple.y(); + Future future = executorService.submit(statement::execute); + try { + // waiting for statement to execute + future.get(10, SECONDS); + } catch (Exception exception) { + future.cancel(true); + if (transactionConflict(exception)) { + failures.put(groupId, exception); + } else { + throw exception; + } + } + } + executorService.shutdown(); + } + + boolean didAllPass(String groupId) { + return failures.get(groupId).isEmpty(); + } + + private boolean transactionConflict(Exception exception) { + if (exception instanceof TimeoutException) { // timed out coz of pessimistic concurrency delay + return true; + } + return exception instanceof ExecutionException + && exception.getCause().getClass() == DatastoreException.class + && (exception.getMessage().contains("contention") + || exception + .getMessage() + .contains("Conflict")); // exception raise coz of optimistic concurrency + } + + interface Statement { + void execute(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.java new file mode 100644 index 000000000000..aca4d12adcf8 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExecutionStatsTest.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 + * + * 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.datastore.models; + +import com.google.cloud.Structs; +import com.google.common.testing.EqualsTester; +import com.google.common.truth.Truth; +import com.google.protobuf.Duration; +import com.google.protobuf.Struct; +import com.google.protobuf.Value; +import org.junit.Test; + +public class ExecutionStatsTest { + private final Struct struct = + Struct.newBuilder() + .putFields("key", Value.newBuilder().setStringValue("val").build()) + .build(); + private final Duration duration = Duration.newBuilder().setSeconds(23).build(); + private final com.google.datastore.v1.ExecutionStats proto = + com.google.datastore.v1.ExecutionStats.newBuilder() + .setDebugStats(struct) + .setExecutionDuration(duration) + .setReadOperations(2) + .setResultsReturned(3) + .build(); + ExecutionStats executionStats = new ExecutionStats(proto); + + @Test + public void testModel() { + Truth.assertThat(executionStats.getDebugStats()).isEqualTo(Structs.asMap(struct)); + Truth.assertThat(executionStats.getExecutionDurationJavaTime()) + .isEqualTo(java.time.Duration.ofNanos(duration.getNanos())); + Truth.assertThat(executionStats.getReadOperations()).isEqualTo(2); + Truth.assertThat(executionStats.getResultsReturned()).isEqualTo(3); + } + + @Test + public void testEqualsAndHashcode() { + com.google.datastore.v1.ExecutionStats proto2 = + com.google.datastore.v1.ExecutionStats.newBuilder() + .setDebugStats(struct) + .setExecutionDuration(duration) + .setReadOperations(6) + .setResultsReturned(7) + .build(); + + ExecutionStats executionStats1 = new ExecutionStats(proto); + ExecutionStats executionStats2 = new ExecutionStats(proto2); + ExecutionStats executionStats3 = new ExecutionStats(proto2); + + Truth.assertThat(executionStats1).isNotEqualTo(executionStats2); + Truth.assertThat(executionStats2).isEqualTo(executionStats3); + + EqualsTester equalsTester = new EqualsTester(); + equalsTester.addEqualityGroup(executionStats1, executionStats1).testEquals(); + + Truth.assertThat(executionStats1.hashCode()).isNotEqualTo(executionStats2.hashCode()); + Truth.assertThat(executionStats2.hashCode()).isEqualTo(executionStats3.hashCode()); + Truth.assertThat(executionStats1.hashCode()).isEqualTo(executionStats1.hashCode()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExplainOptionsTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExplainOptionsTest.java new file mode 100644 index 000000000000..e4f7a3f48f09 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/ExplainOptionsTest.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 + * + * 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.datastore.models; + +import com.google.common.testing.EqualsTester; +import com.google.common.truth.Truth; +import org.junit.Test; + +public class ExplainOptionsTest { + @Test + public void testModel() { + com.google.datastore.v1.ExplainOptions builtProto = + com.google.datastore.v1.ExplainOptions.newBuilder().setAnalyze(true).build(); + + com.google.datastore.v1.ExplainOptions defaultProto = + com.google.datastore.v1.ExplainOptions.newBuilder().build(); + + ExplainOptions explainOptionsAnalyzeTrue = ExplainOptions.newBuilder().setAnalyze(true).build(); + ExplainOptions explainOptionsAnalyzeFalse = + ExplainOptions.newBuilder().setAnalyze(false).build(); + ExplainOptions explainOptionsDefault = ExplainOptions.newBuilder().build(); + + Truth.assertThat(explainOptionsAnalyzeTrue.shouldAnalyze()).isTrue(); + Truth.assertThat(explainOptionsAnalyzeTrue.toPb()).isEqualTo(builtProto); + + Truth.assertThat(explainOptionsAnalyzeFalse.shouldAnalyze()).isFalse(); + Truth.assertThat(explainOptionsAnalyzeFalse.toPb()).isEqualTo(defaultProto); + + Truth.assertThat(explainOptionsDefault.shouldAnalyze()).isFalse(); + Truth.assertThat(explainOptionsDefault.toPb()).isNotEqualTo(builtProto); + Truth.assertThat(explainOptionsDefault.toPb()).isEqualTo(defaultProto); + Truth.assertThat(explainOptionsDefault).isEqualTo(explainOptionsAnalyzeFalse); + } + + @Test + public void testEqualsAndHashcode() { + ExplainOptions explainOptions = ExplainOptions.newBuilder().build(); + ExplainOptions explainOptions2 = ExplainOptions.newBuilder().setAnalyze(true).build(); + + Truth.assertThat(explainOptions).isNotEqualTo(explainOptions2); + EqualsTester equalsTester = new EqualsTester(); + equalsTester.addEqualityGroup(explainOptions, explainOptions).testEquals(); + + Truth.assertThat(explainOptions.hashCode()).isNotEqualTo(explainOptions2.hashCode()); + Truth.assertThat(explainOptions.hashCode()).isEqualTo(explainOptions.hashCode()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/PlanSummaryTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/PlanSummaryTest.java new file mode 100644 index 000000000000..aaa0804eb97f --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/models/PlanSummaryTest.java @@ -0,0 +1,63 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.models; + +import com.google.cloud.Structs; +import com.google.common.collect.Lists; +import com.google.common.testing.EqualsTester; +import com.google.common.truth.Truth; +import com.google.protobuf.Struct; +import com.google.protobuf.Value; +import org.junit.Test; + +public class PlanSummaryTest { + private final Struct struct1 = + Struct.newBuilder() + .putFields("key", Value.newBuilder().setStringValue("val").build()) + .build(); + private final Struct struct2 = + Struct.newBuilder() + .putFields("key2", Value.newBuilder().setStringValue("val2").build()) + .putFields("key3", Value.newBuilder().setStringValue("val3").build()) + .build(); + private final com.google.datastore.v1.PlanSummary proto = + com.google.datastore.v1.PlanSummary.newBuilder() + .addIndexesUsed(struct1) + .addIndexesUsed(struct2) + .build(); + private final PlanSummary planSummary = new PlanSummary(proto); + + @Test + public void testModel() { + Truth.assertThat(planSummary.getIndexesUsed()) + .isEqualTo(Lists.newArrayList(Structs.asMap(struct1), Structs.asMap(struct2))); + Truth.assertThat(planSummary.getIndexesUsed().get(0).get("key")).isEqualTo("val"); + } + + @Test + public void testEqualsAndHashcode() { + com.google.datastore.v1.PlanSummary proto2 = + com.google.datastore.v1.PlanSummary.newBuilder().addIndexesUsed(struct1).build(); + PlanSummary planSummary2 = new PlanSummary(proto2); + EqualsTester equalsTester = new EqualsTester(); + equalsTester.addEqualityGroup(planSummary, planSummary).testEquals(); + + Truth.assertThat(planSummary).isNotEqualTo(planSummary2); + + Truth.assertThat(planSummary.hashCode()).isEqualTo(planSummary.hashCode()); + Truth.assertThat(planSummary.hashCode()).isNotEqualTo(planSummary2.hashCode()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/spi/v1/RpcUtilsTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/spi/v1/RpcUtilsTest.java new file mode 100644 index 000000000000..901876a34e51 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/spi/v1/RpcUtilsTest.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 + * + * 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.datastore.spi.v1; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.api.gax.retrying.RetrySettings; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.cloud.datastore.DatastoreOptions; +import java.time.Duration; +import org.junit.Test; + +public class RpcUtilsTest { + + @Test + public void testRetrySettingSetter() { + UnaryCallSettings.Builder builder = + UnaryCallSettings.newUnaryCallSettingsBuilder(); + + // datastoreOptions with default retry settings + DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder().setProjectId("project-id").build(); + RpcUtils.retrySettingSetter(datastoreOptions).apply(builder); + assertThat(builder.getRetrySettings()).isEqualTo(datastoreOptions.getRetrySettings()); + + // datastoreOptions with custom retry settings + RetrySettings customRetrySettings = + RetrySettings.newBuilder() + .setTotalTimeoutDuration(Duration.ofMinutes(2)) + .setInitialRpcTimeoutDuration(Duration.ofSeconds(5)) + .setMaxRpcTimeoutDuration(Duration.ofSeconds(10)) + .setRetryDelayMultiplier(1.5) + .setMaxAttempts(5) + .build(); + DatastoreOptions datastoreOptionsWithCustomRetrySettings = + DatastoreOptions.newBuilder() + .setProjectId("project-id") + .setRetrySettings(customRetrySettings) + .build(); + RpcUtils.retrySettingSetter(datastoreOptionsWithCustomRetrySettings).apply(builder); + assertThat(builder.getRetrySettings()).isEqualTo(customRetrySettings); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/DisabledTraceUtilTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/DisabledTraceUtilTest.java new file mode 100644 index 000000000000..c867ad583ec2 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/DisabledTraceUtilTest.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 + * + * 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.datastore.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.getCurrentContext() instanceof DisabledTraceUtil.Context).isTrue(); + } + + @Test + public void usesDisabledSpan() { + DisabledTraceUtil traceUtil = new DisabledTraceUtil(); + assertThat(traceUtil.getCurrentSpan() instanceof DisabledTraceUtil.Span).isTrue(); + assertThat(traceUtil.startSpan("foo") instanceof DisabledTraceUtil.Span).isTrue(); + assertThat( + traceUtil.startSpan("foo", traceUtil.getCurrentSpan()) + instanceof DisabledTraceUtil.Span) + .isTrue(); + } + + @Test + public void usesDisabledScope() { + DisabledTraceUtil traceUtil = new DisabledTraceUtil(); + assertThat(traceUtil.getCurrentContext().makeCurrent() instanceof DisabledTraceUtil.Scope) + .isTrue(); + assertThat(traceUtil.getCurrentSpan().makeCurrent() instanceof DisabledTraceUtil.Scope) + .isTrue(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/EnabledTraceUtilTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/EnabledTraceUtilTest.java new file mode 100644 index 000000000000..101ddf610bc7 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/EnabledTraceUtilTest.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 + * + * 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.datastore.telemetry; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.NoCredentials; +import com.google.cloud.datastore.DatastoreOpenTelemetryOptions; +import com.google.cloud.datastore.DatastoreOptions; +import io.opentelemetry.api.GlobalOpenTelemetry; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import org.junit.Before; +import org.junit.Test; + +public class EnabledTraceUtilTest { + @Before + public void setUp() { + GlobalOpenTelemetry.resetForTest(); + } + + DatastoreOptions.Builder getBaseOptions() { + return DatastoreOptions.newBuilder() + .setProjectId("test-project") + .setCredentials(NoCredentials.getInstance()); + } + + DatastoreOptions getTracingEnabledOptions() { + return getBaseOptions() + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(true).build()) + .build(); + } + + EnabledTraceUtil newEnabledTraceUtil() { + return new EnabledTraceUtil(getTracingEnabledOptions()); + } + + @Test + public void usesOpenTelemetryFromOptions() { + OpenTelemetrySdk myOpenTelemetrySdk = OpenTelemetrySdk.builder().build(); + DatastoreOptions firestoreOptions = + getBaseOptions() + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder() + .setTracingEnabled(true) + .setOpenTelemetry(myOpenTelemetrySdk) + .build()) + .build(); + EnabledTraceUtil traceUtil = new EnabledTraceUtil(firestoreOptions); + assertThat(traceUtil.getOpenTelemetry()).isEqualTo(myOpenTelemetrySdk); + } + + @Test + public void usesGlobalOpenTelemetryIfOpenTelemetryInstanceNotProvided() { + OpenTelemetrySdk ignored = OpenTelemetrySdk.builder().buildAndRegisterGlobal(); + DatastoreOptions datastoreOptions = + getBaseOptions() + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(true).build()) + .build(); + EnabledTraceUtil traceUtil = new EnabledTraceUtil(datastoreOptions); + assertThat(traceUtil.getOpenTelemetry()).isEqualTo(GlobalOpenTelemetry.get()); + } + + @Test + public void enabledTraceUtilProvidesChannelConfigurator() { + assertThat(newEnabledTraceUtil().getChannelConfigurator()).isNull(); + } + + @Test + public void openTelemetryInstanceRegistersGrpcChannelConfigurator() { + OpenTelemetrySdk myOpenTelemetrySdk = OpenTelemetrySdk.builder().build(); + DatastoreOptions firestoreOptions = + getBaseOptions() + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder() + .setTracingEnabled(true) + .setOpenTelemetry(myOpenTelemetrySdk) + .build()) + .build(); + EnabledTraceUtil traceUtil = new EnabledTraceUtil(firestoreOptions); + assertThat(traceUtil.getChannelConfigurator()).isNotNull(); + } + + @Test + public void globalOpenTelemetryRegistersGrpcChannelConfigurator() { + + OpenTelemetrySdk.builder().buildAndRegisterGlobal(); + DatastoreOptions datastoreOptions = + getBaseOptions() + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(true).build()) + .build(); + EnabledTraceUtil traceUtil = new EnabledTraceUtil(datastoreOptions); + assertThat(traceUtil.getChannelConfigurator()).isNotNull(); + } + + @Test + public void usesEnabledContext() { + assertThat(newEnabledTraceUtil().getCurrentContext() instanceof EnabledTraceUtil.Context) + .isTrue(); + } + + @Test + public void usesEnabledSpan() { + EnabledTraceUtil traceUtil = newEnabledTraceUtil(); + assertThat(traceUtil.getCurrentSpan() instanceof EnabledTraceUtil.Span).isTrue(); + assertThat(traceUtil.startSpan("foo") != null).isTrue(); + assertThat( + traceUtil.startSpan("foo", traceUtil.getCurrentSpan()) instanceof EnabledTraceUtil.Span) + .isTrue(); + } + + @Test + public void usesEnabledScope() { + EnabledTraceUtil traceUtil = newEnabledTraceUtil(); + assertThat(traceUtil.getCurrentContext().makeCurrent() instanceof EnabledTraceUtil.Scope) + .isTrue(); + assertThat(traceUtil.getCurrentSpan().makeCurrent() instanceof EnabledTraceUtil.Scope).isTrue(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/TraceUtilTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/TraceUtilTest.java new file mode 100644 index 000000000000..788bdd72f689 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/telemetry/TraceUtilTest.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 + * + * 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.datastore.telemetry; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.NoCredentials; +import com.google.cloud.datastore.DatastoreOpenTelemetryOptions; +import com.google.cloud.datastore.DatastoreOptions; +import org.junit.Test; + +public class TraceUtilTest { + @Test + public void defaultOptionsUseDisabledTraceUtil() { + TraceUtil traceUtil = + TraceUtil.getInstance( + DatastoreOptions.newBuilder() + .setProjectId("test-project") + .setCredentials(NoCredentials.getInstance()) + .build()); + assertThat(traceUtil instanceof DisabledTraceUtil).isTrue(); + } + + @Test + public void tracingDisabledOptionsUseDisabledTraceUtil() { + TraceUtil traceUtil = + TraceUtil.getInstance( + DatastoreOptions.newBuilder() + .setProjectId("test-project") + .setCredentials(NoCredentials.getInstance()) + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(false).build()) + .build()); + assertThat(traceUtil instanceof DisabledTraceUtil).isTrue(); + } + + @Test + public void tracingEnabledOptionsUseEnabledTraceUtil() { + TraceUtil traceUtil = + TraceUtil.getInstance( + DatastoreOptions.newBuilder() + .setProjectId("test-project") + .setCredentials(NoCredentials.getInstance()) + .setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder().setTracingEnabled(true).build()) + .build()); + assertThat(traceUtil instanceof EnabledTraceUtil).isTrue(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java new file mode 100644 index 000000000000..c7ba16a29ef1 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/ITLocalDatastoreHelperTest.java @@ -0,0 +1,259 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.testing; + +import static com.google.common.truth.Truth.assertThat; +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.assertSame; +import static org.junit.Assert.assertTrue; + +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.cloud.NoCredentials; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreException; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Key; +import com.google.cloud.grpc.GrpcTransportOptions; +import com.google.cloud.http.HttpTransportOptions; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.time.Duration; +import java.util.concurrent.TimeoutException; +import org.junit.After; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +public class ITLocalDatastoreHelperTest { + + private static final double TOLERANCE = 0.00001; + private static final String PROJECT_ID_PREFIX = "test-project-"; + private static final String NAMESPACE = "namespace"; + private Path dataDir; + + @Before + public void setUp() throws IOException { + dataDir = Files.createTempDirectory("gcd"); + } + + @After + public void tearDown() throws IOException { + LocalDatastoreHelper.deleteRecursively(dataDir); + } + + @Test + public void testCreate() { + LocalDatastoreHelper helper = LocalDatastoreHelper.create(0.75); + assertTrue(Math.abs(0.75 - helper.getConsistency()) < TOLERANCE); + assertTrue(helper.getProjectId().startsWith(PROJECT_ID_PREFIX)); + helper = LocalDatastoreHelper.create(); + assertTrue(Math.abs(0.9 - helper.getConsistency()) < TOLERANCE); + assertTrue(helper.getProjectId().startsWith(PROJECT_ID_PREFIX)); + } + + @Test + public void testCreateWithBuilder() { + LocalDatastoreHelper helper = + LocalDatastoreHelper.newBuilder() + .setConsistency(0.75) + .setPort(8081) + .setStoreOnDisk(false) + .setFirestoreInDatastoreMode(true) + .setDataDir(dataDir) + .build(); + assertTrue(Math.abs(0.75 - helper.getConsistency()) < TOLERANCE); + assertTrue(helper.getProjectId().startsWith(PROJECT_ID_PREFIX)); + assertFalse(helper.isStoreOnDisk()); + assertTrue(helper.isFirestoreInDatastoreMode()); + assertEquals(8081, helper.getPort()); + assertEquals(dataDir, helper.getGcdPath()); + LocalDatastoreHelper incompleteHelper = LocalDatastoreHelper.newBuilder().build(); + assertTrue(Math.abs(0.9 - incompleteHelper.getConsistency()) < TOLERANCE); + assertTrue(incompleteHelper.getProjectId().startsWith(PROJECT_ID_PREFIX)); + } + + @Test + public void testCreateWithCustomProjectId() { + String customProjectId = "custom-project-id"; + LocalDatastoreHelper helper = + LocalDatastoreHelper.newBuilder().setProjectId(customProjectId).build(); + assertEquals(customProjectId, helper.getProjectId()); + } + + @Test + public void testCreateWithToBuilder() throws IOException { + LocalDatastoreHelper helper = + LocalDatastoreHelper.newBuilder() + .setConsistency(0.75) + .setPort(8081) + .setStoreOnDisk(false) + .setFirestoreInDatastoreMode(true) + .setDataDir(dataDir) + .build(); + assertTrue(Math.abs(0.75 - helper.getConsistency()) < TOLERANCE); + assertTrue(helper.getProjectId().startsWith(PROJECT_ID_PREFIX)); + assertFalse(helper.isStoreOnDisk()); + assertTrue(helper.isFirestoreInDatastoreMode()); + assertEquals(8081, helper.getPort()); + assertEquals(dataDir, helper.getGcdPath()); + LocalDatastoreHelper actualHelper = helper.toBuilder().build(); + assertLocalDatastoreHelpersEquivelent(helper, actualHelper); + Path dataDir = Files.createTempDirectory("gcd_data_dir"); + actualHelper = + helper.toBuilder() + .setConsistency(0.85) + .setPort(9091) + .setStoreOnDisk(true) + .setFirestoreInDatastoreMode(false) + .setDataDir(dataDir) + .build(); + assertTrue(Math.abs(0.85 - actualHelper.getConsistency()) < TOLERANCE); + assertTrue(actualHelper.isStoreOnDisk()); + assertFalse(actualHelper.isFirestoreInDatastoreMode()); + assertEquals(9091, actualHelper.getPort()); + assertEquals(dataDir, actualHelper.getGcdPath()); + LocalDatastoreHelper.deleteRecursively(dataDir); + } + + @Test + public void testCreatePort() { + LocalDatastoreHelper helper = LocalDatastoreHelper.create(0.75, 8888); + DatastoreOptions options = helper.setNamespace(NAMESPACE).build(); + assertTrue(options.getHost().endsWith("8888")); + assertTrue(Math.abs(0.75 - helper.getConsistency()) < TOLERANCE); + helper = LocalDatastoreHelper.create(); + options = helper.setNamespace(NAMESPACE).build(); + assertTrue(Math.abs(0.9 - helper.getConsistency()) < TOLERANCE); + assertFalse(options.getHost().endsWith("8888")); + assertFalse(options.getHost().endsWith("8080")); + helper = LocalDatastoreHelper.create(9999); + options = helper.setNamespace(NAMESPACE).build(); + assertTrue(Math.abs(0.9 - helper.getConsistency()) < TOLERANCE); + assertTrue(options.getHost().endsWith("9999")); + } + + @Test + public void testSetDatabaseId() { + LocalDatastoreHelper helper = LocalDatastoreHelper.create(0.75, 8888); + DatastoreOptions options = + helper.setNamespace(NAMESPACE).setDatabaseId("new-database-id").build(); + assertEquals("new-database-id", options.getDatabaseId()); + } + + @Test + public void testOptions() { + LocalDatastoreHelper helper = LocalDatastoreHelper.create(); + DatastoreOptions options = helper.getOptions(); + assertTrue(options.getProjectId().startsWith(PROJECT_ID_PREFIX)); + assertTrue(options.getHost().startsWith("localhost:")); + assertSame(NoCredentials.getInstance(), options.getCredentials()); + options = helper.setNamespace(NAMESPACE).build(); + assertTrue(options.getProjectId().startsWith(PROJECT_ID_PREFIX)); + assertTrue(options.getHost().startsWith("localhost:")); + assertSame(NoCredentials.getInstance(), options.getCredentials()); + assertEquals(NAMESPACE, options.getNamespace()); + } + + @Test + public void testDefaultHttpTransportOptions() { + LocalDatastoreHelper helper = LocalDatastoreHelper.create(); + DatastoreOptions options = helper.getOptions(); + assertThat(options.getTransportOptions()).isInstanceOf(HttpTransportOptions.class); + } + + @Test + public void testSetGrpcTransportOptions() { + LocalDatastoreHelper helper = LocalDatastoreHelper.create(); + DatastoreOptions options = + helper.getGrpcTransportOptions(GrpcTransportOptions.newBuilder().build()); + assertThat(options.getTransportOptions()).isInstanceOf(GrpcTransportOptions.class); + assertThat(options.getTransportChannelProvider()) + .isInstanceOf(InstantiatingGrpcChannelProvider.class); + } + + @Test + public void testStartStopReset() throws IOException, InterruptedException, TimeoutException { + try { + LocalDatastoreHelper helper = LocalDatastoreHelper.create(); + helper.start(); + Datastore datastore = helper.getOptions().getService(); + Key key = datastore.newKeyFactory().setKind("kind").newKey("name"); + datastore.put(Entity.newBuilder(key).build()); + assertNotNull(datastore.get(key)); + helper.reset(); + assertNull(datastore.get(key)); + helper.stopDuration(Duration.ofMinutes(1)); + datastore.get(key); + Assert.fail(); + } catch (DatastoreException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void testStartStopResetWithBuilder() + throws IOException, InterruptedException, TimeoutException { + try { + LocalDatastoreHelper helper = LocalDatastoreHelper.newBuilder().build(); + helper.start(); + Datastore datastore = helper.getOptions().getService(); + Key key = datastore.newKeyFactory().setKind("kind").newKey("name"); + datastore.put(Entity.newBuilder(key).build()); + assertNotNull(datastore.get(key)); + helper.reset(); + assertNull(datastore.get(key)); + helper.stopDuration(Duration.ofMinutes(1)); + datastore.get(key); + Assert.fail(); + } catch (DatastoreException ex) { + assertNotNull(ex.getMessage()); + } + } + + @Test + public void testCreateWithFirestoreInDatastoreMode() + throws IOException, InterruptedException, TimeoutException { + LocalDatastoreHelper helper = + LocalDatastoreHelper.newBuilder().setFirestoreInDatastoreMode(true).build(); + assertTrue(helper.isFirestoreInDatastoreMode()); + helper.start(); + Datastore datastore = helper.getOptions().getService(); + Key key = datastore.newKeyFactory().setKind("kind").newKey("name"); + Entity expected = Entity.newBuilder(key).build(); + datastore.put(expected); + assertNotNull(datastore.get(key)); + Entity actual = datastore.get(key); + assertEquals(expected, actual); + helper.stop(); + } + + public void assertLocalDatastoreHelpersEquivelent( + LocalDatastoreHelper expected, LocalDatastoreHelper actual) { + assertEquals(expected.getConsistency(), actual.getConsistency(), 0); + assertEquals(expected.isStoreOnDisk(), actual.isStoreOnDisk()); + assertEquals(expected.isFirestoreInDatastoreMode(), actual.isFirestoreInDatastoreMode()); + assertEquals(expected.getGcdPath(), actual.getGcdPath()); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java new file mode 100644 index 000000000000..1fc06d429954 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/testing/RemoteDatastoreHelper.java @@ -0,0 +1,145 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.testing; + +import com.google.api.core.InternalApi; +import com.google.api.gax.retrying.RetrySettings; +import com.google.cloud.TransportOptions; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOpenTelemetryOptions; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.grpc.GrpcTransportOptions; +import com.google.cloud.http.HttpTransportOptions; +import io.opentelemetry.sdk.OpenTelemetrySdk; +import java.time.Duration; +import java.util.UUID; +import javax.annotation.Nullable; + +/** + * Utility to create a remote datastore configuration for testing. Datastore options can be obtained + * via the {@link #getOptions()} method. Returned options use a randomly generated namespace ({@link + * DatastoreOptions#getNamespace()}) that can be used to run the tests. Once the tests are run, all + * entities in the namespace can be deleted using {@link #deleteNamespace()}. Returned options also + * have custom {@link DatastoreOptions#getRetrySettings()}: {@link RetrySettings#getMaxAttempts()} + * is {@code 10}, {@link RetrySettings#getMaxRetryDelay()} is {@code 30000}, {@link + * RetrySettings#getTotalTimeout()} is {@code 120000} and {@link + * RetrySettings#getInitialRetryDelay()} is {@code 250}. {@link + * HttpTransportOptions#getConnectTimeout()} and {@link HttpTransportOptions#getReadTimeout()} are + * both both set to {@code 60000}. If an OpenTelemetrySdk object is passed in, OpenTelemetry Trace + * collection will be enabled for the Client application. + * + *

Internal testing use only + */ +@InternalApi +public class RemoteDatastoreHelper { + private final DatastoreOptions options; + private final Datastore datastore; + private final String namespace; + + private RemoteDatastoreHelper(DatastoreOptions options) { + this.options = options; + this.datastore = options.getService(); + this.namespace = options.getNamespace(); + } + + /** + * Returns a {@link DatastoreOptions} object to be used for testing. The options are associated to + * a randomly generated namespace. + */ + public DatastoreOptions getOptions() { + return options; + } + + /** Deletes all entities in the namespace associated with this {@link RemoteDatastoreHelper}. */ + public void deleteNamespace() { + StructuredQuery query = Query.newKeyQueryBuilder().setNamespace(namespace).build(); + QueryResults keys = datastore.run(query); + while (keys.hasNext()) { + datastore.delete(keys.next()); + } + } + + /** Creates a {@code RemoteStorageHelper} object. */ + public static RemoteDatastoreHelper create() { + return create( + "", DatastoreOptions.getDefaultHttpTransportOptions(), /* openTelemetrySdk= */ null); + } + + public static RemoteDatastoreHelper create(String databaseId) { + return create( + databaseId, + DatastoreOptions.getDefaultHttpTransportOptions(), + /* openTelemetrySdk= */ null); + } + + public static RemoteDatastoreHelper create(TransportOptions transportOptions) { + return create("", transportOptions, /* openTelemetrySdk= */ null); + } + + public static RemoteDatastoreHelper create( + String databaseId, @Nullable OpenTelemetrySdk openTelemetrySdk) { + return create(databaseId, DatastoreOptions.getDefaultHttpTransportOptions(), openTelemetrySdk); + } + + public static RemoteDatastoreHelper create(String databaseId, TransportOptions transportOptions) { + return create(databaseId, transportOptions, /* openTelemetrySdk= */ null); + } + + /** Creates a {@code RemoteStorageHelper} object. */ + public static RemoteDatastoreHelper create( + String databaseId, + TransportOptions transportOptions, + @Nullable OpenTelemetrySdk openTelemetrySdk) { + DatastoreOptions.Builder datastoreOptionBuilder = + DatastoreOptions.newBuilder() + .setDatabaseId(databaseId) + .setNamespace(UUID.randomUUID().toString()) + .setRetrySettings(retrySettings()); + if (transportOptions instanceof GrpcTransportOptions) { + datastoreOptionBuilder = + datastoreOptionBuilder.setTransportOptions((GrpcTransportOptions) transportOptions); + } else { + datastoreOptionBuilder = datastoreOptionBuilder.setTransportOptions(transportOptions); + } + + if (openTelemetrySdk != null) { + datastoreOptionBuilder.setOpenTelemetryOptions( + DatastoreOpenTelemetryOptions.newBuilder() + .setOpenTelemetry(openTelemetrySdk) + .setTracingEnabled(true) + .build()); + } + return new RemoteDatastoreHelper(datastoreOptionBuilder.build()); + } + + private static RetrySettings retrySettings() { + return RetrySettings.newBuilder() + .setMaxAttempts(10) + .setMaxRetryDelayDuration(Duration.ofMillis(30000L)) + .setTotalTimeoutDuration(Duration.ofMillis(120000L)) + .setInitialRetryDelayDuration(Duration.ofMillis(250L)) + .setRetryDelayMultiplier(1.0) + .setInitialRpcTimeoutDuration(Duration.ofMillis(120000L)) + .setRpcTimeoutMultiplier(1.0) + .setMaxRpcTimeoutDuration(Duration.ofMillis(120000L)) + .build(); + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientHttpJsonTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientHttpJsonTest.java new file mode 100644 index 000000000000..97cead185516 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientHttpJsonTest.java @@ -0,0 +1,549 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.v1; + +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.datastore.v1.stub.HttpJsonDatastoreStub; +import com.google.datastore.v1.AggregationQuery; +import com.google.datastore.v1.AggregationResultBatch; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.EntityResult; +import com.google.datastore.v1.ExplainMetrics; +import com.google.datastore.v1.ExplainOptions; +import com.google.datastore.v1.Key; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.Mutation; +import com.google.datastore.v1.MutationResult; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.PropertyMask; +import com.google.datastore.v1.Query; +import com.google.datastore.v1.QueryResultBatch; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +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 DatastoreClientHttpJsonTest { + private static MockHttpService mockService; + private static DatastoreClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonDatastoreStub.getMethodDescriptors(), DatastoreSettings.getDefaultEndpoint()); + DatastoreSettings settings = + DatastoreSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + DatastoreSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DatastoreClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void lookupTest() throws Exception { + LookupResponse expectedResponse = + LookupResponse.newBuilder() + .addAllFound(new ArrayList()) + .addAllMissing(new ArrayList()) + .addAllDeferred(new ArrayList()) + .setTransaction(ByteString.EMPTY) + .setReadTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String projectId = "projectId-1530"; + ReadOptions readOptions = ReadOptions.newBuilder().build(); + List keys = new ArrayList<>(); + + LookupResponse actualResponse = client.lookup(projectId, readOptions, keys); + 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 lookupExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String projectId = "projectId-1530"; + ReadOptions readOptions = ReadOptions.newBuilder().build(); + List keys = new ArrayList<>(); + client.lookup(projectId, readOptions, keys); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runQueryTest() throws Exception { + RunQueryResponse expectedResponse = + RunQueryResponse.newBuilder() + .setBatch(QueryResultBatch.newBuilder().build()) + .setQuery(Query.newBuilder().build()) + .setTransaction(ByteString.EMPTY) + .setExplainMetrics(ExplainMetrics.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + RunQueryRequest request = + RunQueryRequest.newBuilder() + .setProjectId("projectId-1530") + .setDatabaseId("databaseId1688905718") + .setPartitionId(PartitionId.newBuilder().build()) + .setReadOptions(ReadOptions.newBuilder().build()) + .setPropertyMask(PropertyMask.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + + RunQueryResponse actualResponse = client.runQuery(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 runQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RunQueryRequest request = + RunQueryRequest.newBuilder() + .setProjectId("projectId-1530") + .setDatabaseId("databaseId1688905718") + .setPartitionId(PartitionId.newBuilder().build()) + .setReadOptions(ReadOptions.newBuilder().build()) + .setPropertyMask(PropertyMask.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + client.runQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runAggregationQueryTest() throws Exception { + RunAggregationQueryResponse expectedResponse = + RunAggregationQueryResponse.newBuilder() + .setBatch(AggregationResultBatch.newBuilder().build()) + .setQuery(AggregationQuery.newBuilder().build()) + .setTransaction(ByteString.EMPTY) + .setExplainMetrics(ExplainMetrics.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + RunAggregationQueryRequest request = + RunAggregationQueryRequest.newBuilder() + .setProjectId("projectId-1530") + .setDatabaseId("databaseId1688905718") + .setPartitionId(PartitionId.newBuilder().build()) + .setReadOptions(ReadOptions.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + + RunAggregationQueryResponse actualResponse = client.runAggregationQuery(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 runAggregationQueryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RunAggregationQueryRequest request = + RunAggregationQueryRequest.newBuilder() + .setProjectId("projectId-1530") + .setDatabaseId("databaseId1688905718") + .setPartitionId(PartitionId.newBuilder().build()) + .setReadOptions(ReadOptions.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + client.runAggregationQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void beginTransactionTest() throws Exception { + BeginTransactionResponse expectedResponse = + BeginTransactionResponse.newBuilder().setTransaction(ByteString.EMPTY).build(); + mockService.addResponse(expectedResponse); + + String projectId = "projectId-1530"; + + BeginTransactionResponse actualResponse = client.beginTransaction(projectId); + 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 projectId = "projectId-1530"; + client.beginTransaction(projectId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void commitTest() throws Exception { + CommitResponse expectedResponse = + CommitResponse.newBuilder() + .addAllMutationResults(new ArrayList()) + .setIndexUpdates(-1425228195) + .setCommitTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String projectId = "projectId-1530"; + CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0); + List mutations = new ArrayList<>(); + + CommitResponse actualResponse = client.commit(projectId, mode, mutations); + 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 projectId = "projectId-1530"; + CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0); + List mutations = new ArrayList<>(); + client.commit(projectId, mode, mutations); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void commitTest2() throws Exception { + CommitResponse expectedResponse = + CommitResponse.newBuilder() + .addAllMutationResults(new ArrayList()) + .setIndexUpdates(-1425228195) + .setCommitTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String projectId = "projectId-1530"; + CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0); + ByteString transaction = ByteString.EMPTY; + List mutations = new ArrayList<>(); + + CommitResponse actualResponse = client.commit(projectId, mode, transaction, mutations); + 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 commitExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String projectId = "projectId-1530"; + CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0); + ByteString transaction = ByteString.EMPTY; + List mutations = new ArrayList<>(); + client.commit(projectId, mode, transaction, mutations); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void rollbackTest() throws Exception { + RollbackResponse expectedResponse = RollbackResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String projectId = "projectId-1530"; + ByteString transaction = ByteString.EMPTY; + + RollbackResponse actualResponse = client.rollback(projectId, transaction); + 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 rollbackExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String projectId = "projectId-1530"; + ByteString transaction = ByteString.EMPTY; + client.rollback(projectId, transaction); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void allocateIdsTest() throws Exception { + AllocateIdsResponse expectedResponse = + AllocateIdsResponse.newBuilder().addAllKeys(new ArrayList()).build(); + mockService.addResponse(expectedResponse); + + String projectId = "projectId-1530"; + List keys = new ArrayList<>(); + + AllocateIdsResponse actualResponse = client.allocateIds(projectId, keys); + 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 allocateIdsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String projectId = "projectId-1530"; + List keys = new ArrayList<>(); + client.allocateIds(projectId, keys); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void reserveIdsTest() throws Exception { + ReserveIdsResponse expectedResponse = ReserveIdsResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String projectId = "projectId-1530"; + List keys = new ArrayList<>(); + + ReserveIdsResponse actualResponse = client.reserveIds(projectId, keys); + 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 reserveIdsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String projectId = "projectId-1530"; + List keys = new ArrayList<>(); + client.reserveIds(projectId, keys); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientTest.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientTest.java new file mode 100644 index 000000000000..d70d277762b4 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/DatastoreClientTest.java @@ -0,0 +1,528 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.v1; + +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.datastore.v1.AggregationQuery; +import com.google.datastore.v1.AggregationResultBatch; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.EntityResult; +import com.google.datastore.v1.ExplainMetrics; +import com.google.datastore.v1.ExplainOptions; +import com.google.datastore.v1.Key; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.Mutation; +import com.google.datastore.v1.MutationResult; +import com.google.datastore.v1.PartitionId; +import com.google.datastore.v1.PropertyMask; +import com.google.datastore.v1.Query; +import com.google.datastore.v1.QueryResultBatch; +import com.google.datastore.v1.ReadOptions; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.protobuf.AbstractMessage; +import com.google.protobuf.ByteString; +import com.google.protobuf.Timestamp; +import io.grpc.StatusRuntimeException; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.UUID; +import 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 DatastoreClientTest { + private static MockDatastore mockDatastore; + private static MockServiceHelper mockServiceHelper; + private LocalChannelProvider channelProvider; + private DatastoreClient client; + + @BeforeClass + public static void startStaticServer() { + mockDatastore = new MockDatastore(); + mockServiceHelper = + new MockServiceHelper( + UUID.randomUUID().toString(), Arrays.asList(mockDatastore)); + mockServiceHelper.start(); + } + + @AfterClass + public static void stopServer() { + mockServiceHelper.stop(); + } + + @Before + public void setUp() throws IOException { + mockServiceHelper.reset(); + channelProvider = mockServiceHelper.createChannelProvider(); + DatastoreSettings settings = + DatastoreSettings.newBuilder() + .setTransportChannelProvider(channelProvider) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = DatastoreClient.create(settings); + } + + @After + public void tearDown() throws Exception { + client.close(); + } + + @Test + public void lookupTest() throws Exception { + LookupResponse expectedResponse = + LookupResponse.newBuilder() + .addAllFound(new ArrayList()) + .addAllMissing(new ArrayList()) + .addAllDeferred(new ArrayList()) + .setTransaction(ByteString.EMPTY) + .setReadTime(Timestamp.newBuilder().build()) + .build(); + mockDatastore.addResponse(expectedResponse); + + String projectId = "projectId-894832108"; + ReadOptions readOptions = ReadOptions.newBuilder().build(); + List keys = new ArrayList<>(); + + LookupResponse actualResponse = client.lookup(projectId, readOptions, keys); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + LookupRequest actualRequest = ((LookupRequest) actualRequests.get(0)); + + Assert.assertEquals(projectId, actualRequest.getProjectId()); + Assert.assertEquals(readOptions, actualRequest.getReadOptions()); + Assert.assertEquals(keys, actualRequest.getKeysList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void lookupExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastore.addException(exception); + + try { + String projectId = "projectId-894832108"; + ReadOptions readOptions = ReadOptions.newBuilder().build(); + List keys = new ArrayList<>(); + client.lookup(projectId, readOptions, keys); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runQueryTest() throws Exception { + RunQueryResponse expectedResponse = + RunQueryResponse.newBuilder() + .setBatch(QueryResultBatch.newBuilder().build()) + .setQuery(Query.newBuilder().build()) + .setTransaction(ByteString.EMPTY) + .setExplainMetrics(ExplainMetrics.newBuilder().build()) + .build(); + mockDatastore.addResponse(expectedResponse); + + RunQueryRequest request = + RunQueryRequest.newBuilder() + .setProjectId("projectId-894832108") + .setDatabaseId("databaseId1688905718") + .setPartitionId(PartitionId.newBuilder().build()) + .setReadOptions(ReadOptions.newBuilder().build()) + .setPropertyMask(PropertyMask.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + + RunQueryResponse actualResponse = client.runQuery(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + RunQueryRequest actualRequest = ((RunQueryRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId()); + Assert.assertEquals(request.getDatabaseId(), actualRequest.getDatabaseId()); + Assert.assertEquals(request.getPartitionId(), actualRequest.getPartitionId()); + Assert.assertEquals(request.getReadOptions(), actualRequest.getReadOptions()); + Assert.assertEquals(request.getQuery(), actualRequest.getQuery()); + Assert.assertEquals(request.getGqlQuery(), actualRequest.getGqlQuery()); + Assert.assertEquals(request.getPropertyMask(), actualRequest.getPropertyMask()); + Assert.assertEquals(request.getExplainOptions(), actualRequest.getExplainOptions()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void runQueryExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastore.addException(exception); + + try { + RunQueryRequest request = + RunQueryRequest.newBuilder() + .setProjectId("projectId-894832108") + .setDatabaseId("databaseId1688905718") + .setPartitionId(PartitionId.newBuilder().build()) + .setReadOptions(ReadOptions.newBuilder().build()) + .setPropertyMask(PropertyMask.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + client.runQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runAggregationQueryTest() throws Exception { + RunAggregationQueryResponse expectedResponse = + RunAggregationQueryResponse.newBuilder() + .setBatch(AggregationResultBatch.newBuilder().build()) + .setQuery(AggregationQuery.newBuilder().build()) + .setTransaction(ByteString.EMPTY) + .setExplainMetrics(ExplainMetrics.newBuilder().build()) + .build(); + mockDatastore.addResponse(expectedResponse); + + RunAggregationQueryRequest request = + RunAggregationQueryRequest.newBuilder() + .setProjectId("projectId-894832108") + .setDatabaseId("databaseId1688905718") + .setPartitionId(PartitionId.newBuilder().build()) + .setReadOptions(ReadOptions.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + + RunAggregationQueryResponse actualResponse = client.runAggregationQuery(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + RunAggregationQueryRequest actualRequest = ((RunAggregationQueryRequest) actualRequests.get(0)); + + Assert.assertEquals(request.getProjectId(), actualRequest.getProjectId()); + Assert.assertEquals(request.getDatabaseId(), actualRequest.getDatabaseId()); + Assert.assertEquals(request.getPartitionId(), actualRequest.getPartitionId()); + Assert.assertEquals(request.getReadOptions(), actualRequest.getReadOptions()); + Assert.assertEquals(request.getAggregationQuery(), actualRequest.getAggregationQuery()); + Assert.assertEquals(request.getGqlQuery(), actualRequest.getGqlQuery()); + Assert.assertEquals(request.getExplainOptions(), actualRequest.getExplainOptions()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void runAggregationQueryExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastore.addException(exception); + + try { + RunAggregationQueryRequest request = + RunAggregationQueryRequest.newBuilder() + .setProjectId("projectId-894832108") + .setDatabaseId("databaseId1688905718") + .setPartitionId(PartitionId.newBuilder().build()) + .setReadOptions(ReadOptions.newBuilder().build()) + .setExplainOptions(ExplainOptions.newBuilder().build()) + .build(); + client.runAggregationQuery(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void beginTransactionTest() throws Exception { + BeginTransactionResponse expectedResponse = + BeginTransactionResponse.newBuilder().setTransaction(ByteString.EMPTY).build(); + mockDatastore.addResponse(expectedResponse); + + String projectId = "projectId-894832108"; + + BeginTransactionResponse actualResponse = client.beginTransaction(projectId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + BeginTransactionRequest actualRequest = ((BeginTransactionRequest) actualRequests.get(0)); + + Assert.assertEquals(projectId, actualRequest.getProjectId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void beginTransactionExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastore.addException(exception); + + try { + String projectId = "projectId-894832108"; + client.beginTransaction(projectId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void commitTest() throws Exception { + CommitResponse expectedResponse = + CommitResponse.newBuilder() + .addAllMutationResults(new ArrayList()) + .setIndexUpdates(-1425228195) + .setCommitTime(Timestamp.newBuilder().build()) + .build(); + mockDatastore.addResponse(expectedResponse); + + String projectId = "projectId-894832108"; + CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0); + List mutations = new ArrayList<>(); + + CommitResponse actualResponse = client.commit(projectId, mode, mutations); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CommitRequest actualRequest = ((CommitRequest) actualRequests.get(0)); + + Assert.assertEquals(projectId, actualRequest.getProjectId()); + Assert.assertEquals(mode, actualRequest.getMode()); + Assert.assertEquals(mutations, actualRequest.getMutationsList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void commitExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastore.addException(exception); + + try { + String projectId = "projectId-894832108"; + CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0); + List mutations = new ArrayList<>(); + client.commit(projectId, mode, mutations); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void commitTest2() throws Exception { + CommitResponse expectedResponse = + CommitResponse.newBuilder() + .addAllMutationResults(new ArrayList()) + .setIndexUpdates(-1425228195) + .setCommitTime(Timestamp.newBuilder().build()) + .build(); + mockDatastore.addResponse(expectedResponse); + + String projectId = "projectId-894832108"; + CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0); + ByteString transaction = ByteString.EMPTY; + List mutations = new ArrayList<>(); + + CommitResponse actualResponse = client.commit(projectId, mode, transaction, mutations); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CommitRequest actualRequest = ((CommitRequest) actualRequests.get(0)); + + Assert.assertEquals(projectId, actualRequest.getProjectId()); + Assert.assertEquals(mode, actualRequest.getMode()); + Assert.assertEquals(transaction, actualRequest.getTransaction()); + Assert.assertEquals(mutations, actualRequest.getMutationsList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void commitExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastore.addException(exception); + + try { + String projectId = "projectId-894832108"; + CommitRequest.Mode mode = CommitRequest.Mode.forNumber(0); + ByteString transaction = ByteString.EMPTY; + List mutations = new ArrayList<>(); + client.commit(projectId, mode, transaction, mutations); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void rollbackTest() throws Exception { + RollbackResponse expectedResponse = RollbackResponse.newBuilder().build(); + mockDatastore.addResponse(expectedResponse); + + String projectId = "projectId-894832108"; + ByteString transaction = ByteString.EMPTY; + + RollbackResponse actualResponse = client.rollback(projectId, transaction); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + RollbackRequest actualRequest = ((RollbackRequest) actualRequests.get(0)); + + Assert.assertEquals(projectId, actualRequest.getProjectId()); + 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); + mockDatastore.addException(exception); + + try { + String projectId = "projectId-894832108"; + ByteString transaction = ByteString.EMPTY; + client.rollback(projectId, transaction); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void allocateIdsTest() throws Exception { + AllocateIdsResponse expectedResponse = + AllocateIdsResponse.newBuilder().addAllKeys(new ArrayList()).build(); + mockDatastore.addResponse(expectedResponse); + + String projectId = "projectId-894832108"; + List keys = new ArrayList<>(); + + AllocateIdsResponse actualResponse = client.allocateIds(projectId, keys); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + AllocateIdsRequest actualRequest = ((AllocateIdsRequest) actualRequests.get(0)); + + Assert.assertEquals(projectId, actualRequest.getProjectId()); + Assert.assertEquals(keys, actualRequest.getKeysList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void allocateIdsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastore.addException(exception); + + try { + String projectId = "projectId-894832108"; + List keys = new ArrayList<>(); + client.allocateIds(projectId, keys); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void reserveIdsTest() throws Exception { + ReserveIdsResponse expectedResponse = ReserveIdsResponse.newBuilder().build(); + mockDatastore.addResponse(expectedResponse); + + String projectId = "projectId-894832108"; + List keys = new ArrayList<>(); + + ReserveIdsResponse actualResponse = client.reserveIds(projectId, keys); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatastore.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ReserveIdsRequest actualRequest = ((ReserveIdsRequest) actualRequests.get(0)); + + Assert.assertEquals(projectId, actualRequest.getProjectId()); + Assert.assertEquals(keys, actualRequest.getKeysList()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void reserveIdsExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatastore.addException(exception); + + try { + String projectId = "projectId-894832108"; + List keys = new ArrayList<>(); + client.reserveIds(projectId, keys); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastore.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastore.java new file mode 100644 index 000000000000..35c889815abd --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastore.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.datastore.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 MockDatastore implements MockGrpcService { + private final MockDatastoreImpl serviceImpl; + + public MockDatastore() { + serviceImpl = new MockDatastoreImpl(); + } + + @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-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastoreImpl.java b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastoreImpl.java new file mode 100644 index 000000000000..e65bd2168e78 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/java/com/google/cloud/datastore/v1/MockDatastoreImpl.java @@ -0,0 +1,241 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.v1; + +import com.google.api.core.BetaApi; +import com.google.datastore.v1.AllocateIdsRequest; +import com.google.datastore.v1.AllocateIdsResponse; +import com.google.datastore.v1.BeginTransactionRequest; +import com.google.datastore.v1.BeginTransactionResponse; +import com.google.datastore.v1.CommitRequest; +import com.google.datastore.v1.CommitResponse; +import com.google.datastore.v1.DatastoreGrpc.DatastoreImplBase; +import com.google.datastore.v1.LookupRequest; +import com.google.datastore.v1.LookupResponse; +import com.google.datastore.v1.ReserveIdsRequest; +import com.google.datastore.v1.ReserveIdsResponse; +import com.google.datastore.v1.RollbackRequest; +import com.google.datastore.v1.RollbackResponse; +import com.google.datastore.v1.RunAggregationQueryRequest; +import com.google.datastore.v1.RunAggregationQueryResponse; +import com.google.datastore.v1.RunQueryRequest; +import com.google.datastore.v1.RunQueryResponse; +import com.google.protobuf.AbstractMessage; +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 MockDatastoreImpl extends DatastoreImplBase { + private List requests; + private Queue responses; + + public MockDatastoreImpl() { + 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 lookup(LookupRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof LookupResponse) { + requests.add(request); + responseObserver.onNext(((LookupResponse) 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 Lookup, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + LookupResponse.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 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 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 RollbackResponse) { + requests.add(request); + responseObserver.onNext(((RollbackResponse) 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(), + RollbackResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void allocateIds( + AllocateIdsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof AllocateIdsResponse) { + requests.add(request); + responseObserver.onNext(((AllocateIdsResponse) 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 AllocateIds, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + AllocateIdsResponse.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void reserveIds( + ReserveIdsRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ReserveIdsResponse) { + requests.add(request); + responseObserver.onNext(((ReserveIdsResponse) 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 ReserveIds, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ReserveIdsResponse.class.getName(), + Exception.class.getName()))); + } + } +} diff --git a/java-datastore/google-cloud-datastore/src/test/resources/index.yaml b/java-datastore/google-cloud-datastore/src/test/resources/index.yaml new file mode 100644 index 000000000000..ff1b086267e4 --- /dev/null +++ b/java-datastore/google-cloud-datastore/src/test/resources/index.yaml @@ -0,0 +1,48 @@ +# 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. + +# one time index creation is required to run ITDatastoreConceptsTest +# see https://cloud.google.com/sdk/gcloud/reference/datastore/indexes/create for more details +indexes: + - kind: TaskConcepts + properties: + - name: done + - name: priority + direction: desc + - kind: TaskConcepts + properties: + - name: tag + - name: tag + - kind: TaskConcepts + properties: + - name: priority + - name: created + - kind: TaskConcepts + properties: + - name: category + - name: priority + - kind: TaskConcepts + properties: + - name: priority + direction: desc + - name: created + - kind: TaskConcepts + properties: + - name: percent_complete + - name: priority + - kind: TaskConcepts + properties: + - name: done + - name: priority + direction: desc \ No newline at end of file diff --git a/java-datastore/grpc-google-cloud-datastore-admin-v1/pom.xml b/java-datastore/grpc-google-cloud-datastore-admin-v1/pom.xml new file mode 100644 index 000000000000..da9cf6beeb52 --- /dev/null +++ b/java-datastore/grpc-google-cloud-datastore-admin-v1/pom.xml @@ -0,0 +1,69 @@ + + 4.0.0 + com.google.api.grpc + grpc-google-cloud-datastore-admin-v1 + 2.33.2 + grpc-google-cloud-datastore-admin-v1 + GRPC library for google-cloud-datastore + + com.google.cloud + google-cloud-datastore-parent + 2.33.2 + + + + io.grpc + grpc-api + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + com.google.api.grpc + proto-google-cloud-datastore-admin-v1 + + + com.google.guava + guava + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + \ No newline at end of file diff --git a/java-datastore/grpc-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreAdminGrpc.java b/java-datastore/grpc-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreAdminGrpc.java new file mode 100644 index 000000000000..8f2552416002 --- /dev/null +++ b/java-datastore/grpc-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreAdminGrpc.java @@ -0,0 +1,1460 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.admin.v1; + +import static io.grpc.MethodDescriptor.generateFullMethodName; + +/** + * + * + *
+ * Google Cloud Datastore Admin API
+ * The Datastore Admin API provides several admin services for Cloud Datastore.
+ * Concepts: Project, namespace, kind, and entity as defined in the Google Cloud
+ * Datastore API.
+ * Operation: An Operation represents work being performed in the background.
+ * EntityFilter: Allows specifying a subset of entities in a project. This is
+ * specified as a combination of kinds and namespaces (either or both of which
+ * may be all).
+ * Export/Import Service:
+ * - The Export/Import service provides the ability to copy all or a subset of
+ * entities to/from Google Cloud Storage.
+ * - Exported data may be imported into Cloud Datastore for any Google Cloud
+ * Platform project. It is not restricted to the export source project. It is
+ * possible to export from one project and then import into another.
+ * - Exported data can also be loaded into Google BigQuery for analysis.
+ * - Exports and imports are performed asynchronously. An Operation resource is
+ * created for each export/import. The state (including any errors encountered)
+ * of the export/import may be queried via the Operation resource.
+ * Index Service:
+ * - The index service manages Cloud Datastore composite indexes.
+ * - Index creation and deletion are 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.
+ * Operation Service:
+ * - 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 not yet done may be cancelled. The request to cancel
+ * is asynchronous and the operation may continue to run for some time after the
+ * request to cancel is made.
+ * - An operation that is done may be deleted so that it is no longer listed as
+ * part of the Operation collection.
+ * - ListOperations returns all pending operations, but not completed
+ * operations.
+ * - Operations are created by service DatastoreAdmin, but are accessed via
+ * service google.longrunning.Operations.
+ * 
+ */ +@io.grpc.stub.annotations.GrpcGenerated +public final class DatastoreAdminGrpc { + + private DatastoreAdminGrpc() {} + + public static final java.lang.String SERVICE_NAME = "google.datastore.admin.v1.DatastoreAdmin"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.ExportEntitiesRequest, com.google.longrunning.Operation> + getExportEntitiesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ExportEntities", + requestType = com.google.datastore.admin.v1.ExportEntitiesRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.ExportEntitiesRequest, com.google.longrunning.Operation> + getExportEntitiesMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.ExportEntitiesRequest, com.google.longrunning.Operation> + getExportEntitiesMethod; + if ((getExportEntitiesMethod = DatastoreAdminGrpc.getExportEntitiesMethod) == null) { + synchronized (DatastoreAdminGrpc.class) { + if ((getExportEntitiesMethod = DatastoreAdminGrpc.getExportEntitiesMethod) == null) { + DatastoreAdminGrpc.getExportEntitiesMethod = + getExportEntitiesMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ExportEntities")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.admin.v1.ExportEntitiesRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new DatastoreAdminMethodDescriptorSupplier("ExportEntities")) + .build(); + } + } + } + return getExportEntitiesMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.ImportEntitiesRequest, com.google.longrunning.Operation> + getImportEntitiesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ImportEntities", + requestType = com.google.datastore.admin.v1.ImportEntitiesRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.ImportEntitiesRequest, com.google.longrunning.Operation> + getImportEntitiesMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.ImportEntitiesRequest, com.google.longrunning.Operation> + getImportEntitiesMethod; + if ((getImportEntitiesMethod = DatastoreAdminGrpc.getImportEntitiesMethod) == null) { + synchronized (DatastoreAdminGrpc.class) { + if ((getImportEntitiesMethod = DatastoreAdminGrpc.getImportEntitiesMethod) == null) { + DatastoreAdminGrpc.getImportEntitiesMethod = + getImportEntitiesMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ImportEntities")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.admin.v1.ImportEntitiesRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new DatastoreAdminMethodDescriptorSupplier("ImportEntities")) + .build(); + } + } + } + return getImportEntitiesMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.CreateIndexRequest, com.google.longrunning.Operation> + getCreateIndexMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreateIndex", + requestType = com.google.datastore.admin.v1.CreateIndexRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.CreateIndexRequest, com.google.longrunning.Operation> + getCreateIndexMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.CreateIndexRequest, com.google.longrunning.Operation> + getCreateIndexMethod; + if ((getCreateIndexMethod = DatastoreAdminGrpc.getCreateIndexMethod) == null) { + synchronized (DatastoreAdminGrpc.class) { + if ((getCreateIndexMethod = DatastoreAdminGrpc.getCreateIndexMethod) == null) { + DatastoreAdminGrpc.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.datastore.admin.v1.CreateIndexRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new DatastoreAdminMethodDescriptorSupplier("CreateIndex")) + .build(); + } + } + } + return getCreateIndexMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.DeleteIndexRequest, com.google.longrunning.Operation> + getDeleteIndexMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeleteIndex", + requestType = com.google.datastore.admin.v1.DeleteIndexRequest.class, + responseType = com.google.longrunning.Operation.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.DeleteIndexRequest, com.google.longrunning.Operation> + getDeleteIndexMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.DeleteIndexRequest, com.google.longrunning.Operation> + getDeleteIndexMethod; + if ((getDeleteIndexMethod = DatastoreAdminGrpc.getDeleteIndexMethod) == null) { + synchronized (DatastoreAdminGrpc.class) { + if ((getDeleteIndexMethod = DatastoreAdminGrpc.getDeleteIndexMethod) == null) { + DatastoreAdminGrpc.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.datastore.admin.v1.DeleteIndexRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.longrunning.Operation.getDefaultInstance())) + .setSchemaDescriptor( + new DatastoreAdminMethodDescriptorSupplier("DeleteIndex")) + .build(); + } + } + } + return getDeleteIndexMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.GetIndexRequest, com.google.datastore.admin.v1.Index> + getGetIndexMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetIndex", + requestType = com.google.datastore.admin.v1.GetIndexRequest.class, + responseType = com.google.datastore.admin.v1.Index.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.GetIndexRequest, com.google.datastore.admin.v1.Index> + getGetIndexMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.GetIndexRequest, com.google.datastore.admin.v1.Index> + getGetIndexMethod; + if ((getGetIndexMethod = DatastoreAdminGrpc.getGetIndexMethod) == null) { + synchronized (DatastoreAdminGrpc.class) { + if ((getGetIndexMethod = DatastoreAdminGrpc.getGetIndexMethod) == null) { + DatastoreAdminGrpc.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.datastore.admin.v1.GetIndexRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.admin.v1.Index.getDefaultInstance())) + .setSchemaDescriptor(new DatastoreAdminMethodDescriptorSupplier("GetIndex")) + .build(); + } + } + } + return getGetIndexMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.ListIndexesRequest, + com.google.datastore.admin.v1.ListIndexesResponse> + getListIndexesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListIndexes", + requestType = com.google.datastore.admin.v1.ListIndexesRequest.class, + responseType = com.google.datastore.admin.v1.ListIndexesResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.ListIndexesRequest, + com.google.datastore.admin.v1.ListIndexesResponse> + getListIndexesMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.admin.v1.ListIndexesRequest, + com.google.datastore.admin.v1.ListIndexesResponse> + getListIndexesMethod; + if ((getListIndexesMethod = DatastoreAdminGrpc.getListIndexesMethod) == null) { + synchronized (DatastoreAdminGrpc.class) { + if ((getListIndexesMethod = DatastoreAdminGrpc.getListIndexesMethod) == null) { + DatastoreAdminGrpc.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.datastore.admin.v1.ListIndexesRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.admin.v1.ListIndexesResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new DatastoreAdminMethodDescriptorSupplier("ListIndexes")) + .build(); + } + } + } + return getListIndexesMethod; + } + + /** Creates a new async stub that supports all call types for the service */ + public static DatastoreAdminStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public DatastoreAdminStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreAdminStub(channel, callOptions); + } + }; + return DatastoreAdminStub.newStub(factory, channel); + } + + /** Creates a new blocking-style stub that supports all types of calls on the service */ + public static DatastoreAdminBlockingV2Stub newBlockingV2Stub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public DatastoreAdminBlockingV2Stub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreAdminBlockingV2Stub(channel, callOptions); + } + }; + return DatastoreAdminBlockingV2Stub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static DatastoreAdminBlockingStub newBlockingStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public DatastoreAdminBlockingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreAdminBlockingStub(channel, callOptions); + } + }; + return DatastoreAdminBlockingStub.newStub(factory, channel); + } + + /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ + public static DatastoreAdminFutureStub newFutureStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public DatastoreAdminFutureStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreAdminFutureStub(channel, callOptions); + } + }; + return DatastoreAdminFutureStub.newStub(factory, channel); + } + + /** + * + * + *
+   * Google Cloud Datastore Admin API
+   * The Datastore Admin API provides several admin services for Cloud Datastore.
+   * Concepts: Project, namespace, kind, and entity as defined in the Google Cloud
+   * Datastore API.
+   * Operation: An Operation represents work being performed in the background.
+   * EntityFilter: Allows specifying a subset of entities in a project. This is
+   * specified as a combination of kinds and namespaces (either or both of which
+   * may be all).
+   * Export/Import Service:
+   * - The Export/Import service provides the ability to copy all or a subset of
+   * entities to/from Google Cloud Storage.
+   * - Exported data may be imported into Cloud Datastore for any Google Cloud
+   * Platform project. It is not restricted to the export source project. It is
+   * possible to export from one project and then import into another.
+   * - Exported data can also be loaded into Google BigQuery for analysis.
+   * - Exports and imports are performed asynchronously. An Operation resource is
+   * created for each export/import. The state (including any errors encountered)
+   * of the export/import may be queried via the Operation resource.
+   * Index Service:
+   * - The index service manages Cloud Datastore composite indexes.
+   * - Index creation and deletion are 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.
+   * Operation Service:
+   * - 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 not yet done may be cancelled. The request to cancel
+   * is asynchronous and the operation may continue to run for some time after the
+   * request to cancel is made.
+   * - An operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection.
+   * - ListOperations returns all pending operations, but not completed
+   * operations.
+   * - Operations are created by service DatastoreAdmin, but are accessed via
+   * service google.longrunning.Operations.
+   * 
+ */ + public interface AsyncService { + + /** + * + * + *
+     * Exports a copy of all or a subset of entities from Google Cloud Datastore
+     * to another storage system, such as Google Cloud Storage. Recent updates to
+     * entities 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.
+     * 
+ */ + default void exportEntities( + com.google.datastore.admin.v1.ExportEntitiesRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getExportEntitiesMethod(), responseObserver); + } + + /** + * + * + *
+     * Imports entities into Google Cloud Datastore. Existing entities with the
+     * same key 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 ImportEntities operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Datastore.
+     * 
+ */ + default void importEntities( + com.google.datastore.admin.v1.ImportEntitiesRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getImportEntitiesMethod(), responseObserver); + } + + /** + * + * + *
+     * Creates the specified index.
+     * A newly created index's initial state is `CREATING`. On completion of the
+     * returned [google.longrunning.Operation][google.longrunning.Operation], the
+     * state will be `READY`. If the index already exists, the call will return an
+     * `ALREADY_EXISTS` status.
+     * During index creation, the process could result in an error, in which
+     * case the index will move to the `ERROR` state. The process can be recovered
+     * by fixing the data that caused the error, removing the index with
+     * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then
+     * re-creating the index with [create]
+     * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
+     * Indexes with a single property cannot be created.
+     * 
+ */ + default void createIndex( + com.google.datastore.admin.v1.CreateIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateIndexMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes an existing index.
+     * An index can only be deleted if it is in a `READY` or `ERROR` state. On
+     * successful execution of the request, the index will be in a `DELETING`
+     * [state][google.datastore.admin.v1.Index.State]. And on completion of the
+     * returned [google.longrunning.Operation][google.longrunning.Operation], the
+     * index will be removed.
+     * During index deletion, the process could result in an error, in which
+     * case the index will move to the `ERROR` state. The process can be recovered
+     * by fixing the data that caused the error, followed by calling
+     * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.
+     * 
+ */ + default void deleteIndex( + com.google.datastore.admin.v1.DeleteIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteIndexMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets an index.
+     * 
+ */ + default void getIndex( + com.google.datastore.admin.v1.GetIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getGetIndexMethod(), responseObserver); + } + + /** + * + * + *
+     * Lists the indexes that match the specified filters.  Datastore uses an
+     * eventually consistent query to fetch the list of indexes and may
+     * occasionally return stale results.
+     * 
+ */ + default void listIndexes( + com.google.datastore.admin.v1.ListIndexesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListIndexesMethod(), responseObserver); + } + } + + /** + * Base class for the server implementation of the service DatastoreAdmin. + * + *
+   * Google Cloud Datastore Admin API
+   * The Datastore Admin API provides several admin services for Cloud Datastore.
+   * Concepts: Project, namespace, kind, and entity as defined in the Google Cloud
+   * Datastore API.
+   * Operation: An Operation represents work being performed in the background.
+   * EntityFilter: Allows specifying a subset of entities in a project. This is
+   * specified as a combination of kinds and namespaces (either or both of which
+   * may be all).
+   * Export/Import Service:
+   * - The Export/Import service provides the ability to copy all or a subset of
+   * entities to/from Google Cloud Storage.
+   * - Exported data may be imported into Cloud Datastore for any Google Cloud
+   * Platform project. It is not restricted to the export source project. It is
+   * possible to export from one project and then import into another.
+   * - Exported data can also be loaded into Google BigQuery for analysis.
+   * - Exports and imports are performed asynchronously. An Operation resource is
+   * created for each export/import. The state (including any errors encountered)
+   * of the export/import may be queried via the Operation resource.
+   * Index Service:
+   * - The index service manages Cloud Datastore composite indexes.
+   * - Index creation and deletion are 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.
+   * Operation Service:
+   * - 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 not yet done may be cancelled. The request to cancel
+   * is asynchronous and the operation may continue to run for some time after the
+   * request to cancel is made.
+   * - An operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection.
+   * - ListOperations returns all pending operations, but not completed
+   * operations.
+   * - Operations are created by service DatastoreAdmin, but are accessed via
+   * service google.longrunning.Operations.
+   * 
+ */ + public abstract static class DatastoreAdminImplBase + implements io.grpc.BindableService, AsyncService { + + @java.lang.Override + public final io.grpc.ServerServiceDefinition bindService() { + return DatastoreAdminGrpc.bindService(this); + } + } + + /** + * A stub to allow clients to do asynchronous rpc calls to service DatastoreAdmin. + * + *
+   * Google Cloud Datastore Admin API
+   * The Datastore Admin API provides several admin services for Cloud Datastore.
+   * Concepts: Project, namespace, kind, and entity as defined in the Google Cloud
+   * Datastore API.
+   * Operation: An Operation represents work being performed in the background.
+   * EntityFilter: Allows specifying a subset of entities in a project. This is
+   * specified as a combination of kinds and namespaces (either or both of which
+   * may be all).
+   * Export/Import Service:
+   * - The Export/Import service provides the ability to copy all or a subset of
+   * entities to/from Google Cloud Storage.
+   * - Exported data may be imported into Cloud Datastore for any Google Cloud
+   * Platform project. It is not restricted to the export source project. It is
+   * possible to export from one project and then import into another.
+   * - Exported data can also be loaded into Google BigQuery for analysis.
+   * - Exports and imports are performed asynchronously. An Operation resource is
+   * created for each export/import. The state (including any errors encountered)
+   * of the export/import may be queried via the Operation resource.
+   * Index Service:
+   * - The index service manages Cloud Datastore composite indexes.
+   * - Index creation and deletion are 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.
+   * Operation Service:
+   * - 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 not yet done may be cancelled. The request to cancel
+   * is asynchronous and the operation may continue to run for some time after the
+   * request to cancel is made.
+   * - An operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection.
+   * - ListOperations returns all pending operations, but not completed
+   * operations.
+   * - Operations are created by service DatastoreAdmin, but are accessed via
+   * service google.longrunning.Operations.
+   * 
+ */ + public static final class DatastoreAdminStub + extends io.grpc.stub.AbstractAsyncStub { + private DatastoreAdminStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected DatastoreAdminStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreAdminStub(channel, callOptions); + } + + /** + * + * + *
+     * Exports a copy of all or a subset of entities from Google Cloud Datastore
+     * to another storage system, such as Google Cloud Storage. Recent updates to
+     * entities 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.
+     * 
+ */ + public void exportEntities( + com.google.datastore.admin.v1.ExportEntitiesRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getExportEntitiesMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Imports entities into Google Cloud Datastore. Existing entities with the
+     * same key 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 ImportEntities operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Datastore.
+     * 
+ */ + public void importEntities( + com.google.datastore.admin.v1.ImportEntitiesRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getImportEntitiesMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Creates the specified index.
+     * A newly created index's initial state is `CREATING`. On completion of the
+     * returned [google.longrunning.Operation][google.longrunning.Operation], the
+     * state will be `READY`. If the index already exists, the call will return an
+     * `ALREADY_EXISTS` status.
+     * During index creation, the process could result in an error, in which
+     * case the index will move to the `ERROR` state. The process can be recovered
+     * by fixing the data that caused the error, removing the index with
+     * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then
+     * re-creating the index with [create]
+     * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
+     * Indexes with a single property cannot be created.
+     * 
+ */ + public void createIndex( + com.google.datastore.admin.v1.CreateIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCreateIndexMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Deletes an existing index.
+     * An index can only be deleted if it is in a `READY` or `ERROR` state. On
+     * successful execution of the request, the index will be in a `DELETING`
+     * [state][google.datastore.admin.v1.Index.State]. And on completion of the
+     * returned [google.longrunning.Operation][google.longrunning.Operation], the
+     * index will be removed.
+     * During index deletion, the process could result in an error, in which
+     * case the index will move to the `ERROR` state. The process can be recovered
+     * by fixing the data that caused the error, followed by calling
+     * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.
+     * 
+ */ + public void deleteIndex( + com.google.datastore.admin.v1.DeleteIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getDeleteIndexMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets an index.
+     * 
+ */ + public void getIndex( + com.google.datastore.admin.v1.GetIndexRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetIndexMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Lists the indexes that match the specified filters.  Datastore uses an
+     * eventually consistent query to fetch the list of indexes and may
+     * occasionally return stale results.
+     * 
+ */ + public void listIndexes( + com.google.datastore.admin.v1.ListIndexesRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListIndexesMethod(), getCallOptions()), + request, + responseObserver); + } + } + + /** + * A stub to allow clients to do synchronous rpc calls to service DatastoreAdmin. + * + *
+   * Google Cloud Datastore Admin API
+   * The Datastore Admin API provides several admin services for Cloud Datastore.
+   * Concepts: Project, namespace, kind, and entity as defined in the Google Cloud
+   * Datastore API.
+   * Operation: An Operation represents work being performed in the background.
+   * EntityFilter: Allows specifying a subset of entities in a project. This is
+   * specified as a combination of kinds and namespaces (either or both of which
+   * may be all).
+   * Export/Import Service:
+   * - The Export/Import service provides the ability to copy all or a subset of
+   * entities to/from Google Cloud Storage.
+   * - Exported data may be imported into Cloud Datastore for any Google Cloud
+   * Platform project. It is not restricted to the export source project. It is
+   * possible to export from one project and then import into another.
+   * - Exported data can also be loaded into Google BigQuery for analysis.
+   * - Exports and imports are performed asynchronously. An Operation resource is
+   * created for each export/import. The state (including any errors encountered)
+   * of the export/import may be queried via the Operation resource.
+   * Index Service:
+   * - The index service manages Cloud Datastore composite indexes.
+   * - Index creation and deletion are 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.
+   * Operation Service:
+   * - 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 not yet done may be cancelled. The request to cancel
+   * is asynchronous and the operation may continue to run for some time after the
+   * request to cancel is made.
+   * - An operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection.
+   * - ListOperations returns all pending operations, but not completed
+   * operations.
+   * - Operations are created by service DatastoreAdmin, but are accessed via
+   * service google.longrunning.Operations.
+   * 
+ */ + public static final class DatastoreAdminBlockingV2Stub + extends io.grpc.stub.AbstractBlockingStub { + private DatastoreAdminBlockingV2Stub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected DatastoreAdminBlockingV2Stub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreAdminBlockingV2Stub(channel, callOptions); + } + + /** + * + * + *
+     * Exports a copy of all or a subset of entities from Google Cloud Datastore
+     * to another storage system, such as Google Cloud Storage. Recent updates to
+     * entities 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.
+     * 
+ */ + public com.google.longrunning.Operation exportEntities( + com.google.datastore.admin.v1.ExportEntitiesRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getExportEntitiesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Imports entities into Google Cloud Datastore. Existing entities with the
+     * same key 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 ImportEntities operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Datastore.
+     * 
+ */ + public com.google.longrunning.Operation importEntities( + com.google.datastore.admin.v1.ImportEntitiesRequest request) + throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getImportEntitiesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates the specified index.
+     * A newly created index's initial state is `CREATING`. On completion of the
+     * returned [google.longrunning.Operation][google.longrunning.Operation], the
+     * state will be `READY`. If the index already exists, the call will return an
+     * `ALREADY_EXISTS` status.
+     * During index creation, the process could result in an error, in which
+     * case the index will move to the `ERROR` state. The process can be recovered
+     * by fixing the data that caused the error, removing the index with
+     * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then
+     * re-creating the index with [create]
+     * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
+     * Indexes with a single property cannot be created.
+     * 
+ */ + public com.google.longrunning.Operation createIndex( + com.google.datastore.admin.v1.CreateIndexRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getCreateIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes an existing index.
+     * An index can only be deleted if it is in a `READY` or `ERROR` state. On
+     * successful execution of the request, the index will be in a `DELETING`
+     * [state][google.datastore.admin.v1.Index.State]. And on completion of the
+     * returned [google.longrunning.Operation][google.longrunning.Operation], the
+     * index will be removed.
+     * During index deletion, the process could result in an error, in which
+     * case the index will move to the `ERROR` state. The process can be recovered
+     * by fixing the data that caused the error, followed by calling
+     * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.
+     * 
+ */ + public com.google.longrunning.Operation deleteIndex( + com.google.datastore.admin.v1.DeleteIndexRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getDeleteIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets an index.
+     * 
+ */ + public com.google.datastore.admin.v1.Index getIndex( + com.google.datastore.admin.v1.GetIndexRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getGetIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists the indexes that match the specified filters.  Datastore uses an
+     * eventually consistent query to fetch the list of indexes and may
+     * occasionally return stale results.
+     * 
+ */ + public com.google.datastore.admin.v1.ListIndexesResponse listIndexes( + com.google.datastore.admin.v1.ListIndexesRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getListIndexesMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do limited synchronous rpc calls to service DatastoreAdmin. + * + *
+   * Google Cloud Datastore Admin API
+   * The Datastore Admin API provides several admin services for Cloud Datastore.
+   * Concepts: Project, namespace, kind, and entity as defined in the Google Cloud
+   * Datastore API.
+   * Operation: An Operation represents work being performed in the background.
+   * EntityFilter: Allows specifying a subset of entities in a project. This is
+   * specified as a combination of kinds and namespaces (either or both of which
+   * may be all).
+   * Export/Import Service:
+   * - The Export/Import service provides the ability to copy all or a subset of
+   * entities to/from Google Cloud Storage.
+   * - Exported data may be imported into Cloud Datastore for any Google Cloud
+   * Platform project. It is not restricted to the export source project. It is
+   * possible to export from one project and then import into another.
+   * - Exported data can also be loaded into Google BigQuery for analysis.
+   * - Exports and imports are performed asynchronously. An Operation resource is
+   * created for each export/import. The state (including any errors encountered)
+   * of the export/import may be queried via the Operation resource.
+   * Index Service:
+   * - The index service manages Cloud Datastore composite indexes.
+   * - Index creation and deletion are 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.
+   * Operation Service:
+   * - 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 not yet done may be cancelled. The request to cancel
+   * is asynchronous and the operation may continue to run for some time after the
+   * request to cancel is made.
+   * - An operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection.
+   * - ListOperations returns all pending operations, but not completed
+   * operations.
+   * - Operations are created by service DatastoreAdmin, but are accessed via
+   * service google.longrunning.Operations.
+   * 
+ */ + public static final class DatastoreAdminBlockingStub + extends io.grpc.stub.AbstractBlockingStub { + private DatastoreAdminBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected DatastoreAdminBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreAdminBlockingStub(channel, callOptions); + } + + /** + * + * + *
+     * Exports a copy of all or a subset of entities from Google Cloud Datastore
+     * to another storage system, such as Google Cloud Storage. Recent updates to
+     * entities 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.
+     * 
+ */ + public com.google.longrunning.Operation exportEntities( + com.google.datastore.admin.v1.ExportEntitiesRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getExportEntitiesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Imports entities into Google Cloud Datastore. Existing entities with the
+     * same key 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 ImportEntities operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Datastore.
+     * 
+ */ + public com.google.longrunning.Operation importEntities( + com.google.datastore.admin.v1.ImportEntitiesRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getImportEntitiesMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Creates the specified index.
+     * A newly created index's initial state is `CREATING`. On completion of the
+     * returned [google.longrunning.Operation][google.longrunning.Operation], the
+     * state will be `READY`. If the index already exists, the call will return an
+     * `ALREADY_EXISTS` status.
+     * During index creation, the process could result in an error, in which
+     * case the index will move to the `ERROR` state. The process can be recovered
+     * by fixing the data that caused the error, removing the index with
+     * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then
+     * re-creating the index with [create]
+     * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
+     * Indexes with a single property cannot be created.
+     * 
+ */ + public com.google.longrunning.Operation createIndex( + com.google.datastore.admin.v1.CreateIndexRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes an existing index.
+     * An index can only be deleted if it is in a `READY` or `ERROR` state. On
+     * successful execution of the request, the index will be in a `DELETING`
+     * [state][google.datastore.admin.v1.Index.State]. And on completion of the
+     * returned [google.longrunning.Operation][google.longrunning.Operation], the
+     * index will be removed.
+     * During index deletion, the process could result in an error, in which
+     * case the index will move to the `ERROR` state. The process can be recovered
+     * by fixing the data that caused the error, followed by calling
+     * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.
+     * 
+ */ + public com.google.longrunning.Operation deleteIndex( + com.google.datastore.admin.v1.DeleteIndexRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets an index.
+     * 
+ */ + public com.google.datastore.admin.v1.Index getIndex( + com.google.datastore.admin.v1.GetIndexRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetIndexMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists the indexes that match the specified filters.  Datastore uses an
+     * eventually consistent query to fetch the list of indexes and may
+     * occasionally return stale results.
+     * 
+ */ + public com.google.datastore.admin.v1.ListIndexesResponse listIndexes( + com.google.datastore.admin.v1.ListIndexesRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListIndexesMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service DatastoreAdmin. + * + *
+   * Google Cloud Datastore Admin API
+   * The Datastore Admin API provides several admin services for Cloud Datastore.
+   * Concepts: Project, namespace, kind, and entity as defined in the Google Cloud
+   * Datastore API.
+   * Operation: An Operation represents work being performed in the background.
+   * EntityFilter: Allows specifying a subset of entities in a project. This is
+   * specified as a combination of kinds and namespaces (either or both of which
+   * may be all).
+   * Export/Import Service:
+   * - The Export/Import service provides the ability to copy all or a subset of
+   * entities to/from Google Cloud Storage.
+   * - Exported data may be imported into Cloud Datastore for any Google Cloud
+   * Platform project. It is not restricted to the export source project. It is
+   * possible to export from one project and then import into another.
+   * - Exported data can also be loaded into Google BigQuery for analysis.
+   * - Exports and imports are performed asynchronously. An Operation resource is
+   * created for each export/import. The state (including any errors encountered)
+   * of the export/import may be queried via the Operation resource.
+   * Index Service:
+   * - The index service manages Cloud Datastore composite indexes.
+   * - Index creation and deletion are 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.
+   * Operation Service:
+   * - 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 not yet done may be cancelled. The request to cancel
+   * is asynchronous and the operation may continue to run for some time after the
+   * request to cancel is made.
+   * - An operation that is done may be deleted so that it is no longer listed as
+   * part of the Operation collection.
+   * - ListOperations returns all pending operations, but not completed
+   * operations.
+   * - Operations are created by service DatastoreAdmin, but are accessed via
+   * service google.longrunning.Operations.
+   * 
+ */ + public static final class DatastoreAdminFutureStub + extends io.grpc.stub.AbstractFutureStub { + private DatastoreAdminFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected DatastoreAdminFutureStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreAdminFutureStub(channel, callOptions); + } + + /** + * + * + *
+     * Exports a copy of all or a subset of entities from Google Cloud Datastore
+     * to another storage system, such as Google Cloud Storage. Recent updates to
+     * entities 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.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + exportEntities(com.google.datastore.admin.v1.ExportEntitiesRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getExportEntitiesMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Imports entities into Google Cloud Datastore. Existing entities with the
+     * same key 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 ImportEntities operation is cancelled, it is possible
+     * that a subset of the data has already been imported to Cloud Datastore.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + importEntities(com.google.datastore.admin.v1.ImportEntitiesRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getImportEntitiesMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Creates the specified index.
+     * A newly created index's initial state is `CREATING`. On completion of the
+     * returned [google.longrunning.Operation][google.longrunning.Operation], the
+     * state will be `READY`. If the index already exists, the call will return an
+     * `ALREADY_EXISTS` status.
+     * During index creation, the process could result in an error, in which
+     * case the index will move to the `ERROR` state. The process can be recovered
+     * by fixing the data that caused the error, removing the index with
+     * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then
+     * re-creating the index with [create]
+     * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
+     * Indexes with a single property cannot be created.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + createIndex(com.google.datastore.admin.v1.CreateIndexRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCreateIndexMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes an existing index.
+     * An index can only be deleted if it is in a `READY` or `ERROR` state. On
+     * successful execution of the request, the index will be in a `DELETING`
+     * [state][google.datastore.admin.v1.Index.State]. And on completion of the
+     * returned [google.longrunning.Operation][google.longrunning.Operation], the
+     * index will be removed.
+     * During index deletion, the process could result in an error, in which
+     * case the index will move to the `ERROR` state. The process can be recovered
+     * by fixing the data that caused the error, followed by calling
+     * [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deleteIndex(com.google.datastore.admin.v1.DeleteIndexRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDeleteIndexMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets an index.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + getIndex(com.google.datastore.admin.v1.GetIndexRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetIndexMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Lists the indexes that match the specified filters.  Datastore uses an
+     * eventually consistent query to fetch the list of indexes and may
+     * occasionally return stale results.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.datastore.admin.v1.ListIndexesResponse> + listIndexes(com.google.datastore.admin.v1.ListIndexesRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListIndexesMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_EXPORT_ENTITIES = 0; + private static final int METHODID_IMPORT_ENTITIES = 1; + private static final int METHODID_CREATE_INDEX = 2; + private static final int METHODID_DELETE_INDEX = 3; + private static final int METHODID_GET_INDEX = 4; + private static final int METHODID_LIST_INDEXES = 5; + + 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_EXPORT_ENTITIES: + serviceImpl.exportEntities( + (com.google.datastore.admin.v1.ExportEntitiesRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_IMPORT_ENTITIES: + serviceImpl.importEntities( + (com.google.datastore.admin.v1.ImportEntitiesRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_CREATE_INDEX: + serviceImpl.createIndex( + (com.google.datastore.admin.v1.CreateIndexRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_DELETE_INDEX: + serviceImpl.deleteIndex( + (com.google.datastore.admin.v1.DeleteIndexRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_GET_INDEX: + serviceImpl.getIndex( + (com.google.datastore.admin.v1.GetIndexRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_INDEXES: + serviceImpl.listIndexes( + (com.google.datastore.admin.v1.ListIndexesRequest) 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( + getExportEntitiesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.admin.v1.ExportEntitiesRequest, + com.google.longrunning.Operation>(service, METHODID_EXPORT_ENTITIES))) + .addMethod( + getImportEntitiesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.admin.v1.ImportEntitiesRequest, + com.google.longrunning.Operation>(service, METHODID_IMPORT_ENTITIES))) + .addMethod( + getCreateIndexMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.admin.v1.CreateIndexRequest, + com.google.longrunning.Operation>(service, METHODID_CREATE_INDEX))) + .addMethod( + getDeleteIndexMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.admin.v1.DeleteIndexRequest, + com.google.longrunning.Operation>(service, METHODID_DELETE_INDEX))) + .addMethod( + getGetIndexMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.admin.v1.GetIndexRequest, + com.google.datastore.admin.v1.Index>(service, METHODID_GET_INDEX))) + .addMethod( + getListIndexesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.admin.v1.ListIndexesRequest, + com.google.datastore.admin.v1.ListIndexesResponse>( + service, METHODID_LIST_INDEXES))) + .build(); + } + + private abstract static class DatastoreAdminBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, + io.grpc.protobuf.ProtoServiceDescriptorSupplier { + DatastoreAdminBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("DatastoreAdmin"); + } + } + + private static final class DatastoreAdminFileDescriptorSupplier + extends DatastoreAdminBaseDescriptorSupplier { + DatastoreAdminFileDescriptorSupplier() {} + } + + private static final class DatastoreAdminMethodDescriptorSupplier + extends DatastoreAdminBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final java.lang.String methodName; + + DatastoreAdminMethodDescriptorSupplier(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 (DatastoreAdminGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = + result = + io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new DatastoreAdminFileDescriptorSupplier()) + .addMethod(getExportEntitiesMethod()) + .addMethod(getImportEntitiesMethod()) + .addMethod(getCreateIndexMethod()) + .addMethod(getDeleteIndexMethod()) + .addMethod(getGetIndexMethod()) + .addMethod(getListIndexesMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/java-datastore/grpc-google-cloud-datastore-v1/pom.xml b/java-datastore/grpc-google-cloud-datastore-v1/pom.xml new file mode 100644 index 000000000000..985fa662c700 --- /dev/null +++ b/java-datastore/grpc-google-cloud-datastore-v1/pom.xml @@ -0,0 +1,65 @@ + + 4.0.0 + com.google.api.grpc + grpc-google-cloud-datastore-v1 + 2.33.2 + grpc-google-cloud-datastore-v1 + GRPC library for google-cloud-datastore + + com.google.cloud + google-cloud-datastore-parent + 2.33.2 + + + + io.grpc + grpc-api + + + io.grpc + grpc-stub + + + io.grpc + grpc-protobuf + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-cloud-datastore-v1 + + + com.google.guava + guava + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + diff --git a/java-datastore/grpc-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/DatastoreGrpc.java b/java-datastore/grpc-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/DatastoreGrpc.java new file mode 100644 index 000000000000..7fda0f92028c --- /dev/null +++ b/java-datastore/grpc-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/DatastoreGrpc.java @@ -0,0 +1,1336 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR 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.datastore.v1; + +import static io.grpc.MethodDescriptor.generateFullMethodName; + +/** + * + * + *
+ * Each RPC normalizes the partition IDs of the keys in its input entities,
+ * and always returns entities with keys with normalized partition IDs.
+ * This applies to all keys and entities, including those in values, except keys
+ * with both an empty path and an empty or unset partition ID. Normalization of
+ * input keys sets the project ID (if not already set) to the project ID from
+ * the request.
+ * 
+ */ +@io.grpc.stub.annotations.GrpcGenerated +public final class DatastoreGrpc { + + private DatastoreGrpc() {} + + public static final java.lang.String SERVICE_NAME = "google.datastore.v1.Datastore"; + + // Static method descriptors that strictly reflect the proto. + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.v1.LookupRequest, com.google.datastore.v1.LookupResponse> + getLookupMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "Lookup", + requestType = com.google.datastore.v1.LookupRequest.class, + responseType = com.google.datastore.v1.LookupResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.v1.LookupRequest, com.google.datastore.v1.LookupResponse> + getLookupMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.v1.LookupRequest, com.google.datastore.v1.LookupResponse> + getLookupMethod; + if ((getLookupMethod = DatastoreGrpc.getLookupMethod) == null) { + synchronized (DatastoreGrpc.class) { + if ((getLookupMethod = DatastoreGrpc.getLookupMethod) == null) { + DatastoreGrpc.getLookupMethod = + getLookupMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "Lookup")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.LookupRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.LookupResponse.getDefaultInstance())) + .setSchemaDescriptor(new DatastoreMethodDescriptorSupplier("Lookup")) + .build(); + } + } + } + return getLookupMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.v1.RunQueryRequest, com.google.datastore.v1.RunQueryResponse> + getRunQueryMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "RunQuery", + requestType = com.google.datastore.v1.RunQueryRequest.class, + responseType = com.google.datastore.v1.RunQueryResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.v1.RunQueryRequest, com.google.datastore.v1.RunQueryResponse> + getRunQueryMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.v1.RunQueryRequest, com.google.datastore.v1.RunQueryResponse> + getRunQueryMethod; + if ((getRunQueryMethod = DatastoreGrpc.getRunQueryMethod) == null) { + synchronized (DatastoreGrpc.class) { + if ((getRunQueryMethod = DatastoreGrpc.getRunQueryMethod) == null) { + DatastoreGrpc.getRunQueryMethod = + getRunQueryMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "RunQuery")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.RunQueryRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.RunQueryResponse.getDefaultInstance())) + .setSchemaDescriptor(new DatastoreMethodDescriptorSupplier("RunQuery")) + .build(); + } + } + } + return getRunQueryMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.v1.RunAggregationQueryRequest, + com.google.datastore.v1.RunAggregationQueryResponse> + getRunAggregationQueryMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "RunAggregationQuery", + requestType = com.google.datastore.v1.RunAggregationQueryRequest.class, + responseType = com.google.datastore.v1.RunAggregationQueryResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.v1.RunAggregationQueryRequest, + com.google.datastore.v1.RunAggregationQueryResponse> + getRunAggregationQueryMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.v1.RunAggregationQueryRequest, + com.google.datastore.v1.RunAggregationQueryResponse> + getRunAggregationQueryMethod; + if ((getRunAggregationQueryMethod = DatastoreGrpc.getRunAggregationQueryMethod) == null) { + synchronized (DatastoreGrpc.class) { + if ((getRunAggregationQueryMethod = DatastoreGrpc.getRunAggregationQueryMethod) == null) { + DatastoreGrpc.getRunAggregationQueryMethod = + getRunAggregationQueryMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "RunAggregationQuery")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.RunAggregationQueryRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.RunAggregationQueryResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new DatastoreMethodDescriptorSupplier("RunAggregationQuery")) + .build(); + } + } + } + return getRunAggregationQueryMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.v1.BeginTransactionRequest, + com.google.datastore.v1.BeginTransactionResponse> + getBeginTransactionMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "BeginTransaction", + requestType = com.google.datastore.v1.BeginTransactionRequest.class, + responseType = com.google.datastore.v1.BeginTransactionResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.v1.BeginTransactionRequest, + com.google.datastore.v1.BeginTransactionResponse> + getBeginTransactionMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.v1.BeginTransactionRequest, + com.google.datastore.v1.BeginTransactionResponse> + getBeginTransactionMethod; + if ((getBeginTransactionMethod = DatastoreGrpc.getBeginTransactionMethod) == null) { + synchronized (DatastoreGrpc.class) { + if ((getBeginTransactionMethod = DatastoreGrpc.getBeginTransactionMethod) == null) { + DatastoreGrpc.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.datastore.v1.BeginTransactionRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.BeginTransactionResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new DatastoreMethodDescriptorSupplier("BeginTransaction")) + .build(); + } + } + } + return getBeginTransactionMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.v1.CommitRequest, com.google.datastore.v1.CommitResponse> + getCommitMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "Commit", + requestType = com.google.datastore.v1.CommitRequest.class, + responseType = com.google.datastore.v1.CommitResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.v1.CommitRequest, com.google.datastore.v1.CommitResponse> + getCommitMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.v1.CommitRequest, com.google.datastore.v1.CommitResponse> + getCommitMethod; + if ((getCommitMethod = DatastoreGrpc.getCommitMethod) == null) { + synchronized (DatastoreGrpc.class) { + if ((getCommitMethod = DatastoreGrpc.getCommitMethod) == null) { + DatastoreGrpc.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.datastore.v1.CommitRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.CommitResponse.getDefaultInstance())) + .setSchemaDescriptor(new DatastoreMethodDescriptorSupplier("Commit")) + .build(); + } + } + } + return getCommitMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.v1.RollbackRequest, com.google.datastore.v1.RollbackResponse> + getRollbackMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "Rollback", + requestType = com.google.datastore.v1.RollbackRequest.class, + responseType = com.google.datastore.v1.RollbackResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.v1.RollbackRequest, com.google.datastore.v1.RollbackResponse> + getRollbackMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.v1.RollbackRequest, com.google.datastore.v1.RollbackResponse> + getRollbackMethod; + if ((getRollbackMethod = DatastoreGrpc.getRollbackMethod) == null) { + synchronized (DatastoreGrpc.class) { + if ((getRollbackMethod = DatastoreGrpc.getRollbackMethod) == null) { + DatastoreGrpc.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.datastore.v1.RollbackRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.RollbackResponse.getDefaultInstance())) + .setSchemaDescriptor(new DatastoreMethodDescriptorSupplier("Rollback")) + .build(); + } + } + } + return getRollbackMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.v1.AllocateIdsRequest, com.google.datastore.v1.AllocateIdsResponse> + getAllocateIdsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "AllocateIds", + requestType = com.google.datastore.v1.AllocateIdsRequest.class, + responseType = com.google.datastore.v1.AllocateIdsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.v1.AllocateIdsRequest, com.google.datastore.v1.AllocateIdsResponse> + getAllocateIdsMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.v1.AllocateIdsRequest, com.google.datastore.v1.AllocateIdsResponse> + getAllocateIdsMethod; + if ((getAllocateIdsMethod = DatastoreGrpc.getAllocateIdsMethod) == null) { + synchronized (DatastoreGrpc.class) { + if ((getAllocateIdsMethod = DatastoreGrpc.getAllocateIdsMethod) == null) { + DatastoreGrpc.getAllocateIdsMethod = + getAllocateIdsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "AllocateIds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.AllocateIdsRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.AllocateIdsResponse.getDefaultInstance())) + .setSchemaDescriptor(new DatastoreMethodDescriptorSupplier("AllocateIds")) + .build(); + } + } + } + return getAllocateIdsMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.datastore.v1.ReserveIdsRequest, com.google.datastore.v1.ReserveIdsResponse> + getReserveIdsMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ReserveIds", + requestType = com.google.datastore.v1.ReserveIdsRequest.class, + responseType = com.google.datastore.v1.ReserveIdsResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.datastore.v1.ReserveIdsRequest, com.google.datastore.v1.ReserveIdsResponse> + getReserveIdsMethod() { + io.grpc.MethodDescriptor< + com.google.datastore.v1.ReserveIdsRequest, com.google.datastore.v1.ReserveIdsResponse> + getReserveIdsMethod; + if ((getReserveIdsMethod = DatastoreGrpc.getReserveIdsMethod) == null) { + synchronized (DatastoreGrpc.class) { + if ((getReserveIdsMethod = DatastoreGrpc.getReserveIdsMethod) == null) { + DatastoreGrpc.getReserveIdsMethod = + getReserveIdsMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "ReserveIds")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.ReserveIdsRequest.getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.datastore.v1.ReserveIdsResponse.getDefaultInstance())) + .setSchemaDescriptor(new DatastoreMethodDescriptorSupplier("ReserveIds")) + .build(); + } + } + } + return getReserveIdsMethod; + } + + /** Creates a new async stub that supports all call types for the service */ + public static DatastoreStub newStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public DatastoreStub newStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreStub(channel, callOptions); + } + }; + return DatastoreStub.newStub(factory, channel); + } + + /** Creates a new blocking-style stub that supports all types of calls on the service */ + public static DatastoreBlockingV2Stub newBlockingV2Stub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public DatastoreBlockingV2Stub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreBlockingV2Stub(channel, callOptions); + } + }; + return DatastoreBlockingV2Stub.newStub(factory, channel); + } + + /** + * Creates a new blocking-style stub that supports unary and streaming output calls on the service + */ + public static DatastoreBlockingStub newBlockingStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public DatastoreBlockingStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreBlockingStub(channel, callOptions); + } + }; + return DatastoreBlockingStub.newStub(factory, channel); + } + + /** Creates a new ListenableFuture-style stub that supports unary calls on the service */ + public static DatastoreFutureStub newFutureStub(io.grpc.Channel channel) { + io.grpc.stub.AbstractStub.StubFactory factory = + new io.grpc.stub.AbstractStub.StubFactory() { + @java.lang.Override + public DatastoreFutureStub newStub( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreFutureStub(channel, callOptions); + } + }; + return DatastoreFutureStub.newStub(factory, channel); + } + + /** + * + * + *
+   * Each RPC normalizes the partition IDs of the keys in its input entities,
+   * and always returns entities with keys with normalized partition IDs.
+   * This applies to all keys and entities, including those in values, except keys
+   * with both an empty path and an empty or unset partition ID. Normalization of
+   * input keys sets the project ID (if not already set) to the project ID from
+   * the request.
+   * 
+ */ + public interface AsyncService { + + /** + * + * + *
+     * Looks up entities by key.
+     * 
+ */ + default void lookup( + com.google.datastore.v1.LookupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getLookupMethod(), responseObserver); + } + + /** + * + * + *
+     * Queries for entities.
+     * 
+ */ + default void runQuery( + com.google.datastore.v1.RunQueryRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getRunQueryMethod(), responseObserver); + } + + /** + * + * + *
+     * Runs an aggregation query.
+     * 
+ */ + default void runAggregationQuery( + com.google.datastore.v1.RunAggregationQueryRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getRunAggregationQueryMethod(), responseObserver); + } + + /** + * + * + *
+     * Begins a new transaction.
+     * 
+ */ + default void beginTransaction( + com.google.datastore.v1.BeginTransactionRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getBeginTransactionMethod(), responseObserver); + } + + /** + * + * + *
+     * Commits a transaction, optionally creating, deleting or modifying some
+     * entities.
+     * 
+ */ + default void commit( + com.google.datastore.v1.CommitRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getCommitMethod(), responseObserver); + } + + /** + * + * + *
+     * Rolls back a transaction.
+     * 
+ */ + default void rollback( + com.google.datastore.v1.RollbackRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getRollbackMethod(), responseObserver); + } + + /** + * + * + *
+     * Allocates IDs for the given keys, which is useful for referencing an entity
+     * before it is inserted.
+     * 
+ */ + default void allocateIds( + com.google.datastore.v1.AllocateIdsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getAllocateIdsMethod(), responseObserver); + } + + /** + * + * + *
+     * Prevents the supplied keys' IDs from being auto-allocated by Cloud
+     * Datastore.
+     * 
+ */ + default void reserveIds( + com.google.datastore.v1.ReserveIdsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall(getReserveIdsMethod(), responseObserver); + } + } + + /** + * Base class for the server implementation of the service Datastore. + * + *
+   * Each RPC normalizes the partition IDs of the keys in its input entities,
+   * and always returns entities with keys with normalized partition IDs.
+   * This applies to all keys and entities, including those in values, except keys
+   * with both an empty path and an empty or unset partition ID. Normalization of
+   * input keys sets the project ID (if not already set) to the project ID from
+   * the request.
+   * 
+ */ + public abstract static class DatastoreImplBase implements io.grpc.BindableService, AsyncService { + + @java.lang.Override + public final io.grpc.ServerServiceDefinition bindService() { + return DatastoreGrpc.bindService(this); + } + } + + /** + * A stub to allow clients to do asynchronous rpc calls to service Datastore. + * + *
+   * Each RPC normalizes the partition IDs of the keys in its input entities,
+   * and always returns entities with keys with normalized partition IDs.
+   * This applies to all keys and entities, including those in values, except keys
+   * with both an empty path and an empty or unset partition ID. Normalization of
+   * input keys sets the project ID (if not already set) to the project ID from
+   * the request.
+   * 
+ */ + public static final class DatastoreStub extends io.grpc.stub.AbstractAsyncStub { + private DatastoreStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected DatastoreStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreStub(channel, callOptions); + } + + /** + * + * + *
+     * Looks up entities by key.
+     * 
+ */ + public void lookup( + com.google.datastore.v1.LookupRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getLookupMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Queries for entities.
+     * 
+ */ + public void runQuery( + com.google.datastore.v1.RunQueryRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getRunQueryMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Runs an aggregation query.
+     * 
+ */ + public void runAggregationQuery( + com.google.datastore.v1.RunAggregationQueryRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getRunAggregationQueryMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Begins a new transaction.
+     * 
+ */ + public void beginTransaction( + com.google.datastore.v1.BeginTransactionRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getBeginTransactionMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Commits a transaction, optionally creating, deleting or modifying some
+     * entities.
+     * 
+ */ + public void commit( + com.google.datastore.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.datastore.v1.RollbackRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getRollbackMethod(), getCallOptions()), request, responseObserver); + } + + /** + * + * + *
+     * Allocates IDs for the given keys, which is useful for referencing an entity
+     * before it is inserted.
+     * 
+ */ + public void allocateIds( + com.google.datastore.v1.AllocateIdsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getAllocateIdsMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Prevents the supplied keys' IDs from being auto-allocated by Cloud
+     * Datastore.
+     * 
+ */ + public void reserveIds( + com.google.datastore.v1.ReserveIdsRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getReserveIdsMethod(), getCallOptions()), request, responseObserver); + } + } + + /** + * A stub to allow clients to do synchronous rpc calls to service Datastore. + * + *
+   * Each RPC normalizes the partition IDs of the keys in its input entities,
+   * and always returns entities with keys with normalized partition IDs.
+   * This applies to all keys and entities, including those in values, except keys
+   * with both an empty path and an empty or unset partition ID. Normalization of
+   * input keys sets the project ID (if not already set) to the project ID from
+   * the request.
+   * 
+ */ + public static final class DatastoreBlockingV2Stub + extends io.grpc.stub.AbstractBlockingStub { + private DatastoreBlockingV2Stub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected DatastoreBlockingV2Stub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreBlockingV2Stub(channel, callOptions); + } + + /** + * + * + *
+     * Looks up entities by key.
+     * 
+ */ + public com.google.datastore.v1.LookupResponse lookup( + com.google.datastore.v1.LookupRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getLookupMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Queries for entities.
+     * 
+ */ + public com.google.datastore.v1.RunQueryResponse runQuery( + com.google.datastore.v1.RunQueryRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getRunQueryMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Runs an aggregation query.
+     * 
+ */ + public com.google.datastore.v1.RunAggregationQueryResponse runAggregationQuery( + com.google.datastore.v1.RunAggregationQueryRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getRunAggregationQueryMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Begins a new transaction.
+     * 
+ */ + public com.google.datastore.v1.BeginTransactionResponse beginTransaction( + com.google.datastore.v1.BeginTransactionRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getBeginTransactionMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Commits a transaction, optionally creating, deleting or modifying some
+     * entities.
+     * 
+ */ + public com.google.datastore.v1.CommitResponse commit( + com.google.datastore.v1.CommitRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getCommitMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Rolls back a transaction.
+     * 
+ */ + public com.google.datastore.v1.RollbackResponse rollback( + com.google.datastore.v1.RollbackRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getRollbackMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Allocates IDs for the given keys, which is useful for referencing an entity
+     * before it is inserted.
+     * 
+ */ + public com.google.datastore.v1.AllocateIdsResponse allocateIds( + com.google.datastore.v1.AllocateIdsRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getAllocateIdsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Prevents the supplied keys' IDs from being auto-allocated by Cloud
+     * Datastore.
+     * 
+ */ + public com.google.datastore.v1.ReserveIdsResponse reserveIds( + com.google.datastore.v1.ReserveIdsRequest request) throws io.grpc.StatusException { + return io.grpc.stub.ClientCalls.blockingV2UnaryCall( + getChannel(), getReserveIdsMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do limited synchronous rpc calls to service Datastore. + * + *
+   * Each RPC normalizes the partition IDs of the keys in its input entities,
+   * and always returns entities with keys with normalized partition IDs.
+   * This applies to all keys and entities, including those in values, except keys
+   * with both an empty path and an empty or unset partition ID. Normalization of
+   * input keys sets the project ID (if not already set) to the project ID from
+   * the request.
+   * 
+ */ + public static final class DatastoreBlockingStub + extends io.grpc.stub.AbstractBlockingStub { + private DatastoreBlockingStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected DatastoreBlockingStub build( + io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreBlockingStub(channel, callOptions); + } + + /** + * + * + *
+     * Looks up entities by key.
+     * 
+ */ + public com.google.datastore.v1.LookupResponse lookup( + com.google.datastore.v1.LookupRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getLookupMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Queries for entities.
+     * 
+ */ + public com.google.datastore.v1.RunQueryResponse runQuery( + com.google.datastore.v1.RunQueryRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getRunQueryMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Runs an aggregation query.
+     * 
+ */ + public com.google.datastore.v1.RunAggregationQueryResponse runAggregationQuery( + com.google.datastore.v1.RunAggregationQueryRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getRunAggregationQueryMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Begins a new transaction.
+     * 
+ */ + public com.google.datastore.v1.BeginTransactionResponse beginTransaction( + com.google.datastore.v1.BeginTransactionRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getBeginTransactionMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Commits a transaction, optionally creating, deleting or modifying some
+     * entities.
+     * 
+ */ + public com.google.datastore.v1.CommitResponse commit( + com.google.datastore.v1.CommitRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCommitMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Rolls back a transaction.
+     * 
+ */ + public com.google.datastore.v1.RollbackResponse rollback( + com.google.datastore.v1.RollbackRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getRollbackMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Allocates IDs for the given keys, which is useful for referencing an entity
+     * before it is inserted.
+     * 
+ */ + public com.google.datastore.v1.AllocateIdsResponse allocateIds( + com.google.datastore.v1.AllocateIdsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getAllocateIdsMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Prevents the supplied keys' IDs from being auto-allocated by Cloud
+     * Datastore.
+     * 
+ */ + public com.google.datastore.v1.ReserveIdsResponse reserveIds( + com.google.datastore.v1.ReserveIdsRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getReserveIdsMethod(), getCallOptions(), request); + } + } + + /** + * A stub to allow clients to do ListenableFuture-style rpc calls to service Datastore. + * + *
+   * Each RPC normalizes the partition IDs of the keys in its input entities,
+   * and always returns entities with keys with normalized partition IDs.
+   * This applies to all keys and entities, including those in values, except keys
+   * with both an empty path and an empty or unset partition ID. Normalization of
+   * input keys sets the project ID (if not already set) to the project ID from
+   * the request.
+   * 
+ */ + public static final class DatastoreFutureStub + extends io.grpc.stub.AbstractFutureStub { + private DatastoreFutureStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + super(channel, callOptions); + } + + @java.lang.Override + protected DatastoreFutureStub build(io.grpc.Channel channel, io.grpc.CallOptions callOptions) { + return new DatastoreFutureStub(channel, callOptions); + } + + /** + * + * + *
+     * Looks up entities by key.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.datastore.v1.LookupResponse> + lookup(com.google.datastore.v1.LookupRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getLookupMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Queries for entities.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.datastore.v1.RunQueryResponse> + runQuery(com.google.datastore.v1.RunQueryRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getRunQueryMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Runs an aggregation query.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.datastore.v1.RunAggregationQueryResponse> + runAggregationQuery(com.google.datastore.v1.RunAggregationQueryRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getRunAggregationQueryMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Begins a new transaction.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.datastore.v1.BeginTransactionResponse> + beginTransaction(com.google.datastore.v1.BeginTransactionRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getBeginTransactionMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Commits a transaction, optionally creating, deleting or modifying some
+     * entities.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.datastore.v1.CommitResponse> + commit(com.google.datastore.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< + com.google.datastore.v1.RollbackResponse> + rollback(com.google.datastore.v1.RollbackRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getRollbackMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Allocates IDs for the given keys, which is useful for referencing an entity
+     * before it is inserted.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.datastore.v1.AllocateIdsResponse> + allocateIds(com.google.datastore.v1.AllocateIdsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getAllocateIdsMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Prevents the supplied keys' IDs from being auto-allocated by Cloud
+     * Datastore.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.datastore.v1.ReserveIdsResponse> + reserveIds(com.google.datastore.v1.ReserveIdsRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getReserveIdsMethod(), getCallOptions()), request); + } + } + + private static final int METHODID_LOOKUP = 0; + private static final int METHODID_RUN_QUERY = 1; + private static final int METHODID_RUN_AGGREGATION_QUERY = 2; + private static final int METHODID_BEGIN_TRANSACTION = 3; + private static final int METHODID_COMMIT = 4; + private static final int METHODID_ROLLBACK = 5; + private static final int METHODID_ALLOCATE_IDS = 6; + private static final int METHODID_RESERVE_IDS = 7; + + 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_LOOKUP: + serviceImpl.lookup( + (com.google.datastore.v1.LookupRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_RUN_QUERY: + serviceImpl.runQuery( + (com.google.datastore.v1.RunQueryRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_RUN_AGGREGATION_QUERY: + serviceImpl.runAggregationQuery( + (com.google.datastore.v1.RunAggregationQueryRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_BEGIN_TRANSACTION: + serviceImpl.beginTransaction( + (com.google.datastore.v1.BeginTransactionRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_COMMIT: + serviceImpl.commit( + (com.google.datastore.v1.CommitRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_ROLLBACK: + serviceImpl.rollback( + (com.google.datastore.v1.RollbackRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_ALLOCATE_IDS: + serviceImpl.allocateIds( + (com.google.datastore.v1.AllocateIdsRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_RESERVE_IDS: + serviceImpl.reserveIds( + (com.google.datastore.v1.ReserveIdsRequest) 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( + getLookupMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.v1.LookupRequest, com.google.datastore.v1.LookupResponse>( + service, METHODID_LOOKUP))) + .addMethod( + getRunQueryMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.v1.RunQueryRequest, + com.google.datastore.v1.RunQueryResponse>(service, METHODID_RUN_QUERY))) + .addMethod( + getRunAggregationQueryMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.v1.RunAggregationQueryRequest, + com.google.datastore.v1.RunAggregationQueryResponse>( + service, METHODID_RUN_AGGREGATION_QUERY))) + .addMethod( + getBeginTransactionMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.v1.BeginTransactionRequest, + com.google.datastore.v1.BeginTransactionResponse>( + service, METHODID_BEGIN_TRANSACTION))) + .addMethod( + getCommitMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.v1.CommitRequest, com.google.datastore.v1.CommitResponse>( + service, METHODID_COMMIT))) + .addMethod( + getRollbackMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.v1.RollbackRequest, + com.google.datastore.v1.RollbackResponse>(service, METHODID_ROLLBACK))) + .addMethod( + getAllocateIdsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.v1.AllocateIdsRequest, + com.google.datastore.v1.AllocateIdsResponse>(service, METHODID_ALLOCATE_IDS))) + .addMethod( + getReserveIdsMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.datastore.v1.ReserveIdsRequest, + com.google.datastore.v1.ReserveIdsResponse>(service, METHODID_RESERVE_IDS))) + .build(); + } + + private abstract static class DatastoreBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoFileDescriptorSupplier, + io.grpc.protobuf.ProtoServiceDescriptorSupplier { + DatastoreBaseDescriptorSupplier() {} + + @java.lang.Override + public com.google.protobuf.Descriptors.FileDescriptor getFileDescriptor() { + return com.google.datastore.v1.DatastoreProto.getDescriptor(); + } + + @java.lang.Override + public com.google.protobuf.Descriptors.ServiceDescriptor getServiceDescriptor() { + return getFileDescriptor().findServiceByName("Datastore"); + } + } + + private static final class DatastoreFileDescriptorSupplier + extends DatastoreBaseDescriptorSupplier { + DatastoreFileDescriptorSupplier() {} + } + + private static final class DatastoreMethodDescriptorSupplier + extends DatastoreBaseDescriptorSupplier + implements io.grpc.protobuf.ProtoMethodDescriptorSupplier { + private final java.lang.String methodName; + + DatastoreMethodDescriptorSupplier(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 (DatastoreGrpc.class) { + result = serviceDescriptor; + if (result == null) { + serviceDescriptor = + result = + io.grpc.ServiceDescriptor.newBuilder(SERVICE_NAME) + .setSchemaDescriptor(new DatastoreFileDescriptorSupplier()) + .addMethod(getLookupMethod()) + .addMethod(getRunQueryMethod()) + .addMethod(getRunAggregationQueryMethod()) + .addMethod(getBeginTransactionMethod()) + .addMethod(getCommitMethod()) + .addMethod(getRollbackMethod()) + .addMethod(getAllocateIdsMethod()) + .addMethod(getReserveIdsMethod()) + .build(); + } + } + } + return result; + } +} diff --git a/java-datastore/owlbot.py b/java-datastore/owlbot.py new file mode 100644 index 000000000000..0d229f0729bb --- /dev/null +++ b/java-datastore/owlbot.py @@ -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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT 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 + +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' +service = 'datastore' +version = 'v1' + +for library in s.get_staging_dirs(): + # put any special-case replacements here + s.replace(f'owl-bot-staging/v1/proto-google-cloud-{service}-{version}-java/src/**/*.java', protobuf_header, f'{license_header}{protobuf_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-datastore/pom.xml b/java-datastore/pom.xml new file mode 100644 index 000000000000..adf2cf23a763 --- /dev/null +++ b/java-datastore/pom.xml @@ -0,0 +1,248 @@ + + + 4.0.0 + com.google.cloud + google-cloud-datastore-parent + pom + 2.33.2 + Google Cloud Datastore Parent + https://github.com/googleapis/google-cloud-java + + Java idiomatic client for Google Cloud Platform services. + + + + com.google.cloud + google-cloud-jar-parent + 1.77.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-datastore-parent + https://googleapis.dev/java/google-api-grpc/latest + + + + 2.42.0 + + + + + + com.google.cloud + google-cloud-shared-dependencies + ${google-cloud-shared-dependencies.version} + pom + import + + + + com.google.api.grpc + proto-google-cloud-datastore-admin-v1 + 2.33.2 + + + com.google.api.grpc + grpc-google-cloud-datastore-admin-v1 + 2.33.2 + + + com.google.cloud + google-cloud-datastore + 2.33.2 + + + com.google.api.grpc + proto-google-cloud-datastore-v1 + 0.124.2 + + + com.google.api.grpc + grpc-google-cloud-datastore-v1 + 2.33.2 + + + com.google.cloud + google-cloud-datastore-utils + 2.31.2 + + + com.google.cloud.datastore + datastore-v1-proto-client + 2.33.2 + + + com.google.api.grpc + proto-google-cloud-datastore-v1 + + + + + junit + junit + 4.13.2 + test + + + org.easymock + easymock + 5.6.0 + test + + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + com.google.http-client:google-http-client-jackson2 + com.google.oauth-client:google-oauth-client + javax.annotation:javax.annotation-api + + + + + + + + + google-cloud-datastore + grpc-google-cloud-datastore-admin-v1 + proto-google-cloud-datastore-v1 + proto-google-cloud-datastore-admin-v1 + grpc-google-cloud-datastore-v1 + datastore-v1-proto-client + google-cloud-datastore-bom + google-cloud-datastore-utils + + + diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/clirr-ignored-differences.xml b/java-datastore/proto-google-cloud-datastore-admin-v1/clirr-ignored-differences.xml new file mode 100644 index 000000000000..7cf3ac808fad --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/clirr-ignored-differences.xml @@ -0,0 +1,81 @@ + + + + + 7012 + com/google/datastore/admin/v1/*OrBuilder + * get*(*) + + + 7012 + com/google/datastore/admin/v1/*OrBuilder + boolean contains*(*) + + + 7012 + com/google/datastore/admin/v1/*OrBuilder + boolean has*(*) + + + + + 7006 + com/google/datastore/admin/v1/** + * getDefaultInstanceForType() + ** + + + 7006 + com/google/datastore/admin/v1/** + * addRepeatedField(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * clear() + ** + + + 7006 + com/google/datastore/admin/v1/** + * clearField(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * clearOneof(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * clone() + ** + + + 7006 + com/google/datastore/admin/v1/** + * mergeUnknownFields(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * setField(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * setRepeatedField(*) + ** + + + 7006 + com/google/datastore/admin/v1/** + * setUnknownFields(*) + ** + + diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/pom.xml b/java-datastore/proto-google-cloud-datastore-admin-v1/pom.xml new file mode 100644 index 000000000000..b1146db027e2 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/pom.xml @@ -0,0 +1,34 @@ + + 4.0.0 + com.google.api.grpc + proto-google-cloud-datastore-admin-v1 + 2.33.2 + proto-google-cloud-datastore-admin-v1 + Proto library for google-cloud-datastore + + com.google.cloud + google-cloud-datastore-parent + 2.33.2 + + + + com.google.protobuf + protobuf-java + + + com.google.api.grpc + proto-google-common-protos + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadata.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadata.java new file mode 100644 index 000000000000..0d6df98015af --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadata.java @@ -0,0 +1,1962 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * Metadata common to all Datastore Admin operations.
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.CommonMetadata} + */ +public final class CommonMetadata extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.CommonMetadata) + CommonMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + // Use CommonMetadata.newBuilder() to construct. + private CommonMetadata(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CommonMetadata() { + operationType_ = 0; + state_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CommonMetadata(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CommonMetadata_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.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CommonMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.CommonMetadata.class, + com.google.datastore.admin.v1.CommonMetadata.Builder.class); + } + + /** + * + * + *
+   * The various possible states for an ongoing Operation.
+   * 
+ * + * Protobuf enum {@code google.datastore.admin.v1.CommonMetadata.State} + */ + public enum State implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + 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), + ; + + /** + * + * + *
+     * Unspecified.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + public static final int 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 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 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 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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.admin.v1.CommonMetadata.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.datastore.admin.v1.CommonMetadata.State) + } + + private int bitField0_; + public static final int START_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp startTime_; + + /** + * + * + *
+   * The time that work began on the operation.
+   * 
+ * + * .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 that work began on the operation.
+   * 
+ * + * .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 that work began on the operation.
+   * 
+ * + * .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 operation ended, either successfully or otherwise.
+   * 
+ * + * .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 operation ended, either successfully or otherwise.
+   * 
+ * + * .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 operation ended, either successfully or otherwise.
+   * 
+ * + * .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_TYPE_FIELD_NUMBER = 3; + private int operationType_ = 0; + + /** + * + * + *
+   * The type of the operation. Can be used as a filter in
+   * ListOperationsRequest.
+   * 
+ * + * .google.datastore.admin.v1.OperationType operation_type = 3; + * + * @return The enum numeric value on the wire for operationType. + */ + @java.lang.Override + public int getOperationTypeValue() { + return operationType_; + } + + /** + * + * + *
+   * The type of the operation. Can be used as a filter in
+   * ListOperationsRequest.
+   * 
+ * + * .google.datastore.admin.v1.OperationType operation_type = 3; + * + * @return The operationType. + */ + @java.lang.Override + public com.google.datastore.admin.v1.OperationType getOperationType() { + com.google.datastore.admin.v1.OperationType result = + com.google.datastore.admin.v1.OperationType.forNumber(operationType_); + return result == null ? com.google.datastore.admin.v1.OperationType.UNRECOGNIZED : result; + } + + 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.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CommonMetadata_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(); + } + + /** + * + * + *
+   * The client-assigned labels which were provided when the operation was
+   * created. May also include additional labels.
+   * 
+ * + * 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(); + } + + /** + * + * + *
+   * The client-assigned labels which were provided when the operation was
+   * created. May also include additional labels.
+   * 
+ * + * map<string, string> labels = 4; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+   * The client-assigned labels which were provided when the operation was
+   * created. May also include additional labels.
+   * 
+ * + * 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; + } + + /** + * + * + *
+   * The client-assigned labels which were provided when the operation was
+   * created. May also include additional labels.
+   * 
+ * + * 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 static final int STATE_FIELD_NUMBER = 5; + private int state_ = 0; + + /** + * + * + *
+   * The current state of the Operation.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata.State state = 5; + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+   * The current state of the Operation.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata.State state = 5; + * + * @return The state. + */ + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadata.State getState() { + com.google.datastore.admin.v1.CommonMetadata.State result = + com.google.datastore.admin.v1.CommonMetadata.State.forNumber(state_); + return result == null + ? com.google.datastore.admin.v1.CommonMetadata.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 (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getStartTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getEndTime()); + } + if (operationType_ + != com.google.datastore.admin.v1.OperationType.OPERATION_TYPE_UNSPECIFIED.getNumber()) { + output.writeEnum(3, operationType_); + } + com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( + output, internalGetLabels(), LabelsDefaultEntryHolder.defaultEntry, 4); + if (state_ + != com.google.datastore.admin.v1.CommonMetadata.State.STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(5, state_); + } + 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 (operationType_ + != com.google.datastore.admin.v1.OperationType.OPERATION_TYPE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(3, operationType_); + } + 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__); + } + if (state_ + != com.google.datastore.admin.v1.CommonMetadata.State.STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(5, 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.datastore.admin.v1.CommonMetadata)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.CommonMetadata other = + (com.google.datastore.admin.v1.CommonMetadata) 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 (operationType_ != other.operationType_) return false; + if (!internalGetLabels().equals(other.internalGetLabels())) 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(); + 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_TYPE_FIELD_NUMBER; + hash = (53 * hash) + operationType_; + if (!internalGetLabels().getMap().isEmpty()) { + hash = (37 * hash) + LABELS_FIELD_NUMBER; + hash = (53 * hash) + internalGetLabels().hashCode(); + } + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.CommonMetadata parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.CommonMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.CommonMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.CommonMetadata 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.datastore.admin.v1.CommonMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.CommonMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.CommonMetadata parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.CommonMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.CommonMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.CommonMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.CommonMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.CommonMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.CommonMetadata 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.CommonMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.CommonMetadata) + com.google.datastore.admin.v1.CommonMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CommonMetadata_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.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CommonMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.CommonMetadata.class, + com.google.datastore.admin.v1.CommonMetadata.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.CommonMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getStartTimeFieldBuilder(); + getEndTimeFieldBuilder(); + } + } + + @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; + } + operationType_ = 0; + internalGetMutableLabels().clear(); + state_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CommonMetadata_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadata getDefaultInstanceForType() { + return com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadata build() { + com.google.datastore.admin.v1.CommonMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadata buildPartial() { + com.google.datastore.admin.v1.CommonMetadata result = + new com.google.datastore.admin.v1.CommonMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.CommonMetadata 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.operationType_ = operationType_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.labels_ = internalGetLabels(); + result.labels_.makeImmutable(); + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.state_ = state_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.CommonMetadata) { + return mergeFrom((com.google.datastore.admin.v1.CommonMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.CommonMetadata other) { + if (other == com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance()) return this; + if (other.hasStartTime()) { + mergeStartTime(other.getStartTime()); + } + if (other.hasEndTime()) { + mergeEndTime(other.getEndTime()); + } + if (other.operationType_ != 0) { + setOperationTypeValue(other.getOperationTypeValue()); + } + internalGetMutableLabels().mergeFrom(other.internalGetLabels()); + bitField0_ |= 0x00000008; + 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: + { + input.readMessage(getStartTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getEndTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + operationType_ = input.readEnum(); + bitField0_ |= 0x00000004; + 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 + case 40: + { + state_ = input.readEnum(); + 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 com.google.protobuf.Timestamp startTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + startTimeBuilder_; + + /** + * + * + *
+     * The time that work began on the operation.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + public boolean hasStartTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The time that work began on the operation.
+     * 
+ * + * .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 that work began on the operation.
+     * 
+ * + * .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 that work began on the operation.
+     * 
+ * + * .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 that work began on the operation.
+     * 
+ * + * .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 that work began on the operation.
+     * 
+ * + * .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 that work began on the operation.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + public com.google.protobuf.Timestamp.Builder getStartTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getStartTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time that work began on the operation.
+     * 
+ * + * .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 that work began on the operation.
+     * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getStartTimeFieldBuilder() { + if (startTimeBuilder_ == null) { + startTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + 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.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + endTimeBuilder_; + + /** + * + * + *
+     * The time the operation ended, either successfully or otherwise.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + public boolean hasEndTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The time the operation ended, either successfully or otherwise.
+     * 
+ * + * .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 operation ended, either successfully or otherwise.
+     * 
+ * + * .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 operation ended, either successfully or otherwise.
+     * 
+ * + * .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 operation ended, either successfully or otherwise.
+     * 
+ * + * .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 operation ended, either successfully or otherwise.
+     * 
+ * + * .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 operation ended, either successfully or otherwise.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + public com.google.protobuf.Timestamp.Builder getEndTimeBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getEndTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time the operation ended, either successfully or otherwise.
+     * 
+ * + * .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 operation ended, either successfully or otherwise.
+     * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getEndTimeFieldBuilder() { + if (endTimeBuilder_ == null) { + endTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getEndTime(), getParentForChildren(), isClean()); + endTime_ = null; + } + return endTimeBuilder_; + } + + private int operationType_ = 0; + + /** + * + * + *
+     * The type of the operation. Can be used as a filter in
+     * ListOperationsRequest.
+     * 
+ * + * .google.datastore.admin.v1.OperationType operation_type = 3; + * + * @return The enum numeric value on the wire for operationType. + */ + @java.lang.Override + public int getOperationTypeValue() { + return operationType_; + } + + /** + * + * + *
+     * The type of the operation. Can be used as a filter in
+     * ListOperationsRequest.
+     * 
+ * + * .google.datastore.admin.v1.OperationType operation_type = 3; + * + * @param value The enum numeric value on the wire for operationType to set. + * @return This builder for chaining. + */ + public Builder setOperationTypeValue(int value) { + operationType_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The type of the operation. Can be used as a filter in
+     * ListOperationsRequest.
+     * 
+ * + * .google.datastore.admin.v1.OperationType operation_type = 3; + * + * @return The operationType. + */ + @java.lang.Override + public com.google.datastore.admin.v1.OperationType getOperationType() { + com.google.datastore.admin.v1.OperationType result = + com.google.datastore.admin.v1.OperationType.forNumber(operationType_); + return result == null ? com.google.datastore.admin.v1.OperationType.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The type of the operation. Can be used as a filter in
+     * ListOperationsRequest.
+     * 
+ * + * .google.datastore.admin.v1.OperationType operation_type = 3; + * + * @param value The operationType to set. + * @return This builder for chaining. + */ + public Builder setOperationType(com.google.datastore.admin.v1.OperationType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + operationType_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The type of the operation. Can be used as a filter in
+     * ListOperationsRequest.
+     * 
+ * + * .google.datastore.admin.v1.OperationType operation_type = 3; + * + * @return This builder for chaining. + */ + public Builder clearOperationType() { + bitField0_ = (bitField0_ & ~0x00000004); + operationType_ = 0; + 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(); + } + + /** + * + * + *
+     * The client-assigned labels which were provided when the operation was
+     * created. May also include additional labels.
+     * 
+ * + * 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(); + } + + /** + * + * + *
+     * The client-assigned labels which were provided when the operation was
+     * created. May also include additional labels.
+     * 
+ * + * map<string, string> labels = 4; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+     * The client-assigned labels which were provided when the operation was
+     * created. May also include additional labels.
+     * 
+ * + * 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; + } + + /** + * + * + *
+     * The client-assigned labels which were provided when the operation was
+     * created. May also include additional labels.
+     * 
+ * + * 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; + } + + /** + * + * + *
+     * The client-assigned labels which were provided when the operation was
+     * created. May also include additional labels.
+     * 
+ * + * 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(); + } + + /** + * + * + *
+     * The client-assigned labels which were provided when the operation was
+     * created. May also include additional labels.
+     * 
+ * + * 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; + } + + /** + * + * + *
+     * The client-assigned labels which were provided when the operation was
+     * created. May also include additional labels.
+     * 
+ * + * map<string, string> labels = 4; + */ + public Builder putAllLabels(java.util.Map values) { + internalGetMutableLabels().getMutableMap().putAll(values); + bitField0_ |= 0x00000008; + return this; + } + + private int state_ = 0; + + /** + * + * + *
+     * The current state of the Operation.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata.State state = 5; + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+     * The current state of the Operation.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata.State 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 current state of the Operation.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata.State state = 5; + * + * @return The state. + */ + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadata.State getState() { + com.google.datastore.admin.v1.CommonMetadata.State result = + com.google.datastore.admin.v1.CommonMetadata.State.forNumber(state_); + return result == null + ? com.google.datastore.admin.v1.CommonMetadata.State.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * The current state of the Operation.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata.State state = 5; + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.datastore.admin.v1.CommonMetadata.State value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000010; + state_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The current state of the Operation.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata.State state = 5; + * + * @return This builder for chaining. + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000010); + state_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.CommonMetadata) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.CommonMetadata) + private static final com.google.datastore.admin.v1.CommonMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.CommonMetadata(); + } + + public static com.google.datastore.admin.v1.CommonMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CommonMetadata 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.datastore.admin.v1.CommonMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadataOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadataOrBuilder.java new file mode 100644 index 000000000000..59a484b0c75d --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CommonMetadataOrBuilder.java @@ -0,0 +1,222 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface CommonMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.CommonMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The time that work began on the operation.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return Whether the startTime field is set. + */ + boolean hasStartTime(); + + /** + * + * + *
+   * The time that work began on the operation.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + * + * @return The startTime. + */ + com.google.protobuf.Timestamp getStartTime(); + + /** + * + * + *
+   * The time that work began on the operation.
+   * 
+ * + * .google.protobuf.Timestamp start_time = 1; + */ + com.google.protobuf.TimestampOrBuilder getStartTimeOrBuilder(); + + /** + * + * + *
+   * The time the operation ended, either successfully or otherwise.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return Whether the endTime field is set. + */ + boolean hasEndTime(); + + /** + * + * + *
+   * The time the operation ended, either successfully or otherwise.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + * + * @return The endTime. + */ + com.google.protobuf.Timestamp getEndTime(); + + /** + * + * + *
+   * The time the operation ended, either successfully or otherwise.
+   * 
+ * + * .google.protobuf.Timestamp end_time = 2; + */ + com.google.protobuf.TimestampOrBuilder getEndTimeOrBuilder(); + + /** + * + * + *
+   * The type of the operation. Can be used as a filter in
+   * ListOperationsRequest.
+   * 
+ * + * .google.datastore.admin.v1.OperationType operation_type = 3; + * + * @return The enum numeric value on the wire for operationType. + */ + int getOperationTypeValue(); + + /** + * + * + *
+   * The type of the operation. Can be used as a filter in
+   * ListOperationsRequest.
+   * 
+ * + * .google.datastore.admin.v1.OperationType operation_type = 3; + * + * @return The operationType. + */ + com.google.datastore.admin.v1.OperationType getOperationType(); + + /** + * + * + *
+   * The client-assigned labels which were provided when the operation was
+   * created. May also include additional labels.
+   * 
+ * + * map<string, string> labels = 4; + */ + int getLabelsCount(); + + /** + * + * + *
+   * The client-assigned labels which were provided when the operation was
+   * created. May also include additional labels.
+   * 
+ * + * map<string, string> labels = 4; + */ + boolean containsLabels(java.lang.String key); + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getLabels(); + + /** + * + * + *
+   * The client-assigned labels which were provided when the operation was
+   * created. May also include additional labels.
+   * 
+ * + * map<string, string> labels = 4; + */ + java.util.Map getLabelsMap(); + + /** + * + * + *
+   * The client-assigned labels which were provided when the operation was
+   * created. May also include additional labels.
+   * 
+ * + * map<string, string> labels = 4; + */ + /* nullable */ + java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue); + + /** + * + * + *
+   * The client-assigned labels which were provided when the operation was
+   * created. May also include additional labels.
+   * 
+ * + * map<string, string> labels = 4; + */ + java.lang.String getLabelsOrThrow(java.lang.String key); + + /** + * + * + *
+   * The current state of the Operation.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata.State state = 5; + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + + /** + * + * + *
+   * The current state of the Operation.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata.State state = 5; + * + * @return The state. + */ + com.google.datastore.admin.v1.CommonMetadata.State getState(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequest.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequest.java new file mode 100644 index 000000000000..07885be65c65 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequest.java @@ -0,0 +1,931 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex][google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.CreateIndexRequest} + */ +public final class CreateIndexRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.CreateIndexRequest) + CreateIndexRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use CreateIndexRequest.newBuilder() to construct. + private CreateIndexRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CreateIndexRequest() { + projectId_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreateIndexRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CreateIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CreateIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.CreateIndexRequest.class, + com.google.datastore.admin.v1.CreateIndexRequest.Builder.class); + } + + private int bitField0_; + public static final int PROJECT_ID_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INDEX_FIELD_NUMBER = 3; + private com.google.datastore.admin.v1.Index index_; + + /** + * + * + *
+   * The index to create. The name and state fields are output only and will be
+   * ignored. Single property indexes cannot be created or deleted.
+   * 
+ * + * .google.datastore.admin.v1.Index index = 3; + * + * @return Whether the index field is set. + */ + @java.lang.Override + public boolean hasIndex() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The index to create. The name and state fields are output only and will be
+   * ignored. Single property indexes cannot be created or deleted.
+   * 
+ * + * .google.datastore.admin.v1.Index index = 3; + * + * @return The index. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Index getIndex() { + return index_ == null ? com.google.datastore.admin.v1.Index.getDefaultInstance() : index_; + } + + /** + * + * + *
+   * The index to create. The name and state fields are output only and will be
+   * ignored. Single property indexes cannot be created or deleted.
+   * 
+ * + * .google.datastore.admin.v1.Index index = 3; + */ + @java.lang.Override + public com.google.datastore.admin.v1.IndexOrBuilder getIndexOrBuilder() { + return index_ == null ? com.google.datastore.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.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, projectId_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getIndex()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, projectId_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, 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.datastore.admin.v1.CreateIndexRequest)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.CreateIndexRequest other = + (com.google.datastore.admin.v1.CreateIndexRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().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.datastore.admin.v1.CreateIndexRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.CreateIndexRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.CreateIndexRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.CreateIndexRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.CreateIndexRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.CreateIndexRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.CreateIndexRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.CreateIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.CreateIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [google.datastore.admin.v1.DatastoreAdmin.CreateIndex][google.datastore.admin.v1.DatastoreAdmin.CreateIndex].
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.CreateIndexRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.CreateIndexRequest) + com.google.datastore.admin.v1.CreateIndexRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CreateIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CreateIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.CreateIndexRequest.class, + com.google.datastore.admin.v1.CreateIndexRequest.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.CreateIndexRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getIndexFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + index_ = null; + if (indexBuilder_ != null) { + indexBuilder_.dispose(); + indexBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_CreateIndexRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.CreateIndexRequest getDefaultInstanceForType() { + return com.google.datastore.admin.v1.CreateIndexRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.CreateIndexRequest build() { + com.google.datastore.admin.v1.CreateIndexRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.CreateIndexRequest buildPartial() { + com.google.datastore.admin.v1.CreateIndexRequest result = + new com.google.datastore.admin.v1.CreateIndexRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.CreateIndexRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + 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 clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.CreateIndexRequest) { + return mergeFrom((com.google.datastore.admin.v1.CreateIndexRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.CreateIndexRequest other) { + if (other == com.google.datastore.admin.v1.CreateIndexRequest.getDefaultInstance()) + return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + 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: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + input.readMessage(getIndexFieldBuilder().getBuilder(), extensionRegistry); + 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 projectId_ = ""; + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.datastore.admin.v1.Index index_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Index, + com.google.datastore.admin.v1.Index.Builder, + com.google.datastore.admin.v1.IndexOrBuilder> + indexBuilder_; + + /** + * + * + *
+     * The index to create. The name and state fields are output only and will be
+     * ignored. Single property indexes cannot be created or deleted.
+     * 
+ * + * .google.datastore.admin.v1.Index index = 3; + * + * @return Whether the index field is set. + */ + public boolean hasIndex() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The index to create. The name and state fields are output only and will be
+     * ignored. Single property indexes cannot be created or deleted.
+     * 
+ * + * .google.datastore.admin.v1.Index index = 3; + * + * @return The index. + */ + public com.google.datastore.admin.v1.Index getIndex() { + if (indexBuilder_ == null) { + return index_ == null ? com.google.datastore.admin.v1.Index.getDefaultInstance() : index_; + } else { + return indexBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The index to create. The name and state fields are output only and will be
+     * ignored. Single property indexes cannot be created or deleted.
+     * 
+ * + * .google.datastore.admin.v1.Index index = 3; + */ + public Builder setIndex(com.google.datastore.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 to create. The name and state fields are output only and will be
+     * ignored. Single property indexes cannot be created or deleted.
+     * 
+ * + * .google.datastore.admin.v1.Index index = 3; + */ + public Builder setIndex(com.google.datastore.admin.v1.Index.Builder builderForValue) { + if (indexBuilder_ == null) { + index_ = builderForValue.build(); + } else { + indexBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The index to create. The name and state fields are output only and will be
+     * ignored. Single property indexes cannot be created or deleted.
+     * 
+ * + * .google.datastore.admin.v1.Index index = 3; + */ + public Builder mergeIndex(com.google.datastore.admin.v1.Index value) { + if (indexBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && index_ != null + && index_ != com.google.datastore.admin.v1.Index.getDefaultInstance()) { + getIndexBuilder().mergeFrom(value); + } else { + index_ = value; + } + } else { + indexBuilder_.mergeFrom(value); + } + if (index_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The index to create. The name and state fields are output only and will be
+     * ignored. Single property indexes cannot be created or deleted.
+     * 
+ * + * .google.datastore.admin.v1.Index index = 3; + */ + public Builder clearIndex() { + bitField0_ = (bitField0_ & ~0x00000002); + index_ = null; + if (indexBuilder_ != null) { + indexBuilder_.dispose(); + indexBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The index to create. The name and state fields are output only and will be
+     * ignored. Single property indexes cannot be created or deleted.
+     * 
+ * + * .google.datastore.admin.v1.Index index = 3; + */ + public com.google.datastore.admin.v1.Index.Builder getIndexBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getIndexFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The index to create. The name and state fields are output only and will be
+     * ignored. Single property indexes cannot be created or deleted.
+     * 
+ * + * .google.datastore.admin.v1.Index index = 3; + */ + public com.google.datastore.admin.v1.IndexOrBuilder getIndexOrBuilder() { + if (indexBuilder_ != null) { + return indexBuilder_.getMessageOrBuilder(); + } else { + return index_ == null ? com.google.datastore.admin.v1.Index.getDefaultInstance() : index_; + } + } + + /** + * + * + *
+     * The index to create. The name and state fields are output only and will be
+     * ignored. Single property indexes cannot be created or deleted.
+     * 
+ * + * .google.datastore.admin.v1.Index index = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Index, + com.google.datastore.admin.v1.Index.Builder, + com.google.datastore.admin.v1.IndexOrBuilder> + getIndexFieldBuilder() { + if (indexBuilder_ == null) { + indexBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Index, + com.google.datastore.admin.v1.Index.Builder, + com.google.datastore.admin.v1.IndexOrBuilder>( + getIndex(), getParentForChildren(), isClean()); + index_ = null; + } + return indexBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.CreateIndexRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.CreateIndexRequest) + private static final com.google.datastore.admin.v1.CreateIndexRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.CreateIndexRequest(); + } + + public static com.google.datastore.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.datastore.admin.v1.CreateIndexRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequestOrBuilder.java new file mode 100644 index 000000000000..0dc20129c49c --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/CreateIndexRequestOrBuilder.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface CreateIndexRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.CreateIndexRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The index to create. The name and state fields are output only and will be
+   * ignored. Single property indexes cannot be created or deleted.
+   * 
+ * + * .google.datastore.admin.v1.Index index = 3; + * + * @return Whether the index field is set. + */ + boolean hasIndex(); + + /** + * + * + *
+   * The index to create. The name and state fields are output only and will be
+   * ignored. Single property indexes cannot be created or deleted.
+   * 
+ * + * .google.datastore.admin.v1.Index index = 3; + * + * @return The index. + */ + com.google.datastore.admin.v1.Index getIndex(); + + /** + * + * + *
+   * The index to create. The name and state fields are output only and will be
+   * ignored. Single property indexes cannot be created or deleted.
+   * 
+ * + * .google.datastore.admin.v1.Index index = 3; + */ + com.google.datastore.admin.v1.IndexOrBuilder getIndexOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreAdminProto.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreAdminProto.java new file mode 100644 index 000000000000..f9a63cb86526 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreAdminProto.java @@ -0,0 +1,421 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public final class DatastoreAdminProto { + private DatastoreAdminProto() {} + + 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_datastore_admin_v1_CommonMetadata_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_CommonMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_CommonMetadata_LabelsEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_CommonMetadata_LabelsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_Progress_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_Progress_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_LabelsEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_LabelsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_LabelsEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_LabelsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_ExportEntitiesResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_ExportEntitiesResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_ExportEntitiesMetadata_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_ExportEntitiesMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_ImportEntitiesMetadata_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_ImportEntitiesMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_EntityFilter_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_EntityFilter_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_CreateIndexRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_CreateIndexRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_DeleteIndexRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_DeleteIndexRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_GetIndexRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_GetIndexRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_ListIndexesRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_ListIndexesRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_ListIndexesResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_ListIndexesResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_IndexOperationMetadata_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_IndexOperationMetadata_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_DatastoreFirestoreMigrationMetadata_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_DatastoreFirestoreMigrationMetadata_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/datastore/admin/v1/datastore_ad" + + "min.proto\022\031google.datastore.admin.v1\032\034go" + + "ogle/api/annotations.proto\032\027google/api/c" + + "lient.proto\032\037google/api/field_behavior.p" + + "roto\032%google/datastore/admin/v1/index.proto\032)google/datastore/admin/v1/migration" + + ".proto\032#google/longrunning/operations.proto\032\037google/protobuf/timestamp.proto\"\364\003\n" + + "\016CommonMetadata\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@\n" + + "\016operation_type\030\003 \001(\0162(.google.datastore.admin.v1.OperationType\022E\n" + + "\006labels\030\004 \003(\01325.google" + + ".datastore.admin.v1.CommonMetadata.LabelsEntry\022>\n" + + "\005state\030\005 \001(\0162/.google.datastore.admin.v1.CommonMetadata.State\032-\n" + + "\013LabelsEntry\022\013\n" + + "\003key\030\001 \001(\t\022\r\n" + + "\005value\030\002 \001(\t:\0028\001\"\213\001\n" + + "\005State\022\025\n" + + "\021STATE_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\007\":\n" + + "\010Progress\022\026\n" + + "\016work_completed\030\001 \001(\003\022\026\n" + + "\016work_estimated\030\002 \001(\003\"\215\002\n" + + "\025ExportEntitiesRequest\022\027\n\n" + + "project_id\030\001 \001(\tB\003\340A\002\022L\n" + + "\006labels\030\002 \003(\0132<.google.data" + + "store.admin.v1.ExportEntitiesRequest.LabelsEntry\022>\n\r" + + "entity_filter\030\003 \001(\0132\'.google.datastore.admin.v1.EntityFilter\022\036\n" + + "\021output_url_prefix\030\004 \001(\tB\003\340A\002\032-\n" + + "\013LabelsEntry\022\013\n" + + "\003key\030\001 \001(\t\022\r\n" + + "\005value\030\002 \001(\t:\0028\001\"\205\002\n" + + "\025ImportEntitiesRequest\022\027\n\n" + + "project_id\030\001 \001(\tB\003\340A\002\022L\n" + + "\006labels\030\002 \003(\0132<.google.datastore.ad" + + "min.v1.ImportEntitiesRequest.LabelsEntry\022\026\n" + + "\tinput_url\030\003 \001(\tB\003\340A\002\022>\n\r" + + "entity_filter\030\004 \001(\0132\'.google.datastore.admin.v1.EntityFilter\032-\n" + + "\013LabelsEntry\022\013\n" + + "\003key\030\001 \001(\t\022\r\n" + + "\005value\030\002 \001(\t:\0028\001\",\n" + + "\026ExportEntitiesResponse\022\022\n\n" + + "output_url\030\001 \001(\t\"\253\002\n" + + "\026ExportEntitiesMetadata\0229\n" + + "\006common\030\001 \001(\0132).google.datastore.admin.v1.CommonMetadata\022>\n" + + "\021progress_entities\030\002 \001(\0132#.google.datastore.admin.v1.Progress\022;\n" + + "\016progress_bytes\030\003 \001(\0132#.google.datastore.admin.v1.Progress\022>\n\r" + + "entity_filter\030\004 \001(\0132\'.google.datastore.admin.v1.EntityFilter\022\031\n" + + "\021output_url_prefix\030\005 \001(\t\"\243\002\n" + + "\026ImportEntitiesMetadata\0229\n" + + "\006common\030\001 \001(\0132).google.datastore.admin.v1.CommonMetadata\022>\n" + + "\021progress_entities\030\002 \001(\0132#.google.datastore.admin.v1.Progress\022;\n" + + "\016progress_bytes\030\003 \001(\0132#.google.datastore.admin.v1.Progress\022>\n\r" + + "entity_filter\030\004 \001(\0132\'.google.datastore.admin.v1.EntityFilter\022\021\n" + + "\tinput_url\030\005 \001(\t\"4\n" + + "\014EntityFilter\022\r\n" + + "\005kinds\030\001 \003(\t\022\025\n\r" + + "namespace_ids\030\002 \003(\t\"Y\n" + + "\022CreateIndexRequest\022\022\n\n" + + "project_id\030\001 \001(\t\022/\n" + + "\005index\030\003 \001(\0132 .google.datastore.admin.v1.Index\":\n" + + "\022DeleteIndexRequest\022\022\n\n" + + "project_id\030\001 \001(\t\022\020\n" + + "\010index_id\030\003 \001(\t\"7\n" + + "\017GetIndexRequest\022\022\n\n" + + "project_id\030\001 \001(\t\022\020\n" + + "\010index_id\030\003 \001(\t\"_\n" + + "\022ListIndexesRequest\022\022\n\n" + + "project_id\030\001 \001(\t\022\016\n" + + "\006filter\030\003 \001(\t\022\021\n" + + "\tpage_size\030\004 \001(\005\022\022\n\n" + + "page_token\030\005 \001(\t\"a\n" + + "\023ListIndexesResponse\0221\n" + + "\007indexes\030\001 \003(\0132 .google.datastore.admin.v1.Index\022\027\n" + + "\017next_page_token\030\002 \001(\t\"\245\001\n" + + "\026IndexOperationMetadata\0229\n" + + "\006common\030\001 \001(\0132).google.datastore.admin.v1.CommonMetadata\022>\n" + + "\021progress_entities\030\002 \001(\0132#.google.datastore.admin.v1.Progress\022\020\n" + + "\010index_id\030\003 \001(\t\"\253\001\n" + + "#DatastoreFirestoreMigrationMetadata\022B\n" + + "\017migration_state\030\001" + + " \001(\0162).google.datastore.admin.v1.MigrationState\022@\n" + + "\016migration_step\030\002 \001(\0162(.google.datastore.admin.v1.MigrationStep*}\n\r" + + "OperationType\022\036\n" + + "\032OPERATION_TYPE_UNSPECIFIED\020\000\022\023\n" + + "\017EXPORT_ENTITIES\020\001\022\023\n" + + "\017IMPORT_ENTITIES\020\002\022\020\n" + + "\014CREATE_INDEX\020\003\022\020\n" + + "\014DELETE_INDEX\020\0042\204\n\n" + + "\016DatastoreAdmin\022\366\001\n" + + "\016ExportEntities\0220.google.datastor" + + "e.admin.v1.ExportEntitiesRequest\032\035.google.longrunning.Operation\"\222\001\312A0\n" + + "\026ExportEntitiesResponse\022\026ExportEntitiesMetadata\332A1" + + "project_id,labels,entity_filter,output_url_prefix\202\323\344\223\002%\"" + + " /v1/projects/{project_id}:export:\001*\022\355\001\n" + + "\016ImportEntities\0220.google" + + ".datastore.admin.v1.ImportEntitiesRequest\032\035.google.longrunning.Operation\"\211\001\312A/\n" + + "\025google.protobuf.Empty\022\026ImportEntitiesMet" + + "adata\332A)project_id,labels,input_url,entity_filter\202\323\344\223\002%\"" + + " /v1/projects/{project_id}:import:\001*\022\257\001\n" + + "\013CreateIndex\022-.google.da" + + "tastore.admin.v1.CreateIndexRequest\032\035.google.longrunning.Operation\"R\312A\037\n" + + "\005Index\022\026" + + "IndexOperationMetadata\202\323\344\223\002*\"!/v1/projects/{project_id}/indexes:\005index\022\263\001\n" + + "\013DeleteIndex\022-.google.datastore.admin.v1.Delet" + + "eIndexRequest\032\035.google.longrunning.Operation\"V\312A\037\n" + + "\005Index\022\026IndexOperationMetadata" + + "\202\323\344\223\002.*,/v1/projects/{project_id}/indexes/{index_id}\022\216\001\n" + + "\010GetIndex\022*.google.datastore.admin.v1.GetIndexRequest\032 .google.d" + + "atastore.admin.v1.Index\"4\202\323\344\223\002.\022,/v1/pro" + + "jects/{project_id}/indexes/{index_id}\022\227\001\n" + + "\013ListIndexes\022-.google.datastore.admin.v" + + "1.ListIndexesRequest\032..google.datastore." + + "admin.v1.ListIndexesResponse\")\202\323\344\223\002#\022!/v" + + "1/projects/{project_id}/indexes\032v\312A\030data" + + "store.googleapis.com\322AXhttps://www.googl" + + "eapis.com/auth/cloud-platform,https://www.googleapis.com/auth/datastoreB\333\001\n" + + "\035com.google.datastore.admin.v1B\023DatastoreAdmi" + + "nProtoP\001Z9cloud.google.com/go/datastore/" + + "admin/apiv1/adminpb;adminpb\252\002\037Google.Clo" + + "ud.Datastore.Admin.V1\312\002\037Google\\Cloud\\Dat" + + "astore\\Admin\\V1\352\002#Google::Cloud::Datastore::Admin::V1b\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.datastore.admin.v1.IndexProto.getDescriptor(), + com.google.datastore.admin.v1.MigrationProto.getDescriptor(), + com.google.longrunning.OperationsProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_datastore_admin_v1_CommonMetadata_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_datastore_admin_v1_CommonMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_CommonMetadata_descriptor, + new java.lang.String[] { + "StartTime", "EndTime", "OperationType", "Labels", "State", + }); + internal_static_google_datastore_admin_v1_CommonMetadata_LabelsEntry_descriptor = + internal_static_google_datastore_admin_v1_CommonMetadata_descriptor.getNestedTypes().get(0); + internal_static_google_datastore_admin_v1_CommonMetadata_LabelsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_CommonMetadata_LabelsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + internal_static_google_datastore_admin_v1_Progress_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_datastore_admin_v1_Progress_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_Progress_descriptor, + new java.lang.String[] { + "WorkCompleted", "WorkEstimated", + }); + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_descriptor, + new java.lang.String[] { + "ProjectId", "Labels", "EntityFilter", "OutputUrlPrefix", + }); + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_LabelsEntry_descriptor = + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_descriptor + .getNestedTypes() + .get(0); + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_LabelsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_ExportEntitiesRequest_LabelsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_descriptor, + new java.lang.String[] { + "ProjectId", "Labels", "InputUrl", "EntityFilter", + }); + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_LabelsEntry_descriptor = + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_descriptor + .getNestedTypes() + .get(0); + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_LabelsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_ImportEntitiesRequest_LabelsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + internal_static_google_datastore_admin_v1_ExportEntitiesResponse_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_datastore_admin_v1_ExportEntitiesResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_ExportEntitiesResponse_descriptor, + new java.lang.String[] { + "OutputUrl", + }); + internal_static_google_datastore_admin_v1_ExportEntitiesMetadata_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_datastore_admin_v1_ExportEntitiesMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_ExportEntitiesMetadata_descriptor, + new java.lang.String[] { + "Common", "ProgressEntities", "ProgressBytes", "EntityFilter", "OutputUrlPrefix", + }); + internal_static_google_datastore_admin_v1_ImportEntitiesMetadata_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_google_datastore_admin_v1_ImportEntitiesMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_ImportEntitiesMetadata_descriptor, + new java.lang.String[] { + "Common", "ProgressEntities", "ProgressBytes", "EntityFilter", "InputUrl", + }); + internal_static_google_datastore_admin_v1_EntityFilter_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_google_datastore_admin_v1_EntityFilter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_EntityFilter_descriptor, + new java.lang.String[] { + "Kinds", "NamespaceIds", + }); + internal_static_google_datastore_admin_v1_CreateIndexRequest_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_google_datastore_admin_v1_CreateIndexRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_CreateIndexRequest_descriptor, + new java.lang.String[] { + "ProjectId", "Index", + }); + internal_static_google_datastore_admin_v1_DeleteIndexRequest_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_google_datastore_admin_v1_DeleteIndexRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_DeleteIndexRequest_descriptor, + new java.lang.String[] { + "ProjectId", "IndexId", + }); + internal_static_google_datastore_admin_v1_GetIndexRequest_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_google_datastore_admin_v1_GetIndexRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_GetIndexRequest_descriptor, + new java.lang.String[] { + "ProjectId", "IndexId", + }); + internal_static_google_datastore_admin_v1_ListIndexesRequest_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_google_datastore_admin_v1_ListIndexesRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_ListIndexesRequest_descriptor, + new java.lang.String[] { + "ProjectId", "Filter", "PageSize", "PageToken", + }); + internal_static_google_datastore_admin_v1_ListIndexesResponse_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_google_datastore_admin_v1_ListIndexesResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_ListIndexesResponse_descriptor, + new java.lang.String[] { + "Indexes", "NextPageToken", + }); + internal_static_google_datastore_admin_v1_IndexOperationMetadata_descriptor = + getDescriptor().getMessageTypes().get(13); + internal_static_google_datastore_admin_v1_IndexOperationMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_IndexOperationMetadata_descriptor, + new java.lang.String[] { + "Common", "ProgressEntities", "IndexId", + }); + internal_static_google_datastore_admin_v1_DatastoreFirestoreMigrationMetadata_descriptor = + getDescriptor().getMessageTypes().get(14); + internal_static_google_datastore_admin_v1_DatastoreFirestoreMigrationMetadata_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_DatastoreFirestoreMigrationMetadata_descriptor, + new java.lang.String[] { + "MigrationState", "MigrationStep", + }); + 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.longrunning.OperationsProto.operationInfo); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.AnnotationsProto.getDescriptor(); + com.google.api.ClientProto.getDescriptor(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.datastore.admin.v1.IndexProto.getDescriptor(); + com.google.datastore.admin.v1.MigrationProto.getDescriptor(); + com.google.longrunning.OperationsProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadata.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadata.java new file mode 100644 index 000000000000..7f6e0c89383f --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadata.java @@ -0,0 +1,799 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * Metadata for Datastore to Firestore migration operations.
+ *
+ * The DatastoreFirestoreMigration operation is not started by the end-user via
+ * an explicit "creation" method. This is an intentional deviation from the LRO
+ * design pattern.
+ *
+ * This singleton resource can be accessed at:
+ * "projects/{project_id}/operations/datastore-firestore-migration"
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata} + */ +public final class DatastoreFirestoreMigrationMetadata + extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata) + DatastoreFirestoreMigrationMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + // Use DatastoreFirestoreMigrationMetadata.newBuilder() to construct. + private DatastoreFirestoreMigrationMetadata( + com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private DatastoreFirestoreMigrationMetadata() { + migrationState_ = 0; + migrationStep_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new DatastoreFirestoreMigrationMetadata(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_DatastoreFirestoreMigrationMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_DatastoreFirestoreMigrationMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.class, + com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.Builder.class); + } + + public static final int MIGRATION_STATE_FIELD_NUMBER = 1; + private int migrationState_ = 0; + + /** + * + * + *
+   * The current state of migration from Cloud Datastore to Cloud Firestore in
+   * Datastore mode.
+   * 
+ * + * .google.datastore.admin.v1.MigrationState migration_state = 1; + * + * @return The enum numeric value on the wire for migrationState. + */ + @java.lang.Override + public int getMigrationStateValue() { + return migrationState_; + } + + /** + * + * + *
+   * The current state of migration from Cloud Datastore to Cloud Firestore in
+   * Datastore mode.
+   * 
+ * + * .google.datastore.admin.v1.MigrationState migration_state = 1; + * + * @return The migrationState. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationState getMigrationState() { + com.google.datastore.admin.v1.MigrationState result = + com.google.datastore.admin.v1.MigrationState.forNumber(migrationState_); + return result == null ? com.google.datastore.admin.v1.MigrationState.UNRECOGNIZED : result; + } + + public static final int MIGRATION_STEP_FIELD_NUMBER = 2; + private int migrationStep_ = 0; + + /** + * + * + *
+   * The current step of migration from Cloud Datastore to Cloud Firestore in
+   * Datastore mode.
+   * 
+ * + * .google.datastore.admin.v1.MigrationStep migration_step = 2; + * + * @return The enum numeric value on the wire for migrationStep. + */ + @java.lang.Override + public int getMigrationStepValue() { + return migrationStep_; + } + + /** + * + * + *
+   * The current step of migration from Cloud Datastore to Cloud Firestore in
+   * Datastore mode.
+   * 
+ * + * .google.datastore.admin.v1.MigrationStep migration_step = 2; + * + * @return The migrationStep. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationStep getMigrationStep() { + com.google.datastore.admin.v1.MigrationStep result = + com.google.datastore.admin.v1.MigrationStep.forNumber(migrationStep_); + return result == null ? com.google.datastore.admin.v1.MigrationStep.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 (migrationState_ + != com.google.datastore.admin.v1.MigrationState.MIGRATION_STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(1, migrationState_); + } + if (migrationStep_ + != com.google.datastore.admin.v1.MigrationStep.MIGRATION_STEP_UNSPECIFIED.getNumber()) { + output.writeEnum(2, migrationStep_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (migrationState_ + != com.google.datastore.admin.v1.MigrationState.MIGRATION_STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, migrationState_); + } + if (migrationStep_ + != com.google.datastore.admin.v1.MigrationStep.MIGRATION_STEP_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, migrationStep_); + } + 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.datastore.admin.v1.DatastoreFirestoreMigrationMetadata)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata other = + (com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata) obj; + + if (migrationState_ != other.migrationState_) return false; + if (migrationStep_ != other.migrationStep_) 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) + MIGRATION_STATE_FIELD_NUMBER; + hash = (53 * hash) + migrationState_; + hash = (37 * hash) + MIGRATION_STEP_FIELD_NUMBER; + hash = (53 * hash) + migrationStep_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata 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.datastore.admin.v1.DatastoreFirestoreMigrationMetadata parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.DatastoreFirestoreMigrationMetadata 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for Datastore to Firestore migration operations.
+   *
+   * The DatastoreFirestoreMigration operation is not started by the end-user via
+   * an explicit "creation" method. This is an intentional deviation from the LRO
+   * design pattern.
+   *
+   * This singleton resource can be accessed at:
+   * "projects/{project_id}/operations/datastore-firestore-migration"
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata) + com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_DatastoreFirestoreMigrationMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_DatastoreFirestoreMigrationMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.class, + com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.Builder.class); + } + + // Construct using + // com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + migrationState_ = 0; + migrationStep_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_DatastoreFirestoreMigrationMetadata_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + getDefaultInstanceForType() { + return com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata build() { + com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata buildPartial() { + com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata result = + new com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.migrationState_ = migrationState_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.migrationStep_ = migrationStep_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata) { + return mergeFrom((com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata other) { + if (other + == com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata.getDefaultInstance()) + return this; + if (other.migrationState_ != 0) { + setMigrationStateValue(other.getMigrationStateValue()); + } + if (other.migrationStep_ != 0) { + setMigrationStepValue(other.getMigrationStepValue()); + } + 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: + { + migrationState_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: + { + migrationStep_ = 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 int migrationState_ = 0; + + /** + * + * + *
+     * The current state of migration from Cloud Datastore to Cloud Firestore in
+     * Datastore mode.
+     * 
+ * + * .google.datastore.admin.v1.MigrationState migration_state = 1; + * + * @return The enum numeric value on the wire for migrationState. + */ + @java.lang.Override + public int getMigrationStateValue() { + return migrationState_; + } + + /** + * + * + *
+     * The current state of migration from Cloud Datastore to Cloud Firestore in
+     * Datastore mode.
+     * 
+ * + * .google.datastore.admin.v1.MigrationState migration_state = 1; + * + * @param value The enum numeric value on the wire for migrationState to set. + * @return This builder for chaining. + */ + public Builder setMigrationStateValue(int value) { + migrationState_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The current state of migration from Cloud Datastore to Cloud Firestore in
+     * Datastore mode.
+     * 
+ * + * .google.datastore.admin.v1.MigrationState migration_state = 1; + * + * @return The migrationState. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationState getMigrationState() { + com.google.datastore.admin.v1.MigrationState result = + com.google.datastore.admin.v1.MigrationState.forNumber(migrationState_); + return result == null ? com.google.datastore.admin.v1.MigrationState.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The current state of migration from Cloud Datastore to Cloud Firestore in
+     * Datastore mode.
+     * 
+ * + * .google.datastore.admin.v1.MigrationState migration_state = 1; + * + * @param value The migrationState to set. + * @return This builder for chaining. + */ + public Builder setMigrationState(com.google.datastore.admin.v1.MigrationState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + migrationState_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The current state of migration from Cloud Datastore to Cloud Firestore in
+     * Datastore mode.
+     * 
+ * + * .google.datastore.admin.v1.MigrationState migration_state = 1; + * + * @return This builder for chaining. + */ + public Builder clearMigrationState() { + bitField0_ = (bitField0_ & ~0x00000001); + migrationState_ = 0; + onChanged(); + return this; + } + + private int migrationStep_ = 0; + + /** + * + * + *
+     * The current step of migration from Cloud Datastore to Cloud Firestore in
+     * Datastore mode.
+     * 
+ * + * .google.datastore.admin.v1.MigrationStep migration_step = 2; + * + * @return The enum numeric value on the wire for migrationStep. + */ + @java.lang.Override + public int getMigrationStepValue() { + return migrationStep_; + } + + /** + * + * + *
+     * The current step of migration from Cloud Datastore to Cloud Firestore in
+     * Datastore mode.
+     * 
+ * + * .google.datastore.admin.v1.MigrationStep migration_step = 2; + * + * @param value The enum numeric value on the wire for migrationStep to set. + * @return This builder for chaining. + */ + public Builder setMigrationStepValue(int value) { + migrationStep_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The current step of migration from Cloud Datastore to Cloud Firestore in
+     * Datastore mode.
+     * 
+ * + * .google.datastore.admin.v1.MigrationStep migration_step = 2; + * + * @return The migrationStep. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationStep getMigrationStep() { + com.google.datastore.admin.v1.MigrationStep result = + com.google.datastore.admin.v1.MigrationStep.forNumber(migrationStep_); + return result == null ? com.google.datastore.admin.v1.MigrationStep.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The current step of migration from Cloud Datastore to Cloud Firestore in
+     * Datastore mode.
+     * 
+ * + * .google.datastore.admin.v1.MigrationStep migration_step = 2; + * + * @param value The migrationStep to set. + * @return This builder for chaining. + */ + public Builder setMigrationStep(com.google.datastore.admin.v1.MigrationStep value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + migrationStep_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The current step of migration from Cloud Datastore to Cloud Firestore in
+     * Datastore mode.
+     * 
+ * + * .google.datastore.admin.v1.MigrationStep migration_step = 2; + * + * @return This builder for chaining. + */ + public Builder clearMigrationStep() { + bitField0_ = (bitField0_ & ~0x00000002); + migrationStep_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata) + private static final com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata(); + } + + public static com.google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DatastoreFirestoreMigrationMetadata 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.datastore.admin.v1.DatastoreFirestoreMigrationMetadata + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadataOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadataOrBuilder.java new file mode 100644 index 000000000000..000588d7ddc4 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DatastoreFirestoreMigrationMetadataOrBuilder.java @@ -0,0 +1,82 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface DatastoreFirestoreMigrationMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.DatastoreFirestoreMigrationMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The current state of migration from Cloud Datastore to Cloud Firestore in
+   * Datastore mode.
+   * 
+ * + * .google.datastore.admin.v1.MigrationState migration_state = 1; + * + * @return The enum numeric value on the wire for migrationState. + */ + int getMigrationStateValue(); + + /** + * + * + *
+   * The current state of migration from Cloud Datastore to Cloud Firestore in
+   * Datastore mode.
+   * 
+ * + * .google.datastore.admin.v1.MigrationState migration_state = 1; + * + * @return The migrationState. + */ + com.google.datastore.admin.v1.MigrationState getMigrationState(); + + /** + * + * + *
+   * The current step of migration from Cloud Datastore to Cloud Firestore in
+   * Datastore mode.
+   * 
+ * + * .google.datastore.admin.v1.MigrationStep migration_step = 2; + * + * @return The enum numeric value on the wire for migrationStep. + */ + int getMigrationStepValue(); + + /** + * + * + *
+   * The current step of migration from Cloud Datastore to Cloud Firestore in
+   * Datastore mode.
+   * 
+ * + * .google.datastore.admin.v1.MigrationStep migration_step = 2; + * + * @return The migrationStep. + */ + com.google.datastore.admin.v1.MigrationStep getMigrationStep(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequest.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequest.java new file mode 100644 index 000000000000..34c33485cc13 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequest.java @@ -0,0 +1,825 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [google.datastore.admin.v1.DatastoreAdmin.DeleteIndex][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex].
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.DeleteIndexRequest} + */ +public final class DeleteIndexRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.DeleteIndexRequest) + DeleteIndexRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use DeleteIndexRequest.newBuilder() to construct. + private DeleteIndexRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private DeleteIndexRequest() { + projectId_ = ""; + indexId_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new DeleteIndexRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_DeleteIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_DeleteIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.DeleteIndexRequest.class, + com.google.datastore.admin.v1.DeleteIndexRequest.Builder.class); + } + + public static final int PROJECT_ID_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INDEX_ID_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object indexId_ = ""; + + /** + * + * + *
+   * The resource ID of the index to delete.
+   * 
+ * + * string index_id = 3; + * + * @return The indexId. + */ + @java.lang.Override + public java.lang.String getIndexId() { + java.lang.Object ref = indexId_; + 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(); + indexId_ = s; + return s; + } + } + + /** + * + * + *
+   * The resource ID of the index to delete.
+   * 
+ * + * string index_id = 3; + * + * @return The bytes for indexId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getIndexIdBytes() { + java.lang.Object ref = indexId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + indexId_ = 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.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(indexId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, indexId_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(indexId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, indexId_); + } + 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.datastore.admin.v1.DeleteIndexRequest)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.DeleteIndexRequest other = + (com.google.datastore.admin.v1.DeleteIndexRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getIndexId().equals(other.getIndexId())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + INDEX_ID_FIELD_NUMBER; + hash = (53 * hash) + getIndexId().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.DeleteIndexRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.DeleteIndexRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.DeleteIndexRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.DeleteIndexRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.DeleteIndexRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.DeleteIndexRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.DeleteIndexRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.DeleteIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.DeleteIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [google.datastore.admin.v1.DatastoreAdmin.DeleteIndex][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex].
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.DeleteIndexRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.DeleteIndexRequest) + com.google.datastore.admin.v1.DeleteIndexRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_DeleteIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_DeleteIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.DeleteIndexRequest.class, + com.google.datastore.admin.v1.DeleteIndexRequest.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.DeleteIndexRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + indexId_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_DeleteIndexRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.DeleteIndexRequest getDefaultInstanceForType() { + return com.google.datastore.admin.v1.DeleteIndexRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.DeleteIndexRequest build() { + com.google.datastore.admin.v1.DeleteIndexRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.DeleteIndexRequest buildPartial() { + com.google.datastore.admin.v1.DeleteIndexRequest result = + new com.google.datastore.admin.v1.DeleteIndexRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.DeleteIndexRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.indexId_ = indexId_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.DeleteIndexRequest) { + return mergeFrom((com.google.datastore.admin.v1.DeleteIndexRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.DeleteIndexRequest other) { + if (other == com.google.datastore.admin.v1.DeleteIndexRequest.getDefaultInstance()) + return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getIndexId().isEmpty()) { + indexId_ = other.indexId_; + 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: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + indexId_ = 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 projectId_ = ""; + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object indexId_ = ""; + + /** + * + * + *
+     * The resource ID of the index to delete.
+     * 
+ * + * string index_id = 3; + * + * @return The indexId. + */ + public java.lang.String getIndexId() { + java.lang.Object ref = indexId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + indexId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The resource ID of the index to delete.
+     * 
+ * + * string index_id = 3; + * + * @return The bytes for indexId. + */ + public com.google.protobuf.ByteString getIndexIdBytes() { + java.lang.Object ref = indexId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + indexId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The resource ID of the index to delete.
+     * 
+ * + * string index_id = 3; + * + * @param value The indexId to set. + * @return This builder for chaining. + */ + public Builder setIndexId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + indexId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource ID of the index to delete.
+     * 
+ * + * string index_id = 3; + * + * @return This builder for chaining. + */ + public Builder clearIndexId() { + indexId_ = getDefaultInstance().getIndexId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource ID of the index to delete.
+     * 
+ * + * string index_id = 3; + * + * @param value The bytes for indexId to set. + * @return This builder for chaining. + */ + public Builder setIndexIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + indexId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.DeleteIndexRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.DeleteIndexRequest) + private static final com.google.datastore.admin.v1.DeleteIndexRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.DeleteIndexRequest(); + } + + public static com.google.datastore.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.datastore.admin.v1.DeleteIndexRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequestOrBuilder.java new file mode 100644 index 000000000000..a1a166d85fa0 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/DeleteIndexRequestOrBuilder.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! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface DeleteIndexRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.DeleteIndexRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The resource ID of the index to delete.
+   * 
+ * + * string index_id = 3; + * + * @return The indexId. + */ + java.lang.String getIndexId(); + + /** + * + * + *
+   * The resource ID of the index to delete.
+   * 
+ * + * string index_id = 3; + * + * @return The bytes for indexId. + */ + com.google.protobuf.ByteString getIndexIdBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilter.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilter.java new file mode 100644 index 000000000000..d9ae8b386f1e --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilter.java @@ -0,0 +1,1138 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * Identifies a subset of entities in a project. This is specified as
+ * combinations of kinds and namespaces (either or both of which may be all, as
+ * described in the following examples).
+ * Example usage:
+ *
+ * Entire project:
+ *   kinds=[], namespace_ids=[]
+ *
+ * Kinds Foo and Bar in all namespaces:
+ *   kinds=['Foo', 'Bar'], namespace_ids=[]
+ *
+ * Kinds Foo and Bar only in the default namespace:
+ *   kinds=['Foo', 'Bar'], namespace_ids=['']
+ *
+ * Kinds Foo and Bar in both the default and Baz namespaces:
+ *   kinds=['Foo', 'Bar'], namespace_ids=['', 'Baz']
+ *
+ * The entire Baz namespace:
+ *   kinds=[], namespace_ids=['Baz']
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.EntityFilter} + */ +public final class EntityFilter extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.EntityFilter) + EntityFilterOrBuilder { + private static final long serialVersionUID = 0L; + + // Use EntityFilter.newBuilder() to construct. + private EntityFilter(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private EntityFilter() { + kinds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new EntityFilter(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_EntityFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_EntityFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.EntityFilter.class, + com.google.datastore.admin.v1.EntityFilter.Builder.class); + } + + public static final int KINDS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList kinds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * If empty, then this represents all kinds.
+   * 
+ * + * repeated string kinds = 1; + * + * @return A list containing the kinds. + */ + public com.google.protobuf.ProtocolStringList getKindsList() { + return kinds_; + } + + /** + * + * + *
+   * If empty, then this represents all kinds.
+   * 
+ * + * repeated string kinds = 1; + * + * @return The count of kinds. + */ + public int getKindsCount() { + return kinds_.size(); + } + + /** + * + * + *
+   * If empty, then this represents all kinds.
+   * 
+ * + * repeated string kinds = 1; + * + * @param index The index of the element to return. + * @return The kinds at the given index. + */ + public java.lang.String getKinds(int index) { + return kinds_.get(index); + } + + /** + * + * + *
+   * If empty, then this represents all kinds.
+   * 
+ * + * repeated string kinds = 1; + * + * @param index The index of the value to return. + * @return The bytes of the kinds at the given index. + */ + public com.google.protobuf.ByteString getKindsBytes(int index) { + return kinds_.getByteString(index); + } + + public static final int NAMESPACE_IDS_FIELD_NUMBER = 2; + + @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 projects that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the project 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 = 2; + * + * @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 projects that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the project 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 = 2; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for projects that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the project 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 = 2; + * + * @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 projects that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the project 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 = 2; + * + * @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 { + for (int i = 0; i < kinds_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, kinds_.getRaw(i)); + } + for (int i = 0; i < namespaceIds_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, namespaceIds_.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 < kinds_.size(); i++) { + dataSize += computeStringSizeNoTag(kinds_.getRaw(i)); + } + size += dataSize; + size += 1 * getKindsList().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.datastore.admin.v1.EntityFilter)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.EntityFilter other = + (com.google.datastore.admin.v1.EntityFilter) obj; + + if (!getKindsList().equals(other.getKindsList())) 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 (getKindsCount() > 0) { + hash = (37 * hash) + KINDS_FIELD_NUMBER; + hash = (53 * hash) + getKindsList().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.datastore.admin.v1.EntityFilter parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.EntityFilter parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.EntityFilter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.EntityFilter 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.datastore.admin.v1.EntityFilter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.EntityFilter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.EntityFilter parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.EntityFilter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.EntityFilter parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.EntityFilter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.EntityFilter parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.EntityFilter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.EntityFilter 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Identifies a subset of entities in a project. This is specified as
+   * combinations of kinds and namespaces (either or both of which may be all, as
+   * described in the following examples).
+   * Example usage:
+   *
+   * Entire project:
+   *   kinds=[], namespace_ids=[]
+   *
+   * Kinds Foo and Bar in all namespaces:
+   *   kinds=['Foo', 'Bar'], namespace_ids=[]
+   *
+   * Kinds Foo and Bar only in the default namespace:
+   *   kinds=['Foo', 'Bar'], namespace_ids=['']
+   *
+   * Kinds Foo and Bar in both the default and Baz namespaces:
+   *   kinds=['Foo', 'Bar'], namespace_ids=['', 'Baz']
+   *
+   * The entire Baz namespace:
+   *   kinds=[], namespace_ids=['Baz']
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.EntityFilter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.EntityFilter) + com.google.datastore.admin.v1.EntityFilterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_EntityFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_EntityFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.EntityFilter.class, + com.google.datastore.admin.v1.EntityFilter.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.EntityFilter.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + kinds_ = 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.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_EntityFilter_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilter getDefaultInstanceForType() { + return com.google.datastore.admin.v1.EntityFilter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilter build() { + com.google.datastore.admin.v1.EntityFilter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilter buildPartial() { + com.google.datastore.admin.v1.EntityFilter result = + new com.google.datastore.admin.v1.EntityFilter(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.EntityFilter result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + kinds_.makeImmutable(); + result.kinds_ = kinds_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + namespaceIds_.makeImmutable(); + result.namespaceIds_ = namespaceIds_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.EntityFilter) { + return mergeFrom((com.google.datastore.admin.v1.EntityFilter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.EntityFilter other) { + if (other == com.google.datastore.admin.v1.EntityFilter.getDefaultInstance()) return this; + if (!other.kinds_.isEmpty()) { + if (kinds_.isEmpty()) { + kinds_ = other.kinds_; + bitField0_ |= 0x00000001; + } else { + ensureKindsIsMutable(); + kinds_.addAll(other.kinds_); + } + onChanged(); + } + if (!other.namespaceIds_.isEmpty()) { + if (namespaceIds_.isEmpty()) { + namespaceIds_ = other.namespaceIds_; + bitField0_ |= 0x00000002; + } 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: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureKindsIsMutable(); + kinds_.add(s); + break; + } // case 10 + case 18: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureNamespaceIdsIsMutable(); + namespaceIds_.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 kinds_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureKindsIsMutable() { + if (!kinds_.isModifiable()) { + kinds_ = new com.google.protobuf.LazyStringArrayList(kinds_); + } + bitField0_ |= 0x00000001; + } + + /** + * + * + *
+     * If empty, then this represents all kinds.
+     * 
+ * + * repeated string kinds = 1; + * + * @return A list containing the kinds. + */ + public com.google.protobuf.ProtocolStringList getKindsList() { + kinds_.makeImmutable(); + return kinds_; + } + + /** + * + * + *
+     * If empty, then this represents all kinds.
+     * 
+ * + * repeated string kinds = 1; + * + * @return The count of kinds. + */ + public int getKindsCount() { + return kinds_.size(); + } + + /** + * + * + *
+     * If empty, then this represents all kinds.
+     * 
+ * + * repeated string kinds = 1; + * + * @param index The index of the element to return. + * @return The kinds at the given index. + */ + public java.lang.String getKinds(int index) { + return kinds_.get(index); + } + + /** + * + * + *
+     * If empty, then this represents all kinds.
+     * 
+ * + * repeated string kinds = 1; + * + * @param index The index of the value to return. + * @return The bytes of the kinds at the given index. + */ + public com.google.protobuf.ByteString getKindsBytes(int index) { + return kinds_.getByteString(index); + } + + /** + * + * + *
+     * If empty, then this represents all kinds.
+     * 
+ * + * repeated string kinds = 1; + * + * @param index The index to set the value at. + * @param value The kinds to set. + * @return This builder for chaining. + */ + public Builder setKinds(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureKindsIsMutable(); + kinds_.set(index, value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * If empty, then this represents all kinds.
+     * 
+ * + * repeated string kinds = 1; + * + * @param value The kinds to add. + * @return This builder for chaining. + */ + public Builder addKinds(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureKindsIsMutable(); + kinds_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * If empty, then this represents all kinds.
+     * 
+ * + * repeated string kinds = 1; + * + * @param values The kinds to add. + * @return This builder for chaining. + */ + public Builder addAllKinds(java.lang.Iterable values) { + ensureKindsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, kinds_); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * If empty, then this represents all kinds.
+     * 
+ * + * repeated string kinds = 1; + * + * @return This builder for chaining. + */ + public Builder clearKinds() { + kinds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * If empty, then this represents all kinds.
+     * 
+ * + * repeated string kinds = 1; + * + * @param value The bytes of the kinds to add. + * @return This builder for chaining. + */ + public Builder addKindsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureKindsIsMutable(); + kinds_.add(value); + bitField0_ |= 0x00000001; + 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_ |= 0x00000002; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for projects that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the project 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 = 2; + * + * @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 projects that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the project 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 = 2; + * + * @return The count of namespaceIds. + */ + public int getNamespaceIdsCount() { + return namespaceIds_.size(); + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for projects that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the project 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 = 2; + * + * @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 projects that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the project 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 = 2; + * + * @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 projects that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the project 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 = 2; + * + * @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_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for projects that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the project 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 = 2; + * + * @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_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for projects that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the project 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 = 2; + * + * @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_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for projects that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the project 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 = 2; + * + * @return This builder for chaining. + */ + public Builder clearNamespaceIds() { + namespaceIds_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * An empty list represents all namespaces. This is the preferred
+     * usage for projects that don't use namespaces.
+     *
+     * An empty string element represents the default namespace. This should be
+     * used if the project 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 = 2; + * + * @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_ |= 0x00000002; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.EntityFilter) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.EntityFilter) + private static final com.google.datastore.admin.v1.EntityFilter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.EntityFilter(); + } + + public static com.google.datastore.admin.v1.EntityFilter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public EntityFilter 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.datastore.admin.v1.EntityFilter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilterOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilterOrBuilder.java new file mode 100644 index 000000000000..75e35d5bb07b --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/EntityFilterOrBuilder.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! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface EntityFilterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.EntityFilter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * If empty, then this represents all kinds.
+   * 
+ * + * repeated string kinds = 1; + * + * @return A list containing the kinds. + */ + java.util.List getKindsList(); + + /** + * + * + *
+   * If empty, then this represents all kinds.
+   * 
+ * + * repeated string kinds = 1; + * + * @return The count of kinds. + */ + int getKindsCount(); + + /** + * + * + *
+   * If empty, then this represents all kinds.
+   * 
+ * + * repeated string kinds = 1; + * + * @param index The index of the element to return. + * @return The kinds at the given index. + */ + java.lang.String getKinds(int index); + + /** + * + * + *
+   * If empty, then this represents all kinds.
+   * 
+ * + * repeated string kinds = 1; + * + * @param index The index of the value to return. + * @return The bytes of the kinds at the given index. + */ + com.google.protobuf.ByteString getKindsBytes(int index); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for projects that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the project 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 = 2; + * + * @return A list containing the namespaceIds. + */ + java.util.List getNamespaceIdsList(); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for projects that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the project 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 = 2; + * + * @return The count of namespaceIds. + */ + int getNamespaceIdsCount(); + + /** + * + * + *
+   * An empty list represents all namespaces. This is the preferred
+   * usage for projects that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the project 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 = 2; + * + * @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 projects that don't use namespaces.
+   *
+   * An empty string element represents the default namespace. This should be
+   * used if the project 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 = 2; + * + * @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-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadata.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadata.java new file mode 100644 index 000000000000..abf0cbe50552 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadata.java @@ -0,0 +1,1800 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * Metadata for ExportEntities operations.
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ExportEntitiesMetadata} + */ +public final class ExportEntitiesMetadata extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.ExportEntitiesMetadata) + ExportEntitiesMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ExportEntitiesMetadata.newBuilder() to construct. + private ExportEntitiesMetadata(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExportEntitiesMetadata() { + outputUrlPrefix_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExportEntitiesMetadata(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ExportEntitiesMetadata.class, + com.google.datastore.admin.v1.ExportEntitiesMetadata.Builder.class); + } + + private int bitField0_; + public static final int COMMON_FIELD_NUMBER = 1; + private com.google.datastore.admin.v1.CommonMetadata common_; + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return Whether the common field is set. + */ + @java.lang.Override + public boolean hasCommon() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return The common. + */ + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadata getCommon() { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadataOrBuilder getCommonOrBuilder() { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } + + public static final int PROGRESS_ENTITIES_FIELD_NUMBER = 2; + private com.google.datastore.admin.v1.Progress progressEntities_; + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return Whether the progressEntities field is set. + */ + @java.lang.Override + public boolean hasProgressEntities() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return The progressEntities. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Progress getProgressEntities() { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + @java.lang.Override + public com.google.datastore.admin.v1.ProgressOrBuilder getProgressEntitiesOrBuilder() { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } + + public static final int PROGRESS_BYTES_FIELD_NUMBER = 3; + private com.google.datastore.admin.v1.Progress progressBytes_; + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return Whether the progressBytes field is set. + */ + @java.lang.Override + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return The progressBytes. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Progress getProgressBytes() { + return progressBytes_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + @java.lang.Override + public com.google.datastore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + return progressBytes_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + public static final int ENTITY_FILTER_FIELD_NUMBER = 4; + private com.google.datastore.admin.v1.EntityFilter entityFilter_; + + /** + * + * + *
+   * Description of which entities are being exported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return Whether the entityFilter field is set. + */ + @java.lang.Override + public boolean hasEntityFilter() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * Description of which entities are being exported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return The entityFilter. + */ + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilter getEntityFilter() { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + + /** + * + * + *
+   * Description of which entities are being exported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder() { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + + public static final int OUTPUT_URL_PREFIX_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private volatile java.lang.Object outputUrlPrefix_ = ""; + + /** + * + * + *
+   * Location for the export metadata and data files. This will be the same
+   * value as the
+   * [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix]
+   * field. The final output location is provided in
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+   * 
+ * + * string output_url_prefix = 5; + * + * @return The outputUrlPrefix. + */ + @java.lang.Override + public java.lang.String getOutputUrlPrefix() { + java.lang.Object ref = outputUrlPrefix_; + 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(); + outputUrlPrefix_ = s; + return s; + } + } + + /** + * + * + *
+   * Location for the export metadata and data files. This will be the same
+   * value as the
+   * [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix]
+   * field. The final output location is provided in
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+   * 
+ * + * string output_url_prefix = 5; + * + * @return The bytes for outputUrlPrefix. + */ + @java.lang.Override + public com.google.protobuf.ByteString getOutputUrlPrefixBytes() { + java.lang.Object ref = outputUrlPrefix_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUrlPrefix_ = 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 (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getCommon()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getProgressEntities()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(3, getProgressBytes()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(4, getEntityFilter()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(outputUrlPrefix_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, outputUrlPrefix_); + } + 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, getCommon()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getProgressEntities()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getProgressBytes()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getEntityFilter()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(outputUrlPrefix_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, outputUrlPrefix_); + } + 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.datastore.admin.v1.ExportEntitiesMetadata)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.ExportEntitiesMetadata other = + (com.google.datastore.admin.v1.ExportEntitiesMetadata) obj; + + if (hasCommon() != other.hasCommon()) return false; + if (hasCommon()) { + if (!getCommon().equals(other.getCommon())) return false; + } + if (hasProgressEntities() != other.hasProgressEntities()) return false; + if (hasProgressEntities()) { + if (!getProgressEntities().equals(other.getProgressEntities())) return false; + } + if (hasProgressBytes() != other.hasProgressBytes()) return false; + if (hasProgressBytes()) { + if (!getProgressBytes().equals(other.getProgressBytes())) return false; + } + if (hasEntityFilter() != other.hasEntityFilter()) return false; + if (hasEntityFilter()) { + if (!getEntityFilter().equals(other.getEntityFilter())) return false; + } + if (!getOutputUrlPrefix().equals(other.getOutputUrlPrefix())) 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 (hasCommon()) { + hash = (37 * hash) + COMMON_FIELD_NUMBER; + hash = (53 * hash) + getCommon().hashCode(); + } + if (hasProgressEntities()) { + hash = (37 * hash) + PROGRESS_ENTITIES_FIELD_NUMBER; + hash = (53 * hash) + getProgressEntities().hashCode(); + } + if (hasProgressBytes()) { + hash = (37 * hash) + PROGRESS_BYTES_FIELD_NUMBER; + hash = (53 * hash) + getProgressBytes().hashCode(); + } + if (hasEntityFilter()) { + hash = (37 * hash) + ENTITY_FILTER_FIELD_NUMBER; + hash = (53 * hash) + getEntityFilter().hashCode(); + } + hash = (37 * hash) + OUTPUT_URL_PREFIX_FIELD_NUMBER; + hash = (53 * hash) + getOutputUrlPrefix().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata 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.datastore.admin.v1.ExportEntitiesMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.ExportEntitiesMetadata 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for ExportEntities operations.
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ExportEntitiesMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.ExportEntitiesMetadata) + com.google.datastore.admin.v1.ExportEntitiesMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ExportEntitiesMetadata.class, + com.google.datastore.admin.v1.ExportEntitiesMetadata.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.ExportEntitiesMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getCommonFieldBuilder(); + getProgressEntitiesFieldBuilder(); + getProgressBytesFieldBuilder(); + getEntityFilterFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + common_ = null; + if (commonBuilder_ != null) { + commonBuilder_.dispose(); + commonBuilder_ = null; + } + progressEntities_ = null; + if (progressEntitiesBuilder_ != null) { + progressEntitiesBuilder_.dispose(); + progressEntitiesBuilder_ = null; + } + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + entityFilter_ = null; + if (entityFilterBuilder_ != null) { + entityFilterBuilder_.dispose(); + entityFilterBuilder_ = null; + } + outputUrlPrefix_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesMetadata_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ExportEntitiesMetadata getDefaultInstanceForType() { + return com.google.datastore.admin.v1.ExportEntitiesMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.ExportEntitiesMetadata build() { + com.google.datastore.admin.v1.ExportEntitiesMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ExportEntitiesMetadata buildPartial() { + com.google.datastore.admin.v1.ExportEntitiesMetadata result = + new com.google.datastore.admin.v1.ExportEntitiesMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.ExportEntitiesMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.common_ = commonBuilder_ == null ? common_ : commonBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.progressEntities_ = + progressEntitiesBuilder_ == null ? progressEntities_ : progressEntitiesBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.progressBytes_ = + progressBytesBuilder_ == null ? progressBytes_ : progressBytesBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.entityFilter_ = + entityFilterBuilder_ == null ? entityFilter_ : entityFilterBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.outputUrlPrefix_ = outputUrlPrefix_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.ExportEntitiesMetadata) { + return mergeFrom((com.google.datastore.admin.v1.ExportEntitiesMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.ExportEntitiesMetadata other) { + if (other == com.google.datastore.admin.v1.ExportEntitiesMetadata.getDefaultInstance()) + return this; + if (other.hasCommon()) { + mergeCommon(other.getCommon()); + } + if (other.hasProgressEntities()) { + mergeProgressEntities(other.getProgressEntities()); + } + if (other.hasProgressBytes()) { + mergeProgressBytes(other.getProgressBytes()); + } + if (other.hasEntityFilter()) { + mergeEntityFilter(other.getEntityFilter()); + } + if (!other.getOutputUrlPrefix().isEmpty()) { + outputUrlPrefix_ = other.outputUrlPrefix_; + bitField0_ |= 0x00000010; + 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(getCommonFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + getProgressEntitiesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(getProgressBytesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + input.readMessage(getEntityFilterFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + outputUrlPrefix_ = input.readStringRequireUtf8(); + 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 com.google.datastore.admin.v1.CommonMetadata common_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.CommonMetadata, + com.google.datastore.admin.v1.CommonMetadata.Builder, + com.google.datastore.admin.v1.CommonMetadataOrBuilder> + commonBuilder_; + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return Whether the common field is set. + */ + public boolean hasCommon() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return The common. + */ + public com.google.datastore.admin.v1.CommonMetadata getCommon() { + if (commonBuilder_ == null) { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } else { + return commonBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder setCommon(com.google.datastore.admin.v1.CommonMetadata value) { + if (commonBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + common_ = value; + } else { + commonBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder setCommon(com.google.datastore.admin.v1.CommonMetadata.Builder builderForValue) { + if (commonBuilder_ == null) { + common_ = builderForValue.build(); + } else { + commonBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder mergeCommon(com.google.datastore.admin.v1.CommonMetadata value) { + if (commonBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && common_ != null + && common_ != com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance()) { + getCommonBuilder().mergeFrom(value); + } else { + common_ = value; + } + } else { + commonBuilder_.mergeFrom(value); + } + if (common_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder clearCommon() { + bitField0_ = (bitField0_ & ~0x00000001); + common_ = null; + if (commonBuilder_ != null) { + commonBuilder_.dispose(); + commonBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public com.google.datastore.admin.v1.CommonMetadata.Builder getCommonBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getCommonFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public com.google.datastore.admin.v1.CommonMetadataOrBuilder getCommonOrBuilder() { + if (commonBuilder_ != null) { + return commonBuilder_.getMessageOrBuilder(); + } else { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.CommonMetadata, + com.google.datastore.admin.v1.CommonMetadata.Builder, + com.google.datastore.admin.v1.CommonMetadataOrBuilder> + getCommonFieldBuilder() { + if (commonBuilder_ == null) { + commonBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.CommonMetadata, + com.google.datastore.admin.v1.CommonMetadata.Builder, + com.google.datastore.admin.v1.CommonMetadataOrBuilder>( + getCommon(), getParentForChildren(), isClean()); + common_ = null; + } + return commonBuilder_; + } + + private com.google.datastore.admin.v1.Progress progressEntities_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder> + progressEntitiesBuilder_; + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return Whether the progressEntities field is set. + */ + public boolean hasProgressEntities() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return The progressEntities. + */ + public com.google.datastore.admin.v1.Progress getProgressEntities() { + if (progressEntitiesBuilder_ == null) { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } else { + return progressEntitiesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder setProgressEntities(com.google.datastore.admin.v1.Progress value) { + if (progressEntitiesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressEntities_ = value; + } else { + progressEntitiesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder setProgressEntities( + com.google.datastore.admin.v1.Progress.Builder builderForValue) { + if (progressEntitiesBuilder_ == null) { + progressEntities_ = builderForValue.build(); + } else { + progressEntitiesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder mergeProgressEntities(com.google.datastore.admin.v1.Progress value) { + if (progressEntitiesBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && progressEntities_ != null + && progressEntities_ != com.google.datastore.admin.v1.Progress.getDefaultInstance()) { + getProgressEntitiesBuilder().mergeFrom(value); + } else { + progressEntities_ = value; + } + } else { + progressEntitiesBuilder_.mergeFrom(value); + } + if (progressEntities_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder clearProgressEntities() { + bitField0_ = (bitField0_ & ~0x00000002); + progressEntities_ = null; + if (progressEntitiesBuilder_ != null) { + progressEntitiesBuilder_.dispose(); + progressEntitiesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public com.google.datastore.admin.v1.Progress.Builder getProgressEntitiesBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getProgressEntitiesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public com.google.datastore.admin.v1.ProgressOrBuilder getProgressEntitiesOrBuilder() { + if (progressEntitiesBuilder_ != null) { + return progressEntitiesBuilder_.getMessageOrBuilder(); + } else { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder> + getProgressEntitiesFieldBuilder() { + if (progressEntitiesBuilder_ == null) { + progressEntitiesBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder>( + getProgressEntities(), getParentForChildren(), isClean()); + progressEntities_ = null; + } + return progressEntitiesBuilder_; + } + + private com.google.datastore.admin.v1.Progress progressBytes_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder> + progressBytesBuilder_; + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return Whether the progressBytes field is set. + */ + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return The progressBytes. + */ + public com.google.datastore.admin.v1.Progress getProgressBytes() { + if (progressBytesBuilder_ == null) { + return progressBytes_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } else { + return progressBytesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public Builder setProgressBytes(com.google.datastore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressBytes_ = value; + } else { + progressBytesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public Builder setProgressBytes( + com.google.datastore.admin.v1.Progress.Builder builderForValue) { + if (progressBytesBuilder_ == null) { + progressBytes_ = builderForValue.build(); + } else { + progressBytesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public Builder mergeProgressBytes(com.google.datastore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && progressBytes_ != null + && progressBytes_ != com.google.datastore.admin.v1.Progress.getDefaultInstance()) { + getProgressBytesBuilder().mergeFrom(value); + } else { + progressBytes_ = value; + } + } else { + progressBytesBuilder_.mergeFrom(value); + } + if (progressBytes_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public Builder clearProgressBytes() { + bitField0_ = (bitField0_ & ~0x00000004); + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public com.google.datastore.admin.v1.Progress.Builder getProgressBytesBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getProgressBytesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public com.google.datastore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + if (progressBytesBuilder_ != null) { + return progressBytesBuilder_.getMessageOrBuilder(); + } else { + return progressBytes_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder> + getProgressBytesFieldBuilder() { + if (progressBytesBuilder_ == null) { + progressBytesBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder>( + getProgressBytes(), getParentForChildren(), isClean()); + progressBytes_ = null; + } + return progressBytesBuilder_; + } + + private com.google.datastore.admin.v1.EntityFilter entityFilter_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder> + entityFilterBuilder_; + + /** + * + * + *
+     * Description of which entities are being exported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return Whether the entityFilter field is set. + */ + public boolean hasEntityFilter() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Description of which entities are being exported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return The entityFilter. + */ + public com.google.datastore.admin.v1.EntityFilter getEntityFilter() { + if (entityFilterBuilder_ == null) { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } else { + return entityFilterBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Description of which entities are being exported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder setEntityFilter(com.google.datastore.admin.v1.EntityFilter value) { + if (entityFilterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + entityFilter_ = value; + } else { + entityFilterBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Description of which entities are being exported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder setEntityFilter( + com.google.datastore.admin.v1.EntityFilter.Builder builderForValue) { + if (entityFilterBuilder_ == null) { + entityFilter_ = builderForValue.build(); + } else { + entityFilterBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Description of which entities are being exported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder mergeEntityFilter(com.google.datastore.admin.v1.EntityFilter value) { + if (entityFilterBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && entityFilter_ != null + && entityFilter_ != com.google.datastore.admin.v1.EntityFilter.getDefaultInstance()) { + getEntityFilterBuilder().mergeFrom(value); + } else { + entityFilter_ = value; + } + } else { + entityFilterBuilder_.mergeFrom(value); + } + if (entityFilter_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Description of which entities are being exported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder clearEntityFilter() { + bitField0_ = (bitField0_ & ~0x00000008); + entityFilter_ = null; + if (entityFilterBuilder_ != null) { + entityFilterBuilder_.dispose(); + entityFilterBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Description of which entities are being exported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public com.google.datastore.admin.v1.EntityFilter.Builder getEntityFilterBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getEntityFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Description of which entities are being exported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder() { + if (entityFilterBuilder_ != null) { + return entityFilterBuilder_.getMessageOrBuilder(); + } else { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + } + + /** + * + * + *
+     * Description of which entities are being exported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder> + getEntityFilterFieldBuilder() { + if (entityFilterBuilder_ == null) { + entityFilterBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder>( + getEntityFilter(), getParentForChildren(), isClean()); + entityFilter_ = null; + } + return entityFilterBuilder_; + } + + private java.lang.Object outputUrlPrefix_ = ""; + + /** + * + * + *
+     * Location for the export metadata and data files. This will be the same
+     * value as the
+     * [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix]
+     * field. The final output location is provided in
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+     * 
+ * + * string output_url_prefix = 5; + * + * @return The outputUrlPrefix. + */ + public java.lang.String getOutputUrlPrefix() { + java.lang.Object ref = outputUrlPrefix_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + outputUrlPrefix_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Location for the export metadata and data files. This will be the same
+     * value as the
+     * [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix]
+     * field. The final output location is provided in
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+     * 
+ * + * string output_url_prefix = 5; + * + * @return The bytes for outputUrlPrefix. + */ + public com.google.protobuf.ByteString getOutputUrlPrefixBytes() { + java.lang.Object ref = outputUrlPrefix_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUrlPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Location for the export metadata and data files. This will be the same
+     * value as the
+     * [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix]
+     * field. The final output location is provided in
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+     * 
+ * + * string output_url_prefix = 5; + * + * @param value The outputUrlPrefix to set. + * @return This builder for chaining. + */ + public Builder setOutputUrlPrefix(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + outputUrlPrefix_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * Location for the export metadata and data files. This will be the same
+     * value as the
+     * [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix]
+     * field. The final output location is provided in
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+     * 
+ * + * string output_url_prefix = 5; + * + * @return This builder for chaining. + */ + public Builder clearOutputUrlPrefix() { + outputUrlPrefix_ = getDefaultInstance().getOutputUrlPrefix(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + /** + * + * + *
+     * Location for the export metadata and data files. This will be the same
+     * value as the
+     * [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix]
+     * field. The final output location is provided in
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+     * 
+ * + * string output_url_prefix = 5; + * + * @param value The bytes for outputUrlPrefix to set. + * @return This builder for chaining. + */ + public Builder setOutputUrlPrefixBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + outputUrlPrefix_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.ExportEntitiesMetadata) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.ExportEntitiesMetadata) + private static final com.google.datastore.admin.v1.ExportEntitiesMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.ExportEntitiesMetadata(); + } + + public static com.google.datastore.admin.v1.ExportEntitiesMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExportEntitiesMetadata 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.datastore.admin.v1.ExportEntitiesMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadataOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadataOrBuilder.java new file mode 100644 index 000000000000..086062f909a6 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesMetadataOrBuilder.java @@ -0,0 +1,208 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface ExportEntitiesMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.ExportEntitiesMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return Whether the common field is set. + */ + boolean hasCommon(); + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return The common. + */ + com.google.datastore.admin.v1.CommonMetadata getCommon(); + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + com.google.datastore.admin.v1.CommonMetadataOrBuilder getCommonOrBuilder(); + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return Whether the progressEntities field is set. + */ + boolean hasProgressEntities(); + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return The progressEntities. + */ + com.google.datastore.admin.v1.Progress getProgressEntities(); + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + com.google.datastore.admin.v1.ProgressOrBuilder getProgressEntitiesOrBuilder(); + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return Whether the progressBytes field is set. + */ + boolean hasProgressBytes(); + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return The progressBytes. + */ + com.google.datastore.admin.v1.Progress getProgressBytes(); + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + com.google.datastore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder(); + + /** + * + * + *
+   * Description of which entities are being exported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return Whether the entityFilter field is set. + */ + boolean hasEntityFilter(); + + /** + * + * + *
+   * Description of which entities are being exported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return The entityFilter. + */ + com.google.datastore.admin.v1.EntityFilter getEntityFilter(); + + /** + * + * + *
+   * Description of which entities are being exported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder(); + + /** + * + * + *
+   * Location for the export metadata and data files. This will be the same
+   * value as the
+   * [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix]
+   * field. The final output location is provided in
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+   * 
+ * + * string output_url_prefix = 5; + * + * @return The outputUrlPrefix. + */ + java.lang.String getOutputUrlPrefix(); + + /** + * + * + *
+   * Location for the export metadata and data files. This will be the same
+   * value as the
+   * [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix]
+   * field. The final output location is provided in
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+   * 
+ * + * string output_url_prefix = 5; + * + * @return The bytes for outputUrlPrefix. + */ + com.google.protobuf.ByteString getOutputUrlPrefixBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequest.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequest.java new file mode 100644 index 000000000000..f5ea6a2f32f4 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequest.java @@ -0,0 +1,1586 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities].
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ExportEntitiesRequest} + */ +public final class ExportEntitiesRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.ExportEntitiesRequest) + ExportEntitiesRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ExportEntitiesRequest.newBuilder() to construct. + private ExportEntitiesRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExportEntitiesRequest() { + projectId_ = ""; + outputUrlPrefix_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExportEntitiesRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ExportEntitiesRequest.class, + com.google.datastore.admin.v1.ExportEntitiesRequest.Builder.class); + } + + private int bitField0_; + public static final int PROJECT_ID_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Required. Project ID against which to make the request.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. Project ID against which to make the request.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LABELS_FIELD_NUMBER = 2; + + private static final class LabelsDefaultEntryHolder { + static final com.google.protobuf.MapEntry defaultEntry = + com.google.protobuf.MapEntry.newDefaultInstance( + com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesRequest_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(); + } + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + @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(); + } + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + @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; + } + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + @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 static final int ENTITY_FILTER_FIELD_NUMBER = 3; + private com.google.datastore.admin.v1.EntityFilter entityFilter_; + + /** + * + * + *
+   * Description of what data from the project is included in the export.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + * + * @return Whether the entityFilter field is set. + */ + @java.lang.Override + public boolean hasEntityFilter() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Description of what data from the project is included in the export.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + * + * @return The entityFilter. + */ + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilter getEntityFilter() { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + + /** + * + * + *
+   * Description of what data from the project is included in the export.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + */ + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder() { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + + public static final int OUTPUT_URL_PREFIX_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object outputUrlPrefix_ = ""; + + /** + * + * + *
+   * Required. Location for the export metadata and data files.
+   *
+   * The full resource URL of the external storage location. Currently, only
+   * Google Cloud Storage is supported. So output_url_prefix should be of the
+   * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the
+   * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
+   * Storage namespace path (this is not a Cloud Datastore namespace). For more
+   * information about Cloud Storage namespace paths, see
+   * [Object name
+   * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+   *
+   * The resulting files will be nested deeper than the specified URL prefix.
+   * The final output URL will be provided in the
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+   * field. That value should be used for subsequent ImportEntities operations.
+   *
+   * By nesting the data files deeper, the same Cloud Storage bucket can be used
+   * in multiple ExportEntities operations without conflict.
+   * 
+ * + * string output_url_prefix = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The outputUrlPrefix. + */ + @java.lang.Override + public java.lang.String getOutputUrlPrefix() { + java.lang.Object ref = outputUrlPrefix_; + 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(); + outputUrlPrefix_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. Location for the export metadata and data files.
+   *
+   * The full resource URL of the external storage location. Currently, only
+   * Google Cloud Storage is supported. So output_url_prefix should be of the
+   * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the
+   * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
+   * Storage namespace path (this is not a Cloud Datastore namespace). For more
+   * information about Cloud Storage namespace paths, see
+   * [Object name
+   * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+   *
+   * The resulting files will be nested deeper than the specified URL prefix.
+   * The final output URL will be provided in the
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+   * field. That value should be used for subsequent ImportEntities operations.
+   *
+   * By nesting the data files deeper, the same Cloud Storage bucket can be used
+   * in multiple ExportEntities operations without conflict.
+   * 
+ * + * string output_url_prefix = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for outputUrlPrefix. + */ + @java.lang.Override + public com.google.protobuf.ByteString getOutputUrlPrefixBytes() { + java.lang.Object ref = outputUrlPrefix_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUrlPrefix_ = 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.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, projectId_); + } + com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( + output, internalGetLabels(), LabelsDefaultEntryHolder.defaultEntry, 2); + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getEntityFilter()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(outputUrlPrefix_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, outputUrlPrefix_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, projectId_); + } + 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(2, labels__); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getEntityFilter()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(outputUrlPrefix_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, outputUrlPrefix_); + } + 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.datastore.admin.v1.ExportEntitiesRequest)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.ExportEntitiesRequest other = + (com.google.datastore.admin.v1.ExportEntitiesRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!internalGetLabels().equals(other.internalGetLabels())) return false; + if (hasEntityFilter() != other.hasEntityFilter()) return false; + if (hasEntityFilter()) { + if (!getEntityFilter().equals(other.getEntityFilter())) return false; + } + if (!getOutputUrlPrefix().equals(other.getOutputUrlPrefix())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + if (!internalGetLabels().getMap().isEmpty()) { + hash = (37 * hash) + LABELS_FIELD_NUMBER; + hash = (53 * hash) + internalGetLabels().hashCode(); + } + if (hasEntityFilter()) { + hash = (37 * hash) + ENTITY_FILTER_FIELD_NUMBER; + hash = (53 * hash) + getEntityFilter().hashCode(); + } + hash = (37 * hash) + OUTPUT_URL_PREFIX_FIELD_NUMBER; + hash = (53 * hash) + getOutputUrlPrefix().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest 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.datastore.admin.v1.ExportEntitiesRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.ExportEntitiesRequest 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities].
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ExportEntitiesRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.ExportEntitiesRequest) + com.google.datastore.admin.v1.ExportEntitiesRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetMutableLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ExportEntitiesRequest.class, + com.google.datastore.admin.v1.ExportEntitiesRequest.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.ExportEntitiesRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getEntityFilterFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + internalGetMutableLabels().clear(); + entityFilter_ = null; + if (entityFilterBuilder_ != null) { + entityFilterBuilder_.dispose(); + entityFilterBuilder_ = null; + } + outputUrlPrefix_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ExportEntitiesRequest getDefaultInstanceForType() { + return com.google.datastore.admin.v1.ExportEntitiesRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.ExportEntitiesRequest build() { + com.google.datastore.admin.v1.ExportEntitiesRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ExportEntitiesRequest buildPartial() { + com.google.datastore.admin.v1.ExportEntitiesRequest result = + new com.google.datastore.admin.v1.ExportEntitiesRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.ExportEntitiesRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.labels_ = internalGetLabels(); + result.labels_.makeImmutable(); + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.entityFilter_ = + entityFilterBuilder_ == null ? entityFilter_ : entityFilterBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.outputUrlPrefix_ = outputUrlPrefix_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.ExportEntitiesRequest) { + return mergeFrom((com.google.datastore.admin.v1.ExportEntitiesRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.ExportEntitiesRequest other) { + if (other == com.google.datastore.admin.v1.ExportEntitiesRequest.getDefaultInstance()) + return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + internalGetMutableLabels().mergeFrom(other.internalGetLabels()); + bitField0_ |= 0x00000002; + if (other.hasEntityFilter()) { + mergeEntityFilter(other.getEntityFilter()); + } + if (!other.getOutputUrlPrefix().isEmpty()) { + outputUrlPrefix_ = other.outputUrlPrefix_; + 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: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.protobuf.MapEntry labels__ = + input.readMessage( + LabelsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableLabels() + .getMutableMap() + .put(labels__.getKey(), labels__.getValue()); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(getEntityFilterFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + outputUrlPrefix_ = 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 projectId_ = ""; + + /** + * + * + *
+     * Required. Project ID against which to make the request.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. Project ID against which to make the request.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. Project ID against which to make the request.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Project ID against which to make the request.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Project ID against which to make the request.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + 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_ |= 0x00000002; + onChanged(); + return labels_; + } + + public int getLabelsCount() { + return internalGetLabels().getMap().size(); + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + @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(); + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + @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; + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + @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_ & ~0x00000002); + internalGetMutableLabels().getMutableMap().clear(); + return this; + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + 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_ |= 0x00000002; + return internalGetMutableLabels().getMutableMap(); + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + 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_ |= 0x00000002; + return this; + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + public Builder putAllLabels(java.util.Map values) { + internalGetMutableLabels().getMutableMap().putAll(values); + bitField0_ |= 0x00000002; + return this; + } + + private com.google.datastore.admin.v1.EntityFilter entityFilter_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder> + entityFilterBuilder_; + + /** + * + * + *
+     * Description of what data from the project is included in the export.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + * + * @return Whether the entityFilter field is set. + */ + public boolean hasEntityFilter() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Description of what data from the project is included in the export.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + * + * @return The entityFilter. + */ + public com.google.datastore.admin.v1.EntityFilter getEntityFilter() { + if (entityFilterBuilder_ == null) { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } else { + return entityFilterBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Description of what data from the project is included in the export.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + */ + public Builder setEntityFilter(com.google.datastore.admin.v1.EntityFilter value) { + if (entityFilterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + entityFilter_ = value; + } else { + entityFilterBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Description of what data from the project is included in the export.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + */ + public Builder setEntityFilter( + com.google.datastore.admin.v1.EntityFilter.Builder builderForValue) { + if (entityFilterBuilder_ == null) { + entityFilter_ = builderForValue.build(); + } else { + entityFilterBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Description of what data from the project is included in the export.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + */ + public Builder mergeEntityFilter(com.google.datastore.admin.v1.EntityFilter value) { + if (entityFilterBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && entityFilter_ != null + && entityFilter_ != com.google.datastore.admin.v1.EntityFilter.getDefaultInstance()) { + getEntityFilterBuilder().mergeFrom(value); + } else { + entityFilter_ = value; + } + } else { + entityFilterBuilder_.mergeFrom(value); + } + if (entityFilter_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Description of what data from the project is included in the export.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + */ + public Builder clearEntityFilter() { + bitField0_ = (bitField0_ & ~0x00000004); + entityFilter_ = null; + if (entityFilterBuilder_ != null) { + entityFilterBuilder_.dispose(); + entityFilterBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Description of what data from the project is included in the export.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + */ + public com.google.datastore.admin.v1.EntityFilter.Builder getEntityFilterBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getEntityFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Description of what data from the project is included in the export.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + */ + public com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder() { + if (entityFilterBuilder_ != null) { + return entityFilterBuilder_.getMessageOrBuilder(); + } else { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + } + + /** + * + * + *
+     * Description of what data from the project is included in the export.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder> + getEntityFilterFieldBuilder() { + if (entityFilterBuilder_ == null) { + entityFilterBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder>( + getEntityFilter(), getParentForChildren(), isClean()); + entityFilter_ = null; + } + return entityFilterBuilder_; + } + + private java.lang.Object outputUrlPrefix_ = ""; + + /** + * + * + *
+     * Required. Location for the export metadata and data files.
+     *
+     * The full resource URL of the external storage location. Currently, only
+     * Google Cloud Storage is supported. So output_url_prefix should be of the
+     * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the
+     * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
+     * Storage namespace path (this is not a Cloud Datastore namespace). For more
+     * information about Cloud Storage namespace paths, see
+     * [Object name
+     * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+     *
+     * The resulting files will be nested deeper than the specified URL prefix.
+     * The final output URL will be provided in the
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+     * field. That value should be used for subsequent ImportEntities operations.
+     *
+     * By nesting the data files deeper, the same Cloud Storage bucket can be used
+     * in multiple ExportEntities operations without conflict.
+     * 
+ * + * string output_url_prefix = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The outputUrlPrefix. + */ + public java.lang.String getOutputUrlPrefix() { + java.lang.Object ref = outputUrlPrefix_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + outputUrlPrefix_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. Location for the export metadata and data files.
+     *
+     * The full resource URL of the external storage location. Currently, only
+     * Google Cloud Storage is supported. So output_url_prefix should be of the
+     * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the
+     * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
+     * Storage namespace path (this is not a Cloud Datastore namespace). For more
+     * information about Cloud Storage namespace paths, see
+     * [Object name
+     * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+     *
+     * The resulting files will be nested deeper than the specified URL prefix.
+     * The final output URL will be provided in the
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+     * field. That value should be used for subsequent ImportEntities operations.
+     *
+     * By nesting the data files deeper, the same Cloud Storage bucket can be used
+     * in multiple ExportEntities operations without conflict.
+     * 
+ * + * string output_url_prefix = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for outputUrlPrefix. + */ + public com.google.protobuf.ByteString getOutputUrlPrefixBytes() { + java.lang.Object ref = outputUrlPrefix_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUrlPrefix_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. Location for the export metadata and data files.
+     *
+     * The full resource URL of the external storage location. Currently, only
+     * Google Cloud Storage is supported. So output_url_prefix should be of the
+     * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the
+     * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
+     * Storage namespace path (this is not a Cloud Datastore namespace). For more
+     * information about Cloud Storage namespace paths, see
+     * [Object name
+     * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+     *
+     * The resulting files will be nested deeper than the specified URL prefix.
+     * The final output URL will be provided in the
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+     * field. That value should be used for subsequent ImportEntities operations.
+     *
+     * By nesting the data files deeper, the same Cloud Storage bucket can be used
+     * in multiple ExportEntities operations without conflict.
+     * 
+ * + * string output_url_prefix = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The outputUrlPrefix to set. + * @return This builder for chaining. + */ + public Builder setOutputUrlPrefix(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + outputUrlPrefix_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Location for the export metadata and data files.
+     *
+     * The full resource URL of the external storage location. Currently, only
+     * Google Cloud Storage is supported. So output_url_prefix should be of the
+     * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the
+     * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
+     * Storage namespace path (this is not a Cloud Datastore namespace). For more
+     * information about Cloud Storage namespace paths, see
+     * [Object name
+     * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+     *
+     * The resulting files will be nested deeper than the specified URL prefix.
+     * The final output URL will be provided in the
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+     * field. That value should be used for subsequent ImportEntities operations.
+     *
+     * By nesting the data files deeper, the same Cloud Storage bucket can be used
+     * in multiple ExportEntities operations without conflict.
+     * 
+ * + * string output_url_prefix = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearOutputUrlPrefix() { + outputUrlPrefix_ = getDefaultInstance().getOutputUrlPrefix(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Location for the export metadata and data files.
+     *
+     * The full resource URL of the external storage location. Currently, only
+     * Google Cloud Storage is supported. So output_url_prefix should be of the
+     * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the
+     * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
+     * Storage namespace path (this is not a Cloud Datastore namespace). For more
+     * information about Cloud Storage namespace paths, see
+     * [Object name
+     * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+     *
+     * The resulting files will be nested deeper than the specified URL prefix.
+     * The final output URL will be provided in the
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+     * field. That value should be used for subsequent ImportEntities operations.
+     *
+     * By nesting the data files deeper, the same Cloud Storage bucket can be used
+     * in multiple ExportEntities operations without conflict.
+     * 
+ * + * string output_url_prefix = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for outputUrlPrefix to set. + * @return This builder for chaining. + */ + public Builder setOutputUrlPrefixBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + outputUrlPrefix_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.ExportEntitiesRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.ExportEntitiesRequest) + private static final com.google.datastore.admin.v1.ExportEntitiesRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.ExportEntitiesRequest(); + } + + public static com.google.datastore.admin.v1.ExportEntitiesRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExportEntitiesRequest 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.datastore.admin.v1.ExportEntitiesRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequestOrBuilder.java new file mode 100644 index 000000000000..3ffa58cc1dc3 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesRequestOrBuilder.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! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface ExportEntitiesRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.ExportEntitiesRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Project ID against which to make the request.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Required. Project ID against which to make the request.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + int getLabelsCount(); + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + boolean containsLabels(java.lang.String key); + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getLabels(); + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + java.util.Map getLabelsMap(); + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + /* nullable */ + java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue); + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + java.lang.String getLabelsOrThrow(java.lang.String key); + + /** + * + * + *
+   * Description of what data from the project is included in the export.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + * + * @return Whether the entityFilter field is set. + */ + boolean hasEntityFilter(); + + /** + * + * + *
+   * Description of what data from the project is included in the export.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + * + * @return The entityFilter. + */ + com.google.datastore.admin.v1.EntityFilter getEntityFilter(); + + /** + * + * + *
+   * Description of what data from the project is included in the export.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 3; + */ + com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder(); + + /** + * + * + *
+   * Required. Location for the export metadata and data files.
+   *
+   * The full resource URL of the external storage location. Currently, only
+   * Google Cloud Storage is supported. So output_url_prefix should be of the
+   * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the
+   * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
+   * Storage namespace path (this is not a Cloud Datastore namespace). For more
+   * information about Cloud Storage namespace paths, see
+   * [Object name
+   * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+   *
+   * The resulting files will be nested deeper than the specified URL prefix.
+   * The final output URL will be provided in the
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+   * field. That value should be used for subsequent ImportEntities operations.
+   *
+   * By nesting the data files deeper, the same Cloud Storage bucket can be used
+   * in multiple ExportEntities operations without conflict.
+   * 
+ * + * string output_url_prefix = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The outputUrlPrefix. + */ + java.lang.String getOutputUrlPrefix(); + + /** + * + * + *
+   * Required. Location for the export metadata and data files.
+   *
+   * The full resource URL of the external storage location. Currently, only
+   * Google Cloud Storage is supported. So output_url_prefix should be of the
+   * form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the
+   * name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud
+   * Storage namespace path (this is not a Cloud Datastore namespace). For more
+   * information about Cloud Storage namespace paths, see
+   * [Object name
+   * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+   *
+   * The resulting files will be nested deeper than the specified URL prefix.
+   * The final output URL will be provided in the
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+   * field. That value should be used for subsequent ImportEntities operations.
+   *
+   * By nesting the data files deeper, the same Cloud Storage bucket can be used
+   * in multiple ExportEntities operations without conflict.
+   * 
+ * + * string output_url_prefix = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for outputUrlPrefix. + */ + com.google.protobuf.ByteString getOutputUrlPrefixBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponse.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponse.java new file mode 100644 index 000000000000..a042fe1d4b62 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponse.java @@ -0,0 +1,657 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * The response for
+ * [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities].
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ExportEntitiesResponse} + */ +public final class ExportEntitiesResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.ExportEntitiesResponse) + ExportEntitiesResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ExportEntitiesResponse.newBuilder() to construct. + private ExportEntitiesResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExportEntitiesResponse() { + outputUrl_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExportEntitiesResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ExportEntitiesResponse.class, + com.google.datastore.admin.v1.ExportEntitiesResponse.Builder.class); + } + + public static final int OUTPUT_URL_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object outputUrl_ = ""; + + /** + * + * + *
+   * Location of the output metadata file. This can be used to begin an import
+   * into Cloud Datastore (this project or another project). See
+   * [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url].
+   * Only present if the operation completed successfully.
+   * 
+ * + * string output_url = 1; + * + * @return The outputUrl. + */ + @java.lang.Override + public java.lang.String getOutputUrl() { + java.lang.Object ref = outputUrl_; + 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(); + outputUrl_ = s; + return s; + } + } + + /** + * + * + *
+   * Location of the output metadata file. This can be used to begin an import
+   * into Cloud Datastore (this project or another project). See
+   * [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url].
+   * Only present if the operation completed successfully.
+   * 
+ * + * string output_url = 1; + * + * @return The bytes for outputUrl. + */ + @java.lang.Override + public com.google.protobuf.ByteString getOutputUrlBytes() { + java.lang.Object ref = outputUrl_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUrl_ = 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.GeneratedMessageV3.isStringEmpty(outputUrl_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, outputUrl_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(outputUrl_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, outputUrl_); + } + 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.datastore.admin.v1.ExportEntitiesResponse)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.ExportEntitiesResponse other = + (com.google.datastore.admin.v1.ExportEntitiesResponse) obj; + + if (!getOutputUrl().equals(other.getOutputUrl())) 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_URL_FIELD_NUMBER; + hash = (53 * hash) + getOutputUrl().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse 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.datastore.admin.v1.ExportEntitiesResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.ExportEntitiesResponse 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities].
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ExportEntitiesResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.ExportEntitiesResponse) + com.google.datastore.admin.v1.ExportEntitiesResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ExportEntitiesResponse.class, + com.google.datastore.admin.v1.ExportEntitiesResponse.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.ExportEntitiesResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + outputUrl_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ExportEntitiesResponse_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ExportEntitiesResponse getDefaultInstanceForType() { + return com.google.datastore.admin.v1.ExportEntitiesResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.ExportEntitiesResponse build() { + com.google.datastore.admin.v1.ExportEntitiesResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ExportEntitiesResponse buildPartial() { + com.google.datastore.admin.v1.ExportEntitiesResponse result = + new com.google.datastore.admin.v1.ExportEntitiesResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.ExportEntitiesResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.outputUrl_ = outputUrl_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.ExportEntitiesResponse) { + return mergeFrom((com.google.datastore.admin.v1.ExportEntitiesResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.ExportEntitiesResponse other) { + if (other == com.google.datastore.admin.v1.ExportEntitiesResponse.getDefaultInstance()) + return this; + if (!other.getOutputUrl().isEmpty()) { + outputUrl_ = other.outputUrl_; + 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: + { + outputUrl_ = 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 outputUrl_ = ""; + + /** + * + * + *
+     * Location of the output metadata file. This can be used to begin an import
+     * into Cloud Datastore (this project or another project). See
+     * [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url].
+     * Only present if the operation completed successfully.
+     * 
+ * + * string output_url = 1; + * + * @return The outputUrl. + */ + public java.lang.String getOutputUrl() { + java.lang.Object ref = outputUrl_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + outputUrl_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Location of the output metadata file. This can be used to begin an import
+     * into Cloud Datastore (this project or another project). See
+     * [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url].
+     * Only present if the operation completed successfully.
+     * 
+ * + * string output_url = 1; + * + * @return The bytes for outputUrl. + */ + public com.google.protobuf.ByteString getOutputUrlBytes() { + java.lang.Object ref = outputUrl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + outputUrl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Location of the output metadata file. This can be used to begin an import
+     * into Cloud Datastore (this project or another project). See
+     * [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url].
+     * Only present if the operation completed successfully.
+     * 
+ * + * string output_url = 1; + * + * @param value The outputUrl to set. + * @return This builder for chaining. + */ + public Builder setOutputUrl(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + outputUrl_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Location of the output metadata file. This can be used to begin an import
+     * into Cloud Datastore (this project or another project). See
+     * [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url].
+     * Only present if the operation completed successfully.
+     * 
+ * + * string output_url = 1; + * + * @return This builder for chaining. + */ + public Builder clearOutputUrl() { + outputUrl_ = getDefaultInstance().getOutputUrl(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Location of the output metadata file. This can be used to begin an import
+     * into Cloud Datastore (this project or another project). See
+     * [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url].
+     * Only present if the operation completed successfully.
+     * 
+ * + * string output_url = 1; + * + * @param value The bytes for outputUrl to set. + * @return This builder for chaining. + */ + public Builder setOutputUrlBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + outputUrl_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.ExportEntitiesResponse) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.ExportEntitiesResponse) + private static final com.google.datastore.admin.v1.ExportEntitiesResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.ExportEntitiesResponse(); + } + + public static com.google.datastore.admin.v1.ExportEntitiesResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ExportEntitiesResponse 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.datastore.admin.v1.ExportEntitiesResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponseOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponseOrBuilder.java new file mode 100644 index 000000000000..1566b7337cf3 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ExportEntitiesResponseOrBuilder.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! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface ExportEntitiesResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.ExportEntitiesResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Location of the output metadata file. This can be used to begin an import
+   * into Cloud Datastore (this project or another project). See
+   * [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url].
+   * Only present if the operation completed successfully.
+   * 
+ * + * string output_url = 1; + * + * @return The outputUrl. + */ + java.lang.String getOutputUrl(); + + /** + * + * + *
+   * Location of the output metadata file. This can be used to begin an import
+   * into Cloud Datastore (this project or another project). See
+   * [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url].
+   * Only present if the operation completed successfully.
+   * 
+ * + * string output_url = 1; + * + * @return The bytes for outputUrl. + */ + com.google.protobuf.ByteString getOutputUrlBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequest.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequest.java new file mode 100644 index 000000000000..26f1baeee3b3 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequest.java @@ -0,0 +1,824 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [google.datastore.admin.v1.DatastoreAdmin.GetIndex][google.datastore.admin.v1.DatastoreAdmin.GetIndex].
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.GetIndexRequest} + */ +public final class GetIndexRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.GetIndexRequest) + GetIndexRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use GetIndexRequest.newBuilder() to construct. + private GetIndexRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private GetIndexRequest() { + projectId_ = ""; + indexId_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetIndexRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_GetIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_GetIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.GetIndexRequest.class, + com.google.datastore.admin.v1.GetIndexRequest.Builder.class); + } + + public static final int PROJECT_ID_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INDEX_ID_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object indexId_ = ""; + + /** + * + * + *
+   * The resource ID of the index to get.
+   * 
+ * + * string index_id = 3; + * + * @return The indexId. + */ + @java.lang.Override + public java.lang.String getIndexId() { + java.lang.Object ref = indexId_; + 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(); + indexId_ = s; + return s; + } + } + + /** + * + * + *
+   * The resource ID of the index to get.
+   * 
+ * + * string index_id = 3; + * + * @return The bytes for indexId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getIndexIdBytes() { + java.lang.Object ref = indexId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + indexId_ = 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.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(indexId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, indexId_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(indexId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, indexId_); + } + 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.datastore.admin.v1.GetIndexRequest)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.GetIndexRequest other = + (com.google.datastore.admin.v1.GetIndexRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getIndexId().equals(other.getIndexId())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + INDEX_ID_FIELD_NUMBER; + hash = (53 * hash) + getIndexId().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.GetIndexRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.GetIndexRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.GetIndexRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.GetIndexRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.GetIndexRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.GetIndexRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.GetIndexRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.GetIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.GetIndexRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [google.datastore.admin.v1.DatastoreAdmin.GetIndex][google.datastore.admin.v1.DatastoreAdmin.GetIndex].
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.GetIndexRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.GetIndexRequest) + com.google.datastore.admin.v1.GetIndexRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_GetIndexRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_GetIndexRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.GetIndexRequest.class, + com.google.datastore.admin.v1.GetIndexRequest.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.GetIndexRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + indexId_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_GetIndexRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.GetIndexRequest getDefaultInstanceForType() { + return com.google.datastore.admin.v1.GetIndexRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.GetIndexRequest build() { + com.google.datastore.admin.v1.GetIndexRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.GetIndexRequest buildPartial() { + com.google.datastore.admin.v1.GetIndexRequest result = + new com.google.datastore.admin.v1.GetIndexRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.GetIndexRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.indexId_ = indexId_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.GetIndexRequest) { + return mergeFrom((com.google.datastore.admin.v1.GetIndexRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.GetIndexRequest other) { + if (other == com.google.datastore.admin.v1.GetIndexRequest.getDefaultInstance()) return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getIndexId().isEmpty()) { + indexId_ = other.indexId_; + 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: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + indexId_ = 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 projectId_ = ""; + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object indexId_ = ""; + + /** + * + * + *
+     * The resource ID of the index to get.
+     * 
+ * + * string index_id = 3; + * + * @return The indexId. + */ + public java.lang.String getIndexId() { + java.lang.Object ref = indexId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + indexId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The resource ID of the index to get.
+     * 
+ * + * string index_id = 3; + * + * @return The bytes for indexId. + */ + public com.google.protobuf.ByteString getIndexIdBytes() { + java.lang.Object ref = indexId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + indexId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The resource ID of the index to get.
+     * 
+ * + * string index_id = 3; + * + * @param value The indexId to set. + * @return This builder for chaining. + */ + public Builder setIndexId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + indexId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource ID of the index to get.
+     * 
+ * + * string index_id = 3; + * + * @return This builder for chaining. + */ + public Builder clearIndexId() { + indexId_ = getDefaultInstance().getIndexId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The resource ID of the index to get.
+     * 
+ * + * string index_id = 3; + * + * @param value The bytes for indexId to set. + * @return This builder for chaining. + */ + public Builder setIndexIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + indexId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.GetIndexRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.GetIndexRequest) + private static final com.google.datastore.admin.v1.GetIndexRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.GetIndexRequest(); + } + + public static com.google.datastore.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.datastore.admin.v1.GetIndexRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequestOrBuilder.java new file mode 100644 index 000000000000..ff233bdd6a33 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/GetIndexRequestOrBuilder.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! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface GetIndexRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.GetIndexRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The resource ID of the index to get.
+   * 
+ * + * string index_id = 3; + * + * @return The indexId. + */ + java.lang.String getIndexId(); + + /** + * + * + *
+   * The resource ID of the index to get.
+   * 
+ * + * string index_id = 3; + * + * @return The bytes for indexId. + */ + com.google.protobuf.ByteString getIndexIdBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadata.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadata.java new file mode 100644 index 000000000000..d7b1d6fe4217 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadata.java @@ -0,0 +1,1793 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * Metadata for ImportEntities operations.
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ImportEntitiesMetadata} + */ +public final class ImportEntitiesMetadata extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.ImportEntitiesMetadata) + ImportEntitiesMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ImportEntitiesMetadata.newBuilder() to construct. + private ImportEntitiesMetadata(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ImportEntitiesMetadata() { + inputUrl_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ImportEntitiesMetadata(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ImportEntitiesMetadata.class, + com.google.datastore.admin.v1.ImportEntitiesMetadata.Builder.class); + } + + private int bitField0_; + public static final int COMMON_FIELD_NUMBER = 1; + private com.google.datastore.admin.v1.CommonMetadata common_; + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return Whether the common field is set. + */ + @java.lang.Override + public boolean hasCommon() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return The common. + */ + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadata getCommon() { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadataOrBuilder getCommonOrBuilder() { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } + + public static final int PROGRESS_ENTITIES_FIELD_NUMBER = 2; + private com.google.datastore.admin.v1.Progress progressEntities_; + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return Whether the progressEntities field is set. + */ + @java.lang.Override + public boolean hasProgressEntities() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return The progressEntities. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Progress getProgressEntities() { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + @java.lang.Override + public com.google.datastore.admin.v1.ProgressOrBuilder getProgressEntitiesOrBuilder() { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } + + public static final int PROGRESS_BYTES_FIELD_NUMBER = 3; + private com.google.datastore.admin.v1.Progress progressBytes_; + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return Whether the progressBytes field is set. + */ + @java.lang.Override + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return The progressBytes. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Progress getProgressBytes() { + return progressBytes_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + @java.lang.Override + public com.google.datastore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + return progressBytes_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + + public static final int ENTITY_FILTER_FIELD_NUMBER = 4; + private com.google.datastore.admin.v1.EntityFilter entityFilter_; + + /** + * + * + *
+   * Description of which entities are being imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return Whether the entityFilter field is set. + */ + @java.lang.Override + public boolean hasEntityFilter() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * Description of which entities are being imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return The entityFilter. + */ + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilter getEntityFilter() { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + + /** + * + * + *
+   * Description of which entities are being imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder() { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + + public static final int INPUT_URL_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private volatile java.lang.Object inputUrl_ = ""; + + /** + * + * + *
+   * The location of the import metadata file. This will be the same value as
+   * the
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+   * field.
+   * 
+ * + * string input_url = 5; + * + * @return The inputUrl. + */ + @java.lang.Override + public java.lang.String getInputUrl() { + java.lang.Object ref = inputUrl_; + 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(); + inputUrl_ = s; + return s; + } + } + + /** + * + * + *
+   * The location of the import metadata file. This will be the same value as
+   * the
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+   * field.
+   * 
+ * + * string input_url = 5; + * + * @return The bytes for inputUrl. + */ + @java.lang.Override + public com.google.protobuf.ByteString getInputUrlBytes() { + java.lang.Object ref = inputUrl_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + inputUrl_ = 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 (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getCommon()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getProgressEntities()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(3, getProgressBytes()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(4, getEntityFilter()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(inputUrl_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, inputUrl_); + } + 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, getCommon()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getProgressEntities()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getProgressBytes()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getEntityFilter()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(inputUrl_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, inputUrl_); + } + 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.datastore.admin.v1.ImportEntitiesMetadata)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.ImportEntitiesMetadata other = + (com.google.datastore.admin.v1.ImportEntitiesMetadata) obj; + + if (hasCommon() != other.hasCommon()) return false; + if (hasCommon()) { + if (!getCommon().equals(other.getCommon())) return false; + } + if (hasProgressEntities() != other.hasProgressEntities()) return false; + if (hasProgressEntities()) { + if (!getProgressEntities().equals(other.getProgressEntities())) return false; + } + if (hasProgressBytes() != other.hasProgressBytes()) return false; + if (hasProgressBytes()) { + if (!getProgressBytes().equals(other.getProgressBytes())) return false; + } + if (hasEntityFilter() != other.hasEntityFilter()) return false; + if (hasEntityFilter()) { + if (!getEntityFilter().equals(other.getEntityFilter())) return false; + } + if (!getInputUrl().equals(other.getInputUrl())) 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 (hasCommon()) { + hash = (37 * hash) + COMMON_FIELD_NUMBER; + hash = (53 * hash) + getCommon().hashCode(); + } + if (hasProgressEntities()) { + hash = (37 * hash) + PROGRESS_ENTITIES_FIELD_NUMBER; + hash = (53 * hash) + getProgressEntities().hashCode(); + } + if (hasProgressBytes()) { + hash = (37 * hash) + PROGRESS_BYTES_FIELD_NUMBER; + hash = (53 * hash) + getProgressBytes().hashCode(); + } + if (hasEntityFilter()) { + hash = (37 * hash) + ENTITY_FILTER_FIELD_NUMBER; + hash = (53 * hash) + getEntityFilter().hashCode(); + } + hash = (37 * hash) + INPUT_URL_FIELD_NUMBER; + hash = (53 * hash) + getInputUrl().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata 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.datastore.admin.v1.ImportEntitiesMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.ImportEntitiesMetadata 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for ImportEntities operations.
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ImportEntitiesMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.ImportEntitiesMetadata) + com.google.datastore.admin.v1.ImportEntitiesMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ImportEntitiesMetadata.class, + com.google.datastore.admin.v1.ImportEntitiesMetadata.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.ImportEntitiesMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getCommonFieldBuilder(); + getProgressEntitiesFieldBuilder(); + getProgressBytesFieldBuilder(); + getEntityFilterFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + common_ = null; + if (commonBuilder_ != null) { + commonBuilder_.dispose(); + commonBuilder_ = null; + } + progressEntities_ = null; + if (progressEntitiesBuilder_ != null) { + progressEntitiesBuilder_.dispose(); + progressEntitiesBuilder_ = null; + } + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + entityFilter_ = null; + if (entityFilterBuilder_ != null) { + entityFilterBuilder_.dispose(); + entityFilterBuilder_ = null; + } + inputUrl_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesMetadata_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ImportEntitiesMetadata getDefaultInstanceForType() { + return com.google.datastore.admin.v1.ImportEntitiesMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.ImportEntitiesMetadata build() { + com.google.datastore.admin.v1.ImportEntitiesMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ImportEntitiesMetadata buildPartial() { + com.google.datastore.admin.v1.ImportEntitiesMetadata result = + new com.google.datastore.admin.v1.ImportEntitiesMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.ImportEntitiesMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.common_ = commonBuilder_ == null ? common_ : commonBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.progressEntities_ = + progressEntitiesBuilder_ == null ? progressEntities_ : progressEntitiesBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.progressBytes_ = + progressBytesBuilder_ == null ? progressBytes_ : progressBytesBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.entityFilter_ = + entityFilterBuilder_ == null ? entityFilter_ : entityFilterBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.inputUrl_ = inputUrl_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.ImportEntitiesMetadata) { + return mergeFrom((com.google.datastore.admin.v1.ImportEntitiesMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.ImportEntitiesMetadata other) { + if (other == com.google.datastore.admin.v1.ImportEntitiesMetadata.getDefaultInstance()) + return this; + if (other.hasCommon()) { + mergeCommon(other.getCommon()); + } + if (other.hasProgressEntities()) { + mergeProgressEntities(other.getProgressEntities()); + } + if (other.hasProgressBytes()) { + mergeProgressBytes(other.getProgressBytes()); + } + if (other.hasEntityFilter()) { + mergeEntityFilter(other.getEntityFilter()); + } + if (!other.getInputUrl().isEmpty()) { + inputUrl_ = other.inputUrl_; + bitField0_ |= 0x00000010; + 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(getCommonFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + getProgressEntitiesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(getProgressBytesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + input.readMessage(getEntityFilterFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + inputUrl_ = input.readStringRequireUtf8(); + 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 com.google.datastore.admin.v1.CommonMetadata common_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.CommonMetadata, + com.google.datastore.admin.v1.CommonMetadata.Builder, + com.google.datastore.admin.v1.CommonMetadataOrBuilder> + commonBuilder_; + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return Whether the common field is set. + */ + public boolean hasCommon() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return The common. + */ + public com.google.datastore.admin.v1.CommonMetadata getCommon() { + if (commonBuilder_ == null) { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } else { + return commonBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder setCommon(com.google.datastore.admin.v1.CommonMetadata value) { + if (commonBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + common_ = value; + } else { + commonBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder setCommon(com.google.datastore.admin.v1.CommonMetadata.Builder builderForValue) { + if (commonBuilder_ == null) { + common_ = builderForValue.build(); + } else { + commonBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder mergeCommon(com.google.datastore.admin.v1.CommonMetadata value) { + if (commonBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && common_ != null + && common_ != com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance()) { + getCommonBuilder().mergeFrom(value); + } else { + common_ = value; + } + } else { + commonBuilder_.mergeFrom(value); + } + if (common_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder clearCommon() { + bitField0_ = (bitField0_ & ~0x00000001); + common_ = null; + if (commonBuilder_ != null) { + commonBuilder_.dispose(); + commonBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public com.google.datastore.admin.v1.CommonMetadata.Builder getCommonBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getCommonFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public com.google.datastore.admin.v1.CommonMetadataOrBuilder getCommonOrBuilder() { + if (commonBuilder_ != null) { + return commonBuilder_.getMessageOrBuilder(); + } else { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.CommonMetadata, + com.google.datastore.admin.v1.CommonMetadata.Builder, + com.google.datastore.admin.v1.CommonMetadataOrBuilder> + getCommonFieldBuilder() { + if (commonBuilder_ == null) { + commonBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.CommonMetadata, + com.google.datastore.admin.v1.CommonMetadata.Builder, + com.google.datastore.admin.v1.CommonMetadataOrBuilder>( + getCommon(), getParentForChildren(), isClean()); + common_ = null; + } + return commonBuilder_; + } + + private com.google.datastore.admin.v1.Progress progressEntities_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder> + progressEntitiesBuilder_; + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return Whether the progressEntities field is set. + */ + public boolean hasProgressEntities() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return The progressEntities. + */ + public com.google.datastore.admin.v1.Progress getProgressEntities() { + if (progressEntitiesBuilder_ == null) { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } else { + return progressEntitiesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder setProgressEntities(com.google.datastore.admin.v1.Progress value) { + if (progressEntitiesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressEntities_ = value; + } else { + progressEntitiesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder setProgressEntities( + com.google.datastore.admin.v1.Progress.Builder builderForValue) { + if (progressEntitiesBuilder_ == null) { + progressEntities_ = builderForValue.build(); + } else { + progressEntitiesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder mergeProgressEntities(com.google.datastore.admin.v1.Progress value) { + if (progressEntitiesBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && progressEntities_ != null + && progressEntities_ != com.google.datastore.admin.v1.Progress.getDefaultInstance()) { + getProgressEntitiesBuilder().mergeFrom(value); + } else { + progressEntities_ = value; + } + } else { + progressEntitiesBuilder_.mergeFrom(value); + } + if (progressEntities_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder clearProgressEntities() { + bitField0_ = (bitField0_ & ~0x00000002); + progressEntities_ = null; + if (progressEntitiesBuilder_ != null) { + progressEntitiesBuilder_.dispose(); + progressEntitiesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public com.google.datastore.admin.v1.Progress.Builder getProgressEntitiesBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getProgressEntitiesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public com.google.datastore.admin.v1.ProgressOrBuilder getProgressEntitiesOrBuilder() { + if (progressEntitiesBuilder_ != null) { + return progressEntitiesBuilder_.getMessageOrBuilder(); + } else { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder> + getProgressEntitiesFieldBuilder() { + if (progressEntitiesBuilder_ == null) { + progressEntitiesBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder>( + getProgressEntities(), getParentForChildren(), isClean()); + progressEntities_ = null; + } + return progressEntitiesBuilder_; + } + + private com.google.datastore.admin.v1.Progress progressBytes_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder> + progressBytesBuilder_; + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return Whether the progressBytes field is set. + */ + public boolean hasProgressBytes() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return The progressBytes. + */ + public com.google.datastore.admin.v1.Progress getProgressBytes() { + if (progressBytesBuilder_ == null) { + return progressBytes_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } else { + return progressBytesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public Builder setProgressBytes(com.google.datastore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressBytes_ = value; + } else { + progressBytesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public Builder setProgressBytes( + com.google.datastore.admin.v1.Progress.Builder builderForValue) { + if (progressBytesBuilder_ == null) { + progressBytes_ = builderForValue.build(); + } else { + progressBytesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public Builder mergeProgressBytes(com.google.datastore.admin.v1.Progress value) { + if (progressBytesBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && progressBytes_ != null + && progressBytes_ != com.google.datastore.admin.v1.Progress.getDefaultInstance()) { + getProgressBytesBuilder().mergeFrom(value); + } else { + progressBytes_ = value; + } + } else { + progressBytesBuilder_.mergeFrom(value); + } + if (progressBytes_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public Builder clearProgressBytes() { + bitField0_ = (bitField0_ & ~0x00000004); + progressBytes_ = null; + if (progressBytesBuilder_ != null) { + progressBytesBuilder_.dispose(); + progressBytesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public com.google.datastore.admin.v1.Progress.Builder getProgressBytesBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getProgressBytesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + public com.google.datastore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder() { + if (progressBytesBuilder_ != null) { + return progressBytesBuilder_.getMessageOrBuilder(); + } else { + return progressBytes_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressBytes_; + } + } + + /** + * + * + *
+     * An estimate of the number of bytes processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder> + getProgressBytesFieldBuilder() { + if (progressBytesBuilder_ == null) { + progressBytesBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder>( + getProgressBytes(), getParentForChildren(), isClean()); + progressBytes_ = null; + } + return progressBytesBuilder_; + } + + private com.google.datastore.admin.v1.EntityFilter entityFilter_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder> + entityFilterBuilder_; + + /** + * + * + *
+     * Description of which entities are being imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return Whether the entityFilter field is set. + */ + public boolean hasEntityFilter() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Description of which entities are being imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return The entityFilter. + */ + public com.google.datastore.admin.v1.EntityFilter getEntityFilter() { + if (entityFilterBuilder_ == null) { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } else { + return entityFilterBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Description of which entities are being imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder setEntityFilter(com.google.datastore.admin.v1.EntityFilter value) { + if (entityFilterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + entityFilter_ = value; + } else { + entityFilterBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Description of which entities are being imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder setEntityFilter( + com.google.datastore.admin.v1.EntityFilter.Builder builderForValue) { + if (entityFilterBuilder_ == null) { + entityFilter_ = builderForValue.build(); + } else { + entityFilterBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Description of which entities are being imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder mergeEntityFilter(com.google.datastore.admin.v1.EntityFilter value) { + if (entityFilterBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && entityFilter_ != null + && entityFilter_ != com.google.datastore.admin.v1.EntityFilter.getDefaultInstance()) { + getEntityFilterBuilder().mergeFrom(value); + } else { + entityFilter_ = value; + } + } else { + entityFilterBuilder_.mergeFrom(value); + } + if (entityFilter_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Description of which entities are being imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder clearEntityFilter() { + bitField0_ = (bitField0_ & ~0x00000008); + entityFilter_ = null; + if (entityFilterBuilder_ != null) { + entityFilterBuilder_.dispose(); + entityFilterBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Description of which entities are being imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public com.google.datastore.admin.v1.EntityFilter.Builder getEntityFilterBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getEntityFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Description of which entities are being imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder() { + if (entityFilterBuilder_ != null) { + return entityFilterBuilder_.getMessageOrBuilder(); + } else { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + } + + /** + * + * + *
+     * Description of which entities are being imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder> + getEntityFilterFieldBuilder() { + if (entityFilterBuilder_ == null) { + entityFilterBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder>( + getEntityFilter(), getParentForChildren(), isClean()); + entityFilter_ = null; + } + return entityFilterBuilder_; + } + + private java.lang.Object inputUrl_ = ""; + + /** + * + * + *
+     * The location of the import metadata file. This will be the same value as
+     * the
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+     * field.
+     * 
+ * + * string input_url = 5; + * + * @return The inputUrl. + */ + public java.lang.String getInputUrl() { + java.lang.Object ref = inputUrl_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + inputUrl_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The location of the import metadata file. This will be the same value as
+     * the
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+     * field.
+     * 
+ * + * string input_url = 5; + * + * @return The bytes for inputUrl. + */ + public com.google.protobuf.ByteString getInputUrlBytes() { + java.lang.Object ref = inputUrl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + inputUrl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The location of the import metadata file. This will be the same value as
+     * the
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+     * field.
+     * 
+ * + * string input_url = 5; + * + * @param value The inputUrl to set. + * @return This builder for chaining. + */ + public Builder setInputUrl(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + inputUrl_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The location of the import metadata file. This will be the same value as
+     * the
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+     * field.
+     * 
+ * + * string input_url = 5; + * + * @return This builder for chaining. + */ + public Builder clearInputUrl() { + inputUrl_ = getDefaultInstance().getInputUrl(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + /** + * + * + *
+     * The location of the import metadata file. This will be the same value as
+     * the
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+     * field.
+     * 
+ * + * string input_url = 5; + * + * @param value The bytes for inputUrl to set. + * @return This builder for chaining. + */ + public Builder setInputUrlBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + inputUrl_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.ImportEntitiesMetadata) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.ImportEntitiesMetadata) + private static final com.google.datastore.admin.v1.ImportEntitiesMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.ImportEntitiesMetadata(); + } + + public static com.google.datastore.admin.v1.ImportEntitiesMetadata getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ImportEntitiesMetadata 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.datastore.admin.v1.ImportEntitiesMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadataOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadataOrBuilder.java new file mode 100644 index 000000000000..82598a6e85aa --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesMetadataOrBuilder.java @@ -0,0 +1,206 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface ImportEntitiesMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.ImportEntitiesMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return Whether the common field is set. + */ + boolean hasCommon(); + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return The common. + */ + com.google.datastore.admin.v1.CommonMetadata getCommon(); + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + com.google.datastore.admin.v1.CommonMetadataOrBuilder getCommonOrBuilder(); + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return Whether the progressEntities field is set. + */ + boolean hasProgressEntities(); + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return The progressEntities. + */ + com.google.datastore.admin.v1.Progress getProgressEntities(); + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + com.google.datastore.admin.v1.ProgressOrBuilder getProgressEntitiesOrBuilder(); + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return Whether the progressBytes field is set. + */ + boolean hasProgressBytes(); + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + * + * @return The progressBytes. + */ + com.google.datastore.admin.v1.Progress getProgressBytes(); + + /** + * + * + *
+   * An estimate of the number of bytes processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_bytes = 3; + */ + com.google.datastore.admin.v1.ProgressOrBuilder getProgressBytesOrBuilder(); + + /** + * + * + *
+   * Description of which entities are being imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return Whether the entityFilter field is set. + */ + boolean hasEntityFilter(); + + /** + * + * + *
+   * Description of which entities are being imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return The entityFilter. + */ + com.google.datastore.admin.v1.EntityFilter getEntityFilter(); + + /** + * + * + *
+   * Description of which entities are being imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder(); + + /** + * + * + *
+   * The location of the import metadata file. This will be the same value as
+   * the
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+   * field.
+   * 
+ * + * string input_url = 5; + * + * @return The inputUrl. + */ + java.lang.String getInputUrl(); + + /** + * + * + *
+   * The location of the import metadata file. This will be the same value as
+   * the
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]
+   * field.
+   * 
+ * + * string input_url = 5; + * + * @return The bytes for inputUrl. + */ + com.google.protobuf.ByteString getInputUrlBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequest.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequest.java new file mode 100644 index 000000000000..fe762d870ea7 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequest.java @@ -0,0 +1,1594 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [google.datastore.admin.v1.DatastoreAdmin.ImportEntities][google.datastore.admin.v1.DatastoreAdmin.ImportEntities].
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ImportEntitiesRequest} + */ +public final class ImportEntitiesRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.ImportEntitiesRequest) + ImportEntitiesRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ImportEntitiesRequest.newBuilder() to construct. + private ImportEntitiesRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ImportEntitiesRequest() { + projectId_ = ""; + inputUrl_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ImportEntitiesRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ImportEntitiesRequest.class, + com.google.datastore.admin.v1.ImportEntitiesRequest.Builder.class); + } + + private int bitField0_; + public static final int PROJECT_ID_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Required. Project ID against which to make the request.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. Project ID against which to make the request.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int LABELS_FIELD_NUMBER = 2; + + private static final class LabelsDefaultEntryHolder { + static final com.google.protobuf.MapEntry defaultEntry = + com.google.protobuf.MapEntry.newDefaultInstance( + com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesRequest_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(); + } + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + @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(); + } + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + @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; + } + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + @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 static final int INPUT_URL_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object inputUrl_ = ""; + + /** + * + * + *
+   * Required. The full resource URL of the external storage location.
+   * Currently, only Google Cloud Storage is supported. So input_url should be
+   * of the form:
+   * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
+   * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
+   * an optional Cloud Storage namespace path (this is not a Cloud Datastore
+   * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
+   * by the ExportEntities operation. For more information about Cloud Storage
+   * namespace paths, see
+   * [Object name
+   * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+   *
+   * For more information, see
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+   * 
+ * + * string input_url = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The inputUrl. + */ + @java.lang.Override + public java.lang.String getInputUrl() { + java.lang.Object ref = inputUrl_; + 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(); + inputUrl_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The full resource URL of the external storage location.
+   * Currently, only Google Cloud Storage is supported. So input_url should be
+   * of the form:
+   * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
+   * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
+   * an optional Cloud Storage namespace path (this is not a Cloud Datastore
+   * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
+   * by the ExportEntities operation. For more information about Cloud Storage
+   * namespace paths, see
+   * [Object name
+   * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+   *
+   * For more information, see
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+   * 
+ * + * string input_url = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for inputUrl. + */ + @java.lang.Override + public com.google.protobuf.ByteString getInputUrlBytes() { + java.lang.Object ref = inputUrl_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + inputUrl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ENTITY_FILTER_FIELD_NUMBER = 4; + private com.google.datastore.admin.v1.EntityFilter entityFilter_; + + /** + * + * + *
+   * Optionally specify which kinds/namespaces are to be imported. If provided,
+   * the list must be a subset of the EntityFilter used in creating the export,
+   * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+   * specified then all entities from the export are imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return Whether the entityFilter field is set. + */ + @java.lang.Override + public boolean hasEntityFilter() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Optionally specify which kinds/namespaces are to be imported. If provided,
+   * the list must be a subset of the EntityFilter used in creating the export,
+   * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+   * specified then all entities from the export are imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return The entityFilter. + */ + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilter getEntityFilter() { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + + /** + * + * + *
+   * Optionally specify which kinds/namespaces are to be imported. If provided,
+   * the list must be a subset of the EntityFilter used in creating the export,
+   * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+   * specified then all entities from the export are imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + @java.lang.Override + public com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder() { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + + 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.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, projectId_); + } + com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( + output, internalGetLabels(), LabelsDefaultEntryHolder.defaultEntry, 2); + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(inputUrl_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, inputUrl_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(4, getEntityFilter()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, projectId_); + } + 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(2, labels__); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(inputUrl_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, inputUrl_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getEntityFilter()); + } + 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.datastore.admin.v1.ImportEntitiesRequest)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.ImportEntitiesRequest other = + (com.google.datastore.admin.v1.ImportEntitiesRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!internalGetLabels().equals(other.internalGetLabels())) return false; + if (!getInputUrl().equals(other.getInputUrl())) return false; + if (hasEntityFilter() != other.hasEntityFilter()) return false; + if (hasEntityFilter()) { + if (!getEntityFilter().equals(other.getEntityFilter())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + if (!internalGetLabels().getMap().isEmpty()) { + hash = (37 * hash) + LABELS_FIELD_NUMBER; + hash = (53 * hash) + internalGetLabels().hashCode(); + } + hash = (37 * hash) + INPUT_URL_FIELD_NUMBER; + hash = (53 * hash) + getInputUrl().hashCode(); + if (hasEntityFilter()) { + hash = (37 * hash) + ENTITY_FILTER_FIELD_NUMBER; + hash = (53 * hash) + getEntityFilter().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest 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.datastore.admin.v1.ImportEntitiesRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.ImportEntitiesRequest 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [google.datastore.admin.v1.DatastoreAdmin.ImportEntities][google.datastore.admin.v1.DatastoreAdmin.ImportEntities].
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ImportEntitiesRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.ImportEntitiesRequest) + com.google.datastore.admin.v1.ImportEntitiesRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesRequest_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetMutableLabels(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ImportEntitiesRequest.class, + com.google.datastore.admin.v1.ImportEntitiesRequest.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.ImportEntitiesRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getEntityFilterFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + internalGetMutableLabels().clear(); + inputUrl_ = ""; + entityFilter_ = null; + if (entityFilterBuilder_ != null) { + entityFilterBuilder_.dispose(); + entityFilterBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ImportEntitiesRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ImportEntitiesRequest getDefaultInstanceForType() { + return com.google.datastore.admin.v1.ImportEntitiesRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.ImportEntitiesRequest build() { + com.google.datastore.admin.v1.ImportEntitiesRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ImportEntitiesRequest buildPartial() { + com.google.datastore.admin.v1.ImportEntitiesRequest result = + new com.google.datastore.admin.v1.ImportEntitiesRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.ImportEntitiesRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.labels_ = internalGetLabels(); + result.labels_.makeImmutable(); + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.inputUrl_ = inputUrl_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.entityFilter_ = + entityFilterBuilder_ == null ? entityFilter_ : entityFilterBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.ImportEntitiesRequest) { + return mergeFrom((com.google.datastore.admin.v1.ImportEntitiesRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.ImportEntitiesRequest other) { + if (other == com.google.datastore.admin.v1.ImportEntitiesRequest.getDefaultInstance()) + return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + internalGetMutableLabels().mergeFrom(other.internalGetLabels()); + bitField0_ |= 0x00000002; + if (!other.getInputUrl().isEmpty()) { + inputUrl_ = other.inputUrl_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (other.hasEntityFilter()) { + mergeEntityFilter(other.getEntityFilter()); + } + 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: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.protobuf.MapEntry labels__ = + input.readMessage( + LabelsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableLabels() + .getMutableMap() + .put(labels__.getKey(), labels__.getValue()); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + inputUrl_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + input.readMessage(getEntityFilterFieldBuilder().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 projectId_ = ""; + + /** + * + * + *
+     * Required. Project ID against which to make the request.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. Project ID against which to make the request.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. Project ID against which to make the request.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Project ID against which to make the request.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. Project ID against which to make the request.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + 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_ |= 0x00000002; + onChanged(); + return labels_; + } + + public int getLabelsCount() { + return internalGetLabels().getMap().size(); + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + @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(); + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + @java.lang.Override + public java.util.Map getLabelsMap() { + return internalGetLabels().getMap(); + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + @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; + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + @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_ & ~0x00000002); + internalGetMutableLabels().getMutableMap().clear(); + return this; + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + 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_ |= 0x00000002; + return internalGetMutableLabels().getMutableMap(); + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + 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_ |= 0x00000002; + return this; + } + + /** + * + * + *
+     * Client-assigned labels.
+     * 
+ * + * map<string, string> labels = 2; + */ + public Builder putAllLabels(java.util.Map values) { + internalGetMutableLabels().getMutableMap().putAll(values); + bitField0_ |= 0x00000002; + return this; + } + + private java.lang.Object inputUrl_ = ""; + + /** + * + * + *
+     * Required. The full resource URL of the external storage location.
+     * Currently, only Google Cloud Storage is supported. So input_url should be
+     * of the form:
+     * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
+     * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
+     * an optional Cloud Storage namespace path (this is not a Cloud Datastore
+     * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
+     * by the ExportEntities operation. For more information about Cloud Storage
+     * namespace paths, see
+     * [Object name
+     * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+     *
+     * For more information, see
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+     * 
+ * + * string input_url = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The inputUrl. + */ + public java.lang.String getInputUrl() { + java.lang.Object ref = inputUrl_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + inputUrl_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The full resource URL of the external storage location.
+     * Currently, only Google Cloud Storage is supported. So input_url should be
+     * of the form:
+     * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
+     * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
+     * an optional Cloud Storage namespace path (this is not a Cloud Datastore
+     * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
+     * by the ExportEntities operation. For more information about Cloud Storage
+     * namespace paths, see
+     * [Object name
+     * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+     *
+     * For more information, see
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+     * 
+ * + * string input_url = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for inputUrl. + */ + public com.google.protobuf.ByteString getInputUrlBytes() { + java.lang.Object ref = inputUrl_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + inputUrl_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The full resource URL of the external storage location.
+     * Currently, only Google Cloud Storage is supported. So input_url should be
+     * of the form:
+     * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
+     * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
+     * an optional Cloud Storage namespace path (this is not a Cloud Datastore
+     * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
+     * by the ExportEntities operation. For more information about Cloud Storage
+     * namespace paths, see
+     * [Object name
+     * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+     *
+     * For more information, see
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+     * 
+ * + * string input_url = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The inputUrl to set. + * @return This builder for chaining. + */ + public Builder setInputUrl(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + inputUrl_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The full resource URL of the external storage location.
+     * Currently, only Google Cloud Storage is supported. So input_url should be
+     * of the form:
+     * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
+     * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
+     * an optional Cloud Storage namespace path (this is not a Cloud Datastore
+     * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
+     * by the ExportEntities operation. For more information about Cloud Storage
+     * namespace paths, see
+     * [Object name
+     * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+     *
+     * For more information, see
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+     * 
+ * + * string input_url = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearInputUrl() { + inputUrl_ = getDefaultInstance().getInputUrl(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The full resource URL of the external storage location.
+     * Currently, only Google Cloud Storage is supported. So input_url should be
+     * of the form:
+     * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
+     * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
+     * an optional Cloud Storage namespace path (this is not a Cloud Datastore
+     * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
+     * by the ExportEntities operation. For more information about Cloud Storage
+     * namespace paths, see
+     * [Object name
+     * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+     *
+     * For more information, see
+     * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+     * 
+ * + * string input_url = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for inputUrl to set. + * @return This builder for chaining. + */ + public Builder setInputUrlBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + inputUrl_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private com.google.datastore.admin.v1.EntityFilter entityFilter_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder> + entityFilterBuilder_; + + /** + * + * + *
+     * Optionally specify which kinds/namespaces are to be imported. If provided,
+     * the list must be a subset of the EntityFilter used in creating the export,
+     * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+     * specified then all entities from the export are imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return Whether the entityFilter field is set. + */ + public boolean hasEntityFilter() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Optionally specify which kinds/namespaces are to be imported. If provided,
+     * the list must be a subset of the EntityFilter used in creating the export,
+     * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+     * specified then all entities from the export are imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return The entityFilter. + */ + public com.google.datastore.admin.v1.EntityFilter getEntityFilter() { + if (entityFilterBuilder_ == null) { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } else { + return entityFilterBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Optionally specify which kinds/namespaces are to be imported. If provided,
+     * the list must be a subset of the EntityFilter used in creating the export,
+     * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+     * specified then all entities from the export are imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder setEntityFilter(com.google.datastore.admin.v1.EntityFilter value) { + if (entityFilterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + entityFilter_ = value; + } else { + entityFilterBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optionally specify which kinds/namespaces are to be imported. If provided,
+     * the list must be a subset of the EntityFilter used in creating the export,
+     * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+     * specified then all entities from the export are imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder setEntityFilter( + com.google.datastore.admin.v1.EntityFilter.Builder builderForValue) { + if (entityFilterBuilder_ == null) { + entityFilter_ = builderForValue.build(); + } else { + entityFilterBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optionally specify which kinds/namespaces are to be imported. If provided,
+     * the list must be a subset of the EntityFilter used in creating the export,
+     * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+     * specified then all entities from the export are imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder mergeEntityFilter(com.google.datastore.admin.v1.EntityFilter value) { + if (entityFilterBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && entityFilter_ != null + && entityFilter_ != com.google.datastore.admin.v1.EntityFilter.getDefaultInstance()) { + getEntityFilterBuilder().mergeFrom(value); + } else { + entityFilter_ = value; + } + } else { + entityFilterBuilder_.mergeFrom(value); + } + if (entityFilter_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Optionally specify which kinds/namespaces are to be imported. If provided,
+     * the list must be a subset of the EntityFilter used in creating the export,
+     * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+     * specified then all entities from the export are imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public Builder clearEntityFilter() { + bitField0_ = (bitField0_ & ~0x00000008); + entityFilter_ = null; + if (entityFilterBuilder_ != null) { + entityFilterBuilder_.dispose(); + entityFilterBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Optionally specify which kinds/namespaces are to be imported. If provided,
+     * the list must be a subset of the EntityFilter used in creating the export,
+     * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+     * specified then all entities from the export are imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public com.google.datastore.admin.v1.EntityFilter.Builder getEntityFilterBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getEntityFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optionally specify which kinds/namespaces are to be imported. If provided,
+     * the list must be a subset of the EntityFilter used in creating the export,
+     * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+     * specified then all entities from the export are imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + public com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder() { + if (entityFilterBuilder_ != null) { + return entityFilterBuilder_.getMessageOrBuilder(); + } else { + return entityFilter_ == null + ? com.google.datastore.admin.v1.EntityFilter.getDefaultInstance() + : entityFilter_; + } + } + + /** + * + * + *
+     * Optionally specify which kinds/namespaces are to be imported. If provided,
+     * the list must be a subset of the EntityFilter used in creating the export,
+     * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+     * specified then all entities from the export are imported.
+     * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder> + getEntityFilterFieldBuilder() { + if (entityFilterBuilder_ == null) { + entityFilterBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.EntityFilter, + com.google.datastore.admin.v1.EntityFilter.Builder, + com.google.datastore.admin.v1.EntityFilterOrBuilder>( + getEntityFilter(), getParentForChildren(), isClean()); + entityFilter_ = null; + } + return entityFilterBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.ImportEntitiesRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.ImportEntitiesRequest) + private static final com.google.datastore.admin.v1.ImportEntitiesRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.ImportEntitiesRequest(); + } + + public static com.google.datastore.admin.v1.ImportEntitiesRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ImportEntitiesRequest 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.datastore.admin.v1.ImportEntitiesRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequestOrBuilder.java new file mode 100644 index 000000000000..e6468c5f3927 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ImportEntitiesRequestOrBuilder.java @@ -0,0 +1,213 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface ImportEntitiesRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.ImportEntitiesRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Project ID against which to make the request.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Required. Project ID against which to make the request.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + int getLabelsCount(); + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + boolean containsLabels(java.lang.String key); + + /** Use {@link #getLabelsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getLabels(); + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + java.util.Map getLabelsMap(); + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + /* nullable */ + java.lang.String getLabelsOrDefault( + java.lang.String key, + /* nullable */ + java.lang.String defaultValue); + + /** + * + * + *
+   * Client-assigned labels.
+   * 
+ * + * map<string, string> labels = 2; + */ + java.lang.String getLabelsOrThrow(java.lang.String key); + + /** + * + * + *
+   * Required. The full resource URL of the external storage location.
+   * Currently, only Google Cloud Storage is supported. So input_url should be
+   * of the form:
+   * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
+   * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
+   * an optional Cloud Storage namespace path (this is not a Cloud Datastore
+   * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
+   * by the ExportEntities operation. For more information about Cloud Storage
+   * namespace paths, see
+   * [Object name
+   * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+   *
+   * For more information, see
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+   * 
+ * + * string input_url = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The inputUrl. + */ + java.lang.String getInputUrl(); + + /** + * + * + *
+   * Required. The full resource URL of the external storage location.
+   * Currently, only Google Cloud Storage is supported. So input_url should be
+   * of the form:
+   * `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where
+   * `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is
+   * an optional Cloud Storage namespace path (this is not a Cloud Datastore
+   * namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written
+   * by the ExportEntities operation. For more information about Cloud Storage
+   * namespace paths, see
+   * [Object name
+   * considerations](https://cloud.google.com/storage/docs/naming#object-considerations).
+   *
+   * For more information, see
+   * [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url].
+   * 
+ * + * string input_url = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for inputUrl. + */ + com.google.protobuf.ByteString getInputUrlBytes(); + + /** + * + * + *
+   * Optionally specify which kinds/namespaces are to be imported. If provided,
+   * the list must be a subset of the EntityFilter used in creating the export,
+   * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+   * specified then all entities from the export are imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return Whether the entityFilter field is set. + */ + boolean hasEntityFilter(); + + /** + * + * + *
+   * Optionally specify which kinds/namespaces are to be imported. If provided,
+   * the list must be a subset of the EntityFilter used in creating the export,
+   * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+   * specified then all entities from the export are imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + * + * @return The entityFilter. + */ + com.google.datastore.admin.v1.EntityFilter getEntityFilter(); + + /** + * + * + *
+   * Optionally specify which kinds/namespaces are to be imported. If provided,
+   * the list must be a subset of the EntityFilter used in creating the export,
+   * otherwise a FAILED_PRECONDITION error will be returned. If no filter is
+   * specified then all entities from the export are imported.
+   * 
+ * + * .google.datastore.admin.v1.EntityFilter entity_filter = 4; + */ + com.google.datastore.admin.v1.EntityFilterOrBuilder getEntityFilterOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Index.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Index.java new file mode 100644 index 000000000000..58f4885b37c4 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Index.java @@ -0,0 +1,3437 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/index.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * Datastore composite index definition.
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.Index} + */ +public final class Index extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.Index) + IndexOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Index.newBuilder() to construct. + private Index(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Index() { + projectId_ = ""; + indexId_ = ""; + kind_ = ""; + ancestor_ = 0; + properties_ = java.util.Collections.emptyList(); + state_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Index(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.IndexProto + .internal_static_google_datastore_admin_v1_Index_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.IndexProto + .internal_static_google_datastore_admin_v1_Index_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.Index.class, + com.google.datastore.admin.v1.Index.Builder.class); + } + + /** + * + * + *
+   * For an ordered index, specifies whether each of the entity's ancestors
+   * will be included.
+   * 
+ * + * Protobuf enum {@code google.datastore.admin.v1.Index.AncestorMode} + */ + public enum AncestorMode implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * The ancestor mode is unspecified.
+     * 
+ * + * ANCESTOR_MODE_UNSPECIFIED = 0; + */ + ANCESTOR_MODE_UNSPECIFIED(0), + /** + * + * + *
+     * Do not include the entity's ancestors in the index.
+     * 
+ * + * NONE = 1; + */ + NONE(1), + /** + * + * + *
+     * Include all the entity's ancestors in the index.
+     * 
+ * + * ALL_ANCESTORS = 2; + */ + ALL_ANCESTORS(2), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * The ancestor mode is unspecified.
+     * 
+ * + * ANCESTOR_MODE_UNSPECIFIED = 0; + */ + public static final int ANCESTOR_MODE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Do not include the entity's ancestors in the index.
+     * 
+ * + * NONE = 1; + */ + public static final int NONE_VALUE = 1; + + /** + * + * + *
+     * Include all the entity's ancestors in the index.
+     * 
+ * + * ALL_ANCESTORS = 2; + */ + public static final int ALL_ANCESTORS_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 AncestorMode 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 AncestorMode forNumber(int value) { + switch (value) { + case 0: + return ANCESTOR_MODE_UNSPECIFIED; + case 1: + return NONE; + case 2: + return ALL_ANCESTORS; + 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 AncestorMode findValueByNumber(int number) { + return AncestorMode.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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.admin.v1.Index.getDescriptor().getEnumTypes().get(0); + } + + private static final AncestorMode[] VALUES = values(); + + public static AncestorMode 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 AncestorMode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.admin.v1.Index.AncestorMode) + } + + /** + * + * + *
+   * The direction determines how a property is indexed.
+   * 
+ * + * Protobuf enum {@code google.datastore.admin.v1.Index.Direction} + */ + public enum Direction implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * The direction is unspecified.
+     * 
+ * + * DIRECTION_UNSPECIFIED = 0; + */ + DIRECTION_UNSPECIFIED(0), + /** + * + * + *
+     * The property's values are indexed so as to support sequencing in
+     * ascending order and also query by <, >, <=, >=, and =.
+     * 
+ * + * ASCENDING = 1; + */ + ASCENDING(1), + /** + * + * + *
+     * The property's values are indexed so as to support sequencing in
+     * descending order and also query by <, >, <=, >=, and =.
+     * 
+ * + * DESCENDING = 2; + */ + DESCENDING(2), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * The direction is unspecified.
+     * 
+ * + * DIRECTION_UNSPECIFIED = 0; + */ + public static final int DIRECTION_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * The property's values are indexed so as to support sequencing in
+     * ascending order and also query by <, >, <=, >=, and =.
+     * 
+ * + * ASCENDING = 1; + */ + public static final int ASCENDING_VALUE = 1; + + /** + * + * + *
+     * The property's values are indexed so as to support sequencing in
+     * descending order and also query by <, >, <=, >=, and =.
+     * 
+ * + * 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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.admin.v1.Index.getDescriptor().getEnumTypes().get(1); + } + + 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.datastore.admin.v1.Index.Direction) + } + + /** + * + * + *
+   * The possible set of states of an index.
+   * 
+ * + * Protobuf enum {@code google.datastore.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, and cannot be used by queries.
+     * There is an active long-running operation for the index.
+     * The index is updated when writing an entity.
+     * Some index data may exist.
+     * 
+ * + * CREATING = 1; + */ + CREATING(1), + /** + * + * + *
+     * The index is ready to be used.
+     * The index is updated when writing an entity.
+     * The index is fully populated from all stored entities it applies to.
+     * 
+ * + * READY = 2; + */ + READY(2), + /** + * + * + *
+     * The index is being deleted, and cannot be used by queries.
+     * There is an active long-running operation for the index.
+     * The index is not updated when writing an entity.
+     * Some index data may exist.
+     * 
+ * + * DELETING = 3; + */ + DELETING(3), + /** + * + * + *
+     * The index was being created or deleted, but something went wrong.
+     * The index cannot by used by queries.
+     * 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 an entity.
+     * Some index data may exist.
+     * 
+ * + * ERROR = 4; + */ + ERROR(4), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * The state is unspecified.
+     * 
+ * + * STATE_UNSPECIFIED = 0; + */ + public static final int STATE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * The index is being created, and cannot be used by queries.
+     * There is an active long-running operation for the index.
+     * The index is updated when writing an entity.
+     * 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 an entity.
+     * The index is fully populated from all stored entities it applies to.
+     * 
+ * + * READY = 2; + */ + public static final int READY_VALUE = 2; + + /** + * + * + *
+     * The index is being deleted, and cannot be used by queries.
+     * There is an active long-running operation for the index.
+     * The index is not updated when writing an entity.
+     * Some index data may exist.
+     * 
+ * + * DELETING = 3; + */ + public static final int DELETING_VALUE = 3; + + /** + * + * + *
+     * The index was being created or deleted, but something went wrong.
+     * The index cannot by used by queries.
+     * 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 an entity.
+     * Some index data may exist.
+     * 
+ * + * ERROR = 4; + */ + public static final int ERROR_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 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 DELETING; + case 4: + return ERROR; + 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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.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.datastore.admin.v1.Index.State) + } + + public interface IndexedPropertyOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.Index.IndexedProperty) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Required. The property name to index.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+     * Required. The property name to index.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+     * Required. The indexed property's direction.  Must not be
+     * DIRECTION_UNSPECIFIED.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.Direction direction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for direction. + */ + int getDirectionValue(); + + /** + * + * + *
+     * Required. The indexed property's direction.  Must not be
+     * DIRECTION_UNSPECIFIED.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.Direction direction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The direction. + */ + com.google.datastore.admin.v1.Index.Direction getDirection(); + } + + /** + * + * + *
+   * A property of an index.
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.Index.IndexedProperty} + */ + public static final class IndexedProperty extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.Index.IndexedProperty) + IndexedPropertyOrBuilder { + private static final long serialVersionUID = 0L; + + // Use IndexedProperty.newBuilder() to construct. + private IndexedProperty(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private IndexedProperty() { + name_ = ""; + direction_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new IndexedProperty(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.IndexProto + .internal_static_google_datastore_admin_v1_Index_IndexedProperty_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.IndexProto + .internal_static_google_datastore_admin_v1_Index_IndexedProperty_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.Index.IndexedProperty.class, + com.google.datastore.admin.v1.Index.IndexedProperty.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+     * Required. The property name to index.
+     * 
+ * + * 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 property name to index.
+     * 
+ * + * 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 DIRECTION_FIELD_NUMBER = 2; + private int direction_ = 0; + + /** + * + * + *
+     * Required. The indexed property's direction.  Must not be
+     * DIRECTION_UNSPECIFIED.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.Direction direction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for direction. + */ + @java.lang.Override + public int getDirectionValue() { + return direction_; + } + + /** + * + * + *
+     * Required. The indexed property's direction.  Must not be
+     * DIRECTION_UNSPECIFIED.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.Direction direction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The direction. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Index.Direction getDirection() { + com.google.datastore.admin.v1.Index.Direction result = + com.google.datastore.admin.v1.Index.Direction.forNumber(direction_); + return result == null ? com.google.datastore.admin.v1.Index.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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (direction_ + != com.google.datastore.admin.v1.Index.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 (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, name_); + } + if (direction_ + != com.google.datastore.admin.v1.Index.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.datastore.admin.v1.Index.IndexedProperty)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.Index.IndexedProperty other = + (com.google.datastore.admin.v1.Index.IndexedProperty) obj; + + if (!getName().equals(other.getName())) 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(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (37 * hash) + DIRECTION_FIELD_NUMBER; + hash = (53 * hash) + direction_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty 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.datastore.admin.v1.Index.IndexedProperty parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.Index.IndexedProperty 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A property of an index.
+     * 
+ * + * Protobuf type {@code google.datastore.admin.v1.Index.IndexedProperty} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.Index.IndexedProperty) + com.google.datastore.admin.v1.Index.IndexedPropertyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.IndexProto + .internal_static_google_datastore_admin_v1_Index_IndexedProperty_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.IndexProto + .internal_static_google_datastore_admin_v1_Index_IndexedProperty_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.Index.IndexedProperty.class, + com.google.datastore.admin.v1.Index.IndexedProperty.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.Index.IndexedProperty.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + direction_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.IndexProto + .internal_static_google_datastore_admin_v1_Index_IndexedProperty_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.Index.IndexedProperty getDefaultInstanceForType() { + return com.google.datastore.admin.v1.Index.IndexedProperty.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.Index.IndexedProperty build() { + com.google.datastore.admin.v1.Index.IndexedProperty result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.Index.IndexedProperty buildPartial() { + com.google.datastore.admin.v1.Index.IndexedProperty result = + new com.google.datastore.admin.v1.Index.IndexedProperty(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.Index.IndexedProperty result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.direction_ = direction_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.Index.IndexedProperty) { + return mergeFrom((com.google.datastore.admin.v1.Index.IndexedProperty) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.Index.IndexedProperty other) { + if (other == com.google.datastore.admin.v1.Index.IndexedProperty.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + 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: + { + name_ = input.readStringRequireUtf8(); + 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 java.lang.Object name_ = ""; + + /** + * + * + *
+       * Required. The property name to index.
+       * 
+ * + * 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 property name to index.
+       * 
+ * + * 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 property name to index.
+       * 
+ * + * 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 property name to index.
+       * 
+ * + * 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 property name to index.
+       * 
+ * + * 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 int direction_ = 0; + + /** + * + * + *
+       * Required. The indexed property's direction.  Must not be
+       * DIRECTION_UNSPECIFIED.
+       * 
+ * + * + * .google.datastore.admin.v1.Index.Direction direction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for direction. + */ + @java.lang.Override + public int getDirectionValue() { + return direction_; + } + + /** + * + * + *
+       * Required. The indexed property's direction.  Must not be
+       * DIRECTION_UNSPECIFIED.
+       * 
+ * + * + * .google.datastore.admin.v1.Index.Direction direction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @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; + } + + /** + * + * + *
+       * Required. The indexed property's direction.  Must not be
+       * DIRECTION_UNSPECIFIED.
+       * 
+ * + * + * .google.datastore.admin.v1.Index.Direction direction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The direction. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Index.Direction getDirection() { + com.google.datastore.admin.v1.Index.Direction result = + com.google.datastore.admin.v1.Index.Direction.forNumber(direction_); + return result == null ? com.google.datastore.admin.v1.Index.Direction.UNRECOGNIZED : result; + } + + /** + * + * + *
+       * Required. The indexed property's direction.  Must not be
+       * DIRECTION_UNSPECIFIED.
+       * 
+ * + * + * .google.datastore.admin.v1.Index.Direction direction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The direction to set. + * @return This builder for chaining. + */ + public Builder setDirection(com.google.datastore.admin.v1.Index.Direction value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + direction_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * Required. The indexed property's direction.  Must not be
+       * DIRECTION_UNSPECIFIED.
+       * 
+ * + * + * .google.datastore.admin.v1.Index.Direction direction = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return This builder for chaining. + */ + public Builder clearDirection() { + bitField0_ = (bitField0_ & ~0x00000002); + direction_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.Index.IndexedProperty) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.Index.IndexedProperty) + private static final com.google.datastore.admin.v1.Index.IndexedProperty DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.Index.IndexedProperty(); + } + + public static com.google.datastore.admin.v1.Index.IndexedProperty getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public IndexedProperty 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.datastore.admin.v1.Index.IndexedProperty getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public static final int PROJECT_ID_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Output only. Project ID.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. Project ID.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int INDEX_ID_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object indexId_ = ""; + + /** + * + * + *
+   * Output only. The resource ID of the index.
+   * 
+ * + * string index_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The indexId. + */ + @java.lang.Override + public java.lang.String getIndexId() { + java.lang.Object ref = indexId_; + 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(); + indexId_ = s; + return s; + } + } + + /** + * + * + *
+   * Output only. The resource ID of the index.
+   * 
+ * + * string index_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for indexId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getIndexIdBytes() { + java.lang.Object ref = indexId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + indexId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int KIND_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object kind_ = ""; + + /** + * + * + *
+   * Required. The entity kind to which this index applies.
+   * 
+ * + * string kind = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The kind. + */ + @java.lang.Override + public java.lang.String getKind() { + java.lang.Object ref = kind_; + 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(); + kind_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The entity kind to which this index applies.
+   * 
+ * + * string kind = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for kind. + */ + @java.lang.Override + public com.google.protobuf.ByteString getKindBytes() { + java.lang.Object ref = kind_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + kind_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ANCESTOR_FIELD_NUMBER = 5; + private int ancestor_ = 0; + + /** + * + * + *
+   * Required. The index's ancestor mode.  Must not be
+   * ANCESTOR_MODE_UNSPECIFIED.
+   * 
+ * + * + * .google.datastore.admin.v1.Index.AncestorMode ancestor = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for ancestor. + */ + @java.lang.Override + public int getAncestorValue() { + return ancestor_; + } + + /** + * + * + *
+   * Required. The index's ancestor mode.  Must not be
+   * ANCESTOR_MODE_UNSPECIFIED.
+   * 
+ * + * + * .google.datastore.admin.v1.Index.AncestorMode ancestor = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The ancestor. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Index.AncestorMode getAncestor() { + com.google.datastore.admin.v1.Index.AncestorMode result = + com.google.datastore.admin.v1.Index.AncestorMode.forNumber(ancestor_); + return result == null ? com.google.datastore.admin.v1.Index.AncestorMode.UNRECOGNIZED : result; + } + + public static final int PROPERTIES_FIELD_NUMBER = 6; + + @SuppressWarnings("serial") + private java.util.List properties_; + + /** + * + * + *
+   * Required. An ordered sequence of property names and their index attributes.
+   *
+   * Requires:
+   *
+   * * A maximum of 100 properties.
+   * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public java.util.List getPropertiesList() { + return properties_; + } + + /** + * + * + *
+   * Required. An ordered sequence of property names and their index attributes.
+   *
+   * Requires:
+   *
+   * * A maximum of 100 properties.
+   * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public java.util.List + getPropertiesOrBuilderList() { + return properties_; + } + + /** + * + * + *
+   * Required. An ordered sequence of property names and their index attributes.
+   *
+   * Requires:
+   *
+   * * A maximum of 100 properties.
+   * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public int getPropertiesCount() { + return properties_.size(); + } + + /** + * + * + *
+   * Required. An ordered sequence of property names and their index attributes.
+   *
+   * Requires:
+   *
+   * * A maximum of 100 properties.
+   * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.admin.v1.Index.IndexedProperty getProperties(int index) { + return properties_.get(index); + } + + /** + * + * + *
+   * Required. An ordered sequence of property names and their index attributes.
+   *
+   * Requires:
+   *
+   * * A maximum of 100 properties.
+   * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.admin.v1.Index.IndexedPropertyOrBuilder getPropertiesOrBuilder( + int index) { + return properties_.get(index); + } + + public static final int STATE_FIELD_NUMBER = 7; + private int state_ = 0; + + /** + * + * + *
+   * Output only. The state of the index.
+   * 
+ * + * + * .google.datastore.admin.v1.Index.State state = 7 [(.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 index.
+   * 
+ * + * + * .google.datastore.admin.v1.Index.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Index.State getState() { + com.google.datastore.admin.v1.Index.State result = + com.google.datastore.admin.v1.Index.State.forNumber(state_); + return result == null ? com.google.datastore.admin.v1.Index.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.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(indexId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, indexId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(kind_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, kind_); + } + if (ancestor_ + != com.google.datastore.admin.v1.Index.AncestorMode.ANCESTOR_MODE_UNSPECIFIED.getNumber()) { + output.writeEnum(5, ancestor_); + } + for (int i = 0; i < properties_.size(); i++) { + output.writeMessage(6, properties_.get(i)); + } + if (state_ != com.google.datastore.admin.v1.Index.State.STATE_UNSPECIFIED.getNumber()) { + output.writeEnum(7, state_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(indexId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, indexId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(kind_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, kind_); + } + if (ancestor_ + != com.google.datastore.admin.v1.Index.AncestorMode.ANCESTOR_MODE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(5, ancestor_); + } + for (int i = 0; i < properties_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, properties_.get(i)); + } + if (state_ != com.google.datastore.admin.v1.Index.State.STATE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(7, 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.datastore.admin.v1.Index)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.Index other = (com.google.datastore.admin.v1.Index) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getIndexId().equals(other.getIndexId())) return false; + if (!getKind().equals(other.getKind())) return false; + if (ancestor_ != other.ancestor_) return false; + if (!getPropertiesList().equals(other.getPropertiesList())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + INDEX_ID_FIELD_NUMBER; + hash = (53 * hash) + getIndexId().hashCode(); + hash = (37 * hash) + KIND_FIELD_NUMBER; + hash = (53 * hash) + getKind().hashCode(); + hash = (37 * hash) + ANCESTOR_FIELD_NUMBER; + hash = (53 * hash) + ancestor_; + if (getPropertiesCount() > 0) { + hash = (37 * hash) + PROPERTIES_FIELD_NUMBER; + hash = (53 * hash) + getPropertiesList().hashCode(); + } + hash = (37 * hash) + STATE_FIELD_NUMBER; + hash = (53 * hash) + state_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.Index parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.Index parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.Index parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.Index parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.Index parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.Index parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.Index parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.Index parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.Index parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Datastore composite index definition.
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.Index} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.Index) + com.google.datastore.admin.v1.IndexOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.IndexProto + .internal_static_google_datastore_admin_v1_Index_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.IndexProto + .internal_static_google_datastore_admin_v1_Index_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.Index.class, + com.google.datastore.admin.v1.Index.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.Index.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + indexId_ = ""; + kind_ = ""; + ancestor_ = 0; + if (propertiesBuilder_ == null) { + properties_ = java.util.Collections.emptyList(); + } else { + properties_ = null; + propertiesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000010); + state_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.IndexProto + .internal_static_google_datastore_admin_v1_Index_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.Index getDefaultInstanceForType() { + return com.google.datastore.admin.v1.Index.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.Index build() { + com.google.datastore.admin.v1.Index result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.Index buildPartial() { + com.google.datastore.admin.v1.Index result = new com.google.datastore.admin.v1.Index(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.admin.v1.Index result) { + if (propertiesBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0)) { + properties_ = java.util.Collections.unmodifiableList(properties_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.properties_ = properties_; + } else { + result.properties_ = propertiesBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.admin.v1.Index result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.indexId_ = indexId_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.kind_ = kind_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.ancestor_ = ancestor_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.state_ = state_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.Index) { + return mergeFrom((com.google.datastore.admin.v1.Index) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.Index other) { + if (other == com.google.datastore.admin.v1.Index.getDefaultInstance()) return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getIndexId().isEmpty()) { + indexId_ = other.indexId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (!other.getKind().isEmpty()) { + kind_ = other.kind_; + bitField0_ |= 0x00000004; + onChanged(); + } + if (other.ancestor_ != 0) { + setAncestorValue(other.getAncestorValue()); + } + if (propertiesBuilder_ == null) { + if (!other.properties_.isEmpty()) { + if (properties_.isEmpty()) { + properties_ = other.properties_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensurePropertiesIsMutable(); + properties_.addAll(other.properties_); + } + onChanged(); + } + } else { + if (!other.properties_.isEmpty()) { + if (propertiesBuilder_.isEmpty()) { + propertiesBuilder_.dispose(); + propertiesBuilder_ = null; + properties_ = other.properties_; + bitField0_ = (bitField0_ & ~0x00000010); + propertiesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getPropertiesFieldBuilder() + : null; + } else { + propertiesBuilder_.addAllMessages(other.properties_); + } + } + } + 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: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + indexId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 34: + { + kind_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000004; + break; + } // case 34 + case 40: + { + ancestor_ = input.readEnum(); + bitField0_ |= 0x00000008; + break; + } // case 40 + case 50: + { + com.google.datastore.admin.v1.Index.IndexedProperty m = + input.readMessage( + com.google.datastore.admin.v1.Index.IndexedProperty.parser(), + extensionRegistry); + if (propertiesBuilder_ == null) { + ensurePropertiesIsMutable(); + properties_.add(m); + } else { + propertiesBuilder_.addMessage(m); + } + break; + } // case 50 + case 56: + { + state_ = input.readEnum(); + bitField0_ |= 0x00000020; + break; + } // case 56 + 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 projectId_ = ""; + + /** + * + * + *
+     * Output only. Project ID.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. Project ID.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. Project ID.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Project ID.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. Project ID.
+     * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object indexId_ = ""; + + /** + * + * + *
+     * Output only. The resource ID of the index.
+     * 
+ * + * string index_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The indexId. + */ + public java.lang.String getIndexId() { + java.lang.Object ref = indexId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + indexId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Output only. The resource ID of the index.
+     * 
+ * + * string index_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for indexId. + */ + public com.google.protobuf.ByteString getIndexIdBytes() { + java.lang.Object ref = indexId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + indexId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Output only. The resource ID of the index.
+     * 
+ * + * string index_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The indexId to set. + * @return This builder for chaining. + */ + public Builder setIndexId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + indexId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The resource ID of the index.
+     * 
+ * + * string index_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearIndexId() { + indexId_ = getDefaultInstance().getIndexId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The resource ID of the index.
+     * 
+ * + * string index_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for indexId to set. + * @return This builder for chaining. + */ + public Builder setIndexIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + indexId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private java.lang.Object kind_ = ""; + + /** + * + * + *
+     * Required. The entity kind to which this index applies.
+     * 
+ * + * string kind = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The kind. + */ + public java.lang.String getKind() { + java.lang.Object ref = kind_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + kind_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The entity kind to which this index applies.
+     * 
+ * + * string kind = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for kind. + */ + public com.google.protobuf.ByteString getKindBytes() { + java.lang.Object ref = kind_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + kind_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The entity kind to which this index applies.
+     * 
+ * + * string kind = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The kind to set. + * @return This builder for chaining. + */ + public Builder setKind(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + kind_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The entity kind to which this index applies.
+     * 
+ * + * string kind = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearKind() { + kind_ = getDefaultInstance().getKind(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The entity kind to which this index applies.
+     * 
+ * + * string kind = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for kind to set. + * @return This builder for chaining. + */ + public Builder setKindBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + kind_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + private int ancestor_ = 0; + + /** + * + * + *
+     * Required. The index's ancestor mode.  Must not be
+     * ANCESTOR_MODE_UNSPECIFIED.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.AncestorMode ancestor = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for ancestor. + */ + @java.lang.Override + public int getAncestorValue() { + return ancestor_; + } + + /** + * + * + *
+     * Required. The index's ancestor mode.  Must not be
+     * ANCESTOR_MODE_UNSPECIFIED.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.AncestorMode ancestor = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The enum numeric value on the wire for ancestor to set. + * @return This builder for chaining. + */ + public Builder setAncestorValue(int value) { + ancestor_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The index's ancestor mode.  Must not be
+     * ANCESTOR_MODE_UNSPECIFIED.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.AncestorMode ancestor = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The ancestor. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Index.AncestorMode getAncestor() { + com.google.datastore.admin.v1.Index.AncestorMode result = + com.google.datastore.admin.v1.Index.AncestorMode.forNumber(ancestor_); + return result == null + ? com.google.datastore.admin.v1.Index.AncestorMode.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * Required. The index's ancestor mode.  Must not be
+     * ANCESTOR_MODE_UNSPECIFIED.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.AncestorMode ancestor = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @param value The ancestor to set. + * @return This builder for chaining. + */ + public Builder setAncestor(com.google.datastore.admin.v1.Index.AncestorMode value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000008; + ancestor_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The index's ancestor mode.  Must not be
+     * ANCESTOR_MODE_UNSPECIFIED.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.AncestorMode ancestor = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return This builder for chaining. + */ + public Builder clearAncestor() { + bitField0_ = (bitField0_ & ~0x00000008); + ancestor_ = 0; + onChanged(); + return this; + } + + private java.util.List properties_ = + java.util.Collections.emptyList(); + + private void ensurePropertiesIsMutable() { + if (!((bitField0_ & 0x00000010) != 0)) { + properties_ = + new java.util.ArrayList( + properties_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.admin.v1.Index.IndexedProperty, + com.google.datastore.admin.v1.Index.IndexedProperty.Builder, + com.google.datastore.admin.v1.Index.IndexedPropertyOrBuilder> + propertiesBuilder_; + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getPropertiesList() { + if (propertiesBuilder_ == null) { + return java.util.Collections.unmodifiableList(properties_); + } else { + return propertiesBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public int getPropertiesCount() { + if (propertiesBuilder_ == null) { + return properties_.size(); + } else { + return propertiesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.admin.v1.Index.IndexedProperty getProperties(int index) { + if (propertiesBuilder_ == null) { + return properties_.get(index); + } else { + return propertiesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setProperties( + int index, com.google.datastore.admin.v1.Index.IndexedProperty value) { + if (propertiesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropertiesIsMutable(); + properties_.set(index, value); + onChanged(); + } else { + propertiesBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setProperties( + int index, com.google.datastore.admin.v1.Index.IndexedProperty.Builder builderForValue) { + if (propertiesBuilder_ == null) { + ensurePropertiesIsMutable(); + properties_.set(index, builderForValue.build()); + onChanged(); + } else { + propertiesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addProperties(com.google.datastore.admin.v1.Index.IndexedProperty value) { + if (propertiesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropertiesIsMutable(); + properties_.add(value); + onChanged(); + } else { + propertiesBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addProperties( + int index, com.google.datastore.admin.v1.Index.IndexedProperty value) { + if (propertiesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropertiesIsMutable(); + properties_.add(index, value); + onChanged(); + } else { + propertiesBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addProperties( + com.google.datastore.admin.v1.Index.IndexedProperty.Builder builderForValue) { + if (propertiesBuilder_ == null) { + ensurePropertiesIsMutable(); + properties_.add(builderForValue.build()); + onChanged(); + } else { + propertiesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addProperties( + int index, com.google.datastore.admin.v1.Index.IndexedProperty.Builder builderForValue) { + if (propertiesBuilder_ == null) { + ensurePropertiesIsMutable(); + properties_.add(index, builderForValue.build()); + onChanged(); + } else { + propertiesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addAllProperties( + java.lang.Iterable values) { + if (propertiesBuilder_ == null) { + ensurePropertiesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, properties_); + onChanged(); + } else { + propertiesBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearProperties() { + if (propertiesBuilder_ == null) { + properties_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + propertiesBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder removeProperties(int index) { + if (propertiesBuilder_ == null) { + ensurePropertiesIsMutable(); + properties_.remove(index); + onChanged(); + } else { + propertiesBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.admin.v1.Index.IndexedProperty.Builder getPropertiesBuilder( + int index) { + return getPropertiesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.admin.v1.Index.IndexedPropertyOrBuilder getPropertiesOrBuilder( + int index) { + if (propertiesBuilder_ == null) { + return properties_.get(index); + } else { + return propertiesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List + getPropertiesOrBuilderList() { + if (propertiesBuilder_ != null) { + return propertiesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(properties_); + } + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.admin.v1.Index.IndexedProperty.Builder addPropertiesBuilder() { + return getPropertiesFieldBuilder() + .addBuilder(com.google.datastore.admin.v1.Index.IndexedProperty.getDefaultInstance()); + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.admin.v1.Index.IndexedProperty.Builder addPropertiesBuilder( + int index) { + return getPropertiesFieldBuilder() + .addBuilder( + index, com.google.datastore.admin.v1.Index.IndexedProperty.getDefaultInstance()); + } + + /** + * + * + *
+     * Required. An ordered sequence of property names and their index attributes.
+     *
+     * Requires:
+     *
+     * * A maximum of 100 properties.
+     * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List + getPropertiesBuilderList() { + return getPropertiesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.admin.v1.Index.IndexedProperty, + com.google.datastore.admin.v1.Index.IndexedProperty.Builder, + com.google.datastore.admin.v1.Index.IndexedPropertyOrBuilder> + getPropertiesFieldBuilder() { + if (propertiesBuilder_ == null) { + propertiesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.admin.v1.Index.IndexedProperty, + com.google.datastore.admin.v1.Index.IndexedProperty.Builder, + com.google.datastore.admin.v1.Index.IndexedPropertyOrBuilder>( + properties_, ((bitField0_ & 0x00000010) != 0), getParentForChildren(), isClean()); + properties_ = null; + } + return propertiesBuilder_; + } + + private int state_ = 0; + + /** + * + * + *
+     * Output only. The state of the index.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.State state = 7 [(.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 index.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.State state = 7 [(.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_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The state of the index.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Index.State getState() { + com.google.datastore.admin.v1.Index.State result = + com.google.datastore.admin.v1.Index.State.forNumber(state_); + return result == null ? com.google.datastore.admin.v1.Index.State.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * Output only. The state of the index.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.datastore.admin.v1.Index.State value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + state_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Output only. The state of the index.
+     * 
+ * + * + * .google.datastore.admin.v1.Index.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000020); + state_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.Index) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.Index) + private static final com.google.datastore.admin.v1.Index DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.Index(); + } + + public static com.google.datastore.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.datastore.admin.v1.Index getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadata.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadata.java new file mode 100644 index 000000000000..5760532b9eba --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadata.java @@ -0,0 +1,1208 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * Metadata for Index operations.
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.IndexOperationMetadata} + */ +public final class IndexOperationMetadata extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.IndexOperationMetadata) + IndexOperationMetadataOrBuilder { + private static final long serialVersionUID = 0L; + + // Use IndexOperationMetadata.newBuilder() to construct. + private IndexOperationMetadata(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private IndexOperationMetadata() { + indexId_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new IndexOperationMetadata(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_IndexOperationMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_IndexOperationMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.IndexOperationMetadata.class, + com.google.datastore.admin.v1.IndexOperationMetadata.Builder.class); + } + + private int bitField0_; + public static final int COMMON_FIELD_NUMBER = 1; + private com.google.datastore.admin.v1.CommonMetadata common_; + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return Whether the common field is set. + */ + @java.lang.Override + public boolean hasCommon() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return The common. + */ + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadata getCommon() { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + @java.lang.Override + public com.google.datastore.admin.v1.CommonMetadataOrBuilder getCommonOrBuilder() { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } + + public static final int PROGRESS_ENTITIES_FIELD_NUMBER = 2; + private com.google.datastore.admin.v1.Progress progressEntities_; + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return Whether the progressEntities field is set. + */ + @java.lang.Override + public boolean hasProgressEntities() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return The progressEntities. + */ + @java.lang.Override + public com.google.datastore.admin.v1.Progress getProgressEntities() { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + @java.lang.Override + public com.google.datastore.admin.v1.ProgressOrBuilder getProgressEntitiesOrBuilder() { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } + + public static final int INDEX_ID_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object indexId_ = ""; + + /** + * + * + *
+   * The index resource ID that this operation is acting on.
+   * 
+ * + * string index_id = 3; + * + * @return The indexId. + */ + @java.lang.Override + public java.lang.String getIndexId() { + java.lang.Object ref = indexId_; + 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(); + indexId_ = s; + return s; + } + } + + /** + * + * + *
+   * The index resource ID that this operation is acting on.
+   * 
+ * + * string index_id = 3; + * + * @return The bytes for indexId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getIndexIdBytes() { + java.lang.Object ref = indexId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + indexId_ = 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 (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getCommon()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getProgressEntities()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(indexId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, indexId_); + } + 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, getCommon()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getProgressEntities()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(indexId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, indexId_); + } + 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.datastore.admin.v1.IndexOperationMetadata)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.IndexOperationMetadata other = + (com.google.datastore.admin.v1.IndexOperationMetadata) obj; + + if (hasCommon() != other.hasCommon()) return false; + if (hasCommon()) { + if (!getCommon().equals(other.getCommon())) return false; + } + if (hasProgressEntities() != other.hasProgressEntities()) return false; + if (hasProgressEntities()) { + if (!getProgressEntities().equals(other.getProgressEntities())) return false; + } + if (!getIndexId().equals(other.getIndexId())) 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 (hasCommon()) { + hash = (37 * hash) + COMMON_FIELD_NUMBER; + hash = (53 * hash) + getCommon().hashCode(); + } + if (hasProgressEntities()) { + hash = (37 * hash) + PROGRESS_ENTITIES_FIELD_NUMBER; + hash = (53 * hash) + getProgressEntities().hashCode(); + } + hash = (37 * hash) + INDEX_ID_FIELD_NUMBER; + hash = (53 * hash) + getIndexId().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.IndexOperationMetadata parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.IndexOperationMetadata parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.IndexOperationMetadata parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.IndexOperationMetadata parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.IndexOperationMetadata parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.IndexOperationMetadata parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.IndexOperationMetadata parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.IndexOperationMetadata parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.IndexOperationMetadata parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Metadata for Index operations.
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.IndexOperationMetadata} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.IndexOperationMetadata) + com.google.datastore.admin.v1.IndexOperationMetadataOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_IndexOperationMetadata_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_IndexOperationMetadata_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.IndexOperationMetadata.class, + com.google.datastore.admin.v1.IndexOperationMetadata.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.IndexOperationMetadata.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getCommonFieldBuilder(); + getProgressEntitiesFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + common_ = null; + if (commonBuilder_ != null) { + commonBuilder_.dispose(); + commonBuilder_ = null; + } + progressEntities_ = null; + if (progressEntitiesBuilder_ != null) { + progressEntitiesBuilder_.dispose(); + progressEntitiesBuilder_ = null; + } + indexId_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_IndexOperationMetadata_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.IndexOperationMetadata getDefaultInstanceForType() { + return com.google.datastore.admin.v1.IndexOperationMetadata.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.IndexOperationMetadata build() { + com.google.datastore.admin.v1.IndexOperationMetadata result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.IndexOperationMetadata buildPartial() { + com.google.datastore.admin.v1.IndexOperationMetadata result = + new com.google.datastore.admin.v1.IndexOperationMetadata(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.IndexOperationMetadata result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.common_ = commonBuilder_ == null ? common_ : commonBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.progressEntities_ = + progressEntitiesBuilder_ == null ? progressEntities_ : progressEntitiesBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.indexId_ = indexId_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.IndexOperationMetadata) { + return mergeFrom((com.google.datastore.admin.v1.IndexOperationMetadata) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.IndexOperationMetadata other) { + if (other == com.google.datastore.admin.v1.IndexOperationMetadata.getDefaultInstance()) + return this; + if (other.hasCommon()) { + mergeCommon(other.getCommon()); + } + if (other.hasProgressEntities()) { + mergeProgressEntities(other.getProgressEntities()); + } + if (!other.getIndexId().isEmpty()) { + indexId_ = other.indexId_; + 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: + { + input.readMessage(getCommonFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage( + getProgressEntitiesFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + indexId_ = 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 com.google.datastore.admin.v1.CommonMetadata common_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.CommonMetadata, + com.google.datastore.admin.v1.CommonMetadata.Builder, + com.google.datastore.admin.v1.CommonMetadataOrBuilder> + commonBuilder_; + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return Whether the common field is set. + */ + public boolean hasCommon() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return The common. + */ + public com.google.datastore.admin.v1.CommonMetadata getCommon() { + if (commonBuilder_ == null) { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } else { + return commonBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder setCommon(com.google.datastore.admin.v1.CommonMetadata value) { + if (commonBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + common_ = value; + } else { + commonBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder setCommon(com.google.datastore.admin.v1.CommonMetadata.Builder builderForValue) { + if (commonBuilder_ == null) { + common_ = builderForValue.build(); + } else { + commonBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder mergeCommon(com.google.datastore.admin.v1.CommonMetadata value) { + if (commonBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && common_ != null + && common_ != com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance()) { + getCommonBuilder().mergeFrom(value); + } else { + common_ = value; + } + } else { + commonBuilder_.mergeFrom(value); + } + if (common_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public Builder clearCommon() { + bitField0_ = (bitField0_ & ~0x00000001); + common_ = null; + if (commonBuilder_ != null) { + commonBuilder_.dispose(); + commonBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public com.google.datastore.admin.v1.CommonMetadata.Builder getCommonBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getCommonFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + public com.google.datastore.admin.v1.CommonMetadataOrBuilder getCommonOrBuilder() { + if (commonBuilder_ != null) { + return commonBuilder_.getMessageOrBuilder(); + } else { + return common_ == null + ? com.google.datastore.admin.v1.CommonMetadata.getDefaultInstance() + : common_; + } + } + + /** + * + * + *
+     * Metadata common to all Datastore Admin operations.
+     * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.CommonMetadata, + com.google.datastore.admin.v1.CommonMetadata.Builder, + com.google.datastore.admin.v1.CommonMetadataOrBuilder> + getCommonFieldBuilder() { + if (commonBuilder_ == null) { + commonBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.CommonMetadata, + com.google.datastore.admin.v1.CommonMetadata.Builder, + com.google.datastore.admin.v1.CommonMetadataOrBuilder>( + getCommon(), getParentForChildren(), isClean()); + common_ = null; + } + return commonBuilder_; + } + + private com.google.datastore.admin.v1.Progress progressEntities_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder> + progressEntitiesBuilder_; + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return Whether the progressEntities field is set. + */ + public boolean hasProgressEntities() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return The progressEntities. + */ + public com.google.datastore.admin.v1.Progress getProgressEntities() { + if (progressEntitiesBuilder_ == null) { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } else { + return progressEntitiesBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder setProgressEntities(com.google.datastore.admin.v1.Progress value) { + if (progressEntitiesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + progressEntities_ = value; + } else { + progressEntitiesBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder setProgressEntities( + com.google.datastore.admin.v1.Progress.Builder builderForValue) { + if (progressEntitiesBuilder_ == null) { + progressEntities_ = builderForValue.build(); + } else { + progressEntitiesBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder mergeProgressEntities(com.google.datastore.admin.v1.Progress value) { + if (progressEntitiesBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && progressEntities_ != null + && progressEntities_ != com.google.datastore.admin.v1.Progress.getDefaultInstance()) { + getProgressEntitiesBuilder().mergeFrom(value); + } else { + progressEntities_ = value; + } + } else { + progressEntitiesBuilder_.mergeFrom(value); + } + if (progressEntities_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public Builder clearProgressEntities() { + bitField0_ = (bitField0_ & ~0x00000002); + progressEntities_ = null; + if (progressEntitiesBuilder_ != null) { + progressEntitiesBuilder_.dispose(); + progressEntitiesBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public com.google.datastore.admin.v1.Progress.Builder getProgressEntitiesBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getProgressEntitiesFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + public com.google.datastore.admin.v1.ProgressOrBuilder getProgressEntitiesOrBuilder() { + if (progressEntitiesBuilder_ != null) { + return progressEntitiesBuilder_.getMessageOrBuilder(); + } else { + return progressEntities_ == null + ? com.google.datastore.admin.v1.Progress.getDefaultInstance() + : progressEntities_; + } + } + + /** + * + * + *
+     * An estimate of the number of entities processed.
+     * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder> + getProgressEntitiesFieldBuilder() { + if (progressEntitiesBuilder_ == null) { + progressEntitiesBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.Progress, + com.google.datastore.admin.v1.Progress.Builder, + com.google.datastore.admin.v1.ProgressOrBuilder>( + getProgressEntities(), getParentForChildren(), isClean()); + progressEntities_ = null; + } + return progressEntitiesBuilder_; + } + + private java.lang.Object indexId_ = ""; + + /** + * + * + *
+     * The index resource ID that this operation is acting on.
+     * 
+ * + * string index_id = 3; + * + * @return The indexId. + */ + public java.lang.String getIndexId() { + java.lang.Object ref = indexId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + indexId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The index resource ID that this operation is acting on.
+     * 
+ * + * string index_id = 3; + * + * @return The bytes for indexId. + */ + public com.google.protobuf.ByteString getIndexIdBytes() { + java.lang.Object ref = indexId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + indexId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The index resource ID that this operation is acting on.
+     * 
+ * + * string index_id = 3; + * + * @param value The indexId to set. + * @return This builder for chaining. + */ + public Builder setIndexId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + indexId_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The index resource ID that this operation is acting on.
+     * 
+ * + * string index_id = 3; + * + * @return This builder for chaining. + */ + public Builder clearIndexId() { + indexId_ = getDefaultInstance().getIndexId(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * The index resource ID that this operation is acting on.
+     * 
+ * + * string index_id = 3; + * + * @param value The bytes for indexId to set. + * @return This builder for chaining. + */ + public Builder setIndexIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + indexId_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.IndexOperationMetadata) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.IndexOperationMetadata) + private static final com.google.datastore.admin.v1.IndexOperationMetadata DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.IndexOperationMetadata(); + } + + public static com.google.datastore.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.datastore.admin.v1.IndexOperationMetadata getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadataOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadataOrBuilder.java new file mode 100644 index 000000000000..c82cb2ef091e --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOperationMetadataOrBuilder.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! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface IndexOperationMetadataOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.IndexOperationMetadata) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return Whether the common field is set. + */ + boolean hasCommon(); + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + * + * @return The common. + */ + com.google.datastore.admin.v1.CommonMetadata getCommon(); + + /** + * + * + *
+   * Metadata common to all Datastore Admin operations.
+   * 
+ * + * .google.datastore.admin.v1.CommonMetadata common = 1; + */ + com.google.datastore.admin.v1.CommonMetadataOrBuilder getCommonOrBuilder(); + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return Whether the progressEntities field is set. + */ + boolean hasProgressEntities(); + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + * + * @return The progressEntities. + */ + com.google.datastore.admin.v1.Progress getProgressEntities(); + + /** + * + * + *
+   * An estimate of the number of entities processed.
+   * 
+ * + * .google.datastore.admin.v1.Progress progress_entities = 2; + */ + com.google.datastore.admin.v1.ProgressOrBuilder getProgressEntitiesOrBuilder(); + + /** + * + * + *
+   * The index resource ID that this operation is acting on.
+   * 
+ * + * string index_id = 3; + * + * @return The indexId. + */ + java.lang.String getIndexId(); + + /** + * + * + *
+   * The index resource ID that this operation is acting on.
+   * 
+ * + * string index_id = 3; + * + * @return The bytes for indexId. + */ + com.google.protobuf.ByteString getIndexIdBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOrBuilder.java new file mode 100644 index 000000000000..fb22e407c2cb --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexOrBuilder.java @@ -0,0 +1,252 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/index.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface IndexOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.Index) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Output only. Project ID.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Output only. Project ID.
+   * 
+ * + * string project_id = 1 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * Output only. The resource ID of the index.
+   * 
+ * + * string index_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The indexId. + */ + java.lang.String getIndexId(); + + /** + * + * + *
+   * Output only. The resource ID of the index.
+   * 
+ * + * string index_id = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for indexId. + */ + com.google.protobuf.ByteString getIndexIdBytes(); + + /** + * + * + *
+   * Required. The entity kind to which this index applies.
+   * 
+ * + * string kind = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The kind. + */ + java.lang.String getKind(); + + /** + * + * + *
+   * Required. The entity kind to which this index applies.
+   * 
+ * + * string kind = 4 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for kind. + */ + com.google.protobuf.ByteString getKindBytes(); + + /** + * + * + *
+   * Required. The index's ancestor mode.  Must not be
+   * ANCESTOR_MODE_UNSPECIFIED.
+   * 
+ * + * + * .google.datastore.admin.v1.Index.AncestorMode ancestor = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The enum numeric value on the wire for ancestor. + */ + int getAncestorValue(); + + /** + * + * + *
+   * Required. The index's ancestor mode.  Must not be
+   * ANCESTOR_MODE_UNSPECIFIED.
+   * 
+ * + * + * .google.datastore.admin.v1.Index.AncestorMode ancestor = 5 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The ancestor. + */ + com.google.datastore.admin.v1.Index.AncestorMode getAncestor(); + + /** + * + * + *
+   * Required. An ordered sequence of property names and their index attributes.
+   *
+   * Requires:
+   *
+   * * A maximum of 100 properties.
+   * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + java.util.List getPropertiesList(); + + /** + * + * + *
+   * Required. An ordered sequence of property names and their index attributes.
+   *
+   * Requires:
+   *
+   * * A maximum of 100 properties.
+   * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.admin.v1.Index.IndexedProperty getProperties(int index); + + /** + * + * + *
+   * Required. An ordered sequence of property names and their index attributes.
+   *
+   * Requires:
+   *
+   * * A maximum of 100 properties.
+   * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + int getPropertiesCount(); + + /** + * + * + *
+   * Required. An ordered sequence of property names and their index attributes.
+   *
+   * Requires:
+   *
+   * * A maximum of 100 properties.
+   * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + java.util.List + getPropertiesOrBuilderList(); + + /** + * + * + *
+   * Required. An ordered sequence of property names and their index attributes.
+   *
+   * Requires:
+   *
+   * * A maximum of 100 properties.
+   * 
+ * + * + * repeated .google.datastore.admin.v1.Index.IndexedProperty properties = 6 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.admin.v1.Index.IndexedPropertyOrBuilder getPropertiesOrBuilder(int index); + + /** + * + * + *
+   * Output only. The state of the index.
+   * 
+ * + * + * .google.datastore.admin.v1.Index.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + + /** + * + * + *
+   * Output only. The state of the index.
+   * 
+ * + * + * .google.datastore.admin.v1.Index.State state = 7 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + com.google.datastore.admin.v1.Index.State getState(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexProto.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexProto.java new file mode 100644 index 000000000000..505a01a0e9af --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/IndexProto.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! +// source: google/datastore/admin/v1/index.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public final class IndexProto { + private 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_datastore_admin_v1_Index_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_Index_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_Index_IndexedProperty_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_Index_IndexedProperty_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/datastore/admin/v1/index.proto\022" + + "\031google.datastore.admin.v1\032\037google/api/field_behavior.proto\"\346\004\n" + + "\005Index\022\027\n\n" + + "project_id\030\001 \001(\tB\003\340A\003\022\025\n" + + "\010index_id\030\003 \001(\tB\003\340A\003\022\021\n" + + "\004kind\030\004 \001(\tB\003\340A\002\022D\n" + + "\010ancestor\030\005 \001(\0162-.goo" + + "gle.datastore.admin.v1.Index.AncestorModeB\003\340A\002\022I\n\n" + + "properties\030\006 \003(\01320.google.data" + + "store.admin.v1.Index.IndexedPropertyB\003\340A\002\022:\n" + + "\005state\030\007" + + " \001(\0162&.google.datastore.admin.v1.Index.StateB\003\340A\003\032h\n" + + "\017IndexedProperty\022\021\n" + + "\004name\030\001 \001(\tB\003\340A\002\022B\n" + + "\tdirection\030\002 \001(\0162*" + + ".google.datastore.admin.v1.Index.DirectionB\003\340A\002\"J\n" + + "\014AncestorMode\022\035\n" + + "\031ANCESTOR_MODE_UNSPECIFIED\020\000\022\010\n" + + "\004NONE\020\001\022\021\n\r" + + "ALL_ANCESTORS\020\002\"E\n" + + "\tDirection\022\031\n" + + "\025DIRECTION_UNSPECIFIED\020\000\022\r\n" + + "\tASCENDING\020\001\022\016\n\n" + + "DESCENDING\020\002\"P\n" + + "\005State\022\025\n" + + "\021STATE_UNSPECIFIED\020\000\022\014\n" + + "\010CREATING\020\001\022\t\n" + + "\005READY\020\002\022\014\n" + + "\010DELETING\020\003\022\t\n" + + "\005ERROR\020\004B\322\001\n" + + "\035com.google.datastore.admin.v1B\n" + + "IndexProtoP\001Z9cloud.google.com/go/datastore/admi" + + "n/apiv1/adminpb;adminpb\252\002\037Google.Cloud.D" + + "atastore.Admin.V1\312\002\037Google\\Cloud\\Datasto" + + "re\\Admin\\V1\352\002#Google::Cloud::Datastore::Admin::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + }); + internal_static_google_datastore_admin_v1_Index_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_datastore_admin_v1_Index_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_Index_descriptor, + new java.lang.String[] { + "ProjectId", "IndexId", "Kind", "Ancestor", "Properties", "State", + }); + internal_static_google_datastore_admin_v1_Index_IndexedProperty_descriptor = + internal_static_google_datastore_admin_v1_Index_descriptor.getNestedTypes().get(0); + internal_static_google_datastore_admin_v1_Index_IndexedProperty_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_Index_IndexedProperty_descriptor, + new java.lang.String[] { + "Name", "Direction", + }); + 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); + com.google.api.FieldBehaviorProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequest.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequest.java new file mode 100644 index 000000000000..0fe980b5ef11 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequest.java @@ -0,0 +1,1073 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * The request for
+ * [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes].
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ListIndexesRequest} + */ +public final class ListIndexesRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.ListIndexesRequest) + ListIndexesRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ListIndexesRequest.newBuilder() to construct. + private ListIndexesRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListIndexesRequest() { + projectId_ = ""; + filter_ = ""; + pageToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListIndexesRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ListIndexesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ListIndexesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ListIndexesRequest.class, + com.google.datastore.admin.v1.ListIndexesRequest.Builder.class); + } + + public static final int PROJECT_ID_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int FILTER_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object filter_ = ""; + + /** + * string filter = 3; + * + * @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; + } + } + + /** + * string filter = 3; + * + * @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 = 4; + private int pageSize_ = 0; + + /** + * + * + *
+   * The maximum number of items to return.  If zero, then all results will be
+   * returned.
+   * 
+ * + * int32 page_size = 4; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private volatile java.lang.Object pageToken_ = ""; + + /** + * + * + *
+   * The next_page_token value returned from a previous List request, if any.
+   * 
+ * + * string page_token = 5; + * + * @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 List request, if any.
+   * 
+ * + * string page_token = 5; + * + * @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.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(filter_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, filter_); + } + if (pageSize_ != 0) { + output.writeInt32(4, pageSize_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, pageToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(filter_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, filter_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(4, pageSize_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, 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.datastore.admin.v1.ListIndexesRequest)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.ListIndexesRequest other = + (com.google.datastore.admin.v1.ListIndexesRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().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.datastore.admin.v1.ListIndexesRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.ListIndexesRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.ListIndexesRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.ListIndexesRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ListIndexesRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ListIndexesRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ListIndexesRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ListIndexesRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ListIndexesRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes].
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ListIndexesRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.ListIndexesRequest) + com.google.datastore.admin.v1.ListIndexesRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ListIndexesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ListIndexesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ListIndexesRequest.class, + com.google.datastore.admin.v1.ListIndexesRequest.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.ListIndexesRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + filter_ = ""; + pageSize_ = 0; + pageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ListIndexesRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ListIndexesRequest getDefaultInstanceForType() { + return com.google.datastore.admin.v1.ListIndexesRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.ListIndexesRequest build() { + com.google.datastore.admin.v1.ListIndexesRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ListIndexesRequest buildPartial() { + com.google.datastore.admin.v1.ListIndexesRequest result = + new com.google.datastore.admin.v1.ListIndexesRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.ListIndexesRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + 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 clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.ListIndexesRequest) { + return mergeFrom((com.google.datastore.admin.v1.ListIndexesRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.ListIndexesRequest other) { + if (other == com.google.datastore.admin.v1.ListIndexesRequest.getDefaultInstance()) + return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + 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: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + filter_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 32: + { + pageSize_ = input.readInt32(); + bitField0_ |= 0x00000004; + break; + } // case 32 + case 42: + { + pageToken_ = input.readStringRequireUtf8(); + 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 java.lang.Object projectId_ = ""; + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Project ID against which to make the request.
+     * 
+ * + * string project_id = 1; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object filter_ = ""; + + /** + * string filter = 3; + * + * @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; + } + } + + /** + * string filter = 3; + * + * @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; + } + } + + /** + * string filter = 3; + * + * @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; + } + + /** + * string filter = 3; + * + * @return This builder for chaining. + */ + public Builder clearFilter() { + filter_ = getDefaultInstance().getFilter(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * string filter = 3; + * + * @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 maximum number of items to return.  If zero, then all results will be
+     * returned.
+     * 
+ * + * int32 page_size = 4; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + /** + * + * + *
+     * The maximum number of items to return.  If zero, then all results will be
+     * returned.
+     * 
+ * + * int32 page_size = 4; + * + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The maximum number of items to return.  If zero, then all results will be
+     * returned.
+     * 
+ * + * int32 page_size = 4; + * + * @return This builder for chaining. + */ + public Builder clearPageSize() { + bitField0_ = (bitField0_ & ~0x00000004); + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + + /** + * + * + *
+     * The next_page_token value returned from a previous List request, if any.
+     * 
+ * + * string page_token = 5; + * + * @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 List request, if any.
+     * 
+ * + * string page_token = 5; + * + * @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 List request, if any.
+     * 
+ * + * string page_token = 5; + * + * @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 List request, if any.
+     * 
+ * + * string page_token = 5; + * + * @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 List request, if any.
+     * 
+ * + * string page_token = 5; + * + * @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; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.ListIndexesRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.ListIndexesRequest) + private static final com.google.datastore.admin.v1.ListIndexesRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.ListIndexesRequest(); + } + + public static com.google.datastore.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.datastore.admin.v1.ListIndexesRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequestOrBuilder.java new file mode 100644 index 000000000000..b771745fd58b --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesRequestOrBuilder.java @@ -0,0 +1,106 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface ListIndexesRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.ListIndexesRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Project ID against which to make the request.
+   * 
+ * + * string project_id = 1; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * string filter = 3; + * + * @return The filter. + */ + java.lang.String getFilter(); + + /** + * string filter = 3; + * + * @return The bytes for filter. + */ + com.google.protobuf.ByteString getFilterBytes(); + + /** + * + * + *
+   * The maximum number of items to return.  If zero, then all results will be
+   * returned.
+   * 
+ * + * int32 page_size = 4; + * + * @return The pageSize. + */ + int getPageSize(); + + /** + * + * + *
+   * The next_page_token value returned from a previous List request, if any.
+   * 
+ * + * string page_token = 5; + * + * @return The pageToken. + */ + java.lang.String getPageToken(); + + /** + * + * + *
+   * The next_page_token value returned from a previous List request, if any.
+   * 
+ * + * string page_token = 5; + * + * @return The bytes for pageToken. + */ + com.google.protobuf.ByteString getPageTokenBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponse.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponse.java new file mode 100644 index 000000000000..2599f3792dfa --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponse.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! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * The response for
+ * [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes].
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ListIndexesResponse} + */ +public final class ListIndexesResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.ListIndexesResponse) + ListIndexesResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ListIndexesResponse.newBuilder() to construct. + private ListIndexesResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListIndexesResponse() { + indexes_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListIndexesResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ListIndexesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ListIndexesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ListIndexesResponse.class, + com.google.datastore.admin.v1.ListIndexesResponse.Builder.class); + } + + public static final int INDEXES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List indexes_; + + /** + * + * + *
+   * The indexes.
+   * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public java.util.List getIndexesList() { + return indexes_; + } + + /** + * + * + *
+   * The indexes.
+   * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public java.util.List + getIndexesOrBuilderList() { + return indexes_; + } + + /** + * + * + *
+   * The indexes.
+   * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public int getIndexesCount() { + return indexes_.size(); + } + + /** + * + * + *
+   * The indexes.
+   * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public com.google.datastore.admin.v1.Index getIndexes(int index) { + return indexes_.get(index); + } + + /** + * + * + *
+   * The indexes.
+   * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + @java.lang.Override + public com.google.datastore.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_ = ""; + + /** + * + * + *
+   * The standard List next-page token.
+   * 
+ * + * 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; + } + } + + /** + * + * + *
+   * The standard List next-page token.
+   * 
+ * + * 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.GeneratedMessageV3.isStringEmpty(nextPageToken_)) { + com.google.protobuf.GeneratedMessageV3.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.GeneratedMessageV3.isStringEmpty(nextPageToken_)) { + size += com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.ListIndexesResponse)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.ListIndexesResponse other = + (com.google.datastore.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.datastore.admin.v1.ListIndexesResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.ListIndexesResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.ListIndexesResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.ListIndexesResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ListIndexesResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ListIndexesResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ListIndexesResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.ListIndexesResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.ListIndexesResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes].
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.ListIndexesResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.ListIndexesResponse) + com.google.datastore.admin.v1.ListIndexesResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ListIndexesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ListIndexesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.ListIndexesResponse.class, + com.google.datastore.admin.v1.ListIndexesResponse.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.ListIndexesResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_ListIndexesResponse_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ListIndexesResponse getDefaultInstanceForType() { + return com.google.datastore.admin.v1.ListIndexesResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.ListIndexesResponse build() { + com.google.datastore.admin.v1.ListIndexesResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.ListIndexesResponse buildPartial() { + com.google.datastore.admin.v1.ListIndexesResponse result = + new com.google.datastore.admin.v1.ListIndexesResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.datastore.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.datastore.admin.v1.ListIndexesResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.nextPageToken_ = nextPageToken_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.ListIndexesResponse) { + return mergeFrom((com.google.datastore.admin.v1.ListIndexesResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.ListIndexesResponse other) { + if (other == com.google.datastore.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.GeneratedMessageV3.alwaysUseFieldBuilders + ? getIndexesFieldBuilder() + : 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.datastore.admin.v1.Index m = + input.readMessage( + com.google.datastore.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.RepeatedFieldBuilderV3< + com.google.datastore.admin.v1.Index, + com.google.datastore.admin.v1.Index.Builder, + com.google.datastore.admin.v1.IndexOrBuilder> + indexesBuilder_; + + /** + * + * + *
+     * The indexes.
+     * 
+ * + * repeated .google.datastore.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.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public int getIndexesCount() { + if (indexesBuilder_ == null) { + return indexes_.size(); + } else { + return indexesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The indexes.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public com.google.datastore.admin.v1.Index getIndexes(int index) { + if (indexesBuilder_ == null) { + return indexes_.get(index); + } else { + return indexesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The indexes.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public Builder setIndexes(int index, com.google.datastore.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.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public Builder setIndexes( + int index, com.google.datastore.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.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes(com.google.datastore.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.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes(int index, com.google.datastore.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.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes(com.google.datastore.admin.v1.Index.Builder builderForValue) { + if (indexesBuilder_ == null) { + ensureIndexesIsMutable(); + indexes_.add(builderForValue.build()); + onChanged(); + } else { + indexesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The indexes.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public Builder addIndexes( + int index, com.google.datastore.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.
+     * 
+ * + * repeated .google.datastore.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.
+     * 
+ * + * repeated .google.datastore.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.
+     * 
+ * + * repeated .google.datastore.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.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public com.google.datastore.admin.v1.Index.Builder getIndexesBuilder(int index) { + return getIndexesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The indexes.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public com.google.datastore.admin.v1.IndexOrBuilder getIndexesOrBuilder(int index) { + if (indexesBuilder_ == null) { + return indexes_.get(index); + } else { + return indexesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The indexes.
+     * 
+ * + * repeated .google.datastore.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.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public com.google.datastore.admin.v1.Index.Builder addIndexesBuilder() { + return getIndexesFieldBuilder() + .addBuilder(com.google.datastore.admin.v1.Index.getDefaultInstance()); + } + + /** + * + * + *
+     * The indexes.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public com.google.datastore.admin.v1.Index.Builder addIndexesBuilder(int index) { + return getIndexesFieldBuilder() + .addBuilder(index, com.google.datastore.admin.v1.Index.getDefaultInstance()); + } + + /** + * + * + *
+     * The indexes.
+     * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + public java.util.List getIndexesBuilderList() { + return getIndexesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.admin.v1.Index, + com.google.datastore.admin.v1.Index.Builder, + com.google.datastore.admin.v1.IndexOrBuilder> + getIndexesFieldBuilder() { + if (indexesBuilder_ == null) { + indexesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.admin.v1.Index, + com.google.datastore.admin.v1.Index.Builder, + com.google.datastore.admin.v1.IndexOrBuilder>( + indexes_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + indexes_ = null; + } + return indexesBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + + /** + * + * + *
+     * The standard List next-page token.
+     * 
+ * + * 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; + } + } + + /** + * + * + *
+     * The standard List next-page token.
+     * 
+ * + * 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; + } + } + + /** + * + * + *
+     * The standard List next-page token.
+     * 
+ * + * 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; + } + + /** + * + * + *
+     * The standard List next-page token.
+     * 
+ * + * string next_page_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearNextPageToken() { + nextPageToken_ = getDefaultInstance().getNextPageToken(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The standard List next-page token.
+     * 
+ * + * 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; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.ListIndexesResponse) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.ListIndexesResponse) + private static final com.google.datastore.admin.v1.ListIndexesResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.ListIndexesResponse(); + } + + public static com.google.datastore.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.datastore.admin.v1.ListIndexesResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponseOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponseOrBuilder.java new file mode 100644 index 000000000000..75cc023adc9e --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ListIndexesResponseOrBuilder.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! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface ListIndexesResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.ListIndexesResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The indexes.
+   * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + java.util.List getIndexesList(); + + /** + * + * + *
+   * The indexes.
+   * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + com.google.datastore.admin.v1.Index getIndexes(int index); + + /** + * + * + *
+   * The indexes.
+   * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + int getIndexesCount(); + + /** + * + * + *
+   * The indexes.
+   * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + java.util.List getIndexesOrBuilderList(); + + /** + * + * + *
+   * The indexes.
+   * 
+ * + * repeated .google.datastore.admin.v1.Index indexes = 1; + */ + com.google.datastore.admin.v1.IndexOrBuilder getIndexesOrBuilder(int index); + + /** + * + * + *
+   * The standard List next-page token.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + java.lang.String getNextPageToken(); + + /** + * + * + *
+   * The standard List next-page token.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + com.google.protobuf.ByteString getNextPageTokenBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEvent.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEvent.java new file mode 100644 index 000000000000..e0a527e0f8a3 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEvent.java @@ -0,0 +1,2971 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/migration.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * An event signifying the start of a new step in a [migration from Cloud
+ * Datastore to Cloud Firestore in Datastore
+ * mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore).
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.MigrationProgressEvent} + */ +public final class MigrationProgressEvent extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.MigrationProgressEvent) + MigrationProgressEventOrBuilder { + private static final long serialVersionUID = 0L; + + // Use MigrationProgressEvent.newBuilder() to construct. + private MigrationProgressEvent(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private MigrationProgressEvent() { + step_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new MigrationProgressEvent(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.MigrationProgressEvent.class, + com.google.datastore.admin.v1.MigrationProgressEvent.Builder.class); + } + + /** + * + * + *
+   * Concurrency modes for transactions in Cloud Firestore.
+   * 
+ * + * Protobuf enum {@code google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode} + */ + public enum ConcurrencyMode implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified.
+     * 
+ * + * CONCURRENCY_MODE_UNSPECIFIED = 0; + */ + CONCURRENCY_MODE_UNSPECIFIED(0), + /** + * + * + *
+     * Pessimistic concurrency.
+     * 
+ * + * PESSIMISTIC = 1; + */ + PESSIMISTIC(1), + /** + * + * + *
+     * Optimistic concurrency.
+     * 
+ * + * OPTIMISTIC = 2; + */ + OPTIMISTIC(2), + /** + * + * + *
+     * Optimistic concurrency with entity groups.
+     * 
+ * + * OPTIMISTIC_WITH_ENTITY_GROUPS = 3; + */ + OPTIMISTIC_WITH_ENTITY_GROUPS(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified.
+     * 
+ * + * CONCURRENCY_MODE_UNSPECIFIED = 0; + */ + public static final int CONCURRENCY_MODE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Pessimistic concurrency.
+     * 
+ * + * PESSIMISTIC = 1; + */ + public static final int PESSIMISTIC_VALUE = 1; + + /** + * + * + *
+     * Optimistic concurrency.
+     * 
+ * + * OPTIMISTIC = 2; + */ + public static final int OPTIMISTIC_VALUE = 2; + + /** + * + * + *
+     * Optimistic concurrency with entity groups.
+     * 
+ * + * 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 PESSIMISTIC; + case 2: + return OPTIMISTIC; + 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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProgressEvent.getDescriptor() + .getEnumTypes() + .get(0); + } + + 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.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode) + } + + public interface PrepareStepDetailsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The concurrency mode this database will use when it reaches the
+     * `REDIRECT_WRITES` step.
+     * 
+ * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The enum numeric value on the wire for concurrencyMode. + */ + int getConcurrencyModeValue(); + + /** + * + * + *
+     * The concurrency mode this database will use when it reaches the
+     * `REDIRECT_WRITES` step.
+     * 
+ * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The concurrencyMode. + */ + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode getConcurrencyMode(); + } + + /** + * + * + *
+   * Details for the `PREPARE` step.
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails} + */ + public static final class PrepareStepDetails extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + PrepareStepDetailsOrBuilder { + private static final long serialVersionUID = 0L; + + // Use PrepareStepDetails.newBuilder() to construct. + private PrepareStepDetails(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PrepareStepDetails() { + concurrencyMode_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PrepareStepDetails(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_PrepareStepDetails_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_PrepareStepDetails_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.class, + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.Builder + .class); + } + + public static final int CONCURRENCY_MODE_FIELD_NUMBER = 1; + private int concurrencyMode_ = 0; + + /** + * + * + *
+     * The concurrency mode this database will use when it reaches the
+     * `REDIRECT_WRITES` step.
+     * 
+ * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The enum numeric value on the wire for concurrencyMode. + */ + @java.lang.Override + public int getConcurrencyModeValue() { + return concurrencyMode_; + } + + /** + * + * + *
+     * The concurrency mode this database will use when it reaches the
+     * `REDIRECT_WRITES` step.
+     * 
+ * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The concurrencyMode. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode + getConcurrencyMode() { + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode result = + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode.forNumber( + concurrencyMode_); + return result == null + ? com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode.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 (concurrencyMode_ + != com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode + .CONCURRENCY_MODE_UNSPECIFIED + .getNumber()) { + output.writeEnum(1, concurrencyMode_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (concurrencyMode_ + != com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode + .CONCURRENCY_MODE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, concurrencyMode_); + } + 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.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails other = + (com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) obj; + + if (concurrencyMode_ != other.concurrencyMode_) 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) + CONCURRENCY_MODE_FIELD_NUMBER; + hash = (53 * hash) + concurrencyMode_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails 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.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Details for the `PREPARE` step.
+     * 
+ * + * Protobuf type {@code google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetailsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_PrepareStepDetails_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_PrepareStepDetails_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.class, + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.Builder + .class); + } + + // Construct using + // com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + concurrencyMode_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_PrepareStepDetails_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + getDefaultInstanceForType() { + return com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails build() { + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + buildPartial() { + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails result = + new com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.concurrencyMode_ = concurrencyMode_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) { + return mergeFrom( + (com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails other) { + if (other + == com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + .getDefaultInstance()) return this; + if (other.concurrencyMode_ != 0) { + setConcurrencyModeValue(other.getConcurrencyModeValue()); + } + 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: + { + concurrencyMode_ = 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 concurrencyMode_ = 0; + + /** + * + * + *
+       * The concurrency mode this database will use when it reaches the
+       * `REDIRECT_WRITES` step.
+       * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The enum numeric value on the wire for concurrencyMode. + */ + @java.lang.Override + public int getConcurrencyModeValue() { + return concurrencyMode_; + } + + /** + * + * + *
+       * The concurrency mode this database will use when it reaches the
+       * `REDIRECT_WRITES` step.
+       * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @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_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The concurrency mode this database will use when it reaches the
+       * `REDIRECT_WRITES` step.
+       * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The concurrencyMode. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode + getConcurrencyMode() { + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode result = + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode.forNumber( + concurrencyMode_); + return result == null + ? com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode.UNRECOGNIZED + : result; + } + + /** + * + * + *
+       * The concurrency mode this database will use when it reaches the
+       * `REDIRECT_WRITES` step.
+       * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @param value The concurrencyMode to set. + * @return This builder for chaining. + */ + public Builder setConcurrencyMode( + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + concurrencyMode_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * The concurrency mode this database will use when it reaches the
+       * `REDIRECT_WRITES` step.
+       * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return This builder for chaining. + */ + public Builder clearConcurrencyMode() { + bitField0_ = (bitField0_ & ~0x00000001); + concurrencyMode_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + private static final com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails(); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PrepareStepDetails 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.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface RedirectWritesStepDetailsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Ths concurrency mode for this database.
+     * 
+ * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The enum numeric value on the wire for concurrencyMode. + */ + int getConcurrencyModeValue(); + + /** + * + * + *
+     * Ths concurrency mode for this database.
+     * 
+ * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The concurrencyMode. + */ + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode getConcurrencyMode(); + } + + /** + * + * + *
+   * Details for the `REDIRECT_WRITES` step.
+   * 
+ * + * Protobuf type {@code + * google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails} + */ + public static final class RedirectWritesStepDetails extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + RedirectWritesStepDetailsOrBuilder { + private static final long serialVersionUID = 0L; + + // Use RedirectWritesStepDetails.newBuilder() to construct. + private RedirectWritesStepDetails(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private RedirectWritesStepDetails() { + concurrencyMode_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new RedirectWritesStepDetails(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_RedirectWritesStepDetails_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_RedirectWritesStepDetails_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.class, + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.Builder + .class); + } + + public static final int CONCURRENCY_MODE_FIELD_NUMBER = 1; + private int concurrencyMode_ = 0; + + /** + * + * + *
+     * Ths concurrency mode for this database.
+     * 
+ * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The enum numeric value on the wire for concurrencyMode. + */ + @java.lang.Override + public int getConcurrencyModeValue() { + return concurrencyMode_; + } + + /** + * + * + *
+     * Ths concurrency mode for this database.
+     * 
+ * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The concurrencyMode. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode + getConcurrencyMode() { + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode result = + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode.forNumber( + concurrencyMode_); + return result == null + ? com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode.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 (concurrencyMode_ + != com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode + .CONCURRENCY_MODE_UNSPECIFIED + .getNumber()) { + output.writeEnum(1, concurrencyMode_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (concurrencyMode_ + != com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode + .CONCURRENCY_MODE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, concurrencyMode_); + } + 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.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails other = + (com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) obj; + + if (concurrencyMode_ != other.concurrencyMode_) 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) + CONCURRENCY_MODE_FIELD_NUMBER; + hash = (53 * hash) + concurrencyMode_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + 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.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Details for the `REDIRECT_WRITES` step.
+     * 
+ * + * Protobuf type {@code + * google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetailsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_RedirectWritesStepDetails_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_RedirectWritesStepDetails_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .class, + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .Builder.class); + } + + // Construct using + // com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + concurrencyMode_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_RedirectWritesStepDetails_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + getDefaultInstanceForType() { + return com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + build() { + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails result = + buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + buildPartial() { + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails result = + new com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails( + this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.concurrencyMode_ = concurrencyMode_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other + instanceof + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) { + return mergeFrom( + (com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails other) { + if (other + == com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .getDefaultInstance()) return this; + if (other.concurrencyMode_ != 0) { + setConcurrencyModeValue(other.getConcurrencyModeValue()); + } + 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: + { + concurrencyMode_ = 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 concurrencyMode_ = 0; + + /** + * + * + *
+       * Ths concurrency mode for this database.
+       * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The enum numeric value on the wire for concurrencyMode. + */ + @java.lang.Override + public int getConcurrencyModeValue() { + return concurrencyMode_; + } + + /** + * + * + *
+       * Ths concurrency mode for this database.
+       * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @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_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Ths concurrency mode for this database.
+       * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return The concurrencyMode. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode + getConcurrencyMode() { + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode result = + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode.forNumber( + concurrencyMode_); + return result == null + ? com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode.UNRECOGNIZED + : result; + } + + /** + * + * + *
+       * Ths concurrency mode for this database.
+       * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @param value The concurrencyMode to set. + * @return This builder for chaining. + */ + public Builder setConcurrencyMode( + com.google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + concurrencyMode_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+       * Ths concurrency mode for this database.
+       * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.ConcurrencyMode concurrency_mode = 1; + * + * + * @return This builder for chaining. + */ + public Builder clearConcurrencyMode() { + bitField0_ = (bitField0_ & ~0x00000001); + concurrencyMode_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + private static final com.google.datastore.admin.v1.MigrationProgressEvent + .RedirectWritesStepDetails + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = + new com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails(); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RedirectWritesStepDetails 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.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int stepDetailsCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object stepDetails_; + + public enum StepDetailsCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + PREPARE_STEP_DETAILS(2), + REDIRECT_WRITES_STEP_DETAILS(3), + STEPDETAILS_NOT_SET(0); + private final int value; + + private StepDetailsCase(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 StepDetailsCase valueOf(int value) { + return forNumber(value); + } + + public static StepDetailsCase forNumber(int value) { + switch (value) { + case 2: + return PREPARE_STEP_DETAILS; + case 3: + return REDIRECT_WRITES_STEP_DETAILS; + case 0: + return STEPDETAILS_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public StepDetailsCase getStepDetailsCase() { + return StepDetailsCase.forNumber(stepDetailsCase_); + } + + public static final int STEP_FIELD_NUMBER = 1; + private int step_ = 0; + + /** + * + * + *
+   * The step that is starting.
+   *
+   * An event with step set to `START` indicates that the migration
+   * has been reverted back to the initial pre-migration state.
+   * 
+ * + * .google.datastore.admin.v1.MigrationStep step = 1; + * + * @return The enum numeric value on the wire for step. + */ + @java.lang.Override + public int getStepValue() { + return step_; + } + + /** + * + * + *
+   * The step that is starting.
+   *
+   * An event with step set to `START` indicates that the migration
+   * has been reverted back to the initial pre-migration state.
+   * 
+ * + * .google.datastore.admin.v1.MigrationStep step = 1; + * + * @return The step. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationStep getStep() { + com.google.datastore.admin.v1.MigrationStep result = + com.google.datastore.admin.v1.MigrationStep.forNumber(step_); + return result == null ? com.google.datastore.admin.v1.MigrationStep.UNRECOGNIZED : result; + } + + public static final int PREPARE_STEP_DETAILS_FIELD_NUMBER = 2; + + /** + * + * + *
+   * Details for the `PREPARE` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + * + * @return Whether the prepareStepDetails field is set. + */ + @java.lang.Override + public boolean hasPrepareStepDetails() { + return stepDetailsCase_ == 2; + } + + /** + * + * + *
+   * Details for the `PREPARE` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + * + * @return The prepareStepDetails. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + getPrepareStepDetails() { + if (stepDetailsCase_ == 2) { + return (com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) stepDetails_; + } + return com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + .getDefaultInstance(); + } + + /** + * + * + *
+   * Details for the `PREPARE` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetailsOrBuilder + getPrepareStepDetailsOrBuilder() { + if (stepDetailsCase_ == 2) { + return (com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) stepDetails_; + } + return com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + .getDefaultInstance(); + } + + public static final int REDIRECT_WRITES_STEP_DETAILS_FIELD_NUMBER = 3; + + /** + * + * + *
+   * Details for the `REDIRECT_WRITES` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + * + * @return Whether the redirectWritesStepDetails field is set. + */ + @java.lang.Override + public boolean hasRedirectWritesStepDetails() { + return stepDetailsCase_ == 3; + } + + /** + * + * + *
+   * Details for the `REDIRECT_WRITES` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + * + * @return The redirectWritesStepDetails. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + getRedirectWritesStepDetails() { + if (stepDetailsCase_ == 3) { + return (com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + stepDetails_; + } + return com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .getDefaultInstance(); + } + + /** + * + * + *
+   * Details for the `REDIRECT_WRITES` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetailsOrBuilder + getRedirectWritesStepDetailsOrBuilder() { + if (stepDetailsCase_ == 3) { + return (com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + stepDetails_; + } + return com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .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 (step_ + != com.google.datastore.admin.v1.MigrationStep.MIGRATION_STEP_UNSPECIFIED.getNumber()) { + output.writeEnum(1, step_); + } + if (stepDetailsCase_ == 2) { + output.writeMessage( + 2, + (com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) stepDetails_); + } + if (stepDetailsCase_ == 3) { + output.writeMessage( + 3, + (com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + stepDetails_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (step_ + != com.google.datastore.admin.v1.MigrationStep.MIGRATION_STEP_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, step_); + } + if (stepDetailsCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, + (com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + stepDetails_); + } + if (stepDetailsCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, + (com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + stepDetails_); + } + 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.datastore.admin.v1.MigrationProgressEvent)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.MigrationProgressEvent other = + (com.google.datastore.admin.v1.MigrationProgressEvent) obj; + + if (step_ != other.step_) return false; + if (!getStepDetailsCase().equals(other.getStepDetailsCase())) return false; + switch (stepDetailsCase_) { + case 2: + if (!getPrepareStepDetails().equals(other.getPrepareStepDetails())) return false; + break; + case 3: + if (!getRedirectWritesStepDetails().equals(other.getRedirectWritesStepDetails())) + 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) + STEP_FIELD_NUMBER; + hash = (53 * hash) + step_; + switch (stepDetailsCase_) { + case 2: + hash = (37 * hash) + PREPARE_STEP_DETAILS_FIELD_NUMBER; + hash = (53 * hash) + getPrepareStepDetails().hashCode(); + break; + case 3: + hash = (37 * hash) + REDIRECT_WRITES_STEP_DETAILS_FIELD_NUMBER; + hash = (53 * hash) + getRedirectWritesStepDetails().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent 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.datastore.admin.v1.MigrationProgressEvent parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.MigrationProgressEvent 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * An event signifying the start of a new step in a [migration from Cloud
+   * Datastore to Cloud Firestore in Datastore
+   * mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore).
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.MigrationProgressEvent} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.MigrationProgressEvent) + com.google.datastore.admin.v1.MigrationProgressEventOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.MigrationProgressEvent.class, + com.google.datastore.admin.v1.MigrationProgressEvent.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.MigrationProgressEvent.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + step_ = 0; + if (prepareStepDetailsBuilder_ != null) { + prepareStepDetailsBuilder_.clear(); + } + if (redirectWritesStepDetailsBuilder_ != null) { + redirectWritesStepDetailsBuilder_.clear(); + } + stepDetailsCase_ = 0; + stepDetails_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationProgressEvent_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent getDefaultInstanceForType() { + return com.google.datastore.admin.v1.MigrationProgressEvent.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent build() { + com.google.datastore.admin.v1.MigrationProgressEvent result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent buildPartial() { + com.google.datastore.admin.v1.MigrationProgressEvent result = + new com.google.datastore.admin.v1.MigrationProgressEvent(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.MigrationProgressEvent result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.step_ = step_; + } + } + + private void buildPartialOneofs(com.google.datastore.admin.v1.MigrationProgressEvent result) { + result.stepDetailsCase_ = stepDetailsCase_; + result.stepDetails_ = this.stepDetails_; + if (stepDetailsCase_ == 2 && prepareStepDetailsBuilder_ != null) { + result.stepDetails_ = prepareStepDetailsBuilder_.build(); + } + if (stepDetailsCase_ == 3 && redirectWritesStepDetailsBuilder_ != null) { + result.stepDetails_ = redirectWritesStepDetailsBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.MigrationProgressEvent) { + return mergeFrom((com.google.datastore.admin.v1.MigrationProgressEvent) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.MigrationProgressEvent other) { + if (other == com.google.datastore.admin.v1.MigrationProgressEvent.getDefaultInstance()) + return this; + if (other.step_ != 0) { + setStepValue(other.getStepValue()); + } + switch (other.getStepDetailsCase()) { + case PREPARE_STEP_DETAILS: + { + mergePrepareStepDetails(other.getPrepareStepDetails()); + break; + } + case REDIRECT_WRITES_STEP_DETAILS: + { + mergeRedirectWritesStepDetails(other.getRedirectWritesStepDetails()); + break; + } + case STEPDETAILS_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: + { + step_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 18: + { + input.readMessage( + getPrepareStepDetailsFieldBuilder().getBuilder(), extensionRegistry); + stepDetailsCase_ = 2; + break; + } // case 18 + case 26: + { + input.readMessage( + getRedirectWritesStepDetailsFieldBuilder().getBuilder(), extensionRegistry); + stepDetailsCase_ = 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 stepDetailsCase_ = 0; + private java.lang.Object stepDetails_; + + public StepDetailsCase getStepDetailsCase() { + return StepDetailsCase.forNumber(stepDetailsCase_); + } + + public Builder clearStepDetails() { + stepDetailsCase_ = 0; + stepDetails_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private int step_ = 0; + + /** + * + * + *
+     * The step that is starting.
+     *
+     * An event with step set to `START` indicates that the migration
+     * has been reverted back to the initial pre-migration state.
+     * 
+ * + * .google.datastore.admin.v1.MigrationStep step = 1; + * + * @return The enum numeric value on the wire for step. + */ + @java.lang.Override + public int getStepValue() { + return step_; + } + + /** + * + * + *
+     * The step that is starting.
+     *
+     * An event with step set to `START` indicates that the migration
+     * has been reverted back to the initial pre-migration state.
+     * 
+ * + * .google.datastore.admin.v1.MigrationStep step = 1; + * + * @param value The enum numeric value on the wire for step to set. + * @return This builder for chaining. + */ + public Builder setStepValue(int value) { + step_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The step that is starting.
+     *
+     * An event with step set to `START` indicates that the migration
+     * has been reverted back to the initial pre-migration state.
+     * 
+ * + * .google.datastore.admin.v1.MigrationStep step = 1; + * + * @return The step. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationStep getStep() { + com.google.datastore.admin.v1.MigrationStep result = + com.google.datastore.admin.v1.MigrationStep.forNumber(step_); + return result == null ? com.google.datastore.admin.v1.MigrationStep.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The step that is starting.
+     *
+     * An event with step set to `START` indicates that the migration
+     * has been reverted back to the initial pre-migration state.
+     * 
+ * + * .google.datastore.admin.v1.MigrationStep step = 1; + * + * @param value The step to set. + * @return This builder for chaining. + */ + public Builder setStep(com.google.datastore.admin.v1.MigrationStep value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + step_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The step that is starting.
+     *
+     * An event with step set to `START` indicates that the migration
+     * has been reverted back to the initial pre-migration state.
+     * 
+ * + * .google.datastore.admin.v1.MigrationStep step = 1; + * + * @return This builder for chaining. + */ + public Builder clearStep() { + bitField0_ = (bitField0_ & ~0x00000001); + step_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails, + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.Builder, + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetailsOrBuilder> + prepareStepDetailsBuilder_; + + /** + * + * + *
+     * Details for the `PREPARE` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + * + * @return Whether the prepareStepDetails field is set. + */ + @java.lang.Override + public boolean hasPrepareStepDetails() { + return stepDetailsCase_ == 2; + } + + /** + * + * + *
+     * Details for the `PREPARE` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + * + * @return The prepareStepDetails. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + getPrepareStepDetails() { + if (prepareStepDetailsBuilder_ == null) { + if (stepDetailsCase_ == 2) { + return (com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + stepDetails_; + } + return com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + .getDefaultInstance(); + } else { + if (stepDetailsCase_ == 2) { + return prepareStepDetailsBuilder_.getMessage(); + } + return com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + .getDefaultInstance(); + } + } + + /** + * + * + *
+     * Details for the `PREPARE` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + */ + public Builder setPrepareStepDetails( + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails value) { + if (prepareStepDetailsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + stepDetails_ = value; + onChanged(); + } else { + prepareStepDetailsBuilder_.setMessage(value); + } + stepDetailsCase_ = 2; + return this; + } + + /** + * + * + *
+     * Details for the `PREPARE` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + */ + public Builder setPrepareStepDetails( + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.Builder + builderForValue) { + if (prepareStepDetailsBuilder_ == null) { + stepDetails_ = builderForValue.build(); + onChanged(); + } else { + prepareStepDetailsBuilder_.setMessage(builderForValue.build()); + } + stepDetailsCase_ = 2; + return this; + } + + /** + * + * + *
+     * Details for the `PREPARE` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + */ + public Builder mergePrepareStepDetails( + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails value) { + if (prepareStepDetailsBuilder_ == null) { + if (stepDetailsCase_ == 2 + && stepDetails_ + != com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + .getDefaultInstance()) { + stepDetails_ = + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.newBuilder( + (com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + stepDetails_) + .mergeFrom(value) + .buildPartial(); + } else { + stepDetails_ = value; + } + onChanged(); + } else { + if (stepDetailsCase_ == 2) { + prepareStepDetailsBuilder_.mergeFrom(value); + } else { + prepareStepDetailsBuilder_.setMessage(value); + } + } + stepDetailsCase_ = 2; + return this; + } + + /** + * + * + *
+     * Details for the `PREPARE` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + */ + public Builder clearPrepareStepDetails() { + if (prepareStepDetailsBuilder_ == null) { + if (stepDetailsCase_ == 2) { + stepDetailsCase_ = 0; + stepDetails_ = null; + onChanged(); + } + } else { + if (stepDetailsCase_ == 2) { + stepDetailsCase_ = 0; + stepDetails_ = null; + } + prepareStepDetailsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Details for the `PREPARE` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + */ + public com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.Builder + getPrepareStepDetailsBuilder() { + return getPrepareStepDetailsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Details for the `PREPARE` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetailsOrBuilder + getPrepareStepDetailsOrBuilder() { + if ((stepDetailsCase_ == 2) && (prepareStepDetailsBuilder_ != null)) { + return prepareStepDetailsBuilder_.getMessageOrBuilder(); + } else { + if (stepDetailsCase_ == 2) { + return (com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + stepDetails_; + } + return com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + .getDefaultInstance(); + } + } + + /** + * + * + *
+     * Details for the `PREPARE` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails, + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.Builder, + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetailsOrBuilder> + getPrepareStepDetailsFieldBuilder() { + if (prepareStepDetailsBuilder_ == null) { + if (!(stepDetailsCase_ == 2)) { + stepDetails_ = + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails + .getDefaultInstance(); + } + prepareStepDetailsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails, + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails.Builder, + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetailsOrBuilder>( + (com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails) + stepDetails_, + getParentForChildren(), + isClean()); + stepDetails_ = null; + } + stepDetailsCase_ = 2; + onChanged(); + return prepareStepDetailsBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails, + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.Builder, + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetailsOrBuilder> + redirectWritesStepDetailsBuilder_; + + /** + * + * + *
+     * Details for the `REDIRECT_WRITES` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + * + * @return Whether the redirectWritesStepDetails field is set. + */ + @java.lang.Override + public boolean hasRedirectWritesStepDetails() { + return stepDetailsCase_ == 3; + } + + /** + * + * + *
+     * Details for the `REDIRECT_WRITES` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + * + * @return The redirectWritesStepDetails. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + getRedirectWritesStepDetails() { + if (redirectWritesStepDetailsBuilder_ == null) { + if (stepDetailsCase_ == 3) { + return (com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + stepDetails_; + } + return com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .getDefaultInstance(); + } else { + if (stepDetailsCase_ == 3) { + return redirectWritesStepDetailsBuilder_.getMessage(); + } + return com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .getDefaultInstance(); + } + } + + /** + * + * + *
+     * Details for the `REDIRECT_WRITES` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + */ + public Builder setRedirectWritesStepDetails( + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails value) { + if (redirectWritesStepDetailsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + stepDetails_ = value; + onChanged(); + } else { + redirectWritesStepDetailsBuilder_.setMessage(value); + } + stepDetailsCase_ = 3; + return this; + } + + /** + * + * + *
+     * Details for the `REDIRECT_WRITES` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + */ + public Builder setRedirectWritesStepDetails( + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.Builder + builderForValue) { + if (redirectWritesStepDetailsBuilder_ == null) { + stepDetails_ = builderForValue.build(); + onChanged(); + } else { + redirectWritesStepDetailsBuilder_.setMessage(builderForValue.build()); + } + stepDetailsCase_ = 3; + return this; + } + + /** + * + * + *
+     * Details for the `REDIRECT_WRITES` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + */ + public Builder mergeRedirectWritesStepDetails( + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails value) { + if (redirectWritesStepDetailsBuilder_ == null) { + if (stepDetailsCase_ == 3 + && stepDetails_ + != com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .getDefaultInstance()) { + stepDetails_ = + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .newBuilder( + (com.google.datastore.admin.v1.MigrationProgressEvent + .RedirectWritesStepDetails) + stepDetails_) + .mergeFrom(value) + .buildPartial(); + } else { + stepDetails_ = value; + } + onChanged(); + } else { + if (stepDetailsCase_ == 3) { + redirectWritesStepDetailsBuilder_.mergeFrom(value); + } else { + redirectWritesStepDetailsBuilder_.setMessage(value); + } + } + stepDetailsCase_ = 3; + return this; + } + + /** + * + * + *
+     * Details for the `REDIRECT_WRITES` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + */ + public Builder clearRedirectWritesStepDetails() { + if (redirectWritesStepDetailsBuilder_ == null) { + if (stepDetailsCase_ == 3) { + stepDetailsCase_ = 0; + stepDetails_ = null; + onChanged(); + } + } else { + if (stepDetailsCase_ == 3) { + stepDetailsCase_ = 0; + stepDetails_ = null; + } + redirectWritesStepDetailsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Details for the `REDIRECT_WRITES` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + */ + public com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.Builder + getRedirectWritesStepDetailsBuilder() { + return getRedirectWritesStepDetailsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Details for the `REDIRECT_WRITES` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetailsOrBuilder + getRedirectWritesStepDetailsOrBuilder() { + if ((stepDetailsCase_ == 3) && (redirectWritesStepDetailsBuilder_ != null)) { + return redirectWritesStepDetailsBuilder_.getMessageOrBuilder(); + } else { + if (stepDetailsCase_ == 3) { + return (com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + stepDetails_; + } + return com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .getDefaultInstance(); + } + } + + /** + * + * + *
+     * Details for the `REDIRECT_WRITES` step.
+     * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails, + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails.Builder, + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetailsOrBuilder> + getRedirectWritesStepDetailsFieldBuilder() { + if (redirectWritesStepDetailsBuilder_ == null) { + if (!(stepDetailsCase_ == 3)) { + stepDetails_ = + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .getDefaultInstance(); + } + redirectWritesStepDetailsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails, + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + .Builder, + com.google.datastore.admin.v1.MigrationProgressEvent + .RedirectWritesStepDetailsOrBuilder>( + (com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails) + stepDetails_, + getParentForChildren(), + isClean()); + stepDetails_ = null; + } + stepDetailsCase_ = 3; + onChanged(); + return redirectWritesStepDetailsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.MigrationProgressEvent) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.MigrationProgressEvent) + private static final com.google.datastore.admin.v1.MigrationProgressEvent DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.MigrationProgressEvent(); + } + + public static com.google.datastore.admin.v1.MigrationProgressEvent getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MigrationProgressEvent 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.datastore.admin.v1.MigrationProgressEvent getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEventOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEventOrBuilder.java new file mode 100644 index 000000000000..b9bef59e8118 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProgressEventOrBuilder.java @@ -0,0 +1,149 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/migration.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface MigrationProgressEventOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.MigrationProgressEvent) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The step that is starting.
+   *
+   * An event with step set to `START` indicates that the migration
+   * has been reverted back to the initial pre-migration state.
+   * 
+ * + * .google.datastore.admin.v1.MigrationStep step = 1; + * + * @return The enum numeric value on the wire for step. + */ + int getStepValue(); + + /** + * + * + *
+   * The step that is starting.
+   *
+   * An event with step set to `START` indicates that the migration
+   * has been reverted back to the initial pre-migration state.
+   * 
+ * + * .google.datastore.admin.v1.MigrationStep step = 1; + * + * @return The step. + */ + com.google.datastore.admin.v1.MigrationStep getStep(); + + /** + * + * + *
+   * Details for the `PREPARE` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + * + * @return Whether the prepareStepDetails field is set. + */ + boolean hasPrepareStepDetails(); + + /** + * + * + *
+   * Details for the `PREPARE` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + * + * @return The prepareStepDetails. + */ + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails getPrepareStepDetails(); + + /** + * + * + *
+   * Details for the `PREPARE` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetails prepare_step_details = 2; + * + */ + com.google.datastore.admin.v1.MigrationProgressEvent.PrepareStepDetailsOrBuilder + getPrepareStepDetailsOrBuilder(); + + /** + * + * + *
+   * Details for the `REDIRECT_WRITES` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + * + * @return Whether the redirectWritesStepDetails field is set. + */ + boolean hasRedirectWritesStepDetails(); + + /** + * + * + *
+   * Details for the `REDIRECT_WRITES` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + * + * @return The redirectWritesStepDetails. + */ + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails + getRedirectWritesStepDetails(); + + /** + * + * + *
+   * Details for the `REDIRECT_WRITES` step.
+   * 
+ * + * + * .google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetails redirect_writes_step_details = 3; + * + */ + com.google.datastore.admin.v1.MigrationProgressEvent.RedirectWritesStepDetailsOrBuilder + getRedirectWritesStepDetailsOrBuilder(); + + com.google.datastore.admin.v1.MigrationProgressEvent.StepDetailsCase getStepDetailsCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProto.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProto.java new file mode 100644 index 000000000000..468872235aa5 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationProto.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! +// source: google/datastore/admin/v1/migration.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public final class MigrationProto { + private MigrationProto() {} + + 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_datastore_admin_v1_MigrationStateEvent_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_MigrationStateEvent_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_MigrationProgressEvent_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_MigrationProgressEvent_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_MigrationProgressEvent_PrepareStepDetails_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_MigrationProgressEvent_PrepareStepDetails_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_admin_v1_MigrationProgressEvent_RedirectWritesStepDetails_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_admin_v1_MigrationProgressEvent_RedirectWritesStepDetails_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/datastore/admin/v1/migration.pr" + + "oto\022\031google.datastore.admin.v1\"O\n\023Migrat" + + "ionStateEvent\0228\n\005state\030\001 \001(\0162).google.da" + + "tastore.admin.v1.MigrationState\"\241\005\n\026Migr" + + "ationProgressEvent\0226\n\004step\030\001 \001(\0162(.googl" + + "e.datastore.admin.v1.MigrationStep\022d\n\024pr" + + "epare_step_details\030\002 \001(\0132D.google.datast" + + "ore.admin.v1.MigrationProgressEvent.Prep" + + "areStepDetailsH\000\022s\n\034redirect_writes_step" + + "_details\030\003 \001(\0132K.google.datastore.admin." + + "v1.MigrationProgressEvent.RedirectWrites" + + "StepDetailsH\000\032q\n\022PrepareStepDetails\022[\n\020c" + + "oncurrency_mode\030\001 \001(\0162A.google.datastore" + + ".admin.v1.MigrationProgressEvent.Concurr" + + "encyMode\032x\n\031RedirectWritesStepDetails\022[\n" + + "\020concurrency_mode\030\001 \001(\0162A.google.datasto" + + "re.admin.v1.MigrationProgressEvent.Concu" + + "rrencyMode\"w\n\017ConcurrencyMode\022 \n\034CONCURR" + + "ENCY_MODE_UNSPECIFIED\020\000\022\017\n\013PESSIMISTIC\020\001" + + "\022\016\n\nOPTIMISTIC\020\002\022!\n\035OPTIMISTIC_WITH_ENTI" + + "TY_GROUPS\020\003B\016\n\014step_details*X\n\016Migration" + + "State\022\037\n\033MIGRATION_STATE_UNSPECIFIED\020\000\022\013" + + "\n\007RUNNING\020\001\022\n\n\006PAUSED\020\002\022\014\n\010COMPLETE\020\003*\343\001" + + "\n\rMigrationStep\022\036\n\032MIGRATION_STEP_UNSPEC" + + "IFIED\020\000\022\013\n\007PREPARE\020\006\022\t\n\005START\020\001\022\036\n\032APPLY" + + "_WRITES_SYNCHRONOUSLY\020\007\022\023\n\017COPY_AND_VERI" + + "FY\020\002\022(\n$REDIRECT_EVENTUALLY_CONSISTENT_R" + + "EADS\020\003\022&\n\"REDIRECT_STRONGLY_CONSISTENT_R" + + "EADS\020\004\022\023\n\017REDIRECT_WRITES\020\005B\326\001\n\035com.goog" + + "le.datastore.admin.v1B\016MigrationProtoP\001Z" + + "9cloud.google.com/go/datastore/admin/api" + + "v1/adminpb;adminpb\252\002\037Google.Cloud.Datast" + + "ore.Admin.V1\312\002\037Google\\Cloud\\Datastore\\Ad" + + "min\\V1\352\002#Google::Cloud::Datastore::Admin" + + "::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] {}); + internal_static_google_datastore_admin_v1_MigrationStateEvent_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_datastore_admin_v1_MigrationStateEvent_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_MigrationStateEvent_descriptor, + new java.lang.String[] { + "State", + }); + internal_static_google_datastore_admin_v1_MigrationProgressEvent_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_datastore_admin_v1_MigrationProgressEvent_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_MigrationProgressEvent_descriptor, + new java.lang.String[] { + "Step", "PrepareStepDetails", "RedirectWritesStepDetails", "StepDetails", + }); + internal_static_google_datastore_admin_v1_MigrationProgressEvent_PrepareStepDetails_descriptor = + internal_static_google_datastore_admin_v1_MigrationProgressEvent_descriptor + .getNestedTypes() + .get(0); + internal_static_google_datastore_admin_v1_MigrationProgressEvent_PrepareStepDetails_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_MigrationProgressEvent_PrepareStepDetails_descriptor, + new java.lang.String[] { + "ConcurrencyMode", + }); + internal_static_google_datastore_admin_v1_MigrationProgressEvent_RedirectWritesStepDetails_descriptor = + internal_static_google_datastore_admin_v1_MigrationProgressEvent_descriptor + .getNestedTypes() + .get(1); + internal_static_google_datastore_admin_v1_MigrationProgressEvent_RedirectWritesStepDetails_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_admin_v1_MigrationProgressEvent_RedirectWritesStepDetails_descriptor, + new java.lang.String[] { + "ConcurrencyMode", + }); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationState.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationState.java new file mode 100644 index 000000000000..e710319806e8 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationState.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! +// source: google/datastore/admin/v1/migration.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * States for a migration.
+ * 
+ * + * Protobuf enum {@code google.datastore.admin.v1.MigrationState} + */ +public enum MigrationState implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+   * Unspecified.
+   * 
+ * + * MIGRATION_STATE_UNSPECIFIED = 0; + */ + MIGRATION_STATE_UNSPECIFIED(0), + /** + * + * + *
+   * The migration is running.
+   * 
+ * + * RUNNING = 1; + */ + RUNNING(1), + /** + * + * + *
+   * The migration is paused.
+   * 
+ * + * PAUSED = 2; + */ + PAUSED(2), + /** + * + * + *
+   * The migration is complete.
+   * 
+ * + * COMPLETE = 3; + */ + COMPLETE(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+   * Unspecified.
+   * 
+ * + * MIGRATION_STATE_UNSPECIFIED = 0; + */ + public static final int MIGRATION_STATE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+   * The migration is running.
+   * 
+ * + * RUNNING = 1; + */ + public static final int RUNNING_VALUE = 1; + + /** + * + * + *
+   * The migration is paused.
+   * 
+ * + * PAUSED = 2; + */ + public static final int PAUSED_VALUE = 2; + + /** + * + * + *
+   * The migration is complete.
+   * 
+ * + * COMPLETE = 3; + */ + public static final int COMPLETE_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 MigrationState 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 MigrationState forNumber(int value) { + switch (value) { + case 0: + return MIGRATION_STATE_UNSPECIFIED; + case 1: + return RUNNING; + case 2: + return PAUSED; + case 3: + return COMPLETE; + 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 MigrationState findValueByNumber(int number) { + return MigrationState.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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProto.getDescriptor().getEnumTypes().get(0); + } + + private static final MigrationState[] VALUES = values(); + + public static MigrationState 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 MigrationState(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.admin.v1.MigrationState) +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEvent.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEvent.java new file mode 100644 index 000000000000..3a2992566f24 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEvent.java @@ -0,0 +1,606 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/migration.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * An event signifying a change in state of a [migration from Cloud Datastore to
+ * Cloud Firestore in Datastore
+ * mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore).
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.MigrationStateEvent} + */ +public final class MigrationStateEvent extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.MigrationStateEvent) + MigrationStateEventOrBuilder { + private static final long serialVersionUID = 0L; + + // Use MigrationStateEvent.newBuilder() to construct. + private MigrationStateEvent(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private MigrationStateEvent() { + state_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new MigrationStateEvent(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationStateEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationStateEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.MigrationStateEvent.class, + com.google.datastore.admin.v1.MigrationStateEvent.Builder.class); + } + + public static final int STATE_FIELD_NUMBER = 1; + private int state_ = 0; + + /** + * + * + *
+   * The new state of the migration.
+   * 
+ * + * .google.datastore.admin.v1.MigrationState state = 1; + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+   * The new state of the migration.
+   * 
+ * + * .google.datastore.admin.v1.MigrationState state = 1; + * + * @return The state. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationState getState() { + com.google.datastore.admin.v1.MigrationState result = + com.google.datastore.admin.v1.MigrationState.forNumber(state_); + return result == null ? com.google.datastore.admin.v1.MigrationState.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.datastore.admin.v1.MigrationState.MIGRATION_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.datastore.admin.v1.MigrationState.MIGRATION_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.datastore.admin.v1.MigrationStateEvent)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.MigrationStateEvent other = + (com.google.datastore.admin.v1.MigrationStateEvent) 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.datastore.admin.v1.MigrationStateEvent parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent 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.datastore.admin.v1.MigrationStateEvent parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.MigrationStateEvent 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * An event signifying a change in state of a [migration from Cloud Datastore to
+   * Cloud Firestore in Datastore
+   * mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore).
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.MigrationStateEvent} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.MigrationStateEvent) + com.google.datastore.admin.v1.MigrationStateEventOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationStateEvent_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationStateEvent_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.MigrationStateEvent.class, + com.google.datastore.admin.v1.MigrationStateEvent.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.MigrationStateEvent.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.admin.v1.MigrationProto + .internal_static_google_datastore_admin_v1_MigrationStateEvent_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationStateEvent getDefaultInstanceForType() { + return com.google.datastore.admin.v1.MigrationStateEvent.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationStateEvent build() { + com.google.datastore.admin.v1.MigrationStateEvent result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.MigrationStateEvent buildPartial() { + com.google.datastore.admin.v1.MigrationStateEvent result = + new com.google.datastore.admin.v1.MigrationStateEvent(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.MigrationStateEvent result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.state_ = state_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.MigrationStateEvent) { + return mergeFrom((com.google.datastore.admin.v1.MigrationStateEvent) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.MigrationStateEvent other) { + if (other == com.google.datastore.admin.v1.MigrationStateEvent.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; + + /** + * + * + *
+     * The new state of the migration.
+     * 
+ * + * .google.datastore.admin.v1.MigrationState state = 1; + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + + /** + * + * + *
+     * The new state of the migration.
+     * 
+ * + * .google.datastore.admin.v1.MigrationState state = 1; + * + * @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; + } + + /** + * + * + *
+     * The new state of the migration.
+     * 
+ * + * .google.datastore.admin.v1.MigrationState state = 1; + * + * @return The state. + */ + @java.lang.Override + public com.google.datastore.admin.v1.MigrationState getState() { + com.google.datastore.admin.v1.MigrationState result = + com.google.datastore.admin.v1.MigrationState.forNumber(state_); + return result == null ? com.google.datastore.admin.v1.MigrationState.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The new state of the migration.
+     * 
+ * + * .google.datastore.admin.v1.MigrationState state = 1; + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.datastore.admin.v1.MigrationState value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + state_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The new state of the migration.
+     * 
+ * + * .google.datastore.admin.v1.MigrationState state = 1; + * + * @return This builder for chaining. + */ + public Builder clearState() { + bitField0_ = (bitField0_ & ~0x00000001); + state_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.MigrationStateEvent) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.MigrationStateEvent) + private static final com.google.datastore.admin.v1.MigrationStateEvent DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.MigrationStateEvent(); + } + + public static com.google.datastore.admin.v1.MigrationStateEvent getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MigrationStateEvent 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.datastore.admin.v1.MigrationStateEvent getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEventOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEventOrBuilder.java new file mode 100644 index 000000000000..149b7b43c8d2 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStateEventOrBuilder.java @@ -0,0 +1,52 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/migration.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface MigrationStateEventOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.MigrationStateEvent) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The new state of the migration.
+   * 
+ * + * .google.datastore.admin.v1.MigrationState state = 1; + * + * @return The enum numeric value on the wire for state. + */ + int getStateValue(); + + /** + * + * + *
+   * The new state of the migration.
+   * 
+ * + * .google.datastore.admin.v1.MigrationState state = 1; + * + * @return The state. + */ + com.google.datastore.admin.v1.MigrationState getState(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStep.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStep.java new file mode 100644 index 000000000000..9f9e47d9d1dc --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/MigrationStep.java @@ -0,0 +1,296 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/migration.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * Steps in a migration.
+ * 
+ * + * Protobuf enum {@code google.datastore.admin.v1.MigrationStep} + */ +public enum MigrationStep implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+   * Unspecified.
+   * 
+ * + * MIGRATION_STEP_UNSPECIFIED = 0; + */ + MIGRATION_STEP_UNSPECIFIED(0), + /** + * + * + *
+   * Pre-migration: the database is prepared for migration.
+   * 
+ * + * PREPARE = 6; + */ + PREPARE(6), + /** + * + * + *
+   * Start of migration.
+   * 
+ * + * START = 1; + */ + START(1), + /** + * + * + *
+   * Writes are applied synchronously to at least one replica.
+   * 
+ * + * APPLY_WRITES_SYNCHRONOUSLY = 7; + */ + APPLY_WRITES_SYNCHRONOUSLY(7), + /** + * + * + *
+   * Data is copied to Cloud Firestore and then verified to match the data in
+   * Cloud Datastore.
+   * 
+ * + * COPY_AND_VERIFY = 2; + */ + COPY_AND_VERIFY(2), + /** + * + * + *
+   * Eventually-consistent reads are redirected to Cloud Firestore.
+   * 
+ * + * REDIRECT_EVENTUALLY_CONSISTENT_READS = 3; + */ + REDIRECT_EVENTUALLY_CONSISTENT_READS(3), + /** + * + * + *
+   * Strongly-consistent reads are redirected to Cloud Firestore.
+   * 
+ * + * REDIRECT_STRONGLY_CONSISTENT_READS = 4; + */ + REDIRECT_STRONGLY_CONSISTENT_READS(4), + /** + * + * + *
+   * Writes are redirected to Cloud Firestore.
+   * 
+ * + * REDIRECT_WRITES = 5; + */ + REDIRECT_WRITES(5), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+   * Unspecified.
+   * 
+ * + * MIGRATION_STEP_UNSPECIFIED = 0; + */ + public static final int MIGRATION_STEP_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+   * Pre-migration: the database is prepared for migration.
+   * 
+ * + * PREPARE = 6; + */ + public static final int PREPARE_VALUE = 6; + + /** + * + * + *
+   * Start of migration.
+   * 
+ * + * START = 1; + */ + public static final int START_VALUE = 1; + + /** + * + * + *
+   * Writes are applied synchronously to at least one replica.
+   * 
+ * + * APPLY_WRITES_SYNCHRONOUSLY = 7; + */ + public static final int APPLY_WRITES_SYNCHRONOUSLY_VALUE = 7; + + /** + * + * + *
+   * Data is copied to Cloud Firestore and then verified to match the data in
+   * Cloud Datastore.
+   * 
+ * + * COPY_AND_VERIFY = 2; + */ + public static final int COPY_AND_VERIFY_VALUE = 2; + + /** + * + * + *
+   * Eventually-consistent reads are redirected to Cloud Firestore.
+   * 
+ * + * REDIRECT_EVENTUALLY_CONSISTENT_READS = 3; + */ + public static final int REDIRECT_EVENTUALLY_CONSISTENT_READS_VALUE = 3; + + /** + * + * + *
+   * Strongly-consistent reads are redirected to Cloud Firestore.
+   * 
+ * + * REDIRECT_STRONGLY_CONSISTENT_READS = 4; + */ + public static final int REDIRECT_STRONGLY_CONSISTENT_READS_VALUE = 4; + + /** + * + * + *
+   * Writes are redirected to Cloud Firestore.
+   * 
+ * + * REDIRECT_WRITES = 5; + */ + public static final int REDIRECT_WRITES_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 MigrationStep 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 MigrationStep forNumber(int value) { + switch (value) { + case 0: + return MIGRATION_STEP_UNSPECIFIED; + case 6: + return PREPARE; + case 1: + return START; + case 7: + return APPLY_WRITES_SYNCHRONOUSLY; + case 2: + return COPY_AND_VERIFY; + case 3: + return REDIRECT_EVENTUALLY_CONSISTENT_READS; + case 4: + return REDIRECT_STRONGLY_CONSISTENT_READS; + case 5: + return REDIRECT_WRITES; + 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 MigrationStep findValueByNumber(int number) { + return MigrationStep.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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.admin.v1.MigrationProto.getDescriptor().getEnumTypes().get(1); + } + + private static final MigrationStep[] VALUES = values(); + + public static MigrationStep 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 MigrationStep(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.admin.v1.MigrationStep) +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/OperationType.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/OperationType.java new file mode 100644 index 000000000000..14a178bdb705 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/OperationType.java @@ -0,0 +1,225 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * Operation types.
+ * 
+ * + * Protobuf enum {@code google.datastore.admin.v1.OperationType} + */ +public enum OperationType implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+   * Unspecified.
+   * 
+ * + * OPERATION_TYPE_UNSPECIFIED = 0; + */ + OPERATION_TYPE_UNSPECIFIED(0), + /** + * + * + *
+   * ExportEntities.
+   * 
+ * + * EXPORT_ENTITIES = 1; + */ + EXPORT_ENTITIES(1), + /** + * + * + *
+   * ImportEntities.
+   * 
+ * + * IMPORT_ENTITIES = 2; + */ + IMPORT_ENTITIES(2), + /** + * + * + *
+   * CreateIndex.
+   * 
+ * + * CREATE_INDEX = 3; + */ + CREATE_INDEX(3), + /** + * + * + *
+   * DeleteIndex.
+   * 
+ * + * DELETE_INDEX = 4; + */ + DELETE_INDEX(4), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+   * Unspecified.
+   * 
+ * + * OPERATION_TYPE_UNSPECIFIED = 0; + */ + public static final int OPERATION_TYPE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+   * ExportEntities.
+   * 
+ * + * EXPORT_ENTITIES = 1; + */ + public static final int EXPORT_ENTITIES_VALUE = 1; + + /** + * + * + *
+   * ImportEntities.
+   * 
+ * + * IMPORT_ENTITIES = 2; + */ + public static final int IMPORT_ENTITIES_VALUE = 2; + + /** + * + * + *
+   * CreateIndex.
+   * 
+ * + * CREATE_INDEX = 3; + */ + public static final int CREATE_INDEX_VALUE = 3; + + /** + * + * + *
+   * DeleteIndex.
+   * 
+ * + * DELETE_INDEX = 4; + */ + public static final int DELETE_INDEX_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 OperationType 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 OperationType forNumber(int value) { + switch (value) { + case 0: + return OPERATION_TYPE_UNSPECIFIED; + case 1: + return EXPORT_ENTITIES; + case 2: + return IMPORT_ENTITIES; + case 3: + return CREATE_INDEX; + case 4: + return DELETE_INDEX; + 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 OperationType findValueByNumber(int number) { + return OperationType.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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto.getDescriptor().getEnumTypes().get(0); + } + + private static final OperationType[] VALUES = values(); + + public static OperationType 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 OperationType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.admin.v1.OperationType) +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Progress.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Progress.java new file mode 100644 index 000000000000..226d3fdd3165 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/Progress.java @@ -0,0 +1,644 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +/** + * + * + *
+ * Measures the progress of a particular metric.
+ * 
+ * + * Protobuf type {@code google.datastore.admin.v1.Progress} + */ +public final class Progress extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.admin.v1.Progress) + ProgressOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Progress.newBuilder() to construct. + private Progress(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Progress() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Progress(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_Progress_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_Progress_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.Progress.class, + com.google.datastore.admin.v1.Progress.Builder.class); + } + + public static final int WORK_COMPLETED_FIELD_NUMBER = 1; + private long workCompleted_ = 0L; + + /** + * + * + *
+   * The amount of work that has been completed. Note that this may be greater
+   * than work_estimated.
+   * 
+ * + * int64 work_completed = 1; + * + * @return The workCompleted. + */ + @java.lang.Override + public long getWorkCompleted() { + return workCompleted_; + } + + public static final int WORK_ESTIMATED_FIELD_NUMBER = 2; + private long workEstimated_ = 0L; + + /** + * + * + *
+   * An estimate of how much work needs to be performed. May be zero if the
+   * work estimate is unavailable.
+   * 
+ * + * int64 work_estimated = 2; + * + * @return The workEstimated. + */ + @java.lang.Override + public long getWorkEstimated() { + return workEstimated_; + } + + 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 (workCompleted_ != 0L) { + output.writeInt64(1, workCompleted_); + } + if (workEstimated_ != 0L) { + output.writeInt64(2, workEstimated_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (workCompleted_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(1, workCompleted_); + } + if (workEstimated_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(2, workEstimated_); + } + 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.datastore.admin.v1.Progress)) { + return super.equals(obj); + } + com.google.datastore.admin.v1.Progress other = (com.google.datastore.admin.v1.Progress) obj; + + if (getWorkCompleted() != other.getWorkCompleted()) return false; + if (getWorkEstimated() != other.getWorkEstimated()) 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) + WORK_COMPLETED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getWorkCompleted()); + hash = (37 * hash) + WORK_ESTIMATED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getWorkEstimated()); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.admin.v1.Progress parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.Progress parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.Progress parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.admin.v1.Progress parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.Progress parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.Progress parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.Progress parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.admin.v1.Progress parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.admin.v1.Progress parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Measures the progress of a particular metric.
+   * 
+ * + * Protobuf type {@code google.datastore.admin.v1.Progress} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.admin.v1.Progress) + com.google.datastore.admin.v1.ProgressOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_Progress_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_Progress_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.admin.v1.Progress.class, + com.google.datastore.admin.v1.Progress.Builder.class); + } + + // Construct using com.google.datastore.admin.v1.Progress.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + workCompleted_ = 0L; + workEstimated_ = 0L; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.admin.v1.DatastoreAdminProto + .internal_static_google_datastore_admin_v1_Progress_descriptor; + } + + @java.lang.Override + public com.google.datastore.admin.v1.Progress getDefaultInstanceForType() { + return com.google.datastore.admin.v1.Progress.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.admin.v1.Progress build() { + com.google.datastore.admin.v1.Progress result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.admin.v1.Progress buildPartial() { + com.google.datastore.admin.v1.Progress result = + new com.google.datastore.admin.v1.Progress(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.admin.v1.Progress result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.workCompleted_ = workCompleted_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.workEstimated_ = workEstimated_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.admin.v1.Progress) { + return mergeFrom((com.google.datastore.admin.v1.Progress) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.admin.v1.Progress other) { + if (other == com.google.datastore.admin.v1.Progress.getDefaultInstance()) return this; + if (other.getWorkCompleted() != 0L) { + setWorkCompleted(other.getWorkCompleted()); + } + if (other.getWorkEstimated() != 0L) { + setWorkEstimated(other.getWorkEstimated()); + } + 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: + { + workCompleted_ = input.readInt64(); + bitField0_ |= 0x00000001; + break; + } // case 8 + case 16: + { + workEstimated_ = 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 workCompleted_; + + /** + * + * + *
+     * The amount of work that has been completed. Note that this may be greater
+     * than work_estimated.
+     * 
+ * + * int64 work_completed = 1; + * + * @return The workCompleted. + */ + @java.lang.Override + public long getWorkCompleted() { + return workCompleted_; + } + + /** + * + * + *
+     * The amount of work that has been completed. Note that this may be greater
+     * than work_estimated.
+     * 
+ * + * int64 work_completed = 1; + * + * @param value The workCompleted to set. + * @return This builder for chaining. + */ + public Builder setWorkCompleted(long value) { + + workCompleted_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The amount of work that has been completed. Note that this may be greater
+     * than work_estimated.
+     * 
+ * + * int64 work_completed = 1; + * + * @return This builder for chaining. + */ + public Builder clearWorkCompleted() { + bitField0_ = (bitField0_ & ~0x00000001); + workCompleted_ = 0L; + onChanged(); + return this; + } + + private long workEstimated_; + + /** + * + * + *
+     * An estimate of how much work needs to be performed. May be zero if the
+     * work estimate is unavailable.
+     * 
+ * + * int64 work_estimated = 2; + * + * @return The workEstimated. + */ + @java.lang.Override + public long getWorkEstimated() { + return workEstimated_; + } + + /** + * + * + *
+     * An estimate of how much work needs to be performed. May be zero if the
+     * work estimate is unavailable.
+     * 
+ * + * int64 work_estimated = 2; + * + * @param value The workEstimated to set. + * @return This builder for chaining. + */ + public Builder setWorkEstimated(long value) { + + workEstimated_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * An estimate of how much work needs to be performed. May be zero if the
+     * work estimate is unavailable.
+     * 
+ * + * int64 work_estimated = 2; + * + * @return This builder for chaining. + */ + public Builder clearWorkEstimated() { + bitField0_ = (bitField0_ & ~0x00000002); + workEstimated_ = 0L; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.admin.v1.Progress) + } + + // @@protoc_insertion_point(class_scope:google.datastore.admin.v1.Progress) + private static final com.google.datastore.admin.v1.Progress DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.admin.v1.Progress(); + } + + public static com.google.datastore.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.datastore.admin.v1.Progress getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ProgressOrBuilder.java b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/admin/v1/ProgressOrBuilder.java new file mode 100644 index 000000000000..9952e72f6090 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/java/com/google/datastore/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! +// source: google/datastore/admin/v1/datastore_admin.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.admin.v1; + +public interface ProgressOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.admin.v1.Progress) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The amount of work that has been completed. Note that this may be greater
+   * than work_estimated.
+   * 
+ * + * int64 work_completed = 1; + * + * @return The workCompleted. + */ + long getWorkCompleted(); + + /** + * + * + *
+   * An estimate of how much work needs to be performed. May be zero if the
+   * work estimate is unavailable.
+   * 
+ * + * int64 work_estimated = 2; + * + * @return The workEstimated. + */ + long getWorkEstimated(); +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/datastore_admin.proto b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/datastore_admin.proto new file mode 100644 index 000000000000..50c4d0cc87e3 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/datastore_admin.proto @@ -0,0 +1,506 @@ +// 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. + +syntax = "proto3"; + +package google.datastore.admin.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/datastore/admin/v1/index.proto"; +import "google/datastore/admin/v1/migration.proto"; +import "google/longrunning/operations.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; +option go_package = "cloud.google.com/go/datastore/admin/apiv1/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "DatastoreAdminProto"; +option java_package = "com.google.datastore.admin.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Datastore::Admin::V1"; + +// Google Cloud Datastore Admin API +// +// The Datastore Admin API provides several admin services for Cloud Datastore. +// +// Concepts: Project, namespace, kind, and entity as defined in the Google Cloud +// Datastore API. +// +// Operation: An Operation represents work being performed in the background. +// +// EntityFilter: Allows specifying a subset of entities in a project. This is +// specified as a combination of kinds and namespaces (either or both of which +// may be all). +// +// Export/Import Service: +// +// - The Export/Import service provides the ability to copy all or a subset of +// entities to/from Google Cloud Storage. +// - Exported data may be imported into Cloud Datastore for any Google Cloud +// Platform project. It is not restricted to the export source project. It is +// possible to export from one project and then import into another. +// - Exported data can also be loaded into Google BigQuery for analysis. +// - Exports and imports are performed asynchronously. An Operation resource is +// created for each export/import. The state (including any errors encountered) +// of the export/import may be queried via the Operation resource. +// +// Index Service: +// +// - The index service manages Cloud Datastore composite indexes. +// - Index creation and deletion are 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. +// +// Operation Service: +// +// - 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 not yet done may be cancelled. The request to cancel +// is asynchronous and the operation may continue to run for some time after the +// request to cancel is made. +// - An operation that is done may be deleted so that it is no longer listed as +// part of the Operation collection. +// - ListOperations returns all pending operations, but not completed +// operations. +// - Operations are created by service DatastoreAdmin, but are accessed via +// service google.longrunning.Operations. +service DatastoreAdmin { + option (google.api.default_host) = "datastore.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/datastore"; + + // Exports a copy of all or a subset of entities from Google Cloud Datastore + // to another storage system, such as Google Cloud Storage. Recent updates to + // entities 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. + rpc ExportEntities(ExportEntitiesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:export" + body: "*" + }; + option (google.api.method_signature) = + "project_id,labels,entity_filter,output_url_prefix"; + option (google.longrunning.operation_info) = { + response_type: "ExportEntitiesResponse" + metadata_type: "ExportEntitiesMetadata" + }; + } + + // Imports entities into Google Cloud Datastore. Existing entities with the + // same key 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 ImportEntities operation is cancelled, it is possible + // that a subset of the data has already been imported to Cloud Datastore. + rpc ImportEntities(ImportEntitiesRequest) + returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:import" + body: "*" + }; + option (google.api.method_signature) = + "project_id,labels,input_url,entity_filter"; + option (google.longrunning.operation_info) = { + response_type: "google.protobuf.Empty" + metadata_type: "ImportEntitiesMetadata" + }; + } + + // Creates the specified index. + // A newly created index's initial state is `CREATING`. On completion of the + // returned [google.longrunning.Operation][google.longrunning.Operation], the + // state will be `READY`. If the index already exists, the call will return an + // `ALREADY_EXISTS` status. + // + // During index creation, the process could result in an error, in which + // case the index will move to the `ERROR` state. The process can be recovered + // by fixing the data that caused the error, removing the index with + // [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex], then + // re-creating the index with [create] + // [google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. + // + // Indexes with a single property cannot be created. + rpc CreateIndex(CreateIndexRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + post: "/v1/projects/{project_id}/indexes" + body: "index" + }; + option (google.longrunning.operation_info) = { + response_type: "Index" + metadata_type: "IndexOperationMetadata" + }; + } + + // Deletes an existing index. + // An index can only be deleted if it is in a `READY` or `ERROR` state. On + // successful execution of the request, the index will be in a `DELETING` + // [state][google.datastore.admin.v1.Index.State]. And on completion of the + // returned [google.longrunning.Operation][google.longrunning.Operation], the + // index will be removed. + // + // During index deletion, the process could result in an error, in which + // case the index will move to the `ERROR` state. The process can be recovered + // by fixing the data that caused the error, followed by calling + // [delete][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex] again. + rpc DeleteIndex(DeleteIndexRequest) returns (google.longrunning.Operation) { + option (google.api.http) = { + delete: "/v1/projects/{project_id}/indexes/{index_id}" + }; + option (google.longrunning.operation_info) = { + response_type: "Index" + metadata_type: "IndexOperationMetadata" + }; + } + + // Gets an index. + rpc GetIndex(GetIndexRequest) returns (Index) { + option (google.api.http) = { + get: "/v1/projects/{project_id}/indexes/{index_id}" + }; + } + + // Lists the indexes that match the specified filters. Datastore uses an + // eventually consistent query to fetch the list of indexes and may + // occasionally return stale results. + rpc ListIndexes(ListIndexesRequest) returns (ListIndexesResponse) { + option (google.api.http) = { + get: "/v1/projects/{project_id}/indexes" + }; + } +} + +// Metadata common to all Datastore Admin operations. +message CommonMetadata { + // The various possible states for an ongoing Operation. + enum State { + // Unspecified. + 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; + } + + // The time that work began on the operation. + google.protobuf.Timestamp start_time = 1; + + // The time the operation ended, either successfully or otherwise. + google.protobuf.Timestamp end_time = 2; + + // The type of the operation. Can be used as a filter in + // ListOperationsRequest. + OperationType operation_type = 3; + + // The client-assigned labels which were provided when the operation was + // created. May also include additional labels. + map labels = 4; + + // The current state of the Operation. + State state = 5; +} + +// Measures the progress of a particular metric. +message Progress { + // The amount of work that has been completed. Note that this may be greater + // than work_estimated. + int64 work_completed = 1; + + // An estimate of how much work needs to be performed. May be zero if the + // work estimate is unavailable. + int64 work_estimated = 2; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities]. +message ExportEntitiesRequest { + // Required. Project ID against which to make the request. + string project_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Client-assigned labels. + map labels = 2; + + // Description of what data from the project is included in the export. + EntityFilter entity_filter = 3; + + // Required. Location for the export metadata and data files. + // + // The full resource URL of the external storage location. Currently, only + // Google Cloud Storage is supported. So output_url_prefix should be of the + // form: `gs://BUCKET_NAME[/NAMESPACE_PATH]`, where `BUCKET_NAME` is the + // name of the Cloud Storage bucket and `NAMESPACE_PATH` is an optional Cloud + // Storage namespace path (this is not a Cloud Datastore namespace). For more + // information about Cloud Storage namespace paths, see + // [Object name + // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + // + // The resulting files will be nested deeper than the specified URL prefix. + // The final output URL will be provided in the + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] + // field. That value should be used for subsequent ImportEntities operations. + // + // By nesting the data files deeper, the same Cloud Storage bucket can be used + // in multiple ExportEntities operations without conflict. + string output_url_prefix = 4 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.ImportEntities][google.datastore.admin.v1.DatastoreAdmin.ImportEntities]. +message ImportEntitiesRequest { + // Required. Project ID against which to make the request. + string project_id = 1 [(google.api.field_behavior) = REQUIRED]; + + // Client-assigned labels. + map labels = 2; + + // Required. The full resource URL of the external storage location. + // Currently, only Google Cloud Storage is supported. So input_url should be + // of the form: + // `gs://BUCKET_NAME[/NAMESPACE_PATH]/OVERALL_EXPORT_METADATA_FILE`, where + // `BUCKET_NAME` is the name of the Cloud Storage bucket, `NAMESPACE_PATH` is + // an optional Cloud Storage namespace path (this is not a Cloud Datastore + // namespace), and `OVERALL_EXPORT_METADATA_FILE` is the metadata file written + // by the ExportEntities operation. For more information about Cloud Storage + // namespace paths, see + // [Object name + // considerations](https://cloud.google.com/storage/docs/naming#object-considerations). + // + // For more information, see + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. + string input_url = 3 [(google.api.field_behavior) = REQUIRED]; + + // Optionally specify which kinds/namespaces are to be imported. If provided, + // the list must be a subset of the EntityFilter used in creating the export, + // otherwise a FAILED_PRECONDITION error will be returned. If no filter is + // specified then all entities from the export are imported. + EntityFilter entity_filter = 4; +} + +// The response for +// [google.datastore.admin.v1.DatastoreAdmin.ExportEntities][google.datastore.admin.v1.DatastoreAdmin.ExportEntities]. +message ExportEntitiesResponse { + // Location of the output metadata file. This can be used to begin an import + // into Cloud Datastore (this project or another project). See + // [google.datastore.admin.v1.ImportEntitiesRequest.input_url][google.datastore.admin.v1.ImportEntitiesRequest.input_url]. + // Only present if the operation completed successfully. + string output_url = 1; +} + +// Metadata for ExportEntities operations. +message ExportEntitiesMetadata { + // Metadata common to all Datastore Admin operations. + CommonMetadata common = 1; + + // An estimate of the number of entities processed. + Progress progress_entities = 2; + + // An estimate of the number of bytes processed. + Progress progress_bytes = 3; + + // Description of which entities are being exported. + EntityFilter entity_filter = 4; + + // Location for the export metadata and data files. This will be the same + // value as the + // [google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix][google.datastore.admin.v1.ExportEntitiesRequest.output_url_prefix] + // field. The final output location is provided in + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url]. + string output_url_prefix = 5; +} + +// Metadata for ImportEntities operations. +message ImportEntitiesMetadata { + // Metadata common to all Datastore Admin operations. + CommonMetadata common = 1; + + // An estimate of the number of entities processed. + Progress progress_entities = 2; + + // An estimate of the number of bytes processed. + Progress progress_bytes = 3; + + // Description of which entities are being imported. + EntityFilter entity_filter = 4; + + // The location of the import metadata file. This will be the same value as + // the + // [google.datastore.admin.v1.ExportEntitiesResponse.output_url][google.datastore.admin.v1.ExportEntitiesResponse.output_url] + // field. + string input_url = 5; +} + +// Identifies a subset of entities in a project. This is specified as +// combinations of kinds and namespaces (either or both of which may be all, as +// described in the following examples). +// Example usage: +// +// Entire project: +// kinds=[], namespace_ids=[] +// +// Kinds Foo and Bar in all namespaces: +// kinds=['Foo', 'Bar'], namespace_ids=[] +// +// Kinds Foo and Bar only in the default namespace: +// kinds=['Foo', 'Bar'], namespace_ids=[''] +// +// Kinds Foo and Bar in both the default and Baz namespaces: +// kinds=['Foo', 'Bar'], namespace_ids=['', 'Baz'] +// +// The entire Baz namespace: +// kinds=[], namespace_ids=['Baz'] +message EntityFilter { + // If empty, then this represents all kinds. + repeated string kinds = 1; + + // An empty list represents all namespaces. This is the preferred + // usage for projects that don't use namespaces. + // + // An empty string element represents the default namespace. This should be + // used if the project 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 = 2; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.CreateIndex][google.datastore.admin.v1.DatastoreAdmin.CreateIndex]. +message CreateIndexRequest { + // Project ID against which to make the request. + string project_id = 1; + + // The index to create. The name and state fields are output only and will be + // ignored. Single property indexes cannot be created or deleted. + Index index = 3; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.DeleteIndex][google.datastore.admin.v1.DatastoreAdmin.DeleteIndex]. +message DeleteIndexRequest { + // Project ID against which to make the request. + string project_id = 1; + + // The resource ID of the index to delete. + string index_id = 3; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.GetIndex][google.datastore.admin.v1.DatastoreAdmin.GetIndex]. +message GetIndexRequest { + // Project ID against which to make the request. + string project_id = 1; + + // The resource ID of the index to get. + string index_id = 3; +} + +// The request for +// [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes]. +message ListIndexesRequest { + // Project ID against which to make the request. + string project_id = 1; + + string filter = 3; + + // The maximum number of items to return. If zero, then all results will be + // returned. + int32 page_size = 4; + + // The next_page_token value returned from a previous List request, if any. + string page_token = 5; +} + +// The response for +// [google.datastore.admin.v1.DatastoreAdmin.ListIndexes][google.datastore.admin.v1.DatastoreAdmin.ListIndexes]. +message ListIndexesResponse { + // The indexes. + repeated Index indexes = 1; + + // The standard List next-page token. + string next_page_token = 2; +} + +// Metadata for Index operations. +message IndexOperationMetadata { + // Metadata common to all Datastore Admin operations. + CommonMetadata common = 1; + + // An estimate of the number of entities processed. + Progress progress_entities = 2; + + // The index resource ID that this operation is acting on. + string index_id = 3; +} + +// Metadata for Datastore to Firestore migration operations. +// +// The DatastoreFirestoreMigration operation is not started by the end-user via +// an explicit "creation" method. This is an intentional deviation from the LRO +// design pattern. +// +// This singleton resource can be accessed at: +// "projects/{project_id}/operations/datastore-firestore-migration" +message DatastoreFirestoreMigrationMetadata { + // The current state of migration from Cloud Datastore to Cloud Firestore in + // Datastore mode. + MigrationState migration_state = 1; + + // The current step of migration from Cloud Datastore to Cloud Firestore in + // Datastore mode. + MigrationStep migration_step = 2; +} + +// Operation types. +enum OperationType { + // Unspecified. + OPERATION_TYPE_UNSPECIFIED = 0; + + // ExportEntities. + EXPORT_ENTITIES = 1; + + // ImportEntities. + IMPORT_ENTITIES = 2; + + // CreateIndex. + CREATE_INDEX = 3; + + // DeleteIndex. + DELETE_INDEX = 4; +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/index.proto b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/index.proto new file mode 100644 index 000000000000..c907660568c6 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/index.proto @@ -0,0 +1,122 @@ +// 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. + +syntax = "proto3"; + +package google.datastore.admin.v1; + +import "google/api/field_behavior.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; +option go_package = "cloud.google.com/go/datastore/admin/apiv1/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "IndexProto"; +option java_package = "com.google.datastore.admin.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Datastore::Admin::V1"; + +// Datastore composite index definition. +message Index { + // For an ordered index, specifies whether each of the entity's ancestors + // will be included. + enum AncestorMode { + // The ancestor mode is unspecified. + ANCESTOR_MODE_UNSPECIFIED = 0; + + // Do not include the entity's ancestors in the index. + NONE = 1; + + // Include all the entity's ancestors in the index. + ALL_ANCESTORS = 2; + } + + // The direction determines how a property is indexed. + enum Direction { + // The direction is unspecified. + DIRECTION_UNSPECIFIED = 0; + + // The property's values are indexed so as to support sequencing in + // ascending order and also query by <, >, <=, >=, and =. + ASCENDING = 1; + + // The property's values are indexed so as to support sequencing in + // descending order and also query by <, >, <=, >=, and =. + DESCENDING = 2; + } + + // A property of an index. + message IndexedProperty { + // Required. The property name to index. + string name = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. The indexed property's direction. Must not be + // DIRECTION_UNSPECIFIED. + Direction direction = 2 [(google.api.field_behavior) = REQUIRED]; + } + + // The possible set of states of an index. + enum State { + // The state is unspecified. + STATE_UNSPECIFIED = 0; + + // The index is being created, and cannot be used by queries. + // There is an active long-running operation for the index. + // The index is updated when writing an entity. + // Some index data may exist. + CREATING = 1; + + // The index is ready to be used. + // The index is updated when writing an entity. + // The index is fully populated from all stored entities it applies to. + READY = 2; + + // The index is being deleted, and cannot be used by queries. + // There is an active long-running operation for the index. + // The index is not updated when writing an entity. + // Some index data may exist. + DELETING = 3; + + // The index was being created or deleted, but something went wrong. + // The index cannot by used by queries. + // 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 an entity. + // Some index data may exist. + ERROR = 4; + } + + // Output only. Project ID. + string project_id = 1 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. The resource ID of the index. + string index_id = 3 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Required. The entity kind to which this index applies. + string kind = 4 [(google.api.field_behavior) = REQUIRED]; + + // Required. The index's ancestor mode. Must not be + // ANCESTOR_MODE_UNSPECIFIED. + AncestorMode ancestor = 5 [(google.api.field_behavior) = REQUIRED]; + + // Required. An ordered sequence of property names and their index attributes. + // + // Requires: + // + // * A maximum of 100 properties. + repeated IndexedProperty properties = 6 + [(google.api.field_behavior) = REQUIRED]; + + // Output only. The state of the index. + State state = 7 [(google.api.field_behavior) = OUTPUT_ONLY]; +} diff --git a/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/migration.proto b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/migration.proto new file mode 100644 index 000000000000..67ac1ab711d7 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-admin-v1/src/main/proto/google/datastore/admin/v1/migration.proto @@ -0,0 +1,124 @@ +// 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. + +syntax = "proto3"; + +package google.datastore.admin.v1; + +option csharp_namespace = "Google.Cloud.Datastore.Admin.V1"; +option go_package = "cloud.google.com/go/datastore/admin/apiv1/adminpb;adminpb"; +option java_multiple_files = true; +option java_outer_classname = "MigrationProto"; +option java_package = "com.google.datastore.admin.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\Admin\\V1"; +option ruby_package = "Google::Cloud::Datastore::Admin::V1"; + +// An event signifying a change in state of a [migration from Cloud Datastore to +// Cloud Firestore in Datastore +// mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore). +message MigrationStateEvent { + // The new state of the migration. + MigrationState state = 1; +} + +// An event signifying the start of a new step in a [migration from Cloud +// Datastore to Cloud Firestore in Datastore +// mode](https://cloud.google.com/datastore/docs/upgrade-to-firestore). +message MigrationProgressEvent { + // Concurrency modes for transactions in Cloud Firestore. + enum ConcurrencyMode { + // Unspecified. + CONCURRENCY_MODE_UNSPECIFIED = 0; + + // Pessimistic concurrency. + PESSIMISTIC = 1; + + // Optimistic concurrency. + OPTIMISTIC = 2; + + // Optimistic concurrency with entity groups. + OPTIMISTIC_WITH_ENTITY_GROUPS = 3; + } + + // Details for the `PREPARE` step. + message PrepareStepDetails { + // The concurrency mode this database will use when it reaches the + // `REDIRECT_WRITES` step. + ConcurrencyMode concurrency_mode = 1; + } + + // Details for the `REDIRECT_WRITES` step. + message RedirectWritesStepDetails { + // Ths concurrency mode for this database. + ConcurrencyMode concurrency_mode = 1; + } + + // The step that is starting. + // + // An event with step set to `START` indicates that the migration + // has been reverted back to the initial pre-migration state. + MigrationStep step = 1; + + // Details about this step. + oneof step_details { + // Details for the `PREPARE` step. + PrepareStepDetails prepare_step_details = 2; + + // Details for the `REDIRECT_WRITES` step. + RedirectWritesStepDetails redirect_writes_step_details = 3; + } +} + +// States for a migration. +enum MigrationState { + // Unspecified. + MIGRATION_STATE_UNSPECIFIED = 0; + + // The migration is running. + RUNNING = 1; + + // The migration is paused. + PAUSED = 2; + + // The migration is complete. + COMPLETE = 3; +} + +// Steps in a migration. +enum MigrationStep { + // Unspecified. + MIGRATION_STEP_UNSPECIFIED = 0; + + // Pre-migration: the database is prepared for migration. + PREPARE = 6; + + // Start of migration. + START = 1; + + // Writes are applied synchronously to at least one replica. + APPLY_WRITES_SYNCHRONOUSLY = 7; + + // Data is copied to Cloud Firestore and then verified to match the data in + // Cloud Datastore. + COPY_AND_VERIFY = 2; + + // Eventually-consistent reads are redirected to Cloud Firestore. + REDIRECT_EVENTUALLY_CONSISTENT_READS = 3; + + // Strongly-consistent reads are redirected to Cloud Firestore. + REDIRECT_STRONGLY_CONSISTENT_READS = 4; + + // Writes are redirected to Cloud Firestore. + REDIRECT_WRITES = 5; +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/clirr-ignored-differences.xml b/java-datastore/proto-google-cloud-datastore-v1/clirr-ignored-differences.xml new file mode 100644 index 000000000000..34662f77c14c --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/clirr-ignored-differences.xml @@ -0,0 +1,123 @@ + + + + + 7012 + com/google/datastore/v1/*OrBuilder + * has*(*) + + + 7012 + com/google/datastore/v1/*OrBuilder + * get*(*) + + + 7012 + com/google/datastore/v1/*OrBuilder + boolean contains*(*) + + + + + com/google/datastore/v1/QueryMode + * + 8001 + + + com/google/datastore/v1/QueryPlan* + * + 8001 + + + com/google/datastore/v1/QueryProfileProto + * + 8001 + + + com/google/datastore/v1/ResultSetStats* + * + 8001 + + + com/google/datastore/v1/* + *Mode* + 7002 + + + com/google/datastore/v1/* + *Stats* + 7002 + + + com/google/datastore/v1/* + MODE_FIELD_NUMBER + 6011 + + + com/google/datastore/v1/* + STATS_FIELD_NUMBER + 6011 + + + + + 7006 + com/google/datastore/v1/** + * getDefaultInstanceForType() + ** + + + 7006 + com/google/datastore/v1/** + * addRepeatedField(*) + ** + + + 7006 + com/google/datastore/v1/** + * clear() + ** + + + 7006 + com/google/datastore/v1/** + * clearField(*) + ** + + + 7006 + com/google/datastore/v1/** + * clearOneof(*) + ** + + + 7006 + com/google/datastore/v1/** + * clone() + ** + + + 7006 + com/google/datastore/v1/** + * mergeUnknownFields(*) + ** + + + 7006 + com/google/datastore/v1/** + * setField(*) + ** + + + 7006 + com/google/datastore/v1/** + * setRepeatedField(*) + ** + + + 7006 + com/google/datastore/v1/** + * setUnknownFields(*) + ** + + diff --git a/java-datastore/proto-google-cloud-datastore-v1/pom.xml b/java-datastore/proto-google-cloud-datastore-v1/pom.xml new file mode 100644 index 000000000000..38fd3a72f0fe --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/pom.xml @@ -0,0 +1,51 @@ + + 4.0.0 + com.google.api.grpc + proto-google-cloud-datastore-v1 + 0.124.2 + proto-google-cloud-datastore-v1 + PROTO library for proto-google-cloud-datastore-v1 + + com.google.cloud + google-cloud-datastore-parent + 2.33.2 + + + + com.google.protobuf + protobuf-java + compile + + + com.google.api.grpc + proto-google-common-protos + compile + + + + + + + org.codehaus.mojo + flatten-maven-plugin + + + + + + + java9 + + [9,) + + + + javax.annotation + javax.annotation-api + + + + + diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQuery.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQuery.java new file mode 100644 index 000000000000..1abd2b308e1c --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQuery.java @@ -0,0 +1,6273 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * Datastore query for running an aggregation over a
+ * [Query][google.datastore.v1.Query].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.AggregationQuery} + */ +public final class AggregationQuery extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.AggregationQuery) + AggregationQueryOrBuilder { + private static final long serialVersionUID = 0L; + + // Use AggregationQuery.newBuilder() to construct. + private AggregationQuery(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private AggregationQuery() { + aggregations_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new AggregationQuery(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationQuery.class, + com.google.datastore.v1.AggregationQuery.Builder.class); + } + + public interface AggregationOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.AggregationQuery.Aggregation) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + * + * @return Whether the count field is set. + */ + boolean hasCount(); + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + * + * @return The count. + */ + com.google.datastore.v1.AggregationQuery.Aggregation.Count getCount(); + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + */ + com.google.datastore.v1.AggregationQuery.Aggregation.CountOrBuilder getCountOrBuilder(); + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + * + * @return Whether the sum field is set. + */ + boolean hasSum(); + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + * + * @return The sum. + */ + com.google.datastore.v1.AggregationQuery.Aggregation.Sum getSum(); + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + */ + com.google.datastore.v1.AggregationQuery.Aggregation.SumOrBuilder getSumOrBuilder(); + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + * + * @return Whether the avg field is set. + */ + boolean hasAvg(); + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + * + * @return The avg. + */ + com.google.datastore.v1.AggregationQuery.Aggregation.Avg getAvg(); + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + */ + com.google.datastore.v1.AggregationQuery.Aggregation.AvgOrBuilder getAvgOrBuilder(); + + /** + * + * + *
+     * Optional. Optional name of the property to store the result of the
+     * aggregation.
+     *
+     * If not provided, Datastore will pick a default name following the format
+     * `property_<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 property_1,
+     *   COUNT_UP_TO(3) AS count_up_to_3,
+     *   COUNT(*) AS property_2
+     * OVER (
+     *   ...
+     * );
+     * ```
+     *
+     * Requires:
+     *
+     * * Must be unique across all aggregation aliases.
+     * * Conform to [entity property
+     * name][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The alias. + */ + java.lang.String getAlias(); + + /** + * + * + *
+     * Optional. Optional name of the property to store the result of the
+     * aggregation.
+     *
+     * If not provided, Datastore will pick a default name following the format
+     * `property_<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 property_1,
+     *   COUNT_UP_TO(3) AS count_up_to_3,
+     *   COUNT(*) AS property_2
+     * OVER (
+     *   ...
+     * );
+     * ```
+     *
+     * Requires:
+     *
+     * * Must be unique across all aggregation aliases.
+     * * Conform to [entity property
+     * name][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string alias = 7 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for alias. + */ + com.google.protobuf.ByteString getAliasBytes(); + + com.google.datastore.v1.AggregationQuery.Aggregation.OperatorCase getOperatorCase(); + } + + /** + * + * + *
+   * Defines an aggregation that produces a single result.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.AggregationQuery.Aggregation} + */ + public static final class Aggregation extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.AggregationQuery.Aggregation) + AggregationOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Aggregation.newBuilder() to construct. + private Aggregation(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Aggregation() { + alias_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Aggregation(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationQuery.Aggregation.class, + com.google.datastore.v1.AggregationQuery.Aggregation.Builder.class); + } + + public interface CountOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.AggregationQuery.Aggregation.Count) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * Optional. Optional constraint on the maximum number of entities to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of entities
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * If a zero value is provided, a count result of zero should always be
+       * expected.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be non-negative 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 entities to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of entities
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * If a zero value is provided, a count result of zero should always be
+       * expected.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be non-negative 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 entities to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of entities
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * If a zero value is provided, a count result of zero should always be
+       * expected.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be non-negative when present.
+       * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.protobuf.Int64ValueOrBuilder getUpToOrBuilder(); + } + + /** + * + * + *
+     * Count of entities that match the query.
+     *
+     * The `COUNT(*)` aggregation function operates on the entire entity
+     * so it does not require a field reference.
+     * 
+ * + * Protobuf type {@code google.datastore.v1.AggregationQuery.Aggregation.Count} + */ + public static final class Count extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.AggregationQuery.Aggregation.Count) + CountOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Count.newBuilder() to construct. + private Count(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Count() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Count(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Count_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Count_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationQuery.Aggregation.Count.class, + com.google.datastore.v1.AggregationQuery.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 entities to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of entities
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * If a zero value is provided, a count result of zero should always be
+       * expected.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be non-negative 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 entities to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of entities
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * If a zero value is provided, a count result of zero should always be
+       * expected.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be non-negative 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 entities to
+       * count.
+       *
+       * This provides a way to set an upper bound on the number of entities
+       * to scan, limiting latency, and cost.
+       *
+       * Unspecified is interpreted as no bound.
+       *
+       * If a zero value is provided, a count result of zero should always be
+       * expected.
+       *
+       * High-Level Example:
+       *
+       * ```
+       * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be non-negative 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.datastore.v1.AggregationQuery.Aggregation.Count)) { + return super.equals(obj); + } + com.google.datastore.v1.AggregationQuery.Aggregation.Count other = + (com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Count parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Count parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Count parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Count parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Count parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Count parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Count parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Count parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Count parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Count parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.AggregationQuery.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * Count of entities that match the query.
+       *
+       * The `COUNT(*)` aggregation function operates on the entire entity
+       * so it does not require a field reference.
+       * 
+ * + * Protobuf type {@code google.datastore.v1.AggregationQuery.Aggregation.Count} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.AggregationQuery.Aggregation.Count) + com.google.datastore.v1.AggregationQuery.Aggregation.CountOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Count_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Count_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationQuery.Aggregation.Count.class, + com.google.datastore.v1.AggregationQuery.Aggregation.Count.Builder.class); + } + + // Construct using com.google.datastore.v1.AggregationQuery.Aggregation.Count.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getUpToFieldBuilder(); + } + } + + @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.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Count_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Count + getDefaultInstanceForType() { + return com.google.datastore.v1.AggregationQuery.Aggregation.Count.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Count build() { + com.google.datastore.v1.AggregationQuery.Aggregation.Count result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Count buildPartial() { + com.google.datastore.v1.AggregationQuery.Aggregation.Count result = + new com.google.datastore.v1.AggregationQuery.Aggregation.Count(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.datastore.v1.AggregationQuery.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 clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.AggregationQuery.Aggregation.Count) { + return mergeFrom((com.google.datastore.v1.AggregationQuery.Aggregation.Count) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.AggregationQuery.Aggregation.Count other) { + if (other + == com.google.datastore.v1.AggregationQuery.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(getUpToFieldBuilder().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.SingleFieldBuilderV3< + com.google.protobuf.Int64Value, + com.google.protobuf.Int64Value.Builder, + com.google.protobuf.Int64ValueOrBuilder> + upToBuilder_; + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of entities to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of entities
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * If a zero value is provided, a count result of zero should always be
+         * expected.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be non-negative 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 entities to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of entities
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * If a zero value is provided, a count result of zero should always be
+         * expected.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be non-negative 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 entities to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of entities
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * If a zero value is provided, a count result of zero should always be
+         * expected.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be non-negative 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 entities to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of entities
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * If a zero value is provided, a count result of zero should always be
+         * expected.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be non-negative 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 entities to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of entities
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * If a zero value is provided, a count result of zero should always be
+         * expected.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be non-negative 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 entities to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of entities
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * If a zero value is provided, a count result of zero should always be
+         * expected.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be non-negative 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 entities to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of entities
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * If a zero value is provided, a count result of zero should always be
+         * expected.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be non-negative when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.protobuf.Int64Value.Builder getUpToBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getUpToFieldBuilder().getBuilder(); + } + + /** + * + * + *
+         * Optional. Optional constraint on the maximum number of entities to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of entities
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * If a zero value is provided, a count result of zero should always be
+         * expected.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be non-negative 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 entities to
+         * count.
+         *
+         * This provides a way to set an upper bound on the number of entities
+         * to scan, limiting latency, and cost.
+         *
+         * Unspecified is interpreted as no bound.
+         *
+         * If a zero value is provided, a count result of zero should always be
+         * expected.
+         *
+         * High-Level Example:
+         *
+         * ```
+         * AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k );
+         * ```
+         *
+         * Requires:
+         *
+         * * Must be non-negative when present.
+         * 
+ * + * .google.protobuf.Int64Value up_to = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int64Value, + com.google.protobuf.Int64Value.Builder, + com.google.protobuf.Int64ValueOrBuilder> + getUpToFieldBuilder() { + if (upToBuilder_ == null) { + upToBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int64Value, + com.google.protobuf.Int64Value.Builder, + com.google.protobuf.Int64ValueOrBuilder>( + getUpTo(), getParentForChildren(), isClean()); + upTo_ = null; + } + return upToBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.AggregationQuery.Aggregation.Count) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.AggregationQuery.Aggregation.Count) + private static final com.google.datastore.v1.AggregationQuery.Aggregation.Count + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.AggregationQuery.Aggregation.Count(); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Count + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface SumOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.AggregationQuery.Aggregation.Sum) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + boolean hasProperty(); + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + com.google.datastore.v1.PropertyReference getProperty(); + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder(); + } + + /** + * + * + *
+     * Sum of the values of the requested property.
+     *
+     * * 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.datastore.v1.AggregationQuery.Aggregation.Sum} + */ + public static final class Sum extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.AggregationQuery.Aggregation.Sum) + SumOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Sum.newBuilder() to construct. + private Sum(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Sum() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Sum(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Sum_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Sum_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationQuery.Aggregation.Sum.class, + com.google.datastore.v1.AggregationQuery.Aggregation.Sum.Builder.class); + } + + private int bitField0_; + public static final int PROPERTY_FIELD_NUMBER = 1; + private com.google.datastore.v1.PropertyReference property_; + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + @java.lang.Override + public boolean hasProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReference getProperty() { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder() { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + + 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, getProperty()); + } + 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, getProperty()); + } + 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.datastore.v1.AggregationQuery.Aggregation.Sum)) { + return super.equals(obj); + } + com.google.datastore.v1.AggregationQuery.Aggregation.Sum other = + (com.google.datastore.v1.AggregationQuery.Aggregation.Sum) obj; + + if (hasProperty() != other.hasProperty()) return false; + if (hasProperty()) { + if (!getProperty().equals(other.getProperty())) 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 (hasProperty()) { + hash = (37 * hash) + PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getProperty().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Sum parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Sum parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Sum parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Sum parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Sum parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Sum parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Sum parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Sum parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Sum parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Sum parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.AggregationQuery.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * Sum of the values of the requested property.
+       *
+       * * 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.datastore.v1.AggregationQuery.Aggregation.Sum} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.AggregationQuery.Aggregation.Sum) + com.google.datastore.v1.AggregationQuery.Aggregation.SumOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Sum_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Sum_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationQuery.Aggregation.Sum.class, + com.google.datastore.v1.AggregationQuery.Aggregation.Sum.Builder.class); + } + + // Construct using com.google.datastore.v1.AggregationQuery.Aggregation.Sum.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPropertyFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + property_ = null; + if (propertyBuilder_ != null) { + propertyBuilder_.dispose(); + propertyBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Sum_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Sum + getDefaultInstanceForType() { + return com.google.datastore.v1.AggregationQuery.Aggregation.Sum.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Sum build() { + com.google.datastore.v1.AggregationQuery.Aggregation.Sum result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Sum buildPartial() { + com.google.datastore.v1.AggregationQuery.Aggregation.Sum result = + new com.google.datastore.v1.AggregationQuery.Aggregation.Sum(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.datastore.v1.AggregationQuery.Aggregation.Sum result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.property_ = propertyBuilder_ == null ? property_ : propertyBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.AggregationQuery.Aggregation.Sum) { + return mergeFrom((com.google.datastore.v1.AggregationQuery.Aggregation.Sum) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.AggregationQuery.Aggregation.Sum other) { + if (other + == com.google.datastore.v1.AggregationQuery.Aggregation.Sum.getDefaultInstance()) + return this; + if (other.hasProperty()) { + mergeProperty(other.getProperty()); + } + 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(getPropertyFieldBuilder().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.datastore.v1.PropertyReference property_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + propertyBuilder_; + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + public boolean hasProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + public com.google.datastore.v1.PropertyReference getProperty() { + if (propertyBuilder_ == null) { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } else { + return propertyBuilder_.getMessage(); + } + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder setProperty(com.google.datastore.v1.PropertyReference value) { + if (propertyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + property_ = value; + } else { + propertyBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder setProperty( + com.google.datastore.v1.PropertyReference.Builder builderForValue) { + if (propertyBuilder_ == null) { + property_ = builderForValue.build(); + } else { + propertyBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder mergeProperty(com.google.datastore.v1.PropertyReference value) { + if (propertyBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && property_ != null + && property_ != com.google.datastore.v1.PropertyReference.getDefaultInstance()) { + getPropertyBuilder().mergeFrom(value); + } else { + property_ = value; + } + } else { + propertyBuilder_.mergeFrom(value); + } + if (property_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder clearProperty() { + bitField0_ = (bitField0_ & ~0x00000001); + property_ = null; + if (propertyBuilder_ != null) { + propertyBuilder_.dispose(); + propertyBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public com.google.datastore.v1.PropertyReference.Builder getPropertyBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getPropertyFieldBuilder().getBuilder(); + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder() { + if (propertyBuilder_ != null) { + return propertyBuilder_.getMessageOrBuilder(); + } else { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + getPropertyFieldBuilder() { + if (propertyBuilder_ == null) { + propertyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder>( + getProperty(), getParentForChildren(), isClean()); + property_ = null; + } + return propertyBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.AggregationQuery.Aggregation.Sum) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.AggregationQuery.Aggregation.Sum) + private static final com.google.datastore.v1.AggregationQuery.Aggregation.Sum + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.AggregationQuery.Aggregation.Sum(); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Sum getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface AvgOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.AggregationQuery.Aggregation.Avg) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + boolean hasProperty(); + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + com.google.datastore.v1.PropertyReference getProperty(); + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder(); + } + + /** + * + * + *
+     * Average of the values of the requested property.
+     *
+     * * 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.datastore.v1.AggregationQuery.Aggregation.Avg} + */ + public static final class Avg extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.AggregationQuery.Aggregation.Avg) + AvgOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Avg.newBuilder() to construct. + private Avg(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Avg() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Avg(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Avg_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Avg_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationQuery.Aggregation.Avg.class, + com.google.datastore.v1.AggregationQuery.Aggregation.Avg.Builder.class); + } + + private int bitField0_; + public static final int PROPERTY_FIELD_NUMBER = 1; + private com.google.datastore.v1.PropertyReference property_; + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + @java.lang.Override + public boolean hasProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReference getProperty() { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + + /** + * + * + *
+       * The property to aggregate on.
+       * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder() { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + + 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, getProperty()); + } + 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, getProperty()); + } + 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.datastore.v1.AggregationQuery.Aggregation.Avg)) { + return super.equals(obj); + } + com.google.datastore.v1.AggregationQuery.Aggregation.Avg other = + (com.google.datastore.v1.AggregationQuery.Aggregation.Avg) obj; + + if (hasProperty() != other.hasProperty()) return false; + if (hasProperty()) { + if (!getProperty().equals(other.getProperty())) 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 (hasProperty()) { + hash = (37 * hash) + PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getProperty().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Avg parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Avg parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Avg parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Avg parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Avg parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Avg parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Avg parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Avg parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Avg parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation.Avg parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.AggregationQuery.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+       * Average of the values of the requested property.
+       *
+       * * 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.datastore.v1.AggregationQuery.Aggregation.Avg} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.AggregationQuery.Aggregation.Avg) + com.google.datastore.v1.AggregationQuery.Aggregation.AvgOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Avg_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Avg_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationQuery.Aggregation.Avg.class, + com.google.datastore.v1.AggregationQuery.Aggregation.Avg.Builder.class); + } + + // Construct using com.google.datastore.v1.AggregationQuery.Aggregation.Avg.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPropertyFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + property_ = null; + if (propertyBuilder_ != null) { + propertyBuilder_.dispose(); + propertyBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_Avg_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Avg + getDefaultInstanceForType() { + return com.google.datastore.v1.AggregationQuery.Aggregation.Avg.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Avg build() { + com.google.datastore.v1.AggregationQuery.Aggregation.Avg result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Avg buildPartial() { + com.google.datastore.v1.AggregationQuery.Aggregation.Avg result = + new com.google.datastore.v1.AggregationQuery.Aggregation.Avg(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.datastore.v1.AggregationQuery.Aggregation.Avg result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.property_ = propertyBuilder_ == null ? property_ : propertyBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.AggregationQuery.Aggregation.Avg) { + return mergeFrom((com.google.datastore.v1.AggregationQuery.Aggregation.Avg) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.AggregationQuery.Aggregation.Avg other) { + if (other + == com.google.datastore.v1.AggregationQuery.Aggregation.Avg.getDefaultInstance()) + return this; + if (other.hasProperty()) { + mergeProperty(other.getProperty()); + } + 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(getPropertyFieldBuilder().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.datastore.v1.PropertyReference property_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + propertyBuilder_; + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + public boolean hasProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + public com.google.datastore.v1.PropertyReference getProperty() { + if (propertyBuilder_ == null) { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } else { + return propertyBuilder_.getMessage(); + } + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder setProperty(com.google.datastore.v1.PropertyReference value) { + if (propertyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + property_ = value; + } else { + propertyBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder setProperty( + com.google.datastore.v1.PropertyReference.Builder builderForValue) { + if (propertyBuilder_ == null) { + property_ = builderForValue.build(); + } else { + propertyBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder mergeProperty(com.google.datastore.v1.PropertyReference value) { + if (propertyBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && property_ != null + && property_ != com.google.datastore.v1.PropertyReference.getDefaultInstance()) { + getPropertyBuilder().mergeFrom(value); + } else { + property_ = value; + } + } else { + propertyBuilder_.mergeFrom(value); + } + if (property_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder clearProperty() { + bitField0_ = (bitField0_ & ~0x00000001); + property_ = null; + if (propertyBuilder_ != null) { + propertyBuilder_.dispose(); + propertyBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public com.google.datastore.v1.PropertyReference.Builder getPropertyBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getPropertyFieldBuilder().getBuilder(); + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder() { + if (propertyBuilder_ != null) { + return propertyBuilder_.getMessageOrBuilder(); + } else { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + } + + /** + * + * + *
+         * The property to aggregate on.
+         * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + getPropertyFieldBuilder() { + if (propertyBuilder_ == null) { + propertyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder>( + getProperty(), getParentForChildren(), isClean()); + property_ = null; + } + return propertyBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.AggregationQuery.Aggregation.Avg) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.AggregationQuery.Aggregation.Avg) + private static final com.google.datastore.v1.AggregationQuery.Aggregation.Avg + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.AggregationQuery.Aggregation.Avg(); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + * + * @return Whether the count field is set. + */ + @java.lang.Override + public boolean hasCount() { + return operatorCase_ == 1; + } + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + * + * @return The count. + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Count getCount() { + if (operatorCase_ == 1) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Count) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Count.getDefaultInstance(); + } + + /** + * + * + *
+     * Count aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.CountOrBuilder getCountOrBuilder() { + if (operatorCase_ == 1) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Count) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Count.getDefaultInstance(); + } + + public static final int SUM_FIELD_NUMBER = 2; + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + * + * @return Whether the sum field is set. + */ + @java.lang.Override + public boolean hasSum() { + return operatorCase_ == 2; + } + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + * + * @return The sum. + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Sum getSum() { + if (operatorCase_ == 2) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Sum) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Sum.getDefaultInstance(); + } + + /** + * + * + *
+     * Sum aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.SumOrBuilder getSumOrBuilder() { + if (operatorCase_ == 2) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Sum) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Sum.getDefaultInstance(); + } + + public static final int AVG_FIELD_NUMBER = 3; + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + * + * @return Whether the avg field is set. + */ + @java.lang.Override + public boolean hasAvg() { + return operatorCase_ == 3; + } + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + * + * @return The avg. + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Avg getAvg() { + if (operatorCase_ == 3) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Avg) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Avg.getDefaultInstance(); + } + + /** + * + * + *
+     * Average aggregator.
+     * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.AvgOrBuilder getAvgOrBuilder() { + if (operatorCase_ == 3) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Avg) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Avg.getDefaultInstance(); + } + + public static final int ALIAS_FIELD_NUMBER = 7; + + @SuppressWarnings("serial") + private volatile java.lang.Object alias_ = ""; + + /** + * + * + *
+     * Optional. Optional name of the property to store the result of the
+     * aggregation.
+     *
+     * If not provided, Datastore will pick a default name following the format
+     * `property_<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 property_1,
+     *   COUNT_UP_TO(3) AS count_up_to_3,
+     *   COUNT(*) AS property_2
+     * OVER (
+     *   ...
+     * );
+     * ```
+     *
+     * Requires:
+     *
+     * * Must be unique across all aggregation aliases.
+     * * Conform to [entity property
+     * name][google.datastore.v1.Entity.properties] 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 property to store the result of the
+     * aggregation.
+     *
+     * If not provided, Datastore will pick a default name following the format
+     * `property_<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 property_1,
+     *   COUNT_UP_TO(3) AS count_up_to_3,
+     *   COUNT(*) AS property_2
+     * OVER (
+     *   ...
+     * );
+     * ```
+     *
+     * Requires:
+     *
+     * * Must be unique across all aggregation aliases.
+     * * Conform to [entity property
+     * name][google.datastore.v1.Entity.properties] 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.datastore.v1.AggregationQuery.Aggregation.Count) operator_); + } + if (operatorCase_ == 2) { + output.writeMessage( + 2, (com.google.datastore.v1.AggregationQuery.Aggregation.Sum) operator_); + } + if (operatorCase_ == 3) { + output.writeMessage( + 3, (com.google.datastore.v1.AggregationQuery.Aggregation.Avg) operator_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(alias_)) { + com.google.protobuf.GeneratedMessageV3.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.datastore.v1.AggregationQuery.Aggregation.Count) operator_); + } + if (operatorCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.datastore.v1.AggregationQuery.Aggregation.Sum) operator_); + } + if (operatorCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.datastore.v1.AggregationQuery.Aggregation.Avg) operator_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(alias_)) { + size += com.google.protobuf.GeneratedMessageV3.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.datastore.v1.AggregationQuery.Aggregation)) { + return super.equals(obj); + } + com.google.datastore.v1.AggregationQuery.Aggregation other = + (com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery.Aggregation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.AggregationQuery.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Defines an aggregation that produces a single result.
+     * 
+ * + * Protobuf type {@code google.datastore.v1.AggregationQuery.Aggregation} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.AggregationQuery.Aggregation) + com.google.datastore.v1.AggregationQuery.AggregationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationQuery.Aggregation.class, + com.google.datastore.v1.AggregationQuery.Aggregation.Builder.class); + } + + // Construct using com.google.datastore.v1.AggregationQuery.Aggregation.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_Aggregation_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation getDefaultInstanceForType() { + return com.google.datastore.v1.AggregationQuery.Aggregation.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation build() { + com.google.datastore.v1.AggregationQuery.Aggregation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation buildPartial() { + com.google.datastore.v1.AggregationQuery.Aggregation result = + new com.google.datastore.v1.AggregationQuery.Aggregation(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.AggregationQuery.Aggregation result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.alias_ = alias_; + } + } + + private void buildPartialOneofs(com.google.datastore.v1.AggregationQuery.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 clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.AggregationQuery.Aggregation) { + return mergeFrom((com.google.datastore.v1.AggregationQuery.Aggregation) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.AggregationQuery.Aggregation other) { + if (other == com.google.datastore.v1.AggregationQuery.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(getCountFieldBuilder().getBuilder(), extensionRegistry); + operatorCase_ = 1; + break; + } // case 10 + case 18: + { + input.readMessage(getSumFieldBuilder().getBuilder(), extensionRegistry); + operatorCase_ = 2; + break; + } // case 18 + case 26: + { + input.readMessage(getAvgFieldBuilder().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.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation.Count, + com.google.datastore.v1.AggregationQuery.Aggregation.Count.Builder, + com.google.datastore.v1.AggregationQuery.Aggregation.CountOrBuilder> + countBuilder_; + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + * + * @return Whether the count field is set. + */ + @java.lang.Override + public boolean hasCount() { + return operatorCase_ == 1; + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + * + * @return The count. + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Count getCount() { + if (countBuilder_ == null) { + if (operatorCase_ == 1) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Count) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Count.getDefaultInstance(); + } else { + if (operatorCase_ == 1) { + return countBuilder_.getMessage(); + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Count.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + */ + public Builder setCount(com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + */ + public Builder setCount( + com.google.datastore.v1.AggregationQuery.Aggregation.Count.Builder builderForValue) { + if (countBuilder_ == null) { + operator_ = builderForValue.build(); + onChanged(); + } else { + countBuilder_.setMessage(builderForValue.build()); + } + operatorCase_ = 1; + return this; + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + */ + public Builder mergeCount(com.google.datastore.v1.AggregationQuery.Aggregation.Count value) { + if (countBuilder_ == null) { + if (operatorCase_ == 1 + && operator_ + != com.google.datastore.v1.AggregationQuery.Aggregation.Count + .getDefaultInstance()) { + operator_ = + com.google.datastore.v1.AggregationQuery.Aggregation.Count.newBuilder( + (com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + */ + public com.google.datastore.v1.AggregationQuery.Aggregation.Count.Builder getCountBuilder() { + return getCountFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.CountOrBuilder + getCountOrBuilder() { + if ((operatorCase_ == 1) && (countBuilder_ != null)) { + return countBuilder_.getMessageOrBuilder(); + } else { + if (operatorCase_ == 1) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Count) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Count.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Count aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Count count = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation.Count, + com.google.datastore.v1.AggregationQuery.Aggregation.Count.Builder, + com.google.datastore.v1.AggregationQuery.Aggregation.CountOrBuilder> + getCountFieldBuilder() { + if (countBuilder_ == null) { + if (!(operatorCase_ == 1)) { + operator_ = + com.google.datastore.v1.AggregationQuery.Aggregation.Count.getDefaultInstance(); + } + countBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation.Count, + com.google.datastore.v1.AggregationQuery.Aggregation.Count.Builder, + com.google.datastore.v1.AggregationQuery.Aggregation.CountOrBuilder>( + (com.google.datastore.v1.AggregationQuery.Aggregation.Count) operator_, + getParentForChildren(), + isClean()); + operator_ = null; + } + operatorCase_ = 1; + onChanged(); + return countBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation.Sum, + com.google.datastore.v1.AggregationQuery.Aggregation.Sum.Builder, + com.google.datastore.v1.AggregationQuery.Aggregation.SumOrBuilder> + sumBuilder_; + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + * + * @return Whether the sum field is set. + */ + @java.lang.Override + public boolean hasSum() { + return operatorCase_ == 2; + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + * + * @return The sum. + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Sum getSum() { + if (sumBuilder_ == null) { + if (operatorCase_ == 2) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Sum) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Sum.getDefaultInstance(); + } else { + if (operatorCase_ == 2) { + return sumBuilder_.getMessage(); + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Sum.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + */ + public Builder setSum(com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + */ + public Builder setSum( + com.google.datastore.v1.AggregationQuery.Aggregation.Sum.Builder builderForValue) { + if (sumBuilder_ == null) { + operator_ = builderForValue.build(); + onChanged(); + } else { + sumBuilder_.setMessage(builderForValue.build()); + } + operatorCase_ = 2; + return this; + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + */ + public Builder mergeSum(com.google.datastore.v1.AggregationQuery.Aggregation.Sum value) { + if (sumBuilder_ == null) { + if (operatorCase_ == 2 + && operator_ + != com.google.datastore.v1.AggregationQuery.Aggregation.Sum + .getDefaultInstance()) { + operator_ = + com.google.datastore.v1.AggregationQuery.Aggregation.Sum.newBuilder( + (com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + */ + public com.google.datastore.v1.AggregationQuery.Aggregation.Sum.Builder getSumBuilder() { + return getSumFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.SumOrBuilder getSumOrBuilder() { + if ((operatorCase_ == 2) && (sumBuilder_ != null)) { + return sumBuilder_.getMessageOrBuilder(); + } else { + if (operatorCase_ == 2) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Sum) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Sum.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Sum aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Sum sum = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation.Sum, + com.google.datastore.v1.AggregationQuery.Aggregation.Sum.Builder, + com.google.datastore.v1.AggregationQuery.Aggregation.SumOrBuilder> + getSumFieldBuilder() { + if (sumBuilder_ == null) { + if (!(operatorCase_ == 2)) { + operator_ = + com.google.datastore.v1.AggregationQuery.Aggregation.Sum.getDefaultInstance(); + } + sumBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation.Sum, + com.google.datastore.v1.AggregationQuery.Aggregation.Sum.Builder, + com.google.datastore.v1.AggregationQuery.Aggregation.SumOrBuilder>( + (com.google.datastore.v1.AggregationQuery.Aggregation.Sum) operator_, + getParentForChildren(), + isClean()); + operator_ = null; + } + operatorCase_ = 2; + onChanged(); + return sumBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation.Avg, + com.google.datastore.v1.AggregationQuery.Aggregation.Avg.Builder, + com.google.datastore.v1.AggregationQuery.Aggregation.AvgOrBuilder> + avgBuilder_; + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + * + * @return Whether the avg field is set. + */ + @java.lang.Override + public boolean hasAvg() { + return operatorCase_ == 3; + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + * + * @return The avg. + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.Avg getAvg() { + if (avgBuilder_ == null) { + if (operatorCase_ == 3) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Avg) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Avg.getDefaultInstance(); + } else { + if (operatorCase_ == 3) { + return avgBuilder_.getMessage(); + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Avg.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + */ + public Builder setAvg(com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + */ + public Builder setAvg( + com.google.datastore.v1.AggregationQuery.Aggregation.Avg.Builder builderForValue) { + if (avgBuilder_ == null) { + operator_ = builderForValue.build(); + onChanged(); + } else { + avgBuilder_.setMessage(builderForValue.build()); + } + operatorCase_ = 3; + return this; + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + */ + public Builder mergeAvg(com.google.datastore.v1.AggregationQuery.Aggregation.Avg value) { + if (avgBuilder_ == null) { + if (operatorCase_ == 3 + && operator_ + != com.google.datastore.v1.AggregationQuery.Aggregation.Avg + .getDefaultInstance()) { + operator_ = + com.google.datastore.v1.AggregationQuery.Aggregation.Avg.newBuilder( + (com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + */ + public com.google.datastore.v1.AggregationQuery.Aggregation.Avg.Builder getAvgBuilder() { + return getAvgFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation.AvgOrBuilder getAvgOrBuilder() { + if ((operatorCase_ == 3) && (avgBuilder_ != null)) { + return avgBuilder_.getMessageOrBuilder(); + } else { + if (operatorCase_ == 3) { + return (com.google.datastore.v1.AggregationQuery.Aggregation.Avg) operator_; + } + return com.google.datastore.v1.AggregationQuery.Aggregation.Avg.getDefaultInstance(); + } + } + + /** + * + * + *
+       * Average aggregator.
+       * 
+ * + * .google.datastore.v1.AggregationQuery.Aggregation.Avg avg = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation.Avg, + com.google.datastore.v1.AggregationQuery.Aggregation.Avg.Builder, + com.google.datastore.v1.AggregationQuery.Aggregation.AvgOrBuilder> + getAvgFieldBuilder() { + if (avgBuilder_ == null) { + if (!(operatorCase_ == 3)) { + operator_ = + com.google.datastore.v1.AggregationQuery.Aggregation.Avg.getDefaultInstance(); + } + avgBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation.Avg, + com.google.datastore.v1.AggregationQuery.Aggregation.Avg.Builder, + com.google.datastore.v1.AggregationQuery.Aggregation.AvgOrBuilder>( + (com.google.datastore.v1.AggregationQuery.Aggregation.Avg) operator_, + getParentForChildren(), + isClean()); + operator_ = null; + } + operatorCase_ = 3; + onChanged(); + return avgBuilder_; + } + + private java.lang.Object alias_ = ""; + + /** + * + * + *
+       * Optional. Optional name of the property to store the result of the
+       * aggregation.
+       *
+       * If not provided, Datastore will pick a default name following the format
+       * `property_<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 property_1,
+       *   COUNT_UP_TO(3) AS count_up_to_3,
+       *   COUNT(*) AS property_2
+       * OVER (
+       *   ...
+       * );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be unique across all aggregation aliases.
+       * * Conform to [entity property
+       * name][google.datastore.v1.Entity.properties] 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 property to store the result of the
+       * aggregation.
+       *
+       * If not provided, Datastore will pick a default name following the format
+       * `property_<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 property_1,
+       *   COUNT_UP_TO(3) AS count_up_to_3,
+       *   COUNT(*) AS property_2
+       * OVER (
+       *   ...
+       * );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be unique across all aggregation aliases.
+       * * Conform to [entity property
+       * name][google.datastore.v1.Entity.properties] 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 property to store the result of the
+       * aggregation.
+       *
+       * If not provided, Datastore will pick a default name following the format
+       * `property_<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 property_1,
+       *   COUNT_UP_TO(3) AS count_up_to_3,
+       *   COUNT(*) AS property_2
+       * OVER (
+       *   ...
+       * );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be unique across all aggregation aliases.
+       * * Conform to [entity property
+       * name][google.datastore.v1.Entity.properties] 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 property to store the result of the
+       * aggregation.
+       *
+       * If not provided, Datastore will pick a default name following the format
+       * `property_<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 property_1,
+       *   COUNT_UP_TO(3) AS count_up_to_3,
+       *   COUNT(*) AS property_2
+       * OVER (
+       *   ...
+       * );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be unique across all aggregation aliases.
+       * * Conform to [entity property
+       * name][google.datastore.v1.Entity.properties] 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 property to store the result of the
+       * aggregation.
+       *
+       * If not provided, Datastore will pick a default name following the format
+       * `property_<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 property_1,
+       *   COUNT_UP_TO(3) AS count_up_to_3,
+       *   COUNT(*) AS property_2
+       * OVER (
+       *   ...
+       * );
+       * ```
+       *
+       * Requires:
+       *
+       * * Must be unique across all aggregation aliases.
+       * * Conform to [entity property
+       * name][google.datastore.v1.Entity.properties] 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; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.AggregationQuery.Aggregation) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.AggregationQuery.Aggregation) + private static final com.google.datastore.v1.AggregationQuery.Aggregation DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.AggregationQuery.Aggregation(); + } + + public static com.google.datastore.v1.AggregationQuery.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.datastore.v1.AggregationQuery.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 { + NESTED_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 NESTED_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 NESTED_QUERY_FIELD_NUMBER = 1; + + /** + * + * + *
+   * Nested query for aggregation
+   * 
+ * + * .google.datastore.v1.Query nested_query = 1; + * + * @return Whether the nestedQuery field is set. + */ + @java.lang.Override + public boolean hasNestedQuery() { + return queryTypeCase_ == 1; + } + + /** + * + * + *
+   * Nested query for aggregation
+   * 
+ * + * .google.datastore.v1.Query nested_query = 1; + * + * @return The nestedQuery. + */ + @java.lang.Override + public com.google.datastore.v1.Query getNestedQuery() { + if (queryTypeCase_ == 1) { + return (com.google.datastore.v1.Query) queryType_; + } + return com.google.datastore.v1.Query.getDefaultInstance(); + } + + /** + * + * + *
+   * Nested query for aggregation
+   * 
+ * + * .google.datastore.v1.Query nested_query = 1; + */ + @java.lang.Override + public com.google.datastore.v1.QueryOrBuilder getNestedQueryOrBuilder() { + if (queryTypeCase_ == 1) { + return (com.google.datastore.v1.Query) queryType_; + } + return com.google.datastore.v1.Query.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
+   * `nested_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.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
+   * `nested_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List + getAggregationsOrBuilderList() { + return aggregations_; + } + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `nested_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.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
+   * `nested_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.Aggregation getAggregations(int index) { + return aggregations_.get(index); + } + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `nested_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery.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.datastore.v1.Query) 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.datastore.v1.Query) 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.datastore.v1.AggregationQuery)) { + return super.equals(obj); + } + com.google.datastore.v1.AggregationQuery other = (com.google.datastore.v1.AggregationQuery) obj; + + if (!getAggregationsList().equals(other.getAggregationsList())) return false; + if (!getQueryTypeCase().equals(other.getQueryTypeCase())) return false; + switch (queryTypeCase_) { + case 1: + if (!getNestedQuery().equals(other.getNestedQuery())) 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) + NESTED_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getNestedQuery().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.AggregationQuery parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery 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.datastore.v1.AggregationQuery parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationQuery parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationQuery parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationQuery parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.AggregationQuery 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Datastore query for running an aggregation over a
+   * [Query][google.datastore.v1.Query].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.AggregationQuery} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.AggregationQuery) + com.google.datastore.v1.AggregationQueryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationQuery.class, + com.google.datastore.v1.AggregationQuery.Builder.class); + } + + // Construct using com.google.datastore.v1.AggregationQuery.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (nestedQueryBuilder_ != null) { + nestedQueryBuilder_.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.datastore.v1.QueryProto + .internal_static_google_datastore_v1_AggregationQuery_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery getDefaultInstanceForType() { + return com.google.datastore.v1.AggregationQuery.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery build() { + com.google.datastore.v1.AggregationQuery result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationQuery buildPartial() { + com.google.datastore.v1.AggregationQuery result = + new com.google.datastore.v1.AggregationQuery(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.AggregationQuery 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.datastore.v1.AggregationQuery result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.datastore.v1.AggregationQuery result) { + result.queryTypeCase_ = queryTypeCase_; + result.queryType_ = this.queryType_; + if (queryTypeCase_ == 1 && nestedQueryBuilder_ != null) { + result.queryType_ = nestedQueryBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.AggregationQuery) { + return mergeFrom((com.google.datastore.v1.AggregationQuery) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.AggregationQuery other) { + if (other == com.google.datastore.v1.AggregationQuery.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.GeneratedMessageV3.alwaysUseFieldBuilders + ? getAggregationsFieldBuilder() + : null; + } else { + aggregationsBuilder_.addAllMessages(other.aggregations_); + } + } + } + switch (other.getQueryTypeCase()) { + case NESTED_QUERY: + { + mergeNestedQuery(other.getNestedQuery()); + 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(getNestedQueryFieldBuilder().getBuilder(), extensionRegistry); + queryTypeCase_ = 1; + break; + } // case 10 + case 26: + { + com.google.datastore.v1.AggregationQuery.Aggregation m = + input.readMessage( + com.google.datastore.v1.AggregationQuery.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.SingleFieldBuilderV3< + com.google.datastore.v1.Query, + com.google.datastore.v1.Query.Builder, + com.google.datastore.v1.QueryOrBuilder> + nestedQueryBuilder_; + + /** + * + * + *
+     * Nested query for aggregation
+     * 
+ * + * .google.datastore.v1.Query nested_query = 1; + * + * @return Whether the nestedQuery field is set. + */ + @java.lang.Override + public boolean hasNestedQuery() { + return queryTypeCase_ == 1; + } + + /** + * + * + *
+     * Nested query for aggregation
+     * 
+ * + * .google.datastore.v1.Query nested_query = 1; + * + * @return The nestedQuery. + */ + @java.lang.Override + public com.google.datastore.v1.Query getNestedQuery() { + if (nestedQueryBuilder_ == null) { + if (queryTypeCase_ == 1) { + return (com.google.datastore.v1.Query) queryType_; + } + return com.google.datastore.v1.Query.getDefaultInstance(); + } else { + if (queryTypeCase_ == 1) { + return nestedQueryBuilder_.getMessage(); + } + return com.google.datastore.v1.Query.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Nested query for aggregation
+     * 
+ * + * .google.datastore.v1.Query nested_query = 1; + */ + public Builder setNestedQuery(com.google.datastore.v1.Query value) { + if (nestedQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + nestedQueryBuilder_.setMessage(value); + } + queryTypeCase_ = 1; + return this; + } + + /** + * + * + *
+     * Nested query for aggregation
+     * 
+ * + * .google.datastore.v1.Query nested_query = 1; + */ + public Builder setNestedQuery(com.google.datastore.v1.Query.Builder builderForValue) { + if (nestedQueryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + nestedQueryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 1; + return this; + } + + /** + * + * + *
+     * Nested query for aggregation
+     * 
+ * + * .google.datastore.v1.Query nested_query = 1; + */ + public Builder mergeNestedQuery(com.google.datastore.v1.Query value) { + if (nestedQueryBuilder_ == null) { + if (queryTypeCase_ == 1 + && queryType_ != com.google.datastore.v1.Query.getDefaultInstance()) { + queryType_ = + com.google.datastore.v1.Query.newBuilder((com.google.datastore.v1.Query) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 1) { + nestedQueryBuilder_.mergeFrom(value); + } else { + nestedQueryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 1; + return this; + } + + /** + * + * + *
+     * Nested query for aggregation
+     * 
+ * + * .google.datastore.v1.Query nested_query = 1; + */ + public Builder clearNestedQuery() { + if (nestedQueryBuilder_ == null) { + if (queryTypeCase_ == 1) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 1) { + queryTypeCase_ = 0; + queryType_ = null; + } + nestedQueryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Nested query for aggregation
+     * 
+ * + * .google.datastore.v1.Query nested_query = 1; + */ + public com.google.datastore.v1.Query.Builder getNestedQueryBuilder() { + return getNestedQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Nested query for aggregation
+     * 
+ * + * .google.datastore.v1.Query nested_query = 1; + */ + @java.lang.Override + public com.google.datastore.v1.QueryOrBuilder getNestedQueryOrBuilder() { + if ((queryTypeCase_ == 1) && (nestedQueryBuilder_ != null)) { + return nestedQueryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 1) { + return (com.google.datastore.v1.Query) queryType_; + } + return com.google.datastore.v1.Query.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Nested query for aggregation
+     * 
+ * + * .google.datastore.v1.Query nested_query = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Query, + com.google.datastore.v1.Query.Builder, + com.google.datastore.v1.QueryOrBuilder> + getNestedQueryFieldBuilder() { + if (nestedQueryBuilder_ == null) { + if (!(queryTypeCase_ == 1)) { + queryType_ = com.google.datastore.v1.Query.getDefaultInstance(); + } + nestedQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Query, + com.google.datastore.v1.Query.Builder, + com.google.datastore.v1.QueryOrBuilder>( + (com.google.datastore.v1.Query) queryType_, getParentForChildren(), isClean()); + queryType_ = null; + } + queryTypeCase_ = 1; + onChanged(); + return nestedQueryBuilder_; + } + + 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.RepeatedFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation, + com.google.datastore.v1.AggregationQuery.Aggregation.Builder, + com.google.datastore.v1.AggregationQuery.AggregationOrBuilder> + aggregationsBuilder_; + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setAggregations( + int index, com.google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setAggregations( + int index, com.google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAggregations(com.google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAggregations( + int index, com.google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAggregations( + com.google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAggregations( + int index, com.google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.AggregationQuery.Aggregation.Builder getAggregationsBuilder( + int index) { + return getAggregationsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.AggregationQuery.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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List + 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
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.AggregationQuery.Aggregation.Builder addAggregationsBuilder() { + return getAggregationsFieldBuilder() + .addBuilder(com.google.datastore.v1.AggregationQuery.Aggregation.getDefaultInstance()); + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.AggregationQuery.Aggregation.Builder addAggregationsBuilder( + int index) { + return getAggregationsFieldBuilder() + .addBuilder( + index, com.google.datastore.v1.AggregationQuery.Aggregation.getDefaultInstance()); + } + + /** + * + * + *
+     * Optional. Series of aggregations to apply over the results of the
+     * `nested_query`.
+     *
+     * Requires:
+     *
+     * * A minimum of one and maximum of five aggregations per query.
+     * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List + getAggregationsBuilderList() { + return getAggregationsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation, + com.google.datastore.v1.AggregationQuery.Aggregation.Builder, + com.google.datastore.v1.AggregationQuery.AggregationOrBuilder> + getAggregationsFieldBuilder() { + if (aggregationsBuilder_ == null) { + aggregationsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.AggregationQuery.Aggregation, + com.google.datastore.v1.AggregationQuery.Aggregation.Builder, + com.google.datastore.v1.AggregationQuery.AggregationOrBuilder>( + aggregations_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + aggregations_ = null; + } + return aggregationsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.AggregationQuery) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.AggregationQuery) + private static final com.google.datastore.v1.AggregationQuery DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.AggregationQuery(); + } + + public static com.google.datastore.v1.AggregationQuery getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public AggregationQuery 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.datastore.v1.AggregationQuery getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQueryOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQueryOrBuilder.java new file mode 100644 index 000000000000..6d09610d2536 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationQueryOrBuilder.java @@ -0,0 +1,156 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface AggregationQueryOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.AggregationQuery) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Nested query for aggregation
+   * 
+ * + * .google.datastore.v1.Query nested_query = 1; + * + * @return Whether the nestedQuery field is set. + */ + boolean hasNestedQuery(); + + /** + * + * + *
+   * Nested query for aggregation
+   * 
+ * + * .google.datastore.v1.Query nested_query = 1; + * + * @return The nestedQuery. + */ + com.google.datastore.v1.Query getNestedQuery(); + + /** + * + * + *
+   * Nested query for aggregation
+   * 
+ * + * .google.datastore.v1.Query nested_query = 1; + */ + com.google.datastore.v1.QueryOrBuilder getNestedQueryOrBuilder(); + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `nested_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List getAggregationsList(); + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `nested_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.datastore.v1.AggregationQuery.Aggregation getAggregations(int index); + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `nested_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + int getAggregationsCount(); + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `nested_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List + getAggregationsOrBuilderList(); + + /** + * + * + *
+   * Optional. Series of aggregations to apply over the results of the
+   * `nested_query`.
+   *
+   * Requires:
+   *
+   * * A minimum of one and maximum of five aggregations per query.
+   * 
+ * + * + * repeated .google.datastore.v1.AggregationQuery.Aggregation aggregations = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.datastore.v1.AggregationQuery.AggregationOrBuilder getAggregationsOrBuilder(int index); + + com.google.datastore.v1.AggregationQuery.QueryTypeCase getQueryTypeCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResult.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResult.java new file mode 100644 index 000000000000..5050ba9df5e5 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResult.java @@ -0,0 +1,948 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/aggregation_result.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The result of a single bucket from a Datastore aggregation query.
+ *
+ * The keys of `aggregate_properties` are the same for all results in an
+ * aggregation query, unlike entity queries which can have different fields
+ * present for each result.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.AggregationResult} + */ +public final class AggregationResult extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.AggregationResult) + AggregationResultOrBuilder { + private static final long serialVersionUID = 0L; + + // Use AggregationResult.newBuilder() to construct. + private AggregationResult(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private AggregationResult() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new AggregationResult(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResult_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetAggregateProperties(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationResult.class, + com.google.datastore.v1.AggregationResult.Builder.class); + } + + public static final int AGGREGATE_PROPERTIES_FIELD_NUMBER = 2; + + private static final class AggregatePropertiesDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResult_AggregatePropertiesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.datastore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField + aggregateProperties_; + + private com.google.protobuf.MapField + internalGetAggregateProperties() { + if (aggregateProperties_ == null) { + return com.google.protobuf.MapField.emptyMapField( + AggregatePropertiesDefaultEntryHolder.defaultEntry); + } + return aggregateProperties_; + } + + public int getAggregatePropertiesCount() { + return internalGetAggregateProperties().getMap().size(); + } + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+   *
+   * The key is the
+   * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + @java.lang.Override + public boolean containsAggregateProperties(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetAggregateProperties().getMap().containsKey(key); + } + + /** Use {@link #getAggregatePropertiesMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getAggregateProperties() { + return getAggregatePropertiesMap(); + } + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+   *
+   * The key is the
+   * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + @java.lang.Override + public java.util.Map + getAggregatePropertiesMap() { + return internalGetAggregateProperties().getMap(); + } + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+   *
+   * The key is the
+   * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + @java.lang.Override + public /* nullable */ com.google.datastore.v1.Value getAggregatePropertiesOrDefault( + java.lang.String key, + /* nullable */ + com.google.datastore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetAggregateProperties().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+   *
+   * The key is the
+   * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + @java.lang.Override + public com.google.datastore.v1.Value getAggregatePropertiesOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetAggregateProperties().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.GeneratedMessageV3.serializeStringMapTo( + output, + internalGetAggregateProperties(), + AggregatePropertiesDefaultEntryHolder.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 : + internalGetAggregateProperties().getMap().entrySet()) { + com.google.protobuf.MapEntry + aggregateProperties__ = + AggregatePropertiesDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, aggregateProperties__); + } + 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.datastore.v1.AggregationResult)) { + return super.equals(obj); + } + com.google.datastore.v1.AggregationResult other = + (com.google.datastore.v1.AggregationResult) obj; + + if (!internalGetAggregateProperties().equals(other.internalGetAggregateProperties())) + 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 (!internalGetAggregateProperties().getMap().isEmpty()) { + hash = (37 * hash) + AGGREGATE_PROPERTIES_FIELD_NUMBER; + hash = (53 * hash) + internalGetAggregateProperties().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.AggregationResult parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.AggregationResult parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.AggregationResult parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationResult parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationResult parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationResult parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationResult parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationResult parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationResult parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationResult parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The result of a single bucket from a Datastore aggregation query.
+   *
+   * The keys of `aggregate_properties` are the same for all results in an
+   * aggregation query, unlike entity queries which can have different fields
+   * present for each result.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.AggregationResult} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.AggregationResult) + com.google.datastore.v1.AggregationResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResult_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetAggregateProperties(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 2: + return internalGetMutableAggregateProperties(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationResult.class, + com.google.datastore.v1.AggregationResult.Builder.class); + } + + // Construct using com.google.datastore.v1.AggregationResult.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + internalGetMutableAggregateProperties().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResult_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationResult getDefaultInstanceForType() { + return com.google.datastore.v1.AggregationResult.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.AggregationResult build() { + com.google.datastore.v1.AggregationResult result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationResult buildPartial() { + com.google.datastore.v1.AggregationResult result = + new com.google.datastore.v1.AggregationResult(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.AggregationResult result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.aggregateProperties_ = + internalGetAggregateProperties() + .build(AggregatePropertiesDefaultEntryHolder.defaultEntry); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.AggregationResult) { + return mergeFrom((com.google.datastore.v1.AggregationResult) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.AggregationResult other) { + if (other == com.google.datastore.v1.AggregationResult.getDefaultInstance()) return this; + internalGetMutableAggregateProperties().mergeFrom(other.internalGetAggregateProperties()); + 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 + aggregateProperties__ = + input.readMessage( + AggregatePropertiesDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableAggregateProperties() + .ensureBuilderMap() + .put(aggregateProperties__.getKey(), aggregateProperties__.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 AggregatePropertiesConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.datastore.v1.ValueOrBuilder, + com.google.datastore.v1.Value> { + @java.lang.Override + public com.google.datastore.v1.Value build(com.google.datastore.v1.ValueOrBuilder val) { + if (val instanceof com.google.datastore.v1.Value) { + return (com.google.datastore.v1.Value) val; + } + return ((com.google.datastore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return AggregatePropertiesDefaultEntryHolder.defaultEntry; + } + } + ; + + private static final AggregatePropertiesConverter aggregatePropertiesConverter = + new AggregatePropertiesConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.datastore.v1.ValueOrBuilder, + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder> + aggregateProperties_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.datastore.v1.ValueOrBuilder, + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder> + internalGetAggregateProperties() { + if (aggregateProperties_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(aggregatePropertiesConverter); + } + return aggregateProperties_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.datastore.v1.ValueOrBuilder, + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder> + internalGetMutableAggregateProperties() { + if (aggregateProperties_ == null) { + aggregateProperties_ = + new com.google.protobuf.MapFieldBuilder<>(aggregatePropertiesConverter); + } + bitField0_ |= 0x00000001; + onChanged(); + return aggregateProperties_; + } + + public int getAggregatePropertiesCount() { + return internalGetAggregateProperties().ensureBuilderMap().size(); + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+     *
+     * The key is the
+     * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + @java.lang.Override + public boolean containsAggregateProperties(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetAggregateProperties().ensureBuilderMap().containsKey(key); + } + + /** Use {@link #getAggregatePropertiesMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getAggregateProperties() { + return getAggregatePropertiesMap(); + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+     *
+     * The key is the
+     * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + @java.lang.Override + public java.util.Map + getAggregatePropertiesMap() { + return internalGetAggregateProperties().getImmutableMap(); + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+     *
+     * The key is the
+     * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + @java.lang.Override + public /* nullable */ com.google.datastore.v1.Value getAggregatePropertiesOrDefault( + java.lang.String key, + /* nullable */ + com.google.datastore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableAggregateProperties().ensureBuilderMap(); + return map.containsKey(key) ? aggregatePropertiesConverter.build(map.get(key)) : defaultValue; + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+     *
+     * The key is the
+     * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + @java.lang.Override + public com.google.datastore.v1.Value getAggregatePropertiesOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableAggregateProperties().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return aggregatePropertiesConverter.build(map.get(key)); + } + + public Builder clearAggregateProperties() { + bitField0_ = (bitField0_ & ~0x00000001); + internalGetMutableAggregateProperties().clear(); + return this; + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+     *
+     * The key is the
+     * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + public Builder removeAggregateProperties(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableAggregateProperties().ensureBuilderMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map + getMutableAggregateProperties() { + bitField0_ |= 0x00000001; + return internalGetMutableAggregateProperties().ensureMessageMap(); + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+     *
+     * The key is the
+     * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + public Builder putAggregateProperties( + java.lang.String key, com.google.datastore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableAggregateProperties().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000001; + return this; + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+     *
+     * The key is the
+     * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + public Builder putAllAggregateProperties( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableAggregateProperties().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000001; + return this; + } + + /** + * + * + *
+     * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+     *
+     * The key is the
+     * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + public com.google.datastore.v1.Value.Builder putAggregatePropertiesBuilderIfAbsent( + java.lang.String key) { + java.util.Map builderMap = + internalGetMutableAggregateProperties().ensureBuilderMap(); + com.google.datastore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.datastore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.datastore.v1.Value) { + entry = ((com.google.datastore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.datastore.v1.Value.Builder) entry; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.AggregationResult) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.AggregationResult) + private static final com.google.datastore.v1.AggregationResult DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.AggregationResult(); + } + + public static com.google.datastore.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.datastore.v1.AggregationResult getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatch.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatch.java new file mode 100644 index 000000000000..dcdff0999200 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatch.java @@ -0,0 +1,1479 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/aggregation_result.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A batch of aggregation results produced by an aggregation query.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.AggregationResultBatch} + */ +public final class AggregationResultBatch extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.AggregationResultBatch) + AggregationResultBatchOrBuilder { + private static final long serialVersionUID = 0L; + + // Use AggregationResultBatch.newBuilder() to construct. + private AggregationResultBatch(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private AggregationResultBatch() { + aggregationResults_ = java.util.Collections.emptyList(); + moreResults_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new AggregationResultBatch(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResultBatch_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResultBatch_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationResultBatch.class, + com.google.datastore.v1.AggregationResultBatch.Builder.class); + } + + private int bitField0_; + public static final int AGGREGATION_RESULTS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List aggregationResults_; + + /** + * + * + *
+   * The aggregation results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + @java.lang.Override + public java.util.List getAggregationResultsList() { + return aggregationResults_; + } + + /** + * + * + *
+   * The aggregation results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + @java.lang.Override + public java.util.List + getAggregationResultsOrBuilderList() { + return aggregationResults_; + } + + /** + * + * + *
+   * The aggregation results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + @java.lang.Override + public int getAggregationResultsCount() { + return aggregationResults_.size(); + } + + /** + * + * + *
+   * The aggregation results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationResult getAggregationResults(int index) { + return aggregationResults_.get(index); + } + + /** + * + * + *
+   * The aggregation results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationResultOrBuilder getAggregationResultsOrBuilder( + int index) { + return aggregationResults_.get(index); + } + + public static final int MORE_RESULTS_FIELD_NUMBER = 2; + private int moreResults_ = 0; + + /** + * + * + *
+   * The state of the query after the current batch.
+   * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
+   * expected result type is limited to `NO_MORE_RESULTS`.
+   * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2; + * + * @return The enum numeric value on the wire for moreResults. + */ + @java.lang.Override + public int getMoreResultsValue() { + return moreResults_; + } + + /** + * + * + *
+   * The state of the query after the current batch.
+   * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
+   * expected result type is limited to `NO_MORE_RESULTS`.
+   * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2; + * + * @return The moreResults. + */ + @java.lang.Override + public com.google.datastore.v1.QueryResultBatch.MoreResultsType getMoreResults() { + com.google.datastore.v1.QueryResultBatch.MoreResultsType result = + com.google.datastore.v1.QueryResultBatch.MoreResultsType.forNumber(moreResults_); + return result == null + ? com.google.datastore.v1.QueryResultBatch.MoreResultsType.UNRECOGNIZED + : result; + } + + public static final int READ_TIME_FIELD_NUMBER = 3; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * 
+ * + * .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_; + } + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * 
+ * + * .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 { + for (int i = 0; i < aggregationResults_.size(); i++) { + output.writeMessage(1, aggregationResults_.get(i)); + } + if (moreResults_ + != com.google.datastore.v1.QueryResultBatch.MoreResultsType.MORE_RESULTS_TYPE_UNSPECIFIED + .getNumber()) { + output.writeEnum(2, moreResults_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getReadTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < aggregationResults_.size(); i++) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize(1, aggregationResults_.get(i)); + } + if (moreResults_ + != com.google.datastore.v1.QueryResultBatch.MoreResultsType.MORE_RESULTS_TYPE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, moreResults_); + } + if (((bitField0_ & 0x00000001) != 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.datastore.v1.AggregationResultBatch)) { + return super.equals(obj); + } + com.google.datastore.v1.AggregationResultBatch other = + (com.google.datastore.v1.AggregationResultBatch) obj; + + if (!getAggregationResultsList().equals(other.getAggregationResultsList())) return false; + if (moreResults_ != other.moreResults_) 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(); + if (getAggregationResultsCount() > 0) { + hash = (37 * hash) + AGGREGATION_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getAggregationResultsList().hashCode(); + } + hash = (37 * hash) + MORE_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + moreResults_; + 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.datastore.v1.AggregationResultBatch parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationResultBatch parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationResultBatch parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationResultBatch 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.datastore.v1.AggregationResultBatch parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AggregationResultBatch parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationResultBatch parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationResultBatch parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationResultBatch parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationResultBatch parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AggregationResultBatch parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AggregationResultBatch parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.AggregationResultBatch 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A batch of aggregation results produced by an aggregation query.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.AggregationResultBatch} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.AggregationResultBatch) + com.google.datastore.v1.AggregationResultBatchOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResultBatch_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResultBatch_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AggregationResultBatch.class, + com.google.datastore.v1.AggregationResultBatch.Builder.class); + } + + // Construct using com.google.datastore.v1.AggregationResultBatch.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getAggregationResultsFieldBuilder(); + getReadTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (aggregationResultsBuilder_ == null) { + aggregationResults_ = java.util.Collections.emptyList(); + } else { + aggregationResults_ = null; + aggregationResultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + moreResults_ = 0; + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.AggregationResultProto + .internal_static_google_datastore_v1_AggregationResultBatch_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationResultBatch getDefaultInstanceForType() { + return com.google.datastore.v1.AggregationResultBatch.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.AggregationResultBatch build() { + com.google.datastore.v1.AggregationResultBatch result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.AggregationResultBatch buildPartial() { + com.google.datastore.v1.AggregationResultBatch result = + new com.google.datastore.v1.AggregationResultBatch(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.AggregationResultBatch result) { + if (aggregationResultsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + aggregationResults_ = java.util.Collections.unmodifiableList(aggregationResults_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.aggregationResults_ = aggregationResults_; + } else { + result.aggregationResults_ = aggregationResultsBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.AggregationResultBatch result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.moreResults_ = moreResults_; + } + 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 clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.AggregationResultBatch) { + return mergeFrom((com.google.datastore.v1.AggregationResultBatch) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.AggregationResultBatch other) { + if (other == com.google.datastore.v1.AggregationResultBatch.getDefaultInstance()) return this; + if (aggregationResultsBuilder_ == null) { + if (!other.aggregationResults_.isEmpty()) { + if (aggregationResults_.isEmpty()) { + aggregationResults_ = other.aggregationResults_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureAggregationResultsIsMutable(); + aggregationResults_.addAll(other.aggregationResults_); + } + onChanged(); + } + } else { + if (!other.aggregationResults_.isEmpty()) { + if (aggregationResultsBuilder_.isEmpty()) { + aggregationResultsBuilder_.dispose(); + aggregationResultsBuilder_ = null; + aggregationResults_ = other.aggregationResults_; + bitField0_ = (bitField0_ & ~0x00000001); + aggregationResultsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getAggregationResultsFieldBuilder() + : null; + } else { + aggregationResultsBuilder_.addAllMessages(other.aggregationResults_); + } + } + } + if (other.moreResults_ != 0) { + setMoreResultsValue(other.getMoreResultsValue()); + } + 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: + { + com.google.datastore.v1.AggregationResult m = + input.readMessage( + com.google.datastore.v1.AggregationResult.parser(), extensionRegistry); + if (aggregationResultsBuilder_ == null) { + ensureAggregationResultsIsMutable(); + aggregationResults_.add(m); + } else { + aggregationResultsBuilder_.addMessage(m); + } + break; + } // case 10 + case 16: + { + moreResults_ = input.readEnum(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: + { + input.readMessage(getReadTimeFieldBuilder().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.util.List aggregationResults_ = + java.util.Collections.emptyList(); + + private void ensureAggregationResultsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + aggregationResults_ = + new java.util.ArrayList(aggregationResults_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.AggregationResult, + com.google.datastore.v1.AggregationResult.Builder, + com.google.datastore.v1.AggregationResultOrBuilder> + aggregationResultsBuilder_; + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public java.util.List getAggregationResultsList() { + if (aggregationResultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(aggregationResults_); + } else { + return aggregationResultsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public int getAggregationResultsCount() { + if (aggregationResultsBuilder_ == null) { + return aggregationResults_.size(); + } else { + return aggregationResultsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public com.google.datastore.v1.AggregationResult getAggregationResults(int index) { + if (aggregationResultsBuilder_ == null) { + return aggregationResults_.get(index); + } else { + return aggregationResultsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public Builder setAggregationResults( + int index, com.google.datastore.v1.AggregationResult value) { + if (aggregationResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAggregationResultsIsMutable(); + aggregationResults_.set(index, value); + onChanged(); + } else { + aggregationResultsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public Builder setAggregationResults( + int index, com.google.datastore.v1.AggregationResult.Builder builderForValue) { + if (aggregationResultsBuilder_ == null) { + ensureAggregationResultsIsMutable(); + aggregationResults_.set(index, builderForValue.build()); + onChanged(); + } else { + aggregationResultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public Builder addAggregationResults(com.google.datastore.v1.AggregationResult value) { + if (aggregationResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAggregationResultsIsMutable(); + aggregationResults_.add(value); + onChanged(); + } else { + aggregationResultsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public Builder addAggregationResults( + int index, com.google.datastore.v1.AggregationResult value) { + if (aggregationResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureAggregationResultsIsMutable(); + aggregationResults_.add(index, value); + onChanged(); + } else { + aggregationResultsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public Builder addAggregationResults( + com.google.datastore.v1.AggregationResult.Builder builderForValue) { + if (aggregationResultsBuilder_ == null) { + ensureAggregationResultsIsMutable(); + aggregationResults_.add(builderForValue.build()); + onChanged(); + } else { + aggregationResultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public Builder addAggregationResults( + int index, com.google.datastore.v1.AggregationResult.Builder builderForValue) { + if (aggregationResultsBuilder_ == null) { + ensureAggregationResultsIsMutable(); + aggregationResults_.add(index, builderForValue.build()); + onChanged(); + } else { + aggregationResultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public Builder addAllAggregationResults( + java.lang.Iterable values) { + if (aggregationResultsBuilder_ == null) { + ensureAggregationResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, aggregationResults_); + onChanged(); + } else { + aggregationResultsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public Builder clearAggregationResults() { + if (aggregationResultsBuilder_ == null) { + aggregationResults_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + aggregationResultsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public Builder removeAggregationResults(int index) { + if (aggregationResultsBuilder_ == null) { + ensureAggregationResultsIsMutable(); + aggregationResults_.remove(index); + onChanged(); + } else { + aggregationResultsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public com.google.datastore.v1.AggregationResult.Builder getAggregationResultsBuilder( + int index) { + return getAggregationResultsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public com.google.datastore.v1.AggregationResultOrBuilder getAggregationResultsOrBuilder( + int index) { + if (aggregationResultsBuilder_ == null) { + return aggregationResults_.get(index); + } else { + return aggregationResultsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public java.util.List + getAggregationResultsOrBuilderList() { + if (aggregationResultsBuilder_ != null) { + return aggregationResultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(aggregationResults_); + } + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public com.google.datastore.v1.AggregationResult.Builder addAggregationResultsBuilder() { + return getAggregationResultsFieldBuilder() + .addBuilder(com.google.datastore.v1.AggregationResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public com.google.datastore.v1.AggregationResult.Builder addAggregationResultsBuilder( + int index) { + return getAggregationResultsFieldBuilder() + .addBuilder(index, com.google.datastore.v1.AggregationResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The aggregation results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + public java.util.List + getAggregationResultsBuilderList() { + return getAggregationResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.AggregationResult, + com.google.datastore.v1.AggregationResult.Builder, + com.google.datastore.v1.AggregationResultOrBuilder> + getAggregationResultsFieldBuilder() { + if (aggregationResultsBuilder_ == null) { + aggregationResultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.AggregationResult, + com.google.datastore.v1.AggregationResult.Builder, + com.google.datastore.v1.AggregationResultOrBuilder>( + aggregationResults_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + aggregationResults_ = null; + } + return aggregationResultsBuilder_; + } + + private int moreResults_ = 0; + + /** + * + * + *
+     * The state of the query after the current batch.
+     * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
+     * expected result type is limited to `NO_MORE_RESULTS`.
+     * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2; + * + * @return The enum numeric value on the wire for moreResults. + */ + @java.lang.Override + public int getMoreResultsValue() { + return moreResults_; + } + + /** + * + * + *
+     * The state of the query after the current batch.
+     * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
+     * expected result type is limited to `NO_MORE_RESULTS`.
+     * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2; + * + * @param value The enum numeric value on the wire for moreResults to set. + * @return This builder for chaining. + */ + public Builder setMoreResultsValue(int value) { + moreResults_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the query after the current batch.
+     * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
+     * expected result type is limited to `NO_MORE_RESULTS`.
+     * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2; + * + * @return The moreResults. + */ + @java.lang.Override + public com.google.datastore.v1.QueryResultBatch.MoreResultsType getMoreResults() { + com.google.datastore.v1.QueryResultBatch.MoreResultsType result = + com.google.datastore.v1.QueryResultBatch.MoreResultsType.forNumber(moreResults_); + return result == null + ? com.google.datastore.v1.QueryResultBatch.MoreResultsType.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * The state of the query after the current batch.
+     * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
+     * expected result type is limited to `NO_MORE_RESULTS`.
+     * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2; + * + * @param value The moreResults to set. + * @return This builder for chaining. + */ + public Builder setMoreResults(com.google.datastore.v1.QueryResultBatch.MoreResultsType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + moreResults_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the query after the current batch.
+     * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
+     * expected result type is limited to `NO_MORE_RESULTS`.
+     * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2; + * + * @return This builder for chaining. + */ + public Builder clearMoreResults() { + bitField0_ = (bitField0_ & ~0x00000002); + moreResults_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * 
+ * + * .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(); + } + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * 
+ * + * .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; + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * 
+ * + * .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; + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * 
+ * + * .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; + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000004); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * 
+ * + * .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_; + } + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.AggregationResultBatch) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.AggregationResultBatch) + private static final com.google.datastore.v1.AggregationResultBatch DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.AggregationResultBatch(); + } + + public static com.google.datastore.v1.AggregationResultBatch getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public AggregationResultBatch 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.datastore.v1.AggregationResultBatch getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatchOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatchOrBuilder.java new file mode 100644 index 000000000000..7eeb07a7a0e0 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultBatchOrBuilder.java @@ -0,0 +1,161 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/aggregation_result.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface AggregationResultBatchOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.AggregationResultBatch) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The aggregation results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + java.util.List getAggregationResultsList(); + + /** + * + * + *
+   * The aggregation results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + com.google.datastore.v1.AggregationResult getAggregationResults(int index); + + /** + * + * + *
+   * The aggregation results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + int getAggregationResultsCount(); + + /** + * + * + *
+   * The aggregation results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + java.util.List + getAggregationResultsOrBuilderList(); + + /** + * + * + *
+   * The aggregation results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.AggregationResult aggregation_results = 1; + */ + com.google.datastore.v1.AggregationResultOrBuilder getAggregationResultsOrBuilder(int index); + + /** + * + * + *
+   * The state of the query after the current batch.
+   * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
+   * expected result type is limited to `NO_MORE_RESULTS`.
+   * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2; + * + * @return The enum numeric value on the wire for moreResults. + */ + int getMoreResultsValue(); + + /** + * + * + *
+   * The state of the query after the current batch.
+   * Only COUNT(*) aggregations are supported in the initial launch. Therefore,
+   * expected result type is limited to `NO_MORE_RESULTS`.
+   * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 2; + * + * @return The moreResults. + */ + com.google.datastore.v1.QueryResultBatch.MoreResultsType getMoreResults(); + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 3; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultOrBuilder.java new file mode 100644 index 000000000000..8e11000cc547 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultOrBuilder.java @@ -0,0 +1,114 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/aggregation_result.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface AggregationResultOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.AggregationResult) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+   *
+   * The key is the
+   * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + int getAggregatePropertiesCount(); + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+   *
+   * The key is the
+   * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + boolean containsAggregateProperties(java.lang.String key); + + /** Use {@link #getAggregatePropertiesMap()} instead. */ + @java.lang.Deprecated + java.util.Map getAggregateProperties(); + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+   *
+   * The key is the
+   * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + java.util.Map getAggregatePropertiesMap(); + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+   *
+   * The key is the
+   * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + /* nullable */ + com.google.datastore.v1.Value getAggregatePropertiesOrDefault( + java.lang.String key, + /* nullable */ + com.google.datastore.v1.Value defaultValue); + + /** + * + * + *
+   * The result of the aggregation functions, ex: `COUNT(*) AS total_entities`.
+   *
+   * The key is the
+   * [alias][google.datastore.v1.AggregationQuery.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.datastore.v1.Value> aggregate_properties = 2; + */ + com.google.datastore.v1.Value getAggregatePropertiesOrThrow(java.lang.String key); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultProto.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultProto.java new file mode 100644 index 000000000000..0b48050e9a93 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AggregationResultProto.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! +// source: google/datastore/v1/aggregation_result.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public final class AggregationResultProto { + private 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_datastore_v1_AggregationResult_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_AggregationResult_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_AggregationResult_AggregatePropertiesEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_AggregationResult_AggregatePropertiesEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_AggregationResultBatch_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_AggregationResultBatch_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/datastore/v1/aggregation_result" + + ".proto\022\023google.datastore.v1\032 google/data" + + "store/v1/entity.proto\032\037google/datastore/" + + "v1/query.proto\032\037google/protobuf/timestam" + + "p.proto\"\312\001\n\021AggregationResult\022]\n\024aggrega" + + "te_properties\030\002 \003(\0132?.google.datastore.v" + + "1.AggregationResult.AggregatePropertiesE" + + "ntry\032V\n\030AggregatePropertiesEntry\022\013\n\003key\030" + + "\001 \001(\t\022)\n\005value\030\002 \001(\0132\032.google.datastore." + + "v1.Value:\0028\001\"\331\001\n\026AggregationResultBatch\022" + + "C\n\023aggregation_results\030\001 \003(\0132&.google.da" + + "tastore.v1.AggregationResult\022K\n\014more_res" + + "ults\030\002 \001(\01625.google.datastore.v1.QueryRe" + + "sultBatch.MoreResultsType\022-\n\tread_time\030\003" + + " \001(\0132\032.google.protobuf.TimestampB\307\001\n\027com" + + ".google.datastore.v1B\026AggregationResultP" + + "rotoP\001Z;cloud.google.com/go/datastore/ap" + + "iv1/datastorepb;datastorepb\252\002\031Google.Clo" + + "ud.Datastore.V1\312\002\031Google\\Cloud\\Datastore" + + "\\V1\352\002\034Google::Cloud::Datastore::V1b\006prot" + + "o3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.datastore.v1.EntityProto.getDescriptor(), + com.google.datastore.v1.QueryProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_datastore_v1_AggregationResult_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_datastore_v1_AggregationResult_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_AggregationResult_descriptor, + new java.lang.String[] { + "AggregateProperties", + }); + internal_static_google_datastore_v1_AggregationResult_AggregatePropertiesEntry_descriptor = + internal_static_google_datastore_v1_AggregationResult_descriptor.getNestedTypes().get(0); + internal_static_google_datastore_v1_AggregationResult_AggregatePropertiesEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_AggregationResult_AggregatePropertiesEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + internal_static_google_datastore_v1_AggregationResultBatch_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_datastore_v1_AggregationResultBatch_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_AggregationResultBatch_descriptor, + new java.lang.String[] { + "AggregationResults", "MoreResults", "ReadTime", + }); + com.google.datastore.v1.EntityProto.getDescriptor(); + com.google.datastore.v1.QueryProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsRequest.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsRequest.java new file mode 100644 index 000000000000..3bceb8c32a75 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsRequest.java @@ -0,0 +1,1396 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The request for
+ * [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.AllocateIdsRequest} + */ +public final class AllocateIdsRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.AllocateIdsRequest) + AllocateIdsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use AllocateIdsRequest.newBuilder() to construct. + private AllocateIdsRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private AllocateIdsRequest() { + projectId_ = ""; + databaseId_ = ""; + keys_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new AllocateIdsRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_AllocateIdsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_AllocateIdsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AllocateIdsRequest.class, + com.google.datastore.v1.AllocateIdsRequest.Builder.class); + } + + public static final int PROJECT_ID_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 9; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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 KEYS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List keys_; + + /** + * + * + *
+   * Required. A list of keys with incomplete key paths for which to allocate
+   * IDs. No key may be reserved/read-only.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public java.util.List getKeysList() { + return keys_; + } + + /** + * + * + *
+   * Required. A list of keys with incomplete key paths for which to allocate
+   * IDs. No key may be reserved/read-only.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public java.util.List getKeysOrBuilderList() { + return keys_; + } + + /** + * + * + *
+   * Required. A list of keys with incomplete key paths for which to allocate
+   * IDs. No key may be reserved/read-only.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public int getKeysCount() { + return keys_.size(); + } + + /** + * + * + *
+   * Required. A list of keys with incomplete key paths for which to allocate
+   * IDs. No key may be reserved/read-only.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.v1.Key getKeys(int index) { + return keys_.get(index); + } + + /** + * + * + *
+   * Required. A list of keys with incomplete key paths for which to allocate
+   * IDs. No key may be reserved/read-only.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index) { + return keys_.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 < keys_.size(); i++) { + output.writeMessage(1, keys_.get(i)); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, databaseId_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < keys_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, keys_.get(i)); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, 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.datastore.v1.AllocateIdsRequest)) { + return super.equals(obj); + } + com.google.datastore.v1.AllocateIdsRequest other = + (com.google.datastore.v1.AllocateIdsRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (!getKeysList().equals(other.getKeysList())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + if (getKeysCount() > 0) { + hash = (37 * hash) + KEYS_FIELD_NUMBER; + hash = (53 * hash) + getKeysList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.AllocateIdsRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AllocateIdsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AllocateIdsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AllocateIdsRequest 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.datastore.v1.AllocateIdsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AllocateIdsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AllocateIdsRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AllocateIdsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AllocateIdsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AllocateIdsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AllocateIdsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AllocateIdsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.AllocateIdsRequest 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.AllocateIdsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.AllocateIdsRequest) + com.google.datastore.v1.AllocateIdsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_AllocateIdsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_AllocateIdsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AllocateIdsRequest.class, + com.google.datastore.v1.AllocateIdsRequest.Builder.class); + } + + // Construct using com.google.datastore.v1.AllocateIdsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + databaseId_ = ""; + if (keysBuilder_ == null) { + keys_ = java.util.Collections.emptyList(); + } else { + keys_ = null; + keysBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_AllocateIdsRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.AllocateIdsRequest getDefaultInstanceForType() { + return com.google.datastore.v1.AllocateIdsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.AllocateIdsRequest build() { + com.google.datastore.v1.AllocateIdsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.AllocateIdsRequest buildPartial() { + com.google.datastore.v1.AllocateIdsRequest result = + new com.google.datastore.v1.AllocateIdsRequest(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.AllocateIdsRequest result) { + if (keysBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0)) { + keys_ = java.util.Collections.unmodifiableList(keys_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.keys_ = keys_; + } else { + result.keys_ = keysBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.AllocateIdsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.AllocateIdsRequest) { + return mergeFrom((com.google.datastore.v1.AllocateIdsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.AllocateIdsRequest other) { + if (other == com.google.datastore.v1.AllocateIdsRequest.getDefaultInstance()) return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (keysBuilder_ == null) { + if (!other.keys_.isEmpty()) { + if (keys_.isEmpty()) { + keys_ = other.keys_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureKeysIsMutable(); + keys_.addAll(other.keys_); + } + onChanged(); + } + } else { + if (!other.keys_.isEmpty()) { + if (keysBuilder_.isEmpty()) { + keysBuilder_.dispose(); + keysBuilder_ = null; + keys_ = other.keys_; + bitField0_ = (bitField0_ & ~0x00000004); + keysBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getKeysFieldBuilder() + : null; + } else { + keysBuilder_.addAllMessages(other.keys_); + } + } + } + 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.datastore.v1.Key m = + input.readMessage(com.google.datastore.v1.Key.parser(), extensionRegistry); + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(m); + } else { + keysBuilder_.addMessage(m); + } + break; + } // case 10 + case 66: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 66 + case 74: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + 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 java.lang.Object projectId_ = ""; + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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.util.List keys_ = java.util.Collections.emptyList(); + + private void ensureKeysIsMutable() { + if (!((bitField0_ & 0x00000004) != 0)) { + keys_ = new java.util.ArrayList(keys_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + keysBuilder_; + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getKeysList() { + if (keysBuilder_ == null) { + return java.util.Collections.unmodifiableList(keys_); + } else { + return keysBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public int getKeysCount() { + if (keysBuilder_ == null) { + return keys_.size(); + } else { + return keysBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key getKeys(int index) { + if (keysBuilder_ == null) { + return keys_.get(index); + } else { + return keysBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setKeys(int index, com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.set(index, value); + onChanged(); + } else { + keysBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setKeys(int index, com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.set(index, builderForValue.build()); + onChanged(); + } else { + keysBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.add(value); + onChanged(); + } else { + keysBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(int index, com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.add(index, value); + onChanged(); + } else { + keysBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(builderForValue.build()); + onChanged(); + } else { + keysBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(int index, com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(index, builderForValue.build()); + onChanged(); + } else { + keysBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addAllKeys(java.lang.Iterable values) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, keys_); + onChanged(); + } else { + keysBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearKeys() { + if (keysBuilder_ == null) { + keys_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + keysBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder removeKeys(int index) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.remove(index); + onChanged(); + } else { + keysBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key.Builder getKeysBuilder(int index) { + return getKeysFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index) { + if (keysBuilder_ == null) { + return keys_.get(index); + } else { + return keysBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getKeysOrBuilderList() { + if (keysBuilder_ != null) { + return keysBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(keys_); + } + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key.Builder addKeysBuilder() { + return getKeysFieldBuilder().addBuilder(com.google.datastore.v1.Key.getDefaultInstance()); + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key.Builder addKeysBuilder(int index) { + return getKeysFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Key.getDefaultInstance()); + } + + /** + * + * + *
+     * Required. A list of keys with incomplete key paths for which to allocate
+     * IDs. No key may be reserved/read-only.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getKeysBuilderList() { + return getKeysFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + getKeysFieldBuilder() { + if (keysBuilder_ == null) { + keysBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder>( + keys_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean()); + keys_ = null; + } + return keysBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.AllocateIdsRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.AllocateIdsRequest) + private static final com.google.datastore.v1.AllocateIdsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.AllocateIdsRequest(); + } + + public static com.google.datastore.v1.AllocateIdsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public AllocateIdsRequest 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.datastore.v1.AllocateIdsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsRequestOrBuilder.java new file mode 100644 index 000000000000..1665521ad527 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsRequestOrBuilder.java @@ -0,0 +1,149 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface AllocateIdsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.AllocateIdsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * Required. A list of keys with incomplete key paths for which to allocate
+   * IDs. No key may be reserved/read-only.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + java.util.List getKeysList(); + + /** + * + * + *
+   * Required. A list of keys with incomplete key paths for which to allocate
+   * IDs. No key may be reserved/read-only.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.v1.Key getKeys(int index); + + /** + * + * + *
+   * Required. A list of keys with incomplete key paths for which to allocate
+   * IDs. No key may be reserved/read-only.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + int getKeysCount(); + + /** + * + * + *
+   * Required. A list of keys with incomplete key paths for which to allocate
+   * IDs. No key may be reserved/read-only.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + java.util.List getKeysOrBuilderList(); + + /** + * + * + *
+   * Required. A list of keys with incomplete key paths for which to allocate
+   * IDs. No key may be reserved/read-only.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsResponse.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsResponse.java new file mode 100644 index 000000000000..792bd26f6d9b --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsResponse.java @@ -0,0 +1,974 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The response for
+ * [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.AllocateIdsResponse} + */ +public final class AllocateIdsResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.AllocateIdsResponse) + AllocateIdsResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use AllocateIdsResponse.newBuilder() to construct. + private AllocateIdsResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private AllocateIdsResponse() { + keys_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new AllocateIdsResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_AllocateIdsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_AllocateIdsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AllocateIdsResponse.class, + com.google.datastore.v1.AllocateIdsResponse.Builder.class); + } + + public static final int KEYS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List keys_; + + /** + * + * + *
+   * The keys specified in the request (in the same order), each with
+   * its key path completed with a newly allocated ID.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + @java.lang.Override + public java.util.List getKeysList() { + return keys_; + } + + /** + * + * + *
+   * The keys specified in the request (in the same order), each with
+   * its key path completed with a newly allocated ID.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + @java.lang.Override + public java.util.List getKeysOrBuilderList() { + return keys_; + } + + /** + * + * + *
+   * The keys specified in the request (in the same order), each with
+   * its key path completed with a newly allocated ID.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + @java.lang.Override + public int getKeysCount() { + return keys_.size(); + } + + /** + * + * + *
+   * The keys specified in the request (in the same order), each with
+   * its key path completed with a newly allocated ID.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + @java.lang.Override + public com.google.datastore.v1.Key getKeys(int index) { + return keys_.get(index); + } + + /** + * + * + *
+   * The keys specified in the request (in the same order), each with
+   * its key path completed with a newly allocated ID.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index) { + return keys_.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 < keys_.size(); i++) { + output.writeMessage(1, keys_.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 < keys_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, keys_.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.datastore.v1.AllocateIdsResponse)) { + return super.equals(obj); + } + com.google.datastore.v1.AllocateIdsResponse other = + (com.google.datastore.v1.AllocateIdsResponse) obj; + + if (!getKeysList().equals(other.getKeysList())) 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 (getKeysCount() > 0) { + hash = (37 * hash) + KEYS_FIELD_NUMBER; + hash = (53 * hash) + getKeysList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.AllocateIdsResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AllocateIdsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AllocateIdsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AllocateIdsResponse 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.datastore.v1.AllocateIdsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.AllocateIdsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.AllocateIdsResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AllocateIdsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AllocateIdsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AllocateIdsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.AllocateIdsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.AllocateIdsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.AllocateIdsResponse 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.AllocateIdsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.AllocateIdsResponse) + com.google.datastore.v1.AllocateIdsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_AllocateIdsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_AllocateIdsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.AllocateIdsResponse.class, + com.google.datastore.v1.AllocateIdsResponse.Builder.class); + } + + // Construct using com.google.datastore.v1.AllocateIdsResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (keysBuilder_ == null) { + keys_ = java.util.Collections.emptyList(); + } else { + keys_ = null; + keysBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_AllocateIdsResponse_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.AllocateIdsResponse getDefaultInstanceForType() { + return com.google.datastore.v1.AllocateIdsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.AllocateIdsResponse build() { + com.google.datastore.v1.AllocateIdsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.AllocateIdsResponse buildPartial() { + com.google.datastore.v1.AllocateIdsResponse result = + new com.google.datastore.v1.AllocateIdsResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.AllocateIdsResponse result) { + if (keysBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + keys_ = java.util.Collections.unmodifiableList(keys_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.keys_ = keys_; + } else { + result.keys_ = keysBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.AllocateIdsResponse result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.AllocateIdsResponse) { + return mergeFrom((com.google.datastore.v1.AllocateIdsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.AllocateIdsResponse other) { + if (other == com.google.datastore.v1.AllocateIdsResponse.getDefaultInstance()) return this; + if (keysBuilder_ == null) { + if (!other.keys_.isEmpty()) { + if (keys_.isEmpty()) { + keys_ = other.keys_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureKeysIsMutable(); + keys_.addAll(other.keys_); + } + onChanged(); + } + } else { + if (!other.keys_.isEmpty()) { + if (keysBuilder_.isEmpty()) { + keysBuilder_.dispose(); + keysBuilder_ = null; + keys_ = other.keys_; + bitField0_ = (bitField0_ & ~0x00000001); + keysBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getKeysFieldBuilder() + : null; + } else { + keysBuilder_.addAllMessages(other.keys_); + } + } + } + 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.datastore.v1.Key m = + input.readMessage(com.google.datastore.v1.Key.parser(), extensionRegistry); + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(m); + } else { + keysBuilder_.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 keys_ = java.util.Collections.emptyList(); + + private void ensureKeysIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + keys_ = new java.util.ArrayList(keys_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + keysBuilder_; + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public java.util.List getKeysList() { + if (keysBuilder_ == null) { + return java.util.Collections.unmodifiableList(keys_); + } else { + return keysBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public int getKeysCount() { + if (keysBuilder_ == null) { + return keys_.size(); + } else { + return keysBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public com.google.datastore.v1.Key getKeys(int index) { + if (keysBuilder_ == null) { + return keys_.get(index); + } else { + return keysBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public Builder setKeys(int index, com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.set(index, value); + onChanged(); + } else { + keysBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public Builder setKeys(int index, com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.set(index, builderForValue.build()); + onChanged(); + } else { + keysBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public Builder addKeys(com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.add(value); + onChanged(); + } else { + keysBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public Builder addKeys(int index, com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.add(index, value); + onChanged(); + } else { + keysBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public Builder addKeys(com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(builderForValue.build()); + onChanged(); + } else { + keysBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public Builder addKeys(int index, com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(index, builderForValue.build()); + onChanged(); + } else { + keysBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public Builder addAllKeys(java.lang.Iterable values) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, keys_); + onChanged(); + } else { + keysBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public Builder clearKeys() { + if (keysBuilder_ == null) { + keys_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + keysBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public Builder removeKeys(int index) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.remove(index); + onChanged(); + } else { + keysBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public com.google.datastore.v1.Key.Builder getKeysBuilder(int index) { + return getKeysFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index) { + if (keysBuilder_ == null) { + return keys_.get(index); + } else { + return keysBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public java.util.List getKeysOrBuilderList() { + if (keysBuilder_ != null) { + return keysBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(keys_); + } + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public com.google.datastore.v1.Key.Builder addKeysBuilder() { + return getKeysFieldBuilder().addBuilder(com.google.datastore.v1.Key.getDefaultInstance()); + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public com.google.datastore.v1.Key.Builder addKeysBuilder(int index) { + return getKeysFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Key.getDefaultInstance()); + } + + /** + * + * + *
+     * The keys specified in the request (in the same order), each with
+     * its key path completed with a newly allocated ID.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + public java.util.List getKeysBuilderList() { + return getKeysFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + getKeysFieldBuilder() { + if (keysBuilder_ == null) { + keysBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder>( + keys_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + keys_ = null; + } + return keysBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.AllocateIdsResponse) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.AllocateIdsResponse) + private static final com.google.datastore.v1.AllocateIdsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.AllocateIdsResponse(); + } + + public static com.google.datastore.v1.AllocateIdsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public AllocateIdsResponse 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.datastore.v1.AllocateIdsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsResponseOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsResponseOrBuilder.java new file mode 100644 index 000000000000..0a15ec9ca235 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/AllocateIdsResponseOrBuilder.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface AllocateIdsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.AllocateIdsResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The keys specified in the request (in the same order), each with
+   * its key path completed with a newly allocated ID.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + java.util.List getKeysList(); + + /** + * + * + *
+   * The keys specified in the request (in the same order), each with
+   * its key path completed with a newly allocated ID.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + com.google.datastore.v1.Key getKeys(int index); + + /** + * + * + *
+   * The keys specified in the request (in the same order), each with
+   * its key path completed with a newly allocated ID.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + int getKeysCount(); + + /** + * + * + *
+   * The keys specified in the request (in the same order), each with
+   * its key path completed with a newly allocated ID.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + java.util.List getKeysOrBuilderList(); + + /** + * + * + *
+   * The keys specified in the request (in the same order), each with
+   * its key path completed with a newly allocated ID.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1; + */ + com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ArrayValue.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ArrayValue.java new file mode 100644 index 000000000000..bc9cae3cfbc3 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ArrayValue.java @@ -0,0 +1,995 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * An array value.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.ArrayValue} + */ +public final class ArrayValue extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.ArrayValue) + ArrayValueOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ArrayValue.newBuilder() to construct. + private ArrayValue(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ArrayValue() { + values_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ArrayValue(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_ArrayValue_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_ArrayValue_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ArrayValue.class, + com.google.datastore.v1.ArrayValue.Builder.class); + } + + public static final int VALUES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List values_; + + /** + * + * + *
+   * Values in the array.
+   * The order of values in an array is preserved as long as all values have
+   * identical settings for 'exclude_from_indexes'.
+   * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + @java.lang.Override + public java.util.List getValuesList() { + return values_; + } + + /** + * + * + *
+   * Values in the array.
+   * The order of values in an array is preserved as long as all values have
+   * identical settings for 'exclude_from_indexes'.
+   * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + @java.lang.Override + public java.util.List getValuesOrBuilderList() { + return values_; + } + + /** + * + * + *
+   * Values in the array.
+   * The order of values in an array is preserved as long as all values have
+   * identical settings for 'exclude_from_indexes'.
+   * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + @java.lang.Override + public int getValuesCount() { + return values_.size(); + } + + /** + * + * + *
+   * Values in the array.
+   * The order of values in an array is preserved as long as all values have
+   * identical settings for 'exclude_from_indexes'.
+   * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + @java.lang.Override + public com.google.datastore.v1.Value getValues(int index) { + return values_.get(index); + } + + /** + * + * + *
+   * Values in the array.
+   * The order of values in an array is preserved as long as all values have
+   * identical settings for 'exclude_from_indexes'.
+   * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + @java.lang.Override + public com.google.datastore.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.datastore.v1.ArrayValue)) { + return super.equals(obj); + } + com.google.datastore.v1.ArrayValue other = (com.google.datastore.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.datastore.v1.ArrayValue parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.ArrayValue parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.ArrayValue parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ArrayValue parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.ArrayValue parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ArrayValue parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ArrayValue parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ArrayValue parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ArrayValue parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ArrayValue parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * An array value.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.ArrayValue} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.ArrayValue) + com.google.datastore.v1.ArrayValueOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_ArrayValue_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_ArrayValue_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ArrayValue.class, + com.google.datastore.v1.ArrayValue.Builder.class); + } + + // Construct using com.google.datastore.v1.ArrayValue.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.v1.EntityProto + .internal_static_google_datastore_v1_ArrayValue_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.ArrayValue getDefaultInstanceForType() { + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.ArrayValue build() { + com.google.datastore.v1.ArrayValue result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.ArrayValue buildPartial() { + com.google.datastore.v1.ArrayValue result = new com.google.datastore.v1.ArrayValue(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.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.datastore.v1.ArrayValue result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.ArrayValue) { + return mergeFrom((com.google.datastore.v1.ArrayValue) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.ArrayValue other) { + if (other == com.google.datastore.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.GeneratedMessageV3.alwaysUseFieldBuilders + ? getValuesFieldBuilder() + : 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.datastore.v1.Value m = + input.readMessage(com.google.datastore.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.RepeatedFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + valuesBuilder_; + + /** + * + * + *
+     * Values in the array.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.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.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public int getValuesCount() { + if (valuesBuilder_ == null) { + return values_.size(); + } else { + return valuesBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Values in the array.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public com.google.datastore.v1.Value getValues(int index) { + if (valuesBuilder_ == null) { + return values_.get(index); + } else { + return valuesBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Values in the array.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public Builder setValues(int index, com.google.datastore.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.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public Builder setValues(int index, com.google.datastore.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.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public Builder addValues(com.google.datastore.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.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public Builder addValues(int index, com.google.datastore.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.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public Builder addValues(com.google.datastore.v1.Value.Builder builderForValue) { + if (valuesBuilder_ == null) { + ensureValuesIsMutable(); + values_.add(builderForValue.build()); + onChanged(); + } else { + valuesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Values in the array.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public Builder addValues(int index, com.google.datastore.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.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.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.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.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.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.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.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public com.google.datastore.v1.Value.Builder getValuesBuilder(int index) { + return getValuesFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Values in the array.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public com.google.datastore.v1.ValueOrBuilder getValuesOrBuilder(int index) { + if (valuesBuilder_ == null) { + return values_.get(index); + } else { + return valuesBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Values in the array.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.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.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public com.google.datastore.v1.Value.Builder addValuesBuilder() { + return getValuesFieldBuilder().addBuilder(com.google.datastore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * Values in the array.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public com.google.datastore.v1.Value.Builder addValuesBuilder(int index) { + return getValuesFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * Values in the array.
+     * The order of values in an array is preserved as long as all values have
+     * identical settings for 'exclude_from_indexes'.
+     * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + public java.util.List getValuesBuilderList() { + return getValuesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getValuesFieldBuilder() { + if (valuesBuilder_ == null) { + valuesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + values_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + values_ = null; + } + return valuesBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.ArrayValue) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.ArrayValue) + private static final com.google.datastore.v1.ArrayValue DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.ArrayValue(); + } + + public static com.google.datastore.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.datastore.v1.ArrayValue getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ArrayValueOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ArrayValueOrBuilder.java new file mode 100644 index 000000000000..5c64d8281765 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ArrayValueOrBuilder.java @@ -0,0 +1,91 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface ArrayValueOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.ArrayValue) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Values in the array.
+   * The order of values in an array is preserved as long as all values have
+   * identical settings for 'exclude_from_indexes'.
+   * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + java.util.List getValuesList(); + + /** + * + * + *
+   * Values in the array.
+   * The order of values in an array is preserved as long as all values have
+   * identical settings for 'exclude_from_indexes'.
+   * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + com.google.datastore.v1.Value getValues(int index); + + /** + * + * + *
+   * Values in the array.
+   * The order of values in an array is preserved as long as all values have
+   * identical settings for 'exclude_from_indexes'.
+   * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + int getValuesCount(); + + /** + * + * + *
+   * Values in the array.
+   * The order of values in an array is preserved as long as all values have
+   * identical settings for 'exclude_from_indexes'.
+   * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + java.util.List getValuesOrBuilderList(); + + /** + * + * + *
+   * Values in the array.
+   * The order of values in an array is preserved as long as all values have
+   * identical settings for 'exclude_from_indexes'.
+   * 
+ * + * repeated .google.datastore.v1.Value values = 1; + */ + com.google.datastore.v1.ValueOrBuilder getValuesOrBuilder(int index); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionRequest.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionRequest.java new file mode 100644 index 000000000000..dffdd9d44e12 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionRequest.java @@ -0,0 +1,1143 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The request for
+ * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.BeginTransactionRequest} + */ +public final class BeginTransactionRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.BeginTransactionRequest) + BeginTransactionRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use BeginTransactionRequest.newBuilder() to construct. + private BeginTransactionRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private BeginTransactionRequest() { + projectId_ = ""; + databaseId_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new BeginTransactionRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_BeginTransactionRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_BeginTransactionRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.BeginTransactionRequest.class, + com.google.datastore.v1.BeginTransactionRequest.Builder.class); + } + + private int bitField0_; + public static final int PROJECT_ID_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 9; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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 TRANSACTION_OPTIONS_FIELD_NUMBER = 10; + private com.google.datastore.v1.TransactionOptions transactionOptions_; + + /** + * + * + *
+   * Options for a new transaction.
+   * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + * + * @return Whether the transactionOptions field is set. + */ + @java.lang.Override + public boolean hasTransactionOptions() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Options for a new transaction.
+   * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + * + * @return The transactionOptions. + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions getTransactionOptions() { + return transactionOptions_ == null + ? com.google.datastore.v1.TransactionOptions.getDefaultInstance() + : transactionOptions_; + } + + /** + * + * + *
+   * Options for a new transaction.
+   * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptionsOrBuilder getTransactionOptionsOrBuilder() { + return transactionOptions_ == null + ? com.google.datastore.v1.TransactionOptions.getDefaultInstance() + : transactionOptions_; + } + + 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.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, databaseId_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(10, getTransactionOptions()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, databaseId_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getTransactionOptions()); + } + 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.datastore.v1.BeginTransactionRequest)) { + return super.equals(obj); + } + com.google.datastore.v1.BeginTransactionRequest other = + (com.google.datastore.v1.BeginTransactionRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (hasTransactionOptions() != other.hasTransactionOptions()) return false; + if (hasTransactionOptions()) { + if (!getTransactionOptions().equals(other.getTransactionOptions())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + if (hasTransactionOptions()) { + hash = (37 * hash) + TRANSACTION_OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + getTransactionOptions().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.BeginTransactionRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.BeginTransactionRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.BeginTransactionRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.BeginTransactionRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.BeginTransactionRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.BeginTransactionRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.BeginTransactionRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.BeginTransactionRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.BeginTransactionRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.BeginTransactionRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.BeginTransactionRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.BeginTransactionRequest) + com.google.datastore.v1.BeginTransactionRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_BeginTransactionRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_BeginTransactionRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.BeginTransactionRequest.class, + com.google.datastore.v1.BeginTransactionRequest.Builder.class); + } + + // Construct using com.google.datastore.v1.BeginTransactionRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getTransactionOptionsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + databaseId_ = ""; + transactionOptions_ = null; + if (transactionOptionsBuilder_ != null) { + transactionOptionsBuilder_.dispose(); + transactionOptionsBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_BeginTransactionRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.BeginTransactionRequest getDefaultInstanceForType() { + return com.google.datastore.v1.BeginTransactionRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.BeginTransactionRequest build() { + com.google.datastore.v1.BeginTransactionRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.BeginTransactionRequest buildPartial() { + com.google.datastore.v1.BeginTransactionRequest result = + new com.google.datastore.v1.BeginTransactionRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.BeginTransactionRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.transactionOptions_ = + transactionOptionsBuilder_ == null + ? transactionOptions_ + : transactionOptionsBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.BeginTransactionRequest) { + return mergeFrom((com.google.datastore.v1.BeginTransactionRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.BeginTransactionRequest other) { + if (other == com.google.datastore.v1.BeginTransactionRequest.getDefaultInstance()) + return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.hasTransactionOptions()) { + mergeTransactionOptions(other.getTransactionOptions()); + } + 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 66: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 66 + case 74: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 74 + case 82: + { + input.readMessage( + getTransactionOptionsFieldBuilder().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 bitField0_; + + private java.lang.Object projectId_ = ""; + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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.datastore.v1.TransactionOptions transactionOptions_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions, + com.google.datastore.v1.TransactionOptions.Builder, + com.google.datastore.v1.TransactionOptionsOrBuilder> + transactionOptionsBuilder_; + + /** + * + * + *
+     * Options for a new transaction.
+     * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + * + * @return Whether the transactionOptions field is set. + */ + public boolean hasTransactionOptions() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Options for a new transaction.
+     * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + * + * @return The transactionOptions. + */ + public com.google.datastore.v1.TransactionOptions getTransactionOptions() { + if (transactionOptionsBuilder_ == null) { + return transactionOptions_ == null + ? com.google.datastore.v1.TransactionOptions.getDefaultInstance() + : transactionOptions_; + } else { + return transactionOptionsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Options for a new transaction.
+     * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + */ + public Builder setTransactionOptions(com.google.datastore.v1.TransactionOptions value) { + if (transactionOptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transactionOptions_ = value; + } else { + transactionOptionsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Options for a new transaction.
+     * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + */ + public Builder setTransactionOptions( + com.google.datastore.v1.TransactionOptions.Builder builderForValue) { + if (transactionOptionsBuilder_ == null) { + transactionOptions_ = builderForValue.build(); + } else { + transactionOptionsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Options for a new transaction.
+     * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + */ + public Builder mergeTransactionOptions(com.google.datastore.v1.TransactionOptions value) { + if (transactionOptionsBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && transactionOptions_ != null + && transactionOptions_ + != com.google.datastore.v1.TransactionOptions.getDefaultInstance()) { + getTransactionOptionsBuilder().mergeFrom(value); + } else { + transactionOptions_ = value; + } + } else { + transactionOptionsBuilder_.mergeFrom(value); + } + if (transactionOptions_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Options for a new transaction.
+     * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + */ + public Builder clearTransactionOptions() { + bitField0_ = (bitField0_ & ~0x00000004); + transactionOptions_ = null; + if (transactionOptionsBuilder_ != null) { + transactionOptionsBuilder_.dispose(); + transactionOptionsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Options for a new transaction.
+     * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + */ + public com.google.datastore.v1.TransactionOptions.Builder getTransactionOptionsBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getTransactionOptionsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Options for a new transaction.
+     * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + */ + public com.google.datastore.v1.TransactionOptionsOrBuilder getTransactionOptionsOrBuilder() { + if (transactionOptionsBuilder_ != null) { + return transactionOptionsBuilder_.getMessageOrBuilder(); + } else { + return transactionOptions_ == null + ? com.google.datastore.v1.TransactionOptions.getDefaultInstance() + : transactionOptions_; + } + } + + /** + * + * + *
+     * Options for a new transaction.
+     * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions, + com.google.datastore.v1.TransactionOptions.Builder, + com.google.datastore.v1.TransactionOptionsOrBuilder> + getTransactionOptionsFieldBuilder() { + if (transactionOptionsBuilder_ == null) { + transactionOptionsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions, + com.google.datastore.v1.TransactionOptions.Builder, + com.google.datastore.v1.TransactionOptionsOrBuilder>( + getTransactionOptions(), getParentForChildren(), isClean()); + transactionOptions_ = null; + } + return transactionOptionsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.BeginTransactionRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.BeginTransactionRequest) + private static final com.google.datastore.v1.BeginTransactionRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.BeginTransactionRequest(); + } + + public static com.google.datastore.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.datastore.v1.BeginTransactionRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionRequestOrBuilder.java new file mode 100644 index 000000000000..e1513d8cd5a9 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionRequestOrBuilder.java @@ -0,0 +1,121 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface BeginTransactionRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.BeginTransactionRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * Options for a new transaction.
+   * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + * + * @return Whether the transactionOptions field is set. + */ + boolean hasTransactionOptions(); + + /** + * + * + *
+   * Options for a new transaction.
+   * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + * + * @return The transactionOptions. + */ + com.google.datastore.v1.TransactionOptions getTransactionOptions(); + + /** + * + * + *
+   * Options for a new transaction.
+   * 
+ * + * .google.datastore.v1.TransactionOptions transaction_options = 10; + */ + com.google.datastore.v1.TransactionOptionsOrBuilder getTransactionOptionsOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionResponse.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionResponse.java new file mode 100644 index 000000000000..c69be99ceaf3 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionResponse.java @@ -0,0 +1,547 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The response for
+ * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.BeginTransactionResponse} + */ +public final class BeginTransactionResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.BeginTransactionResponse) + BeginTransactionResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use BeginTransactionResponse.newBuilder() to construct. + private BeginTransactionResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private BeginTransactionResponse() { + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new BeginTransactionResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_BeginTransactionResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_BeginTransactionResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.BeginTransactionResponse.class, + com.google.datastore.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 identifier (always present).
+   * 
+ * + * 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.datastore.v1.BeginTransactionResponse)) { + return super.equals(obj); + } + com.google.datastore.v1.BeginTransactionResponse other = + (com.google.datastore.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.datastore.v1.BeginTransactionResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.BeginTransactionResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.BeginTransactionResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.BeginTransactionResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.BeginTransactionResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.BeginTransactionResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.BeginTransactionResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.BeginTransactionResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.BeginTransactionResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.BeginTransactionResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.BeginTransactionResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.BeginTransactionResponse) + com.google.datastore.v1.BeginTransactionResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_BeginTransactionResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_BeginTransactionResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.BeginTransactionResponse.class, + com.google.datastore.v1.BeginTransactionResponse.Builder.class); + } + + // Construct using com.google.datastore.v1.BeginTransactionResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_BeginTransactionResponse_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.BeginTransactionResponse getDefaultInstanceForType() { + return com.google.datastore.v1.BeginTransactionResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.BeginTransactionResponse build() { + com.google.datastore.v1.BeginTransactionResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.BeginTransactionResponse buildPartial() { + com.google.datastore.v1.BeginTransactionResponse result = + new com.google.datastore.v1.BeginTransactionResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.BeginTransactionResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.transaction_ = transaction_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.BeginTransactionResponse) { + return mergeFrom((com.google.datastore.v1.BeginTransactionResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.BeginTransactionResponse other) { + if (other == com.google.datastore.v1.BeginTransactionResponse.getDefaultInstance()) + return this; + if (other.getTransaction() != com.google.protobuf.ByteString.EMPTY) { + 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 identifier (always present).
+     * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * The transaction identifier (always present).
+     * 
+ * + * 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 identifier (always present).
+     * 
+ * + * bytes transaction = 1; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000001); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.BeginTransactionResponse) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.BeginTransactionResponse) + private static final com.google.datastore.v1.BeginTransactionResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.BeginTransactionResponse(); + } + + public static com.google.datastore.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.datastore.v1.BeginTransactionResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionResponseOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionResponseOrBuilder.java new file mode 100644 index 000000000000..74b0190f99c6 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/BeginTransactionResponseOrBuilder.java @@ -0,0 +1,39 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface BeginTransactionResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.BeginTransactionResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The transaction identifier (always present).
+   * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitRequest.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitRequest.java new file mode 100644 index 000000000000..dc2995770eda --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitRequest.java @@ -0,0 +1,2526 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The request for [Datastore.Commit][google.datastore.v1.Datastore.Commit].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.CommitRequest} + */ +public final class CommitRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.CommitRequest) + CommitRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use CommitRequest.newBuilder() to construct. + private CommitRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CommitRequest() { + projectId_ = ""; + databaseId_ = ""; + mode_ = 0; + mutations_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CommitRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_CommitRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_CommitRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.CommitRequest.class, + com.google.datastore.v1.CommitRequest.Builder.class); + } + + /** + * + * + *
+   * The modes available for commits.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.CommitRequest.Mode} + */ + public enum Mode implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * MODE_UNSPECIFIED = 0; + */ + MODE_UNSPECIFIED(0), + /** + * + * + *
+     * Transactional: The mutations are either all applied, or none are applied.
+     * Learn about transactions
+     * [here](https://cloud.google.com/datastore/docs/concepts/transactions).
+     * 
+ * + * TRANSACTIONAL = 1; + */ + TRANSACTIONAL(1), + /** + * + * + *
+     * Non-transactional: The mutations may not apply as all or none.
+     * 
+ * + * NON_TRANSACTIONAL = 2; + */ + NON_TRANSACTIONAL(2), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * MODE_UNSPECIFIED = 0; + */ + public static final int MODE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Transactional: The mutations are either all applied, or none are applied.
+     * Learn about transactions
+     * [here](https://cloud.google.com/datastore/docs/concepts/transactions).
+     * 
+ * + * TRANSACTIONAL = 1; + */ + public static final int TRANSACTIONAL_VALUE = 1; + + /** + * + * + *
+     * Non-transactional: The mutations may not apply as all or none.
+     * 
+ * + * NON_TRANSACTIONAL = 2; + */ + public static final int NON_TRANSACTIONAL_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 Mode 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 Mode forNumber(int value) { + switch (value) { + case 0: + return MODE_UNSPECIFIED; + case 1: + return TRANSACTIONAL; + case 2: + return NON_TRANSACTIONAL; + 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 Mode findValueByNumber(int number) { + return Mode.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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.CommitRequest.getDescriptor().getEnumTypes().get(0); + } + + private static final Mode[] VALUES = values(); + + public static Mode 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 Mode(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.v1.CommitRequest.Mode) + } + + private int transactionSelectorCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object transactionSelector_; + + public enum TransactionSelectorCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + TRANSACTION(1), + SINGLE_USE_TRANSACTION(10), + TRANSACTIONSELECTOR_NOT_SET(0); + private final int value; + + private TransactionSelectorCase(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 TransactionSelectorCase valueOf(int value) { + return forNumber(value); + } + + public static TransactionSelectorCase forNumber(int value) { + switch (value) { + case 1: + return TRANSACTION; + case 10: + return SINGLE_USE_TRANSACTION; + case 0: + return TRANSACTIONSELECTOR_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public TransactionSelectorCase getTransactionSelectorCase() { + return TransactionSelectorCase.forNumber(transactionSelectorCase_); + } + + public static final int PROJECT_ID_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 9; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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 MODE_FIELD_NUMBER = 5; + private int mode_ = 0; + + /** + * + * + *
+   * The type of commit to perform. Defaults to `TRANSACTIONAL`.
+   * 
+ * + * .google.datastore.v1.CommitRequest.Mode mode = 5; + * + * @return The enum numeric value on the wire for mode. + */ + @java.lang.Override + public int getModeValue() { + return mode_; + } + + /** + * + * + *
+   * The type of commit to perform. Defaults to `TRANSACTIONAL`.
+   * 
+ * + * .google.datastore.v1.CommitRequest.Mode mode = 5; + * + * @return The mode. + */ + @java.lang.Override + public com.google.datastore.v1.CommitRequest.Mode getMode() { + com.google.datastore.v1.CommitRequest.Mode result = + com.google.datastore.v1.CommitRequest.Mode.forNumber(mode_); + return result == null ? com.google.datastore.v1.CommitRequest.Mode.UNRECOGNIZED : result; + } + + public static final int TRANSACTION_FIELD_NUMBER = 1; + + /** + * + * + *
+   * The identifier of the transaction associated with the commit. A
+   * transaction identifier is returned by a call to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * bytes transaction = 1; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return transactionSelectorCase_ == 1; + } + + /** + * + * + *
+   * The identifier of the transaction associated with the commit. A
+   * transaction identifier is returned by a call to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + if (transactionSelectorCase_ == 1) { + return (com.google.protobuf.ByteString) transactionSelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int SINGLE_USE_TRANSACTION_FIELD_NUMBER = 10; + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   * The transaction is committed when the request completes. If specified,
+   * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+   * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+   * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + * + * @return Whether the singleUseTransaction field is set. + */ + @java.lang.Override + public boolean hasSingleUseTransaction() { + return transactionSelectorCase_ == 10; + } + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   * The transaction is committed when the request completes. If specified,
+   * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+   * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+   * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + * + * @return The singleUseTransaction. + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions getSingleUseTransaction() { + if (transactionSelectorCase_ == 10) { + return (com.google.datastore.v1.TransactionOptions) transactionSelector_; + } + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   * The transaction is committed when the request completes. If specified,
+   * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+   * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+   * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptionsOrBuilder getSingleUseTransactionOrBuilder() { + if (transactionSelectorCase_ == 10) { + return (com.google.datastore.v1.TransactionOptions) transactionSelector_; + } + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + + public static final int MUTATIONS_FIELD_NUMBER = 6; + + @SuppressWarnings("serial") + private java.util.List mutations_; + + /** + * + * + *
+   * The mutations to perform.
+   *
+   * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+   * applied in order. The following sequences of mutations affecting a single
+   * entity are not permitted in a single `Commit` request:
+   *
+   * - `insert` followed by `insert`
+   * - `update` followed by `insert`
+   * - `upsert` followed by `insert`
+   * - `delete` followed by `update`
+   *
+   * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+   * entity.
+   * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + @java.lang.Override + public java.util.List getMutationsList() { + return mutations_; + } + + /** + * + * + *
+   * The mutations to perform.
+   *
+   * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+   * applied in order. The following sequences of mutations affecting a single
+   * entity are not permitted in a single `Commit` request:
+   *
+   * - `insert` followed by `insert`
+   * - `update` followed by `insert`
+   * - `upsert` followed by `insert`
+   * - `delete` followed by `update`
+   *
+   * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+   * entity.
+   * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + @java.lang.Override + public java.util.List + getMutationsOrBuilderList() { + return mutations_; + } + + /** + * + * + *
+   * The mutations to perform.
+   *
+   * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+   * applied in order. The following sequences of mutations affecting a single
+   * entity are not permitted in a single `Commit` request:
+   *
+   * - `insert` followed by `insert`
+   * - `update` followed by `insert`
+   * - `upsert` followed by `insert`
+   * - `delete` followed by `update`
+   *
+   * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+   * entity.
+   * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + @java.lang.Override + public int getMutationsCount() { + return mutations_.size(); + } + + /** + * + * + *
+   * The mutations to perform.
+   *
+   * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+   * applied in order. The following sequences of mutations affecting a single
+   * entity are not permitted in a single `Commit` request:
+   *
+   * - `insert` followed by `insert`
+   * - `update` followed by `insert`
+   * - `upsert` followed by `insert`
+   * - `delete` followed by `update`
+   *
+   * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+   * entity.
+   * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + @java.lang.Override + public com.google.datastore.v1.Mutation getMutations(int index) { + return mutations_.get(index); + } + + /** + * + * + *
+   * The mutations to perform.
+   *
+   * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+   * applied in order. The following sequences of mutations affecting a single
+   * entity are not permitted in a single `Commit` request:
+   *
+   * - `insert` followed by `insert`
+   * - `update` followed by `insert`
+   * - `upsert` followed by `insert`
+   * - `delete` followed by `update`
+   *
+   * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+   * entity.
+   * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + @java.lang.Override + public com.google.datastore.v1.MutationOrBuilder getMutationsOrBuilder(int index) { + return mutations_.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 (transactionSelectorCase_ == 1) { + output.writeBytes(1, (com.google.protobuf.ByteString) transactionSelector_); + } + if (mode_ != com.google.datastore.v1.CommitRequest.Mode.MODE_UNSPECIFIED.getNumber()) { + output.writeEnum(5, mode_); + } + for (int i = 0; i < mutations_.size(); i++) { + output.writeMessage(6, mutations_.get(i)); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, databaseId_); + } + if (transactionSelectorCase_ == 10) { + output.writeMessage(10, (com.google.datastore.v1.TransactionOptions) transactionSelector_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (transactionSelectorCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 1, (com.google.protobuf.ByteString) transactionSelector_); + } + if (mode_ != com.google.datastore.v1.CommitRequest.Mode.MODE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(5, mode_); + } + for (int i = 0; i < mutations_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, mutations_.get(i)); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, databaseId_); + } + if (transactionSelectorCase_ == 10) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 10, (com.google.datastore.v1.TransactionOptions) transactionSelector_); + } + 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.datastore.v1.CommitRequest)) { + return super.equals(obj); + } + com.google.datastore.v1.CommitRequest other = (com.google.datastore.v1.CommitRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (mode_ != other.mode_) return false; + if (!getMutationsList().equals(other.getMutationsList())) return false; + if (!getTransactionSelectorCase().equals(other.getTransactionSelectorCase())) return false; + switch (transactionSelectorCase_) { + case 1: + if (!getTransaction().equals(other.getTransaction())) return false; + break; + case 10: + if (!getSingleUseTransaction().equals(other.getSingleUseTransaction())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + hash = (37 * hash) + MODE_FIELD_NUMBER; + hash = (53 * hash) + mode_; + if (getMutationsCount() > 0) { + hash = (37 * hash) + MUTATIONS_FIELD_NUMBER; + hash = (53 * hash) + getMutationsList().hashCode(); + } + switch (transactionSelectorCase_) { + case 1: + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + break; + case 10: + hash = (37 * hash) + SINGLE_USE_TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getSingleUseTransaction().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.CommitRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.CommitRequest parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.CommitRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.CommitRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.CommitRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.CommitRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.CommitRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.CommitRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.CommitRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.CommitRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for [Datastore.Commit][google.datastore.v1.Datastore.Commit].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.CommitRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.CommitRequest) + com.google.datastore.v1.CommitRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_CommitRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_CommitRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.CommitRequest.class, + com.google.datastore.v1.CommitRequest.Builder.class); + } + + // Construct using com.google.datastore.v1.CommitRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + databaseId_ = ""; + mode_ = 0; + if (singleUseTransactionBuilder_ != null) { + singleUseTransactionBuilder_.clear(); + } + if (mutationsBuilder_ == null) { + mutations_ = java.util.Collections.emptyList(); + } else { + mutations_ = null; + mutationsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000020); + transactionSelectorCase_ = 0; + transactionSelector_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_CommitRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.CommitRequest getDefaultInstanceForType() { + return com.google.datastore.v1.CommitRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.CommitRequest build() { + com.google.datastore.v1.CommitRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.CommitRequest buildPartial() { + com.google.datastore.v1.CommitRequest result = + new com.google.datastore.v1.CommitRequest(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.CommitRequest result) { + if (mutationsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0)) { + mutations_ = java.util.Collections.unmodifiableList(mutations_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.mutations_ = mutations_; + } else { + result.mutations_ = mutationsBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.CommitRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.mode_ = mode_; + } + } + + private void buildPartialOneofs(com.google.datastore.v1.CommitRequest result) { + result.transactionSelectorCase_ = transactionSelectorCase_; + result.transactionSelector_ = this.transactionSelector_; + if (transactionSelectorCase_ == 10 && singleUseTransactionBuilder_ != null) { + result.transactionSelector_ = singleUseTransactionBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.CommitRequest) { + return mergeFrom((com.google.datastore.v1.CommitRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.CommitRequest other) { + if (other == com.google.datastore.v1.CommitRequest.getDefaultInstance()) return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.mode_ != 0) { + setModeValue(other.getModeValue()); + } + if (mutationsBuilder_ == null) { + if (!other.mutations_.isEmpty()) { + if (mutations_.isEmpty()) { + mutations_ = other.mutations_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureMutationsIsMutable(); + mutations_.addAll(other.mutations_); + } + onChanged(); + } + } else { + if (!other.mutations_.isEmpty()) { + if (mutationsBuilder_.isEmpty()) { + mutationsBuilder_.dispose(); + mutationsBuilder_ = null; + mutations_ = other.mutations_; + bitField0_ = (bitField0_ & ~0x00000020); + mutationsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getMutationsFieldBuilder() + : null; + } else { + mutationsBuilder_.addAllMessages(other.mutations_); + } + } + } + switch (other.getTransactionSelectorCase()) { + case TRANSACTION: + { + setTransaction(other.getTransaction()); + break; + } + case SINGLE_USE_TRANSACTION: + { + mergeSingleUseTransaction(other.getSingleUseTransaction()); + break; + } + case TRANSACTIONSELECTOR_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: + { + transactionSelector_ = input.readBytes(); + transactionSelectorCase_ = 1; + break; + } // case 10 + case 40: + { + mode_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 40 + case 50: + { + com.google.datastore.v1.Mutation m = + input.readMessage(com.google.datastore.v1.Mutation.parser(), extensionRegistry); + if (mutationsBuilder_ == null) { + ensureMutationsIsMutable(); + mutations_.add(m); + } else { + mutationsBuilder_.addMessage(m); + } + break; + } // case 50 + case 66: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 66 + case 74: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 74 + case 82: + { + input.readMessage( + getSingleUseTransactionFieldBuilder().getBuilder(), extensionRegistry); + transactionSelectorCase_ = 10; + 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 transactionSelectorCase_ = 0; + private java.lang.Object transactionSelector_; + + public TransactionSelectorCase getTransactionSelectorCase() { + return TransactionSelectorCase.forNumber(transactionSelectorCase_); + } + + public Builder clearTransactionSelector() { + transactionSelectorCase_ = 0; + transactionSelector_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object projectId_ = ""; + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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 int mode_ = 0; + + /** + * + * + *
+     * The type of commit to perform. Defaults to `TRANSACTIONAL`.
+     * 
+ * + * .google.datastore.v1.CommitRequest.Mode mode = 5; + * + * @return The enum numeric value on the wire for mode. + */ + @java.lang.Override + public int getModeValue() { + return mode_; + } + + /** + * + * + *
+     * The type of commit to perform. Defaults to `TRANSACTIONAL`.
+     * 
+ * + * .google.datastore.v1.CommitRequest.Mode mode = 5; + * + * @param value The enum numeric value on the wire for mode to set. + * @return This builder for chaining. + */ + public Builder setModeValue(int value) { + mode_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The type of commit to perform. Defaults to `TRANSACTIONAL`.
+     * 
+ * + * .google.datastore.v1.CommitRequest.Mode mode = 5; + * + * @return The mode. + */ + @java.lang.Override + public com.google.datastore.v1.CommitRequest.Mode getMode() { + com.google.datastore.v1.CommitRequest.Mode result = + com.google.datastore.v1.CommitRequest.Mode.forNumber(mode_); + return result == null ? com.google.datastore.v1.CommitRequest.Mode.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The type of commit to perform. Defaults to `TRANSACTIONAL`.
+     * 
+ * + * .google.datastore.v1.CommitRequest.Mode mode = 5; + * + * @param value The mode to set. + * @return This builder for chaining. + */ + public Builder setMode(com.google.datastore.v1.CommitRequest.Mode value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + mode_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The type of commit to perform. Defaults to `TRANSACTIONAL`.
+     * 
+ * + * .google.datastore.v1.CommitRequest.Mode mode = 5; + * + * @return This builder for chaining. + */ + public Builder clearMode() { + bitField0_ = (bitField0_ & ~0x00000004); + mode_ = 0; + onChanged(); + return this; + } + + /** + * + * + *
+     * The identifier of the transaction associated with the commit. A
+     * transaction identifier is returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * bytes transaction = 1; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return transactionSelectorCase_ == 1; + } + + /** + * + * + *
+     * The identifier of the transaction associated with the commit. A
+     * transaction identifier is returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + public com.google.protobuf.ByteString getTransaction() { + if (transactionSelectorCase_ == 1) { + return (com.google.protobuf.ByteString) transactionSelector_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * The identifier of the transaction associated with the commit. A
+     * transaction identifier is returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * 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(); + } + transactionSelectorCase_ = 1; + transactionSelector_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * The identifier of the transaction associated with the commit. A
+     * transaction identifier is returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * bytes transaction = 1; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + if (transactionSelectorCase_ == 1) { + transactionSelectorCase_ = 0; + transactionSelector_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions, + com.google.datastore.v1.TransactionOptions.Builder, + com.google.datastore.v1.TransactionOptionsOrBuilder> + singleUseTransactionBuilder_; + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     * The transaction is committed when the request completes. If specified,
+     * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+     * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+     * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + * + * @return Whether the singleUseTransaction field is set. + */ + @java.lang.Override + public boolean hasSingleUseTransaction() { + return transactionSelectorCase_ == 10; + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     * The transaction is committed when the request completes. If specified,
+     * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+     * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+     * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + * + * @return The singleUseTransaction. + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions getSingleUseTransaction() { + if (singleUseTransactionBuilder_ == null) { + if (transactionSelectorCase_ == 10) { + return (com.google.datastore.v1.TransactionOptions) transactionSelector_; + } + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } else { + if (transactionSelectorCase_ == 10) { + return singleUseTransactionBuilder_.getMessage(); + } + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     * The transaction is committed when the request completes. If specified,
+     * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+     * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+     * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + */ + public Builder setSingleUseTransaction(com.google.datastore.v1.TransactionOptions value) { + if (singleUseTransactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transactionSelector_ = value; + onChanged(); + } else { + singleUseTransactionBuilder_.setMessage(value); + } + transactionSelectorCase_ = 10; + return this; + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     * The transaction is committed when the request completes. If specified,
+     * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+     * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+     * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + */ + public Builder setSingleUseTransaction( + com.google.datastore.v1.TransactionOptions.Builder builderForValue) { + if (singleUseTransactionBuilder_ == null) { + transactionSelector_ = builderForValue.build(); + onChanged(); + } else { + singleUseTransactionBuilder_.setMessage(builderForValue.build()); + } + transactionSelectorCase_ = 10; + return this; + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     * The transaction is committed when the request completes. If specified,
+     * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+     * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+     * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + */ + public Builder mergeSingleUseTransaction(com.google.datastore.v1.TransactionOptions value) { + if (singleUseTransactionBuilder_ == null) { + if (transactionSelectorCase_ == 10 + && transactionSelector_ + != com.google.datastore.v1.TransactionOptions.getDefaultInstance()) { + transactionSelector_ = + com.google.datastore.v1.TransactionOptions.newBuilder( + (com.google.datastore.v1.TransactionOptions) transactionSelector_) + .mergeFrom(value) + .buildPartial(); + } else { + transactionSelector_ = value; + } + onChanged(); + } else { + if (transactionSelectorCase_ == 10) { + singleUseTransactionBuilder_.mergeFrom(value); + } else { + singleUseTransactionBuilder_.setMessage(value); + } + } + transactionSelectorCase_ = 10; + return this; + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     * The transaction is committed when the request completes. If specified,
+     * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+     * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+     * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + */ + public Builder clearSingleUseTransaction() { + if (singleUseTransactionBuilder_ == null) { + if (transactionSelectorCase_ == 10) { + transactionSelectorCase_ = 0; + transactionSelector_ = null; + onChanged(); + } + } else { + if (transactionSelectorCase_ == 10) { + transactionSelectorCase_ = 0; + transactionSelector_ = null; + } + singleUseTransactionBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     * The transaction is committed when the request completes. If specified,
+     * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+     * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+     * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + */ + public com.google.datastore.v1.TransactionOptions.Builder getSingleUseTransactionBuilder() { + return getSingleUseTransactionFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     * The transaction is committed when the request completes. If specified,
+     * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+     * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+     * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptionsOrBuilder getSingleUseTransactionOrBuilder() { + if ((transactionSelectorCase_ == 10) && (singleUseTransactionBuilder_ != null)) { + return singleUseTransactionBuilder_.getMessageOrBuilder(); + } else { + if (transactionSelectorCase_ == 10) { + return (com.google.datastore.v1.TransactionOptions) transactionSelector_; + } + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     * The transaction is committed when the request completes. If specified,
+     * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+     * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+     * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions, + com.google.datastore.v1.TransactionOptions.Builder, + com.google.datastore.v1.TransactionOptionsOrBuilder> + getSingleUseTransactionFieldBuilder() { + if (singleUseTransactionBuilder_ == null) { + if (!(transactionSelectorCase_ == 10)) { + transactionSelector_ = com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + singleUseTransactionBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions, + com.google.datastore.v1.TransactionOptions.Builder, + com.google.datastore.v1.TransactionOptionsOrBuilder>( + (com.google.datastore.v1.TransactionOptions) transactionSelector_, + getParentForChildren(), + isClean()); + transactionSelector_ = null; + } + transactionSelectorCase_ = 10; + onChanged(); + return singleUseTransactionBuilder_; + } + + private java.util.List mutations_ = + java.util.Collections.emptyList(); + + private void ensureMutationsIsMutable() { + if (!((bitField0_ & 0x00000020) != 0)) { + mutations_ = new java.util.ArrayList(mutations_); + bitField0_ |= 0x00000020; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Mutation, + com.google.datastore.v1.Mutation.Builder, + com.google.datastore.v1.MutationOrBuilder> + mutationsBuilder_; + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public java.util.List getMutationsList() { + if (mutationsBuilder_ == null) { + return java.util.Collections.unmodifiableList(mutations_); + } else { + return mutationsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public int getMutationsCount() { + if (mutationsBuilder_ == null) { + return mutations_.size(); + } else { + return mutationsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public com.google.datastore.v1.Mutation getMutations(int index) { + if (mutationsBuilder_ == null) { + return mutations_.get(index); + } else { + return mutationsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public Builder setMutations(int index, com.google.datastore.v1.Mutation value) { + if (mutationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMutationsIsMutable(); + mutations_.set(index, value); + onChanged(); + } else { + mutationsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public Builder setMutations( + int index, com.google.datastore.v1.Mutation.Builder builderForValue) { + if (mutationsBuilder_ == null) { + ensureMutationsIsMutable(); + mutations_.set(index, builderForValue.build()); + onChanged(); + } else { + mutationsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public Builder addMutations(com.google.datastore.v1.Mutation value) { + if (mutationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMutationsIsMutable(); + mutations_.add(value); + onChanged(); + } else { + mutationsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public Builder addMutations(int index, com.google.datastore.v1.Mutation value) { + if (mutationsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMutationsIsMutable(); + mutations_.add(index, value); + onChanged(); + } else { + mutationsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public Builder addMutations(com.google.datastore.v1.Mutation.Builder builderForValue) { + if (mutationsBuilder_ == null) { + ensureMutationsIsMutable(); + mutations_.add(builderForValue.build()); + onChanged(); + } else { + mutationsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public Builder addMutations( + int index, com.google.datastore.v1.Mutation.Builder builderForValue) { + if (mutationsBuilder_ == null) { + ensureMutationsIsMutable(); + mutations_.add(index, builderForValue.build()); + onChanged(); + } else { + mutationsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public Builder addAllMutations( + java.lang.Iterable values) { + if (mutationsBuilder_ == null) { + ensureMutationsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, mutations_); + onChanged(); + } else { + mutationsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public Builder clearMutations() { + if (mutationsBuilder_ == null) { + mutations_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + mutationsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public Builder removeMutations(int index) { + if (mutationsBuilder_ == null) { + ensureMutationsIsMutable(); + mutations_.remove(index); + onChanged(); + } else { + mutationsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public com.google.datastore.v1.Mutation.Builder getMutationsBuilder(int index) { + return getMutationsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public com.google.datastore.v1.MutationOrBuilder getMutationsOrBuilder(int index) { + if (mutationsBuilder_ == null) { + return mutations_.get(index); + } else { + return mutationsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public java.util.List + getMutationsOrBuilderList() { + if (mutationsBuilder_ != null) { + return mutationsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(mutations_); + } + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public com.google.datastore.v1.Mutation.Builder addMutationsBuilder() { + return getMutationsFieldBuilder() + .addBuilder(com.google.datastore.v1.Mutation.getDefaultInstance()); + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public com.google.datastore.v1.Mutation.Builder addMutationsBuilder(int index) { + return getMutationsFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Mutation.getDefaultInstance()); + } + + /** + * + * + *
+     * The mutations to perform.
+     *
+     * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+     * applied in order. The following sequences of mutations affecting a single
+     * entity are not permitted in a single `Commit` request:
+     *
+     * - `insert` followed by `insert`
+     * - `update` followed by `insert`
+     * - `upsert` followed by `insert`
+     * - `delete` followed by `update`
+     *
+     * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+     * entity.
+     * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + public java.util.List getMutationsBuilderList() { + return getMutationsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Mutation, + com.google.datastore.v1.Mutation.Builder, + com.google.datastore.v1.MutationOrBuilder> + getMutationsFieldBuilder() { + if (mutationsBuilder_ == null) { + mutationsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Mutation, + com.google.datastore.v1.Mutation.Builder, + com.google.datastore.v1.MutationOrBuilder>( + mutations_, ((bitField0_ & 0x00000020) != 0), getParentForChildren(), isClean()); + mutations_ = null; + } + return mutationsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.CommitRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.CommitRequest) + private static final com.google.datastore.v1.CommitRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.CommitRequest(); + } + + public static com.google.datastore.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.datastore.v1.CommitRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitRequestOrBuilder.java new file mode 100644 index 000000000000..ec719960e930 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitRequestOrBuilder.java @@ -0,0 +1,303 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface CommitRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.CommitRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * The type of commit to perform. Defaults to `TRANSACTIONAL`.
+   * 
+ * + * .google.datastore.v1.CommitRequest.Mode mode = 5; + * + * @return The enum numeric value on the wire for mode. + */ + int getModeValue(); + + /** + * + * + *
+   * The type of commit to perform. Defaults to `TRANSACTIONAL`.
+   * 
+ * + * .google.datastore.v1.CommitRequest.Mode mode = 5; + * + * @return The mode. + */ + com.google.datastore.v1.CommitRequest.Mode getMode(); + + /** + * + * + *
+   * The identifier of the transaction associated with the commit. A
+   * transaction identifier is returned by a call to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * bytes transaction = 1; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); + + /** + * + * + *
+   * The identifier of the transaction associated with the commit. A
+   * transaction identifier is returned by a call to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * bytes transaction = 1; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   * The transaction is committed when the request completes. If specified,
+   * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+   * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+   * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + * + * @return Whether the singleUseTransaction field is set. + */ + boolean hasSingleUseTransaction(); + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   * The transaction is committed when the request completes. If specified,
+   * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+   * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+   * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + * + * @return The singleUseTransaction. + */ + com.google.datastore.v1.TransactionOptions getSingleUseTransaction(); + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   * The transaction is committed when the request completes. If specified,
+   * [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be
+   * [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite].
+   * 
+ * + * .google.datastore.v1.TransactionOptions single_use_transaction = 10; + */ + com.google.datastore.v1.TransactionOptionsOrBuilder getSingleUseTransactionOrBuilder(); + + /** + * + * + *
+   * The mutations to perform.
+   *
+   * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+   * applied in order. The following sequences of mutations affecting a single
+   * entity are not permitted in a single `Commit` request:
+   *
+   * - `insert` followed by `insert`
+   * - `update` followed by `insert`
+   * - `upsert` followed by `insert`
+   * - `delete` followed by `update`
+   *
+   * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+   * entity.
+   * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + java.util.List getMutationsList(); + + /** + * + * + *
+   * The mutations to perform.
+   *
+   * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+   * applied in order. The following sequences of mutations affecting a single
+   * entity are not permitted in a single `Commit` request:
+   *
+   * - `insert` followed by `insert`
+   * - `update` followed by `insert`
+   * - `upsert` followed by `insert`
+   * - `delete` followed by `update`
+   *
+   * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+   * entity.
+   * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + com.google.datastore.v1.Mutation getMutations(int index); + + /** + * + * + *
+   * The mutations to perform.
+   *
+   * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+   * applied in order. The following sequences of mutations affecting a single
+   * entity are not permitted in a single `Commit` request:
+   *
+   * - `insert` followed by `insert`
+   * - `update` followed by `insert`
+   * - `upsert` followed by `insert`
+   * - `delete` followed by `update`
+   *
+   * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+   * entity.
+   * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + int getMutationsCount(); + + /** + * + * + *
+   * The mutations to perform.
+   *
+   * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+   * applied in order. The following sequences of mutations affecting a single
+   * entity are not permitted in a single `Commit` request:
+   *
+   * - `insert` followed by `insert`
+   * - `update` followed by `insert`
+   * - `upsert` followed by `insert`
+   * - `delete` followed by `update`
+   *
+   * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+   * entity.
+   * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + java.util.List getMutationsOrBuilderList(); + + /** + * + * + *
+   * The mutations to perform.
+   *
+   * When mode is `TRANSACTIONAL`, mutations affecting a single entity are
+   * applied in order. The following sequences of mutations affecting a single
+   * entity are not permitted in a single `Commit` request:
+   *
+   * - `insert` followed by `insert`
+   * - `update` followed by `insert`
+   * - `upsert` followed by `insert`
+   * - `delete` followed by `update`
+   *
+   * When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
+   * entity.
+   * 
+ * + * repeated .google.datastore.v1.Mutation mutations = 6; + */ + com.google.datastore.v1.MutationOrBuilder getMutationsOrBuilder(int index); + + com.google.datastore.v1.CommitRequest.TransactionSelectorCase getTransactionSelectorCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitResponse.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitResponse.java new file mode 100644 index 000000000000..ccc3121406dd --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitResponse.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! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The response for [Datastore.Commit][google.datastore.v1.Datastore.Commit].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.CommitResponse} + */ +public final class CommitResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.CommitResponse) + CommitResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use CommitResponse.newBuilder() to construct. + private CommitResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CommitResponse() { + mutationResults_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CommitResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_CommitResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_CommitResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.CommitResponse.class, + com.google.datastore.v1.CommitResponse.Builder.class); + } + + private int bitField0_; + public static final int MUTATION_RESULTS_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private java.util.List mutationResults_; + + /** + * + * + *
+   * The result of performing the mutations.
+   * The i-th mutation result corresponds to the i-th mutation in the request.
+   * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + @java.lang.Override + public java.util.List getMutationResultsList() { + return mutationResults_; + } + + /** + * + * + *
+   * The result of performing the mutations.
+   * The i-th mutation result corresponds to the i-th mutation in the request.
+   * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + @java.lang.Override + public java.util.List + getMutationResultsOrBuilderList() { + return mutationResults_; + } + + /** + * + * + *
+   * The result of performing the mutations.
+   * The i-th mutation result corresponds to the i-th mutation in the request.
+   * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + @java.lang.Override + public int getMutationResultsCount() { + return mutationResults_.size(); + } + + /** + * + * + *
+   * The result of performing the mutations.
+   * The i-th mutation result corresponds to the i-th mutation in the request.
+   * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + @java.lang.Override + public com.google.datastore.v1.MutationResult getMutationResults(int index) { + return mutationResults_.get(index); + } + + /** + * + * + *
+   * The result of performing the mutations.
+   * The i-th mutation result corresponds to the i-th mutation in the request.
+   * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + @java.lang.Override + public com.google.datastore.v1.MutationResultOrBuilder getMutationResultsOrBuilder(int index) { + return mutationResults_.get(index); + } + + public static final int INDEX_UPDATES_FIELD_NUMBER = 4; + private int indexUpdates_ = 0; + + /** + * + * + *
+   * The number of index entries updated during the commit, or zero if none were
+   * updated.
+   * 
+ * + * int32 index_updates = 4; + * + * @return The indexUpdates. + */ + @java.lang.Override + public int getIndexUpdates() { + return indexUpdates_; + } + + public static final int COMMIT_TIME_FIELD_NUMBER = 8; + private com.google.protobuf.Timestamp commitTime_; + + /** + * + * + *
+   * The transaction commit timestamp. Not set for non-transactional commits.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + * + * @return Whether the commitTime field is set. + */ + @java.lang.Override + public boolean hasCommitTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The transaction commit timestamp. Not set for non-transactional commits.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + * + * @return The commitTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCommitTime() { + return commitTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : commitTime_; + } + + /** + * + * + *
+   * The transaction commit timestamp. Not set for non-transactional commits.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + */ + @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 < mutationResults_.size(); i++) { + output.writeMessage(3, mutationResults_.get(i)); + } + if (indexUpdates_ != 0) { + output.writeInt32(4, indexUpdates_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(8, 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 < mutationResults_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, mutationResults_.get(i)); + } + if (indexUpdates_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(4, indexUpdates_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, 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.datastore.v1.CommitResponse)) { + return super.equals(obj); + } + com.google.datastore.v1.CommitResponse other = (com.google.datastore.v1.CommitResponse) obj; + + if (!getMutationResultsList().equals(other.getMutationResultsList())) return false; + if (getIndexUpdates() != other.getIndexUpdates()) 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 (getMutationResultsCount() > 0) { + hash = (37 * hash) + MUTATION_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getMutationResultsList().hashCode(); + } + hash = (37 * hash) + INDEX_UPDATES_FIELD_NUMBER; + hash = (53 * hash) + getIndexUpdates(); + 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.datastore.v1.CommitResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.CommitResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.CommitResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.CommitResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.CommitResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.CommitResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.CommitResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.CommitResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.CommitResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.CommitResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for [Datastore.Commit][google.datastore.v1.Datastore.Commit].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.CommitResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.CommitResponse) + com.google.datastore.v1.CommitResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_CommitResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_CommitResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.CommitResponse.class, + com.google.datastore.v1.CommitResponse.Builder.class); + } + + // Construct using com.google.datastore.v1.CommitResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getMutationResultsFieldBuilder(); + getCommitTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (mutationResultsBuilder_ == null) { + mutationResults_ = java.util.Collections.emptyList(); + } else { + mutationResults_ = null; + mutationResultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + indexUpdates_ = 0; + commitTime_ = null; + if (commitTimeBuilder_ != null) { + commitTimeBuilder_.dispose(); + commitTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_CommitResponse_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.CommitResponse getDefaultInstanceForType() { + return com.google.datastore.v1.CommitResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.CommitResponse build() { + com.google.datastore.v1.CommitResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.CommitResponse buildPartial() { + com.google.datastore.v1.CommitResponse result = + new com.google.datastore.v1.CommitResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.CommitResponse result) { + if (mutationResultsBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + mutationResults_ = java.util.Collections.unmodifiableList(mutationResults_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.mutationResults_ = mutationResults_; + } else { + result.mutationResults_ = mutationResultsBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.CommitResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.indexUpdates_ = indexUpdates_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.commitTime_ = commitTimeBuilder_ == null ? commitTime_ : commitTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.CommitResponse) { + return mergeFrom((com.google.datastore.v1.CommitResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.CommitResponse other) { + if (other == com.google.datastore.v1.CommitResponse.getDefaultInstance()) return this; + if (mutationResultsBuilder_ == null) { + if (!other.mutationResults_.isEmpty()) { + if (mutationResults_.isEmpty()) { + mutationResults_ = other.mutationResults_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureMutationResultsIsMutable(); + mutationResults_.addAll(other.mutationResults_); + } + onChanged(); + } + } else { + if (!other.mutationResults_.isEmpty()) { + if (mutationResultsBuilder_.isEmpty()) { + mutationResultsBuilder_.dispose(); + mutationResultsBuilder_ = null; + mutationResults_ = other.mutationResults_; + bitField0_ = (bitField0_ & ~0x00000001); + mutationResultsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getMutationResultsFieldBuilder() + : null; + } else { + mutationResultsBuilder_.addAllMessages(other.mutationResults_); + } + } + } + if (other.getIndexUpdates() != 0) { + setIndexUpdates(other.getIndexUpdates()); + } + 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 26: + { + com.google.datastore.v1.MutationResult m = + input.readMessage( + com.google.datastore.v1.MutationResult.parser(), extensionRegistry); + if (mutationResultsBuilder_ == null) { + ensureMutationResultsIsMutable(); + mutationResults_.add(m); + } else { + mutationResultsBuilder_.addMessage(m); + } + break; + } // case 26 + case 32: + { + indexUpdates_ = input.readInt32(); + bitField0_ |= 0x00000002; + break; + } // case 32 + case 66: + { + input.readMessage(getCommitTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + 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 java.util.List mutationResults_ = + java.util.Collections.emptyList(); + + private void ensureMutationResultsIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + mutationResults_ = + new java.util.ArrayList(mutationResults_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.MutationResult, + com.google.datastore.v1.MutationResult.Builder, + com.google.datastore.v1.MutationResultOrBuilder> + mutationResultsBuilder_; + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public java.util.List getMutationResultsList() { + if (mutationResultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(mutationResults_); + } else { + return mutationResultsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public int getMutationResultsCount() { + if (mutationResultsBuilder_ == null) { + return mutationResults_.size(); + } else { + return mutationResultsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public com.google.datastore.v1.MutationResult getMutationResults(int index) { + if (mutationResultsBuilder_ == null) { + return mutationResults_.get(index); + } else { + return mutationResultsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public Builder setMutationResults(int index, com.google.datastore.v1.MutationResult value) { + if (mutationResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMutationResultsIsMutable(); + mutationResults_.set(index, value); + onChanged(); + } else { + mutationResultsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public Builder setMutationResults( + int index, com.google.datastore.v1.MutationResult.Builder builderForValue) { + if (mutationResultsBuilder_ == null) { + ensureMutationResultsIsMutable(); + mutationResults_.set(index, builderForValue.build()); + onChanged(); + } else { + mutationResultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public Builder addMutationResults(com.google.datastore.v1.MutationResult value) { + if (mutationResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMutationResultsIsMutable(); + mutationResults_.add(value); + onChanged(); + } else { + mutationResultsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public Builder addMutationResults(int index, com.google.datastore.v1.MutationResult value) { + if (mutationResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMutationResultsIsMutable(); + mutationResults_.add(index, value); + onChanged(); + } else { + mutationResultsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public Builder addMutationResults( + com.google.datastore.v1.MutationResult.Builder builderForValue) { + if (mutationResultsBuilder_ == null) { + ensureMutationResultsIsMutable(); + mutationResults_.add(builderForValue.build()); + onChanged(); + } else { + mutationResultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public Builder addMutationResults( + int index, com.google.datastore.v1.MutationResult.Builder builderForValue) { + if (mutationResultsBuilder_ == null) { + ensureMutationResultsIsMutable(); + mutationResults_.add(index, builderForValue.build()); + onChanged(); + } else { + mutationResultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public Builder addAllMutationResults( + java.lang.Iterable values) { + if (mutationResultsBuilder_ == null) { + ensureMutationResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, mutationResults_); + onChanged(); + } else { + mutationResultsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public Builder clearMutationResults() { + if (mutationResultsBuilder_ == null) { + mutationResults_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + mutationResultsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public Builder removeMutationResults(int index) { + if (mutationResultsBuilder_ == null) { + ensureMutationResultsIsMutable(); + mutationResults_.remove(index); + onChanged(); + } else { + mutationResultsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public com.google.datastore.v1.MutationResult.Builder getMutationResultsBuilder(int index) { + return getMutationResultsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public com.google.datastore.v1.MutationResultOrBuilder getMutationResultsOrBuilder(int index) { + if (mutationResultsBuilder_ == null) { + return mutationResults_.get(index); + } else { + return mutationResultsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public java.util.List + getMutationResultsOrBuilderList() { + if (mutationResultsBuilder_ != null) { + return mutationResultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(mutationResults_); + } + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public com.google.datastore.v1.MutationResult.Builder addMutationResultsBuilder() { + return getMutationResultsFieldBuilder() + .addBuilder(com.google.datastore.v1.MutationResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public com.google.datastore.v1.MutationResult.Builder addMutationResultsBuilder(int index) { + return getMutationResultsFieldBuilder() + .addBuilder(index, com.google.datastore.v1.MutationResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The result of performing the mutations.
+     * The i-th mutation result corresponds to the i-th mutation in the request.
+     * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + public java.util.List + getMutationResultsBuilderList() { + return getMutationResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.MutationResult, + com.google.datastore.v1.MutationResult.Builder, + com.google.datastore.v1.MutationResultOrBuilder> + getMutationResultsFieldBuilder() { + if (mutationResultsBuilder_ == null) { + mutationResultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.MutationResult, + com.google.datastore.v1.MutationResult.Builder, + com.google.datastore.v1.MutationResultOrBuilder>( + mutationResults_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + mutationResults_ = null; + } + return mutationResultsBuilder_; + } + + private int indexUpdates_; + + /** + * + * + *
+     * The number of index entries updated during the commit, or zero if none were
+     * updated.
+     * 
+ * + * int32 index_updates = 4; + * + * @return The indexUpdates. + */ + @java.lang.Override + public int getIndexUpdates() { + return indexUpdates_; + } + + /** + * + * + *
+     * The number of index entries updated during the commit, or zero if none were
+     * updated.
+     * 
+ * + * int32 index_updates = 4; + * + * @param value The indexUpdates to set. + * @return This builder for chaining. + */ + public Builder setIndexUpdates(int value) { + + indexUpdates_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of index entries updated during the commit, or zero if none were
+     * updated.
+     * 
+ * + * int32 index_updates = 4; + * + * @return This builder for chaining. + */ + public Builder clearIndexUpdates() { + bitField0_ = (bitField0_ & ~0x00000002); + indexUpdates_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp commitTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + commitTimeBuilder_; + + /** + * + * + *
+     * The transaction commit timestamp. Not set for non-transactional commits.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + * + * @return Whether the commitTime field is set. + */ + public boolean hasCommitTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The transaction commit timestamp. Not set for non-transactional commits.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + * + * @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 transaction commit timestamp. Not set for non-transactional commits.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + */ + public Builder setCommitTime(com.google.protobuf.Timestamp value) { + if (commitTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + commitTime_ = value; + } else { + commitTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The transaction commit timestamp. Not set for non-transactional commits.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + */ + public Builder setCommitTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (commitTimeBuilder_ == null) { + commitTime_ = builderForValue.build(); + } else { + commitTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The transaction commit timestamp. Not set for non-transactional commits.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + */ + public Builder mergeCommitTime(com.google.protobuf.Timestamp value) { + if (commitTimeBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && commitTime_ != null + && commitTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getCommitTimeBuilder().mergeFrom(value); + } else { + commitTime_ = value; + } + } else { + commitTimeBuilder_.mergeFrom(value); + } + if (commitTime_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The transaction commit timestamp. Not set for non-transactional commits.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + */ + public Builder clearCommitTime() { + bitField0_ = (bitField0_ & ~0x00000004); + commitTime_ = null; + if (commitTimeBuilder_ != null) { + commitTimeBuilder_.dispose(); + commitTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The transaction commit timestamp. Not set for non-transactional commits.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + */ + public com.google.protobuf.Timestamp.Builder getCommitTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getCommitTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The transaction commit timestamp. Not set for non-transactional commits.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + */ + public com.google.protobuf.TimestampOrBuilder getCommitTimeOrBuilder() { + if (commitTimeBuilder_ != null) { + return commitTimeBuilder_.getMessageOrBuilder(); + } else { + return commitTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : commitTime_; + } + } + + /** + * + * + *
+     * The transaction commit timestamp. Not set for non-transactional commits.
+     * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getCommitTimeFieldBuilder() { + if (commitTimeBuilder_ == null) { + commitTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getCommitTime(), getParentForChildren(), isClean()); + commitTime_ = null; + } + return commitTimeBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.CommitResponse) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.CommitResponse) + private static final com.google.datastore.v1.CommitResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.CommitResponse(); + } + + public static com.google.datastore.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.datastore.v1.CommitResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitResponseOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitResponseOrBuilder.java new file mode 100644 index 000000000000..062e2a36efd6 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CommitResponseOrBuilder.java @@ -0,0 +1,138 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface CommitResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.CommitResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The result of performing the mutations.
+   * The i-th mutation result corresponds to the i-th mutation in the request.
+   * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + java.util.List getMutationResultsList(); + + /** + * + * + *
+   * The result of performing the mutations.
+   * The i-th mutation result corresponds to the i-th mutation in the request.
+   * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + com.google.datastore.v1.MutationResult getMutationResults(int index); + + /** + * + * + *
+   * The result of performing the mutations.
+   * The i-th mutation result corresponds to the i-th mutation in the request.
+   * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + int getMutationResultsCount(); + + /** + * + * + *
+   * The result of performing the mutations.
+   * The i-th mutation result corresponds to the i-th mutation in the request.
+   * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + java.util.List + getMutationResultsOrBuilderList(); + + /** + * + * + *
+   * The result of performing the mutations.
+   * The i-th mutation result corresponds to the i-th mutation in the request.
+   * 
+ * + * repeated .google.datastore.v1.MutationResult mutation_results = 3; + */ + com.google.datastore.v1.MutationResultOrBuilder getMutationResultsOrBuilder(int index); + + /** + * + * + *
+   * The number of index entries updated during the commit, or zero if none were
+   * updated.
+   * 
+ * + * int32 index_updates = 4; + * + * @return The indexUpdates. + */ + int getIndexUpdates(); + + /** + * + * + *
+   * The transaction commit timestamp. Not set for non-transactional commits.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + * + * @return Whether the commitTime field is set. + */ + boolean hasCommitTime(); + + /** + * + * + *
+   * The transaction commit timestamp. Not set for non-transactional commits.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + * + * @return The commitTime. + */ + com.google.protobuf.Timestamp getCommitTime(); + + /** + * + * + *
+   * The transaction commit timestamp. Not set for non-transactional commits.
+   * 
+ * + * .google.protobuf.Timestamp commit_time = 8; + */ + com.google.protobuf.TimestampOrBuilder getCommitTimeOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CompositeFilter.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CompositeFilter.java new file mode 100644 index 000000000000..40a7539c4052 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CompositeFilter.java @@ -0,0 +1,1361 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A filter that merges multiple other filters using the given operator.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.CompositeFilter} + */ +public final class CompositeFilter extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.CompositeFilter) + CompositeFilterOrBuilder { + private static final long serialVersionUID = 0L; + + // Use CompositeFilter.newBuilder() to construct. + private CompositeFilter(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CompositeFilter() { + op_ = 0; + filters_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CompositeFilter(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_CompositeFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_CompositeFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.CompositeFilter.class, + com.google.datastore.v1.CompositeFilter.Builder.class); + } + + /** + * + * + *
+   * A composite filter operator.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.CompositeFilter.Operator} + */ + public enum Operator implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * OPERATOR_UNSPECIFIED = 0; + */ + OPERATOR_UNSPECIFIED(0), + /** + * + * + *
+     * The results are required to satisfy each 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), + ; + + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * OPERATOR_UNSPECIFIED = 0; + */ + public static final int OPERATOR_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * The results are required to satisfy each 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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.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.datastore.v1.CompositeFilter.Operator) + } + + public static final int OP_FIELD_NUMBER = 1; + private int op_ = 0; + + /** + * + * + *
+   * The operator for combining multiple filters.
+   * 
+ * + * .google.datastore.v1.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.datastore.v1.CompositeFilter.Operator op = 1; + * + * @return The op. + */ + @java.lang.Override + public com.google.datastore.v1.CompositeFilter.Operator getOp() { + com.google.datastore.v1.CompositeFilter.Operator result = + com.google.datastore.v1.CompositeFilter.Operator.forNumber(op_); + return result == null ? com.google.datastore.v1.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.datastore.v1.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.datastore.v1.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.datastore.v1.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.datastore.v1.Filter filters = 2; + */ + @java.lang.Override + public com.google.datastore.v1.Filter getFilters(int index) { + return filters_.get(index); + } + + /** + * + * + *
+   * The list of filters to combine.
+   *
+   * Requires:
+   *
+   * * At least one filter is present.
+   * 
+ * + * repeated .google.datastore.v1.Filter filters = 2; + */ + @java.lang.Override + public com.google.datastore.v1.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.datastore.v1.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.datastore.v1.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.datastore.v1.CompositeFilter)) { + return super.equals(obj); + } + com.google.datastore.v1.CompositeFilter other = (com.google.datastore.v1.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.datastore.v1.CompositeFilter parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.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.datastore.v1.CompositeFilter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.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.datastore.v1.CompositeFilter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.CompositeFilter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.CompositeFilter parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.CompositeFilter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.CompositeFilter parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.CompositeFilter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.CompositeFilter parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.CompositeFilter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A filter that merges multiple other filters using the given operator.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.CompositeFilter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.CompositeFilter) + com.google.datastore.v1.CompositeFilterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_CompositeFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_CompositeFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.CompositeFilter.class, + com.google.datastore.v1.CompositeFilter.Builder.class); + } + + // Construct using com.google.datastore.v1.CompositeFilter.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.v1.QueryProto + .internal_static_google_datastore_v1_CompositeFilter_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.CompositeFilter getDefaultInstanceForType() { + return com.google.datastore.v1.CompositeFilter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.CompositeFilter build() { + com.google.datastore.v1.CompositeFilter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.CompositeFilter buildPartial() { + com.google.datastore.v1.CompositeFilter result = + new com.google.datastore.v1.CompositeFilter(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.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.datastore.v1.CompositeFilter result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.op_ = op_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.CompositeFilter) { + return mergeFrom((com.google.datastore.v1.CompositeFilter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.CompositeFilter other) { + if (other == com.google.datastore.v1.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.GeneratedMessageV3.alwaysUseFieldBuilders + ? getFiltersFieldBuilder() + : 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.datastore.v1.Filter m = + input.readMessage(com.google.datastore.v1.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.datastore.v1.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.datastore.v1.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.datastore.v1.CompositeFilter.Operator op = 1; + * + * @return The op. + */ + @java.lang.Override + public com.google.datastore.v1.CompositeFilter.Operator getOp() { + com.google.datastore.v1.CompositeFilter.Operator result = + com.google.datastore.v1.CompositeFilter.Operator.forNumber(op_); + return result == null + ? com.google.datastore.v1.CompositeFilter.Operator.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * The operator for combining multiple filters.
+     * 
+ * + * .google.datastore.v1.CompositeFilter.Operator op = 1; + * + * @param value The op to set. + * @return This builder for chaining. + */ + public Builder setOp(com.google.datastore.v1.CompositeFilter.Operator value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + op_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The operator for combining multiple filters.
+     * 
+ * + * .google.datastore.v1.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.RepeatedFieldBuilderV3< + com.google.datastore.v1.Filter, + com.google.datastore.v1.Filter.Builder, + com.google.datastore.v1.FilterOrBuilder> + filtersBuilder_; + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.datastore.v1.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.datastore.v1.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.datastore.v1.Filter filters = 2; + */ + public com.google.datastore.v1.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.datastore.v1.Filter filters = 2; + */ + public Builder setFilters(int index, com.google.datastore.v1.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.datastore.v1.Filter filters = 2; + */ + public Builder setFilters(int index, com.google.datastore.v1.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.datastore.v1.Filter filters = 2; + */ + public Builder addFilters(com.google.datastore.v1.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.datastore.v1.Filter filters = 2; + */ + public Builder addFilters(int index, com.google.datastore.v1.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.datastore.v1.Filter filters = 2; + */ + public Builder addFilters(com.google.datastore.v1.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.datastore.v1.Filter filters = 2; + */ + public Builder addFilters(int index, com.google.datastore.v1.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.datastore.v1.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.datastore.v1.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.datastore.v1.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.datastore.v1.Filter filters = 2; + */ + public com.google.datastore.v1.Filter.Builder getFiltersBuilder(int index) { + return getFiltersFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.datastore.v1.Filter filters = 2; + */ + public com.google.datastore.v1.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.datastore.v1.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.datastore.v1.Filter filters = 2; + */ + public com.google.datastore.v1.Filter.Builder addFiltersBuilder() { + return getFiltersFieldBuilder() + .addBuilder(com.google.datastore.v1.Filter.getDefaultInstance()); + } + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.datastore.v1.Filter filters = 2; + */ + public com.google.datastore.v1.Filter.Builder addFiltersBuilder(int index) { + return getFiltersFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Filter.getDefaultInstance()); + } + + /** + * + * + *
+     * The list of filters to combine.
+     *
+     * Requires:
+     *
+     * * At least one filter is present.
+     * 
+ * + * repeated .google.datastore.v1.Filter filters = 2; + */ + public java.util.List getFiltersBuilderList() { + return getFiltersFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Filter, + com.google.datastore.v1.Filter.Builder, + com.google.datastore.v1.FilterOrBuilder> + getFiltersFieldBuilder() { + if (filtersBuilder_ == null) { + filtersBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Filter, + com.google.datastore.v1.Filter.Builder, + com.google.datastore.v1.FilterOrBuilder>( + filters_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + filters_ = null; + } + return filtersBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.CompositeFilter) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.CompositeFilter) + private static final com.google.datastore.v1.CompositeFilter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.CompositeFilter(); + } + + public static com.google.datastore.v1.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.datastore.v1.CompositeFilter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CompositeFilterOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CompositeFilterOrBuilder.java new file mode 100644 index 000000000000..4394f2ef75db --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/CompositeFilterOrBuilder.java @@ -0,0 +1,127 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface CompositeFilterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.CompositeFilter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The operator for combining multiple filters.
+   * 
+ * + * .google.datastore.v1.CompositeFilter.Operator op = 1; + * + * @return The enum numeric value on the wire for op. + */ + int getOpValue(); + + /** + * + * + *
+   * The operator for combining multiple filters.
+   * 
+ * + * .google.datastore.v1.CompositeFilter.Operator op = 1; + * + * @return The op. + */ + com.google.datastore.v1.CompositeFilter.Operator getOp(); + + /** + * + * + *
+   * The list of filters to combine.
+   *
+   * Requires:
+   *
+   * * At least one filter is present.
+   * 
+ * + * repeated .google.datastore.v1.Filter filters = 2; + */ + java.util.List getFiltersList(); + + /** + * + * + *
+   * The list of filters to combine.
+   *
+   * Requires:
+   *
+   * * At least one filter is present.
+   * 
+ * + * repeated .google.datastore.v1.Filter filters = 2; + */ + com.google.datastore.v1.Filter getFilters(int index); + + /** + * + * + *
+   * The list of filters to combine.
+   *
+   * Requires:
+   *
+   * * At least one filter is present.
+   * 
+ * + * repeated .google.datastore.v1.Filter filters = 2; + */ + int getFiltersCount(); + + /** + * + * + *
+   * The list of filters to combine.
+   *
+   * Requires:
+   *
+   * * At least one filter is present.
+   * 
+ * + * repeated .google.datastore.v1.Filter filters = 2; + */ + java.util.List getFiltersOrBuilderList(); + + /** + * + * + *
+   * The list of filters to combine.
+   *
+   * Requires:
+   *
+   * * At least one filter is present.
+   * 
+ * + * repeated .google.datastore.v1.Filter filters = 2; + */ + com.google.datastore.v1.FilterOrBuilder getFiltersOrBuilder(int index); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/DatastoreProto.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/DatastoreProto.java new file mode 100644 index 000000000000..bca4d71553a9 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/DatastoreProto.java @@ -0,0 +1,610 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public final class DatastoreProto { + private DatastoreProto() {} + + 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_datastore_v1_LookupRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_LookupRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_LookupResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_LookupResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_RunQueryRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_RunQueryRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_RunQueryResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_RunQueryResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_RunAggregationQueryRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_RunAggregationQueryRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_RunAggregationQueryResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_RunAggregationQueryResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_BeginTransactionRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_BeginTransactionRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_BeginTransactionResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_BeginTransactionResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_RollbackRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_RollbackRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_RollbackResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_RollbackResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_CommitRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_CommitRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_CommitResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_CommitResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_AllocateIdsRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_AllocateIdsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_AllocateIdsResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_AllocateIdsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_ReserveIdsRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_ReserveIdsRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_ReserveIdsResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_ReserveIdsResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_Mutation_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_Mutation_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_PropertyTransform_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_PropertyTransform_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_MutationResult_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_MutationResult_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_PropertyMask_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_PropertyMask_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_ReadOptions_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_ReadOptions_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_TransactionOptions_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_TransactionOptions_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_TransactionOptions_ReadWrite_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_TransactionOptions_ReadWrite_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_TransactionOptions_ReadOnly_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_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/datastore/v1/datastore.proto\022\023g" + + "oogle.datastore.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/datastore/v1/aggregation_result.proto\032 google/datastore/v1/" + + "entity.proto\032\037google/datastore/v1/query." + + "proto\032\'google/datastore/v1/query_profile" + + ".proto\032\037google/protobuf/timestamp.proto\"\334\001\n\r" + + "LookupRequest\022\027\n\n" + + "project_id\030\010 \001(\tB\003\340A\002\022\023\n" + + "\013database_id\030\t \001(\t\0226\n" + + "\014read_options\030\001 \001(\0132 .google.datastore.v1.ReadOptions\022+\n" + + "\004keys\030\003 \003(\0132\030.google.datastore.v1.KeyB\003\340A\002\0228\n\r" + + "property_mask\030\005 \001(\0132!.google.datastore.v1.PropertyMask\"\346\001\n" + + "\016LookupResponse\0220\n" + + "\005found\030\001 \003(\0132!.google.datastore.v1.EntityResult\0222\n" + + "\007missing\030\002 \003(\0132!.google.datastore.v1.EntityResult\022*\n" + + "\010deferred\030\003 \003(\0132\030.google.datastore.v1.Key\022\023\n" + + "\013transaction\030\005 \001(\014\022-\n" + + "\tread_time\030\007 \001(\0132\032.google.protobuf.Timestamp\"\233\003\n" + + "\017RunQueryRequest\022\027\n\n" + + "project_id\030\010 \001(\tB\003\340A\002\022\023\n" + + "\013database_id\030\t \001(\t\0226\n" + + "\014partition_id\030\002 \001(\0132 .google.datastore.v1.PartitionId\0226\n" + + "\014read_options\030\001 \001(\0132 .google.datastore.v1.ReadOptions\022+\n" + + "\005query\030\003 \001(\0132\032.google.datastore.v1.QueryH\000\0222\n" + + "\tgql_query\030\007 \001(\0132\035.google.datastore.v1.GqlQueryH\000\0228\n\r" + + "property_mask\030\n" + + " \001(\0132!.google.datastore.v1.PropertyMask\022A\n" + + "\017explain_options\030\014" + + " \001(\0132#.google.datastore.v1.ExplainOptionsB\003\340A\001B\014\n\n" + + "query_type\"\306\001\n" + + "\020RunQueryResponse\0224\n" + + "\005batch\030\001 \001(\0132%.google.datastore.v1.QueryResultBatch\022)\n" + + "\005query\030\002 \001(\0132\032.google.datastore.v1.Query\022\023\n" + + "\013transaction\030\005 \001(\014\022<\n" + + "\017explain_metrics\030\t \001(\0132#.google.datastore.v1.ExplainMetrics\"\203\003\n" + + "\032RunAggregationQueryRequest\022\027\n\n" + + "project_id\030\010 \001(\tB\003\340A\002\022\023\n" + + "\013database_id\030\t \001(\t\0226\n" + + "\014partition_id\030\002 \001(\0132 .google.datastore.v1.PartitionId\0226\n" + + "\014read_options\030\001 \001(\0132 .google.datastore.v1.ReadOptions\022B\n" + + "\021aggregation_query\030\003" + + " \001(\0132%.google.datastore.v1.AggregationQueryH\000\0222\n" + + "\tgql_query\030\007 \001(\0132\035.google.datastore.v1.GqlQueryH\000\022A\n" + + "\017explain_options\030\013" + + " \001(\0132#.google.datastore.v1.ExplainOptionsB\003\340A\001B\014\n\n" + + "query_type\"\342\001\n" + + "\033RunAggregationQueryResponse\022:\n" + + "\005batch\030\001 \001(\0132+.google.datastore.v1.AggregationResultBatch\0224\n" + + "\005query\030\002 \001(\0132%.google.datastore.v1.AggregationQuery\022\023\n" + + "\013transaction\030\005 \001(\014\022<\n" + + "\017explain_metrics\030\t \001(\0132#.google.datastore.v1.ExplainMetrics\"\215\001\n" + + "\027BeginTransactionRequest\022\027\n" + + "\n" + + "project_id\030\010 \001(\tB\003\340A\002\022\023\n" + + "\013database_id\030\t \001(\t\022D\n" + + "\023transaction_options\030\n" + + " \001(\0132\'.google.datastore.v1.TransactionOptions\"/\n" + + "\030BeginTransactionResponse\022\023\n" + + "\013transaction\030\001 \001(\014\"Y\n" + + "\017RollbackRequest\022\027\n\n" + + "project_id\030\010 \001(\tB\003\340A\002\022\023\n" + + "\013database_id\030\t \001(\t\022\030\n" + + "\013transaction\030\001 \001(\014B\003\340A\002\"\022\n" + + "\020RollbackResponse\"\350\002\n\r" + + "CommitRequest\022\027\n\n" + + "project_id\030\010 \001(\tB\003\340A\002\022\023\n" + + "\013database_id\030\t \001(\t\0225\n" + + "\004mode\030\005 \001(\0162\'.google.datastore.v1.CommitRequest.Mode\022\025\n" + + "\013transaction\030\001 \001(\014H\000\022I\n" + + "\026single_use_transaction\030\n" + + " \001(\0132\'.google.datastore.v1.TransactionOptionsH\000\0220\n" + + "\tmutations\030\006 \003(\0132\035.google.datastore.v1.Mutation\"F\n" + + "\004Mode\022\024\n" + + "\020MODE_UNSPECIFIED\020\000\022\021\n\r" + + "TRANSACTIONAL\020\001\022\025\n" + + "\021NON_TRANSACTIONAL\020\002B\026\n" + + "\024transaction_selector\"\227\001\n" + + "\016CommitResponse\022=\n" + + "\020mutation_results\030\003 \003(" + + "\0132#.google.datastore.v1.MutationResult\022\025\n\r" + + "index_updates\030\004 \001(\005\022/\n" + + "\013commit_time\030\010 \001(\0132\032.google.protobuf.Timestamp\"o\n" + + "\022AllocateIdsRequest\022\027\n\n" + + "project_id\030\010 \001(\tB\003\340A\002\022\023\n" + + "\013database_id\030\t \001(\t\022+\n" + + "\004keys\030\001 \003(\0132\030.google.datastore.v1.KeyB\003\340A\002\"=\n" + + "\023AllocateIdsResponse\022&\n" + + "\004keys\030\001 \003(\0132\030.google.datastore.v1.Key\"n\n" + + "\021ReserveIdsRequest\022\027\n\n" + + "project_id\030\010 \001(\tB\003\340A\002\022\023\n" + + "\013database_id\030\t \001(\t\022+\n" + + "\004keys\030\001 \003(\0132\030.google.datastore.v1.KeyB\003\340A\002\"\024\n" + + "\022ReserveIdsResponse\"\362\004\n" + + "\010Mutation\022-\n" + + "\006insert\030\004 \001(\0132\033.google.datastore.v1.EntityH\000\022-\n" + + "\006update\030\005 \001(\0132\033.google.datastore.v1.EntityH\000\022-\n" + + "\006upsert\030\006 \001(\0132\033.google.datastore.v1.EntityH\000\022*\n" + + "\006delete\030\007 \001(\0132\030.google.datastore.v1.KeyH\000\022\026\n" + + "\014base_version\030\010 \001(\003H\001\0221\n" + + "\013update_time\030\013 \001(\0132\032.google.protobuf.TimestampH\001\022^\n" + + "\034conflict_resolution_strategy\030\n" + + " \001(\01628.google.datastore.v1.Mutation.ConflictResolutionStrategy\0228\n\r" + + "property_mask\030\t \001(\0132!.google.datastore.v1.PropertyMask\022H\n" + + "\023property_transforms\030\014 \003(\0132&.g" + + "oogle.datastore.v1.PropertyTransformB\003\340A\001\"R\n" + + "\032ConflictResolutionStrategy\022\030\n" + + "\024STRATEGY_UNSPECIFIED\020\000\022\020\n" + + "\014SERVER_VALUE\020\001\022\010\n" + + "\004FAIL\020\003B\013\n" + + "\toperationB\035\n" + + "\033conflict_detection_strategy\"\343\003\n" + + "\021PropertyTransform\022\025\n" + + "\010property\030\001 \001(\tB\003\340A\001\022Q\n" + + "\023set_to_server_value\030\002 " + + "\001(\01622.google.datastore.v1.PropertyTransform.ServerValueH\000\022/\n" + + "\tincrement\030\003 \001(\0132\032.google.datastore.v1.ValueH\000\022-\n" + + "\007maximum\030\004 \001(\0132\032.google.datastore.v1.ValueH\000\022-\n" + + "\007minimum\030\005 \001(\0132\032.google.datastore.v1.ValueH\000\022B\n" + + "\027append_missing_elements\030\006" + + " \001(\0132\037.google.datastore.v1.ArrayValueH\000\022@\n" + + "\025remove_all_from_array\030\007" + + " \001(\0132\037.google.datastore.v1.ArrayValueH\000\"=\n" + + "\013ServerValue\022\034\n" + + "\030SERVER_VALUE_UNSPECIFIED\020\000\022\020\n" + + "\014REQUEST_TIME\020\001B\020\n" + + "\016transform_type\"\374\001\n" + + "\016MutationResult\022%\n" + + "\003key\030\003 \001(\0132\030.google.datastore.v1.Key\022\017\n" + + "\007version\030\004 \001(\003\022/\n" + + "\013create_time\030\007 \001(\0132\032.google.protobuf.Timestamp\022/\n" + + "\013update_time\030\006 \001(\0132\032.google.protobuf.Timestamp\022\031\n" + + "\021conflict_detected\030\005 \001(\010\0225\n" + + "\021transform_results\030\010 \003(\0132\032.google.datastore.v1.Value\"\035\n" + + "\014PropertyMask\022\r\n" + + "\005paths\030\001 \003(\t\"\312\002\n" + + "\013ReadOptions\022L\n" + + "\020read_consistency\030\001" + + " \001(\01620.google.datastore.v1.ReadOptions.ReadConsistencyH\000\022\025\n" + + "\013transaction\030\002 \001(\014H\000\022B\n" + + "\017new_transaction\030\003 " + + "\001(\0132\'.google.datastore.v1.TransactionOptionsH\000\022/\n" + + "\tread_time\030\004 \001(\0132\032.google.protobuf.TimestampH\000\"M\n" + + "\017ReadConsistency\022 \n" + + "\034READ_CONSISTENCY_UNSPECIFIED\020\000\022\n\n" + + "\006STRONG\020\001\022\014\n" + + "\010EVENTUAL\020\002B\022\n" + + "\020consistency_type\"\222\002\n" + + "\022TransactionOptions\022G\n\n" + + "read_write\030\001 \001(\01321." + + "google.datastore.v1.TransactionOptions.ReadWriteH\000\022E\n" + + "\tread_only\030\002 \001(\01320.google.d" + + "atastore.v1.TransactionOptions.ReadOnlyH\000\032)\n" + + "\tReadWrite\022\034\n" + + "\024previous_transaction\030\001 \001(\014\0329\n" + + "\010ReadOnly\022-\n" + + "\tread_time\030\001 \001(\0132\032.google.protobuf.TimestampB\006\n" + + "\004mode2\341\r\n" + + "\tDatastore\022\300\001\n" + + "\006Lookup\022\".google.datastore.v1.LookupRequest\032#.google.datastore.v1.Looku" + + "pResponse\"m\332A\034project_id,read_options,keys\202\323\344\223\002%\"" + + " /v1/projects/{project_id}:lookup:\001*\212\323\344\223\002\035\022\014\n\n" + + "project_id\022\r\n" + + "\013database_id\022\251\001\n" + + "\010RunQuery\022$.google.datastore.v1.RunQueryRequest\032%.google.datastore.v1.RunQue" + + "ryResponse\"P\202\323\344\223\002\'\"\"/v1/projects/{project_id}:runQuery:\001*\212\323\344\223\002\035\022\014\n\n" + + "project_id\022\r\n" + + "\013database_id\022\325\001\n" + + "\023RunAggregationQuery\022/.google.datastore.v1.RunAggregationQueryRe" + + "quest\0320.google.datastore.v1.RunAggregati" + + "onQueryResponse\"[\202\323\344\223\0022\"-/v1/projects/{p" + + "roject_id}:runAggregationQuery:\001*\212\323\344\223\002\035\022\014\n\n" + + "project_id\022\r\n" + + "\013database_id\022\326\001\n" + + "\020BeginTransaction\022,.google.datastore.v1.BeginTra" + + "nsactionRequest\032-.google.datastore.v1.BeginTransactionResponse\"e\332A\n" + + "project_id\202\323\344" + + "\223\002/\"*/v1/projects/{project_id}:beginTransaction:\001*\212\323\344\223\002\035\022\014\n\n" + + "project_id\022\r\n" + + "\013database_id\022\346\001\n" + + "\006Commit\022\".google.datastore.v1.CommitRequest\032#.google.datastore.v1.Commi" + + "tResponse\"\222\001\332A%project_id,mode,transacti" + + "on,mutations\332A\031project_id,mode,mutations\202\323\344\223\002%\"" + + " /v1/projects/{project_id}:commit:\001*\212\323\344\223\002\035\022\014\n\n" + + "project_id\022\r\n" + + "\013database_id\022\302\001\n" + + "\010Rollback\022$.google.datastore.v1.Rollba" + + "ckRequest\032%.google.datastore.v1.Rollback" + + "Response\"i\332A\026project_id,transaction\202\323\344\223\002" + + "\'\"\"/v1/projects/{project_id}:rollback:\001*\212\323\344\223\002\035\022\014\n\n" + + "project_id\022\r\n" + + "\013database_id\022\307\001\n" + + "\013AllocateIds\022\'.google.datastore.v1.Alloca" + + "teIdsRequest\032(.google.datastore.v1.Alloc" + + "ateIdsResponse\"e\332A\017project_id,keys\202\323\344\223\002*" + + "\"%/v1/projects/{project_id}:allocateIds:\001*\212\323\344\223\002\035\022\014\n\n" + + "project_id\022\r\n" + + "\013database_id\022\303\001\n\n" + + "ReserveIds\022&.google.datastore.v1.ReserveIdsRequest\032\'.google.datastore.v1.Reser" + + "veIdsResponse\"d\332A\017project_id,keys\202\323\344\223\002)\"" + + "$/v1/projects/{project_id}:reserveIds:\001*\212\323\344\223\002\035\022\014\n\n" + + "project_id\022\r\n" + + "\013database_id\032v\312A\030datastore.googleapis.com\322AXhttps://www.g" + + "oogleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/datastoreB\277\001\n" + + "\027com.google.datastore.v1B\016DatastoreProtoP" + + "\001Z;cloud.google.com/go/datastore/apiv1/d" + + "atastorepb;datastorepb\252\002\031Google.Cloud.Da" + + "tastore.V1\312\002\031Google\\Cloud\\Datastore\\V1\352\002" + + "\034Google::Cloud::Datastore::V1b\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.RoutingProto.getDescriptor(), + com.google.datastore.v1.AggregationResultProto.getDescriptor(), + com.google.datastore.v1.EntityProto.getDescriptor(), + com.google.datastore.v1.QueryProto.getDescriptor(), + com.google.datastore.v1.QueryProfileProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + }); + internal_static_google_datastore_v1_LookupRequest_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_datastore_v1_LookupRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_LookupRequest_descriptor, + new java.lang.String[] { + "ProjectId", "DatabaseId", "ReadOptions", "Keys", "PropertyMask", + }); + internal_static_google_datastore_v1_LookupResponse_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_datastore_v1_LookupResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_LookupResponse_descriptor, + new java.lang.String[] { + "Found", "Missing", "Deferred", "Transaction", "ReadTime", + }); + internal_static_google_datastore_v1_RunQueryRequest_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_datastore_v1_RunQueryRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_RunQueryRequest_descriptor, + new java.lang.String[] { + "ProjectId", + "DatabaseId", + "PartitionId", + "ReadOptions", + "Query", + "GqlQuery", + "PropertyMask", + "ExplainOptions", + "QueryType", + }); + internal_static_google_datastore_v1_RunQueryResponse_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_datastore_v1_RunQueryResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_RunQueryResponse_descriptor, + new java.lang.String[] { + "Batch", "Query", "Transaction", "ExplainMetrics", + }); + internal_static_google_datastore_v1_RunAggregationQueryRequest_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_datastore_v1_RunAggregationQueryRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_RunAggregationQueryRequest_descriptor, + new java.lang.String[] { + "ProjectId", + "DatabaseId", + "PartitionId", + "ReadOptions", + "AggregationQuery", + "GqlQuery", + "ExplainOptions", + "QueryType", + }); + internal_static_google_datastore_v1_RunAggregationQueryResponse_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_datastore_v1_RunAggregationQueryResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_RunAggregationQueryResponse_descriptor, + new java.lang.String[] { + "Batch", "Query", "Transaction", "ExplainMetrics", + }); + internal_static_google_datastore_v1_BeginTransactionRequest_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_google_datastore_v1_BeginTransactionRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_BeginTransactionRequest_descriptor, + new java.lang.String[] { + "ProjectId", "DatabaseId", "TransactionOptions", + }); + internal_static_google_datastore_v1_BeginTransactionResponse_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_google_datastore_v1_BeginTransactionResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_BeginTransactionResponse_descriptor, + new java.lang.String[] { + "Transaction", + }); + internal_static_google_datastore_v1_RollbackRequest_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_google_datastore_v1_RollbackRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_RollbackRequest_descriptor, + new java.lang.String[] { + "ProjectId", "DatabaseId", "Transaction", + }); + internal_static_google_datastore_v1_RollbackResponse_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_google_datastore_v1_RollbackResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_RollbackResponse_descriptor, + new java.lang.String[] {}); + internal_static_google_datastore_v1_CommitRequest_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_google_datastore_v1_CommitRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_CommitRequest_descriptor, + new java.lang.String[] { + "ProjectId", + "DatabaseId", + "Mode", + "Transaction", + "SingleUseTransaction", + "Mutations", + "TransactionSelector", + }); + internal_static_google_datastore_v1_CommitResponse_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_google_datastore_v1_CommitResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_CommitResponse_descriptor, + new java.lang.String[] { + "MutationResults", "IndexUpdates", "CommitTime", + }); + internal_static_google_datastore_v1_AllocateIdsRequest_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_google_datastore_v1_AllocateIdsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_AllocateIdsRequest_descriptor, + new java.lang.String[] { + "ProjectId", "DatabaseId", "Keys", + }); + internal_static_google_datastore_v1_AllocateIdsResponse_descriptor = + getDescriptor().getMessageTypes().get(13); + internal_static_google_datastore_v1_AllocateIdsResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_AllocateIdsResponse_descriptor, + new java.lang.String[] { + "Keys", + }); + internal_static_google_datastore_v1_ReserveIdsRequest_descriptor = + getDescriptor().getMessageTypes().get(14); + internal_static_google_datastore_v1_ReserveIdsRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_ReserveIdsRequest_descriptor, + new java.lang.String[] { + "ProjectId", "DatabaseId", "Keys", + }); + internal_static_google_datastore_v1_ReserveIdsResponse_descriptor = + getDescriptor().getMessageTypes().get(15); + internal_static_google_datastore_v1_ReserveIdsResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_ReserveIdsResponse_descriptor, + new java.lang.String[] {}); + internal_static_google_datastore_v1_Mutation_descriptor = + getDescriptor().getMessageTypes().get(16); + internal_static_google_datastore_v1_Mutation_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_Mutation_descriptor, + new java.lang.String[] { + "Insert", + "Update", + "Upsert", + "Delete", + "BaseVersion", + "UpdateTime", + "ConflictResolutionStrategy", + "PropertyMask", + "PropertyTransforms", + "Operation", + "ConflictDetectionStrategy", + }); + internal_static_google_datastore_v1_PropertyTransform_descriptor = + getDescriptor().getMessageTypes().get(17); + internal_static_google_datastore_v1_PropertyTransform_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_PropertyTransform_descriptor, + new java.lang.String[] { + "Property", + "SetToServerValue", + "Increment", + "Maximum", + "Minimum", + "AppendMissingElements", + "RemoveAllFromArray", + "TransformType", + }); + internal_static_google_datastore_v1_MutationResult_descriptor = + getDescriptor().getMessageTypes().get(18); + internal_static_google_datastore_v1_MutationResult_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_MutationResult_descriptor, + new java.lang.String[] { + "Key", "Version", "CreateTime", "UpdateTime", "ConflictDetected", "TransformResults", + }); + internal_static_google_datastore_v1_PropertyMask_descriptor = + getDescriptor().getMessageTypes().get(19); + internal_static_google_datastore_v1_PropertyMask_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_PropertyMask_descriptor, + new java.lang.String[] { + "Paths", + }); + internal_static_google_datastore_v1_ReadOptions_descriptor = + getDescriptor().getMessageTypes().get(20); + internal_static_google_datastore_v1_ReadOptions_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_ReadOptions_descriptor, + new java.lang.String[] { + "ReadConsistency", "Transaction", "NewTransaction", "ReadTime", "ConsistencyType", + }); + internal_static_google_datastore_v1_TransactionOptions_descriptor = + getDescriptor().getMessageTypes().get(21); + internal_static_google_datastore_v1_TransactionOptions_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_TransactionOptions_descriptor, + new java.lang.String[] { + "ReadWrite", "ReadOnly", "Mode", + }); + internal_static_google_datastore_v1_TransactionOptions_ReadWrite_descriptor = + internal_static_google_datastore_v1_TransactionOptions_descriptor.getNestedTypes().get(0); + internal_static_google_datastore_v1_TransactionOptions_ReadWrite_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_TransactionOptions_ReadWrite_descriptor, + new java.lang.String[] { + "PreviousTransaction", + }); + internal_static_google_datastore_v1_TransactionOptions_ReadOnly_descriptor = + internal_static_google_datastore_v1_TransactionOptions_descriptor.getNestedTypes().get(1); + internal_static_google_datastore_v1_TransactionOptions_ReadOnly_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_TransactionOptions_ReadOnly_descriptor, + new java.lang.String[] { + "ReadTime", + }); + 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.RoutingProto.routing); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.AnnotationsProto.getDescriptor(); + com.google.api.ClientProto.getDescriptor(); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.RoutingProto.getDescriptor(); + com.google.datastore.v1.AggregationResultProto.getDescriptor(); + com.google.datastore.v1.EntityProto.getDescriptor(); + com.google.datastore.v1.QueryProto.getDescriptor(); + com.google.datastore.v1.QueryProfileProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Entity.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Entity.java new file mode 100644 index 000000000000..b539dc621918 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Entity.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! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A Datastore data object.
+ *
+ * Must not exceed 1 MiB - 4 bytes.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.Entity} + */ +public final class Entity extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.Entity) + EntityOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Entity.newBuilder() to construct. + private Entity(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Entity() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Entity(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Entity_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetProperties(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Entity_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Entity.class, com.google.datastore.v1.Entity.Builder.class); + } + + private int bitField0_; + public static final int KEY_FIELD_NUMBER = 1; + private com.google.datastore.v1.Key key_; + + /** + * + * + *
+   * The entity's key.
+   *
+   * An entity must have a key, unless otherwise documented (for example,
+   * an entity in `Value.entity_value` may have no key).
+   * An entity's kind is its key path's last element's kind,
+   * or null if it has no key.
+   * 
+ * + * .google.datastore.v1.Key key = 1; + * + * @return Whether the key field is set. + */ + @java.lang.Override + public boolean hasKey() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The entity's key.
+   *
+   * An entity must have a key, unless otherwise documented (for example,
+   * an entity in `Value.entity_value` may have no key).
+   * An entity's kind is its key path's last element's kind,
+   * or null if it has no key.
+   * 
+ * + * .google.datastore.v1.Key key = 1; + * + * @return The key. + */ + @java.lang.Override + public com.google.datastore.v1.Key getKey() { + return key_ == null ? com.google.datastore.v1.Key.getDefaultInstance() : key_; + } + + /** + * + * + *
+   * The entity's key.
+   *
+   * An entity must have a key, unless otherwise documented (for example,
+   * an entity in `Value.entity_value` may have no key).
+   * An entity's kind is its key path's last element's kind,
+   * or null if it has no key.
+   * 
+ * + * .google.datastore.v1.Key key = 1; + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getKeyOrBuilder() { + return key_ == null ? com.google.datastore.v1.Key.getDefaultInstance() : key_; + } + + public static final int PROPERTIES_FIELD_NUMBER = 3; + + private static final class PropertiesDefaultEntryHolder { + static final com.google.protobuf.MapEntry + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Entity_PropertiesEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.datastore.v1.Value.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField properties_; + + private com.google.protobuf.MapField + internalGetProperties() { + if (properties_ == null) { + return com.google.protobuf.MapField.emptyMapField(PropertiesDefaultEntryHolder.defaultEntry); + } + return properties_; + } + + public int getPropertiesCount() { + return internalGetProperties().getMap().size(); + } + + /** + * + * + *
+   * The entity's properties.
+   * The map's keys are property names.
+   * A property name matching regex `__.*__` is reserved.
+   * A reserved property name is forbidden in certain documented contexts.
+   * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+   * be empty.
+   * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + @java.lang.Override + public boolean containsProperties(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetProperties().getMap().containsKey(key); + } + + /** Use {@link #getPropertiesMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getProperties() { + return getPropertiesMap(); + } + + /** + * + * + *
+   * The entity's properties.
+   * The map's keys are property names.
+   * A property name matching regex `__.*__` is reserved.
+   * A reserved property name is forbidden in certain documented contexts.
+   * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+   * be empty.
+   * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + @java.lang.Override + public java.util.Map getPropertiesMap() { + return internalGetProperties().getMap(); + } + + /** + * + * + *
+   * The entity's properties.
+   * The map's keys are property names.
+   * A property name matching regex `__.*__` is reserved.
+   * A reserved property name is forbidden in certain documented contexts.
+   * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+   * be empty.
+   * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + @java.lang.Override + public /* nullable */ com.google.datastore.v1.Value getPropertiesOrDefault( + java.lang.String key, + /* nullable */ + com.google.datastore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetProperties().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * The entity's properties.
+   * The map's keys are property names.
+   * A property name matching regex `__.*__` is reserved.
+   * A reserved property name is forbidden in certain documented contexts.
+   * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+   * be empty.
+   * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + @java.lang.Override + public com.google.datastore.v1.Value getPropertiesOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetProperties().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, getKey()); + } + com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( + output, internalGetProperties(), PropertiesDefaultEntryHolder.defaultEntry, 3); + 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, getKey()); + } + for (java.util.Map.Entry entry : + internalGetProperties().getMap().entrySet()) { + com.google.protobuf.MapEntry properties__ = + PropertiesDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, properties__); + } + 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.datastore.v1.Entity)) { + return super.equals(obj); + } + com.google.datastore.v1.Entity other = (com.google.datastore.v1.Entity) obj; + + if (hasKey() != other.hasKey()) return false; + if (hasKey()) { + if (!getKey().equals(other.getKey())) return false; + } + if (!internalGetProperties().equals(other.internalGetProperties())) 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 (hasKey()) { + hash = (37 * hash) + KEY_FIELD_NUMBER; + hash = (53 * hash) + getKey().hashCode(); + } + if (!internalGetProperties().getMap().isEmpty()) { + hash = (37 * hash) + PROPERTIES_FIELD_NUMBER; + hash = (53 * hash) + internalGetProperties().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.Entity parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Entity parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Entity parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Entity 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.datastore.v1.Entity parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Entity parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Entity parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Entity parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Entity parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Entity parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Entity parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Entity parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.Entity 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A Datastore data object.
+   *
+   * Must not exceed 1 MiB - 4 bytes.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.Entity} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.Entity) + com.google.datastore.v1.EntityOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Entity_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetProperties(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 3: + return internalGetMutableProperties(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Entity_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Entity.class, com.google.datastore.v1.Entity.Builder.class); + } + + // Construct using com.google.datastore.v1.Entity.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getKeyFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + key_ = null; + if (keyBuilder_ != null) { + keyBuilder_.dispose(); + keyBuilder_ = null; + } + internalGetMutableProperties().clear(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Entity_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.Entity getDefaultInstanceForType() { + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.Entity build() { + com.google.datastore.v1.Entity result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.Entity buildPartial() { + com.google.datastore.v1.Entity result = new com.google.datastore.v1.Entity(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.Entity result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.key_ = keyBuilder_ == null ? key_ : keyBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.properties_ = + internalGetProperties().build(PropertiesDefaultEntryHolder.defaultEntry); + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.Entity) { + return mergeFrom((com.google.datastore.v1.Entity) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.Entity other) { + if (other == com.google.datastore.v1.Entity.getDefaultInstance()) return this; + if (other.hasKey()) { + mergeKey(other.getKey()); + } + internalGetMutableProperties().mergeFrom(other.internalGetProperties()); + 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(getKeyFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + com.google.protobuf.MapEntry + properties__ = + input.readMessage( + PropertiesDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableProperties() + .ensureBuilderMap() + .put(properties__.getKey(), properties__.getValue()); + 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 com.google.datastore.v1.Key key_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + keyBuilder_; + + /** + * + * + *
+     * The entity's key.
+     *
+     * An entity must have a key, unless otherwise documented (for example,
+     * an entity in `Value.entity_value` may have no key).
+     * An entity's kind is its key path's last element's kind,
+     * or null if it has no key.
+     * 
+ * + * .google.datastore.v1.Key key = 1; + * + * @return Whether the key field is set. + */ + public boolean hasKey() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The entity's key.
+     *
+     * An entity must have a key, unless otherwise documented (for example,
+     * an entity in `Value.entity_value` may have no key).
+     * An entity's kind is its key path's last element's kind,
+     * or null if it has no key.
+     * 
+ * + * .google.datastore.v1.Key key = 1; + * + * @return The key. + */ + public com.google.datastore.v1.Key getKey() { + if (keyBuilder_ == null) { + return key_ == null ? com.google.datastore.v1.Key.getDefaultInstance() : key_; + } else { + return keyBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The entity's key.
+     *
+     * An entity must have a key, unless otherwise documented (for example,
+     * an entity in `Value.entity_value` may have no key).
+     * An entity's kind is its key path's last element's kind,
+     * or null if it has no key.
+     * 
+ * + * .google.datastore.v1.Key key = 1; + */ + public Builder setKey(com.google.datastore.v1.Key value) { + if (keyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + key_ = value; + } else { + keyBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The entity's key.
+     *
+     * An entity must have a key, unless otherwise documented (for example,
+     * an entity in `Value.entity_value` may have no key).
+     * An entity's kind is its key path's last element's kind,
+     * or null if it has no key.
+     * 
+ * + * .google.datastore.v1.Key key = 1; + */ + public Builder setKey(com.google.datastore.v1.Key.Builder builderForValue) { + if (keyBuilder_ == null) { + key_ = builderForValue.build(); + } else { + keyBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The entity's key.
+     *
+     * An entity must have a key, unless otherwise documented (for example,
+     * an entity in `Value.entity_value` may have no key).
+     * An entity's kind is its key path's last element's kind,
+     * or null if it has no key.
+     * 
+ * + * .google.datastore.v1.Key key = 1; + */ + public Builder mergeKey(com.google.datastore.v1.Key value) { + if (keyBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && key_ != null + && key_ != com.google.datastore.v1.Key.getDefaultInstance()) { + getKeyBuilder().mergeFrom(value); + } else { + key_ = value; + } + } else { + keyBuilder_.mergeFrom(value); + } + if (key_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The entity's key.
+     *
+     * An entity must have a key, unless otherwise documented (for example,
+     * an entity in `Value.entity_value` may have no key).
+     * An entity's kind is its key path's last element's kind,
+     * or null if it has no key.
+     * 
+ * + * .google.datastore.v1.Key key = 1; + */ + public Builder clearKey() { + bitField0_ = (bitField0_ & ~0x00000001); + key_ = null; + if (keyBuilder_ != null) { + keyBuilder_.dispose(); + keyBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The entity's key.
+     *
+     * An entity must have a key, unless otherwise documented (for example,
+     * an entity in `Value.entity_value` may have no key).
+     * An entity's kind is its key path's last element's kind,
+     * or null if it has no key.
+     * 
+ * + * .google.datastore.v1.Key key = 1; + */ + public com.google.datastore.v1.Key.Builder getKeyBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getKeyFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The entity's key.
+     *
+     * An entity must have a key, unless otherwise documented (for example,
+     * an entity in `Value.entity_value` may have no key).
+     * An entity's kind is its key path's last element's kind,
+     * or null if it has no key.
+     * 
+ * + * .google.datastore.v1.Key key = 1; + */ + public com.google.datastore.v1.KeyOrBuilder getKeyOrBuilder() { + if (keyBuilder_ != null) { + return keyBuilder_.getMessageOrBuilder(); + } else { + return key_ == null ? com.google.datastore.v1.Key.getDefaultInstance() : key_; + } + } + + /** + * + * + *
+     * The entity's key.
+     *
+     * An entity must have a key, unless otherwise documented (for example,
+     * an entity in `Value.entity_value` may have no key).
+     * An entity's kind is its key path's last element's kind,
+     * or null if it has no key.
+     * 
+ * + * .google.datastore.v1.Key key = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + getKeyFieldBuilder() { + if (keyBuilder_ == null) { + keyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder>(getKey(), getParentForChildren(), isClean()); + key_ = null; + } + return keyBuilder_; + } + + private static final class PropertiesConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.datastore.v1.ValueOrBuilder, + com.google.datastore.v1.Value> { + @java.lang.Override + public com.google.datastore.v1.Value build(com.google.datastore.v1.ValueOrBuilder val) { + if (val instanceof com.google.datastore.v1.Value) { + return (com.google.datastore.v1.Value) val; + } + return ((com.google.datastore.v1.Value.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry + defaultEntry() { + return PropertiesDefaultEntryHolder.defaultEntry; + } + } + ; + + private static final PropertiesConverter propertiesConverter = new PropertiesConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.datastore.v1.ValueOrBuilder, + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder> + properties_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.datastore.v1.ValueOrBuilder, + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder> + internalGetProperties() { + if (properties_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(propertiesConverter); + } + return properties_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.datastore.v1.ValueOrBuilder, + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder> + internalGetMutableProperties() { + if (properties_ == null) { + properties_ = new com.google.protobuf.MapFieldBuilder<>(propertiesConverter); + } + bitField0_ |= 0x00000002; + onChanged(); + return properties_; + } + + public int getPropertiesCount() { + return internalGetProperties().ensureBuilderMap().size(); + } + + /** + * + * + *
+     * The entity's properties.
+     * The map's keys are property names.
+     * A property name matching regex `__.*__` is reserved.
+     * A reserved property name is forbidden in certain documented contexts.
+     * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+     * be empty.
+     * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + @java.lang.Override + public boolean containsProperties(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetProperties().ensureBuilderMap().containsKey(key); + } + + /** Use {@link #getPropertiesMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map getProperties() { + return getPropertiesMap(); + } + + /** + * + * + *
+     * The entity's properties.
+     * The map's keys are property names.
+     * A property name matching regex `__.*__` is reserved.
+     * A reserved property name is forbidden in certain documented contexts.
+     * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+     * be empty.
+     * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + @java.lang.Override + public java.util.Map getPropertiesMap() { + return internalGetProperties().getImmutableMap(); + } + + /** + * + * + *
+     * The entity's properties.
+     * The map's keys are property names.
+     * A property name matching regex `__.*__` is reserved.
+     * A reserved property name is forbidden in certain documented contexts.
+     * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+     * be empty.
+     * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + @java.lang.Override + public /* nullable */ com.google.datastore.v1.Value getPropertiesOrDefault( + java.lang.String key, + /* nullable */ + com.google.datastore.v1.Value defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableProperties().ensureBuilderMap(); + return map.containsKey(key) ? propertiesConverter.build(map.get(key)) : defaultValue; + } + + /** + * + * + *
+     * The entity's properties.
+     * The map's keys are property names.
+     * A property name matching regex `__.*__` is reserved.
+     * A reserved property name is forbidden in certain documented contexts.
+     * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+     * be empty.
+     * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + @java.lang.Override + public com.google.datastore.v1.Value getPropertiesOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableProperties().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return propertiesConverter.build(map.get(key)); + } + + public Builder clearProperties() { + bitField0_ = (bitField0_ & ~0x00000002); + internalGetMutableProperties().clear(); + return this; + } + + /** + * + * + *
+     * The entity's properties.
+     * The map's keys are property names.
+     * A property name matching regex `__.*__` is reserved.
+     * A reserved property name is forbidden in certain documented contexts.
+     * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+     * be empty.
+     * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + public Builder removeProperties(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableProperties().ensureBuilderMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map getMutableProperties() { + bitField0_ |= 0x00000002; + return internalGetMutableProperties().ensureMessageMap(); + } + + /** + * + * + *
+     * The entity's properties.
+     * The map's keys are property names.
+     * A property name matching regex `__.*__` is reserved.
+     * A reserved property name is forbidden in certain documented contexts.
+     * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+     * be empty.
+     * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + public Builder putProperties(java.lang.String key, com.google.datastore.v1.Value value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableProperties().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000002; + return this; + } + + /** + * + * + *
+     * The entity's properties.
+     * The map's keys are property names.
+     * A property name matching regex `__.*__` is reserved.
+     * A reserved property name is forbidden in certain documented contexts.
+     * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+     * be empty.
+     * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + public Builder putAllProperties( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableProperties().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000002; + return this; + } + + /** + * + * + *
+     * The entity's properties.
+     * The map's keys are property names.
+     * A property name matching regex `__.*__` is reserved.
+     * A reserved property name is forbidden in certain documented contexts.
+     * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+     * be empty.
+     * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + public com.google.datastore.v1.Value.Builder putPropertiesBuilderIfAbsent( + java.lang.String key) { + java.util.Map builderMap = + internalGetMutableProperties().ensureBuilderMap(); + com.google.datastore.v1.ValueOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.datastore.v1.Value.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.datastore.v1.Value) { + entry = ((com.google.datastore.v1.Value) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.datastore.v1.Value.Builder) entry; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.Entity) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.Entity) + private static final com.google.datastore.v1.Entity DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.Entity(); + } + + public static com.google.datastore.v1.Entity getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Entity 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.datastore.v1.Entity getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityOrBuilder.java new file mode 100644 index 000000000000..b6d546e2fa3f --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityOrBuilder.java @@ -0,0 +1,166 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface EntityOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.Entity) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The entity's key.
+   *
+   * An entity must have a key, unless otherwise documented (for example,
+   * an entity in `Value.entity_value` may have no key).
+   * An entity's kind is its key path's last element's kind,
+   * or null if it has no key.
+   * 
+ * + * .google.datastore.v1.Key key = 1; + * + * @return Whether the key field is set. + */ + boolean hasKey(); + + /** + * + * + *
+   * The entity's key.
+   *
+   * An entity must have a key, unless otherwise documented (for example,
+   * an entity in `Value.entity_value` may have no key).
+   * An entity's kind is its key path's last element's kind,
+   * or null if it has no key.
+   * 
+ * + * .google.datastore.v1.Key key = 1; + * + * @return The key. + */ + com.google.datastore.v1.Key getKey(); + + /** + * + * + *
+   * The entity's key.
+   *
+   * An entity must have a key, unless otherwise documented (for example,
+   * an entity in `Value.entity_value` may have no key).
+   * An entity's kind is its key path's last element's kind,
+   * or null if it has no key.
+   * 
+ * + * .google.datastore.v1.Key key = 1; + */ + com.google.datastore.v1.KeyOrBuilder getKeyOrBuilder(); + + /** + * + * + *
+   * The entity's properties.
+   * The map's keys are property names.
+   * A property name matching regex `__.*__` is reserved.
+   * A reserved property name is forbidden in certain documented contexts.
+   * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+   * be empty.
+   * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + int getPropertiesCount(); + + /** + * + * + *
+   * The entity's properties.
+   * The map's keys are property names.
+   * A property name matching regex `__.*__` is reserved.
+   * A reserved property name is forbidden in certain documented contexts.
+   * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+   * be empty.
+   * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + boolean containsProperties(java.lang.String key); + + /** Use {@link #getPropertiesMap()} instead. */ + @java.lang.Deprecated + java.util.Map getProperties(); + + /** + * + * + *
+   * The entity's properties.
+   * The map's keys are property names.
+   * A property name matching regex `__.*__` is reserved.
+   * A reserved property name is forbidden in certain documented contexts.
+   * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+   * be empty.
+   * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + java.util.Map getPropertiesMap(); + + /** + * + * + *
+   * The entity's properties.
+   * The map's keys are property names.
+   * A property name matching regex `__.*__` is reserved.
+   * A reserved property name is forbidden in certain documented contexts.
+   * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+   * be empty.
+   * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + /* nullable */ + com.google.datastore.v1.Value getPropertiesOrDefault( + java.lang.String key, + /* nullable */ + com.google.datastore.v1.Value defaultValue); + + /** + * + * + *
+   * The entity's properties.
+   * The map's keys are property names.
+   * A property name matching regex `__.*__` is reserved.
+   * A reserved property name is forbidden in certain documented contexts.
+   * The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot
+   * be empty.
+   * 
+ * + * map<string, .google.datastore.v1.Value> properties = 3; + */ + com.google.datastore.v1.Value getPropertiesOrThrow(java.lang.String key); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityProto.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityProto.java new file mode 100644 index 000000000000..adcd56c78745 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityProto.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! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public final class EntityProto { + private EntityProto() {} + + 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_datastore_v1_PartitionId_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_PartitionId_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_Key_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_Key_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_Key_PathElement_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_Key_PathElement_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_ArrayValue_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_ArrayValue_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_Value_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_Value_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_Entity_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_Entity_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_Entity_PropertiesEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_Entity_PropertiesEntry_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/datastore/v1/entity.proto\022\023goog" + + "le.datastore.v1\032\034google/protobuf/struct." + + "proto\032\037google/protobuf/timestamp.proto\032\030google/type/latlng.proto\"L\n" + + "\013PartitionId\022\022\n\n" + + "project_id\030\002 \001(\t\022\023\n" + + "\013database_id\030\003 \001(\t\022\024\n" + + "\014namespace_id\030\004 \001(\t\"\267\001\n" + + "\003Key\0226\n" + + "\014partition_id\030\001 \001(\0132 .google.datastore.v1.PartitionId\0222\n" + + "\004path\030\002 \003(\0132$.google.datastore.v1.Key.PathElement\032D\n" + + "\013PathElement\022\014\n" + + "\004kind\030\001 \001(\t\022\014\n" + + "\002id\030\002 \001(\003H\000\022\016\n" + + "\004name\030\003 \001(\tH\000B\t\n" + + "\007id_type\"8\n\n" + + "ArrayValue\022*\n" + + "\006values\030\001 \003(\0132\032.google.datastore.v1.Value\"\361\003\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-\n" + + "\tkey_value\030\005 \001(\0132\030.google.datastore.v1.KeyH\000\022\026\n" + + "\014string_value\030\021 \001(\tH\000\022\024\n\n" + + "blob_value\030\022 \001(\014H\000\022.\n" + + "\017geo_point_value\030\010 \001(\0132\023.google.type.LatLngH\000\0223\n" + + "\014entity_value\030\006 \001(\0132\033.google.datastore.v1.EntityH\000\0226\n" + + "\013array_value\030\t \001(\0132\037.google.datastore.v1.ArrayValueH\000\022\017\n" + + "\007meaning\030\016 \001(\005\022\034\n" + + "\024exclude_from_indexes\030\023 \001(\010B\014\n\n" + + "value_type\"\277\001\n" + + "\006Entity\022%\n" + + "\003key\030\001 \001(\0132\030.google.datastore.v1.Key\022?\n\n" + + "properties\030\003 \003(\0132+.google.datastore.v1.Entity.PropertiesEntry\032M\n" + + "\017PropertiesEntry\022\013\n" + + "\003key\030\001 \001(\t\022)\n" + + "\005value\030\002 \001(\0132\032.google.datastore.v1.Value:\0028\001B\274\001\n" + + "\027com.google.datastore.v1B\013EntityProtoP\001Z;cloud.google.com/go/datastore/apiv1" + + "/datastorepb;datastorepb\252\002\031Google.Cloud." + + "Datastore.V1\312\002\031Google\\Cloud\\Datastore\\V1" + + "\352\002\034Google::Cloud::Datastore::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.protobuf.StructProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + com.google.type.LatLngProto.getDescriptor(), + }); + internal_static_google_datastore_v1_PartitionId_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_datastore_v1_PartitionId_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_PartitionId_descriptor, + new java.lang.String[] { + "ProjectId", "DatabaseId", "NamespaceId", + }); + internal_static_google_datastore_v1_Key_descriptor = getDescriptor().getMessageTypes().get(1); + internal_static_google_datastore_v1_Key_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_Key_descriptor, + new java.lang.String[] { + "PartitionId", "Path", + }); + internal_static_google_datastore_v1_Key_PathElement_descriptor = + internal_static_google_datastore_v1_Key_descriptor.getNestedTypes().get(0); + internal_static_google_datastore_v1_Key_PathElement_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_Key_PathElement_descriptor, + new java.lang.String[] { + "Kind", "Id", "Name", "IdType", + }); + internal_static_google_datastore_v1_ArrayValue_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_datastore_v1_ArrayValue_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_ArrayValue_descriptor, + new java.lang.String[] { + "Values", + }); + internal_static_google_datastore_v1_Value_descriptor = getDescriptor().getMessageTypes().get(3); + internal_static_google_datastore_v1_Value_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_Value_descriptor, + new java.lang.String[] { + "NullValue", + "BooleanValue", + "IntegerValue", + "DoubleValue", + "TimestampValue", + "KeyValue", + "StringValue", + "BlobValue", + "GeoPointValue", + "EntityValue", + "ArrayValue", + "Meaning", + "ExcludeFromIndexes", + "ValueType", + }); + internal_static_google_datastore_v1_Entity_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_datastore_v1_Entity_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_Entity_descriptor, + new java.lang.String[] { + "Key", "Properties", + }); + internal_static_google_datastore_v1_Entity_PropertiesEntry_descriptor = + internal_static_google_datastore_v1_Entity_descriptor.getNestedTypes().get(0); + internal_static_google_datastore_v1_Entity_PropertiesEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_Entity_PropertiesEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + com.google.protobuf.StructProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.type.LatLngProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityResult.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityResult.java new file mode 100644 index 000000000000..22432f8ff3fb --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityResult.java @@ -0,0 +1,1767 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The result of fetching an entity from Datastore.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.EntityResult} + */ +public final class EntityResult extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.EntityResult) + EntityResultOrBuilder { + private static final long serialVersionUID = 0L; + + // Use EntityResult.newBuilder() to construct. + private EntityResult(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private EntityResult() { + cursor_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new EntityResult(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_EntityResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_EntityResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.EntityResult.class, + com.google.datastore.v1.EntityResult.Builder.class); + } + + /** + * + * + *
+   * Specifies what data the 'entity' field contains.
+   * A `ResultType` is either implied (for example, in `LookupResponse.missing`
+   * from `datastore.proto`, it is always `KEY_ONLY`) or specified by context
+   * (for example, in message `QueryResultBatch`, field `entity_result_type`
+   * specifies a `ResultType` for all the values in field `entity_results`).
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.EntityResult.ResultType} + */ + public enum ResultType implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. This value is never used.
+     * 
+ * + * RESULT_TYPE_UNSPECIFIED = 0; + */ + RESULT_TYPE_UNSPECIFIED(0), + /** + * + * + *
+     * The key and properties.
+     * 
+ * + * FULL = 1; + */ + FULL(1), + /** + * + * + *
+     * A projected subset of properties. The entity may have no key.
+     * 
+ * + * PROJECTION = 2; + */ + PROJECTION(2), + /** + * + * + *
+     * Only the key.
+     * 
+ * + * KEY_ONLY = 3; + */ + KEY_ONLY(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified. This value is never used.
+     * 
+ * + * RESULT_TYPE_UNSPECIFIED = 0; + */ + public static final int RESULT_TYPE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * The key and properties.
+     * 
+ * + * FULL = 1; + */ + public static final int FULL_VALUE = 1; + + /** + * + * + *
+     * A projected subset of properties. The entity may have no key.
+     * 
+ * + * PROJECTION = 2; + */ + public static final int PROJECTION_VALUE = 2; + + /** + * + * + *
+     * Only the key.
+     * 
+ * + * KEY_ONLY = 3; + */ + public static final int KEY_ONLY_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 ResultType 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 ResultType forNumber(int value) { + switch (value) { + case 0: + return RESULT_TYPE_UNSPECIFIED; + case 1: + return FULL; + case 2: + return PROJECTION; + case 3: + return KEY_ONLY; + 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 ResultType findValueByNumber(int number) { + return ResultType.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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.EntityResult.getDescriptor().getEnumTypes().get(0); + } + + private static final ResultType[] VALUES = values(); + + public static ResultType 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 ResultType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.v1.EntityResult.ResultType) + } + + private int bitField0_; + public static final int ENTITY_FIELD_NUMBER = 1; + private com.google.datastore.v1.Entity entity_; + + /** + * + * + *
+   * The resulting entity.
+   * 
+ * + * .google.datastore.v1.Entity entity = 1; + * + * @return Whether the entity field is set. + */ + @java.lang.Override + public boolean hasEntity() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The resulting entity.
+   * 
+ * + * .google.datastore.v1.Entity entity = 1; + * + * @return The entity. + */ + @java.lang.Override + public com.google.datastore.v1.Entity getEntity() { + return entity_ == null ? com.google.datastore.v1.Entity.getDefaultInstance() : entity_; + } + + /** + * + * + *
+   * The resulting entity.
+   * 
+ * + * .google.datastore.v1.Entity entity = 1; + */ + @java.lang.Override + public com.google.datastore.v1.EntityOrBuilder getEntityOrBuilder() { + return entity_ == null ? com.google.datastore.v1.Entity.getDefaultInstance() : entity_; + } + + public static final int VERSION_FIELD_NUMBER = 4; + private long version_ = 0L; + + /** + * + * + *
+   * The version of the entity, a strictly positive number that monotonically
+   * increases with changes to the entity.
+   *
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   *
+   * For [missing][google.datastore.v1.LookupResponse.missing] entities in
+   * `LookupResponse`, this is the version of the snapshot that was used to look
+   * up the entity, and it is always set except for eventually consistent reads.
+   * 
+ * + * int64 version = 4; + * + * @return The version. + */ + @java.lang.Override + public long getVersion() { + return version_; + } + + public static final int CREATE_TIME_FIELD_NUMBER = 6; + private com.google.protobuf.Timestamp createTime_; + + /** + * + * + *
+   * The time at which the entity was created.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 6; + * + * @return Whether the createTime field is set. + */ + @java.lang.Override + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The time at which the entity was created.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 6; + * + * @return The createTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCreateTime() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + /** + * + * + *
+   * The time at which the entity was created.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 6; + */ + @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 = 5; + private com.google.protobuf.Timestamp updateTime_; + + /** + * + * + *
+   * The time at which the entity was last changed.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 5; + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * The time at which the entity was last changed.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 5; + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + /** + * + * + *
+   * The time at which the entity was last changed.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 5; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + public static final int CURSOR_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString cursor_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * A cursor that points to the position after the result entity.
+   * Set only when the `EntityResult` is part of a `QueryResultBatch` message.
+   * 
+ * + * bytes cursor = 3; + * + * @return The cursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getCursor() { + return cursor_; + } + + 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, getEntity()); + } + if (!cursor_.isEmpty()) { + output.writeBytes(3, cursor_); + } + if (version_ != 0L) { + output.writeInt64(4, version_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(5, getUpdateTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(6, getCreateTime()); + } + 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, getEntity()); + } + if (!cursor_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, cursor_); + } + if (version_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(4, version_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getUpdateTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getCreateTime()); + } + 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.datastore.v1.EntityResult)) { + return super.equals(obj); + } + com.google.datastore.v1.EntityResult other = (com.google.datastore.v1.EntityResult) obj; + + if (hasEntity() != other.hasEntity()) return false; + if (hasEntity()) { + if (!getEntity().equals(other.getEntity())) return false; + } + if (getVersion() != other.getVersion()) 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 (!getCursor().equals(other.getCursor())) 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 (hasEntity()) { + hash = (37 * hash) + ENTITY_FIELD_NUMBER; + hash = (53 * hash) + getEntity().hashCode(); + } + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getVersion()); + 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) + CURSOR_FIELD_NUMBER; + hash = (53 * hash) + getCursor().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.EntityResult parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.EntityResult parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.EntityResult parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.EntityResult 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.datastore.v1.EntityResult parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.EntityResult parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.EntityResult parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.EntityResult parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.EntityResult parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.EntityResult parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.EntityResult parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.EntityResult parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.EntityResult 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The result of fetching an entity from Datastore.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.EntityResult} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.EntityResult) + com.google.datastore.v1.EntityResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_EntityResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_EntityResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.EntityResult.class, + com.google.datastore.v1.EntityResult.Builder.class); + } + + // Construct using com.google.datastore.v1.EntityResult.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getEntityFieldBuilder(); + getCreateTimeFieldBuilder(); + getUpdateTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + entity_ = null; + if (entityBuilder_ != null) { + entityBuilder_.dispose(); + entityBuilder_ = null; + } + version_ = 0L; + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + cursor_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_EntityResult_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.EntityResult getDefaultInstanceForType() { + return com.google.datastore.v1.EntityResult.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.EntityResult build() { + com.google.datastore.v1.EntityResult result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.EntityResult buildPartial() { + com.google.datastore.v1.EntityResult result = new com.google.datastore.v1.EntityResult(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.EntityResult result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.entity_ = entityBuilder_ == null ? entity_ : entityBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.version_ = version_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.createTime_ = createTimeBuilder_ == null ? createTime_ : createTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.updateTime_ = updateTimeBuilder_ == null ? updateTime_ : updateTimeBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.cursor_ = cursor_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.EntityResult) { + return mergeFrom((com.google.datastore.v1.EntityResult) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.EntityResult other) { + if (other == com.google.datastore.v1.EntityResult.getDefaultInstance()) return this; + if (other.hasEntity()) { + mergeEntity(other.getEntity()); + } + if (other.getVersion() != 0L) { + setVersion(other.getVersion()); + } + if (other.hasCreateTime()) { + mergeCreateTime(other.getCreateTime()); + } + if (other.hasUpdateTime()) { + mergeUpdateTime(other.getUpdateTime()); + } + if (other.getCursor() != com.google.protobuf.ByteString.EMPTY) { + setCursor(other.getCursor()); + } + 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(getEntityFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + cursor_ = input.readBytes(); + bitField0_ |= 0x00000010; + break; + } // case 26 + case 32: + { + version_ = input.readInt64(); + bitField0_ |= 0x00000002; + break; + } // case 32 + case 42: + { + input.readMessage(getUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 42 + case 50: + { + input.readMessage(getCreateTimeFieldBuilder().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 com.google.datastore.v1.Entity entity_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder> + entityBuilder_; + + /** + * + * + *
+     * The resulting entity.
+     * 
+ * + * .google.datastore.v1.Entity entity = 1; + * + * @return Whether the entity field is set. + */ + public boolean hasEntity() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The resulting entity.
+     * 
+ * + * .google.datastore.v1.Entity entity = 1; + * + * @return The entity. + */ + public com.google.datastore.v1.Entity getEntity() { + if (entityBuilder_ == null) { + return entity_ == null ? com.google.datastore.v1.Entity.getDefaultInstance() : entity_; + } else { + return entityBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The resulting entity.
+     * 
+ * + * .google.datastore.v1.Entity entity = 1; + */ + public Builder setEntity(com.google.datastore.v1.Entity value) { + if (entityBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + entity_ = value; + } else { + entityBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The resulting entity.
+     * 
+ * + * .google.datastore.v1.Entity entity = 1; + */ + public Builder setEntity(com.google.datastore.v1.Entity.Builder builderForValue) { + if (entityBuilder_ == null) { + entity_ = builderForValue.build(); + } else { + entityBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The resulting entity.
+     * 
+ * + * .google.datastore.v1.Entity entity = 1; + */ + public Builder mergeEntity(com.google.datastore.v1.Entity value) { + if (entityBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && entity_ != null + && entity_ != com.google.datastore.v1.Entity.getDefaultInstance()) { + getEntityBuilder().mergeFrom(value); + } else { + entity_ = value; + } + } else { + entityBuilder_.mergeFrom(value); + } + if (entity_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The resulting entity.
+     * 
+ * + * .google.datastore.v1.Entity entity = 1; + */ + public Builder clearEntity() { + bitField0_ = (bitField0_ & ~0x00000001); + entity_ = null; + if (entityBuilder_ != null) { + entityBuilder_.dispose(); + entityBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The resulting entity.
+     * 
+ * + * .google.datastore.v1.Entity entity = 1; + */ + public com.google.datastore.v1.Entity.Builder getEntityBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getEntityFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The resulting entity.
+     * 
+ * + * .google.datastore.v1.Entity entity = 1; + */ + public com.google.datastore.v1.EntityOrBuilder getEntityOrBuilder() { + if (entityBuilder_ != null) { + return entityBuilder_.getMessageOrBuilder(); + } else { + return entity_ == null ? com.google.datastore.v1.Entity.getDefaultInstance() : entity_; + } + } + + /** + * + * + *
+     * The resulting entity.
+     * 
+ * + * .google.datastore.v1.Entity entity = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder> + getEntityFieldBuilder() { + if (entityBuilder_ == null) { + entityBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder>( + getEntity(), getParentForChildren(), isClean()); + entity_ = null; + } + return entityBuilder_; + } + + private long version_; + + /** + * + * + *
+     * The version of the entity, a strictly positive number that monotonically
+     * increases with changes to the entity.
+     *
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     *
+     * For [missing][google.datastore.v1.LookupResponse.missing] entities in
+     * `LookupResponse`, this is the version of the snapshot that was used to look
+     * up the entity, and it is always set except for eventually consistent reads.
+     * 
+ * + * int64 version = 4; + * + * @return The version. + */ + @java.lang.Override + public long getVersion() { + return version_; + } + + /** + * + * + *
+     * The version of the entity, a strictly positive number that monotonically
+     * increases with changes to the entity.
+     *
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     *
+     * For [missing][google.datastore.v1.LookupResponse.missing] entities in
+     * `LookupResponse`, this is the version of the snapshot that was used to look
+     * up the entity, and it is always set except for eventually consistent reads.
+     * 
+ * + * int64 version = 4; + * + * @param value The version to set. + * @return This builder for chaining. + */ + public Builder setVersion(long value) { + + version_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The version of the entity, a strictly positive number that monotonically
+     * increases with changes to the entity.
+     *
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     *
+     * For [missing][google.datastore.v1.LookupResponse.missing] entities in
+     * `LookupResponse`, this is the version of the snapshot that was used to look
+     * up the entity, and it is always set except for eventually consistent reads.
+     * 
+ * + * int64 version = 4; + * + * @return This builder for chaining. + */ + public Builder clearVersion() { + bitField0_ = (bitField0_ & ~0x00000002); + version_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp createTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + createTimeBuilder_; + + /** + * + * + *
+     * The time at which the entity was created.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 6; + * + * @return Whether the createTime field is set. + */ + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The time at which the entity was created.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 6; + * + * @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(); + } + } + + /** + * + * + *
+     * The time at which the entity was created.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 6; + */ + 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; + } + + /** + * + * + *
+     * The time at which the entity was created.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 6; + */ + 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; + } + + /** + * + * + *
+     * The time at which the entity was created.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 6; + */ + 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; + } + + /** + * + * + *
+     * The time at which the entity was created.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 6; + */ + public Builder clearCreateTime() { + bitField0_ = (bitField0_ & ~0x00000004); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the entity was created.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 6; + */ + public com.google.protobuf.Timestamp.Builder getCreateTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getCreateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time at which the entity was created.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 6; + */ + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + if (createTimeBuilder_ != null) { + return createTimeBuilder_.getMessageOrBuilder(); + } else { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } + } + + /** + * + * + *
+     * The time at which the entity was created.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getCreateTimeFieldBuilder() { + if (createTimeBuilder_ == null) { + createTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + 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.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + + /** + * + * + *
+     * The time at which the entity was last changed.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 5; + * + * @return Whether the updateTime field is set. + */ + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * The time at which the entity was last changed.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 5; + * + * @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 time at which the entity was last changed.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 5; + */ + 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; + } + + /** + * + * + *
+     * The time at which the entity was last changed.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 5; + */ + 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; + } + + /** + * + * + *
+     * The time at which the entity was last changed.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 5; + */ + 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; + } + + /** + * + * + *
+     * The time at which the entity was last changed.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 5; + */ + public Builder clearUpdateTime() { + bitField0_ = (bitField0_ & ~0x00000008); + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which the entity was last changed.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 5; + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getUpdateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time at which the entity was last changed.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 5; + */ + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (updateTimeBuilder_ != null) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } + } + + /** + * + * + *
+     * The time at which the entity was last changed.
+     * This field is set for
+     * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+     * If this entity is missing, this field will not be set.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getUpdateTime(), getParentForChildren(), isClean()); + updateTime_ = null; + } + return updateTimeBuilder_; + } + + private com.google.protobuf.ByteString cursor_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * A cursor that points to the position after the result entity.
+     * Set only when the `EntityResult` is part of a `QueryResultBatch` message.
+     * 
+ * + * bytes cursor = 3; + * + * @return The cursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getCursor() { + return cursor_; + } + + /** + * + * + *
+     * A cursor that points to the position after the result entity.
+     * Set only when the `EntityResult` is part of a `QueryResultBatch` message.
+     * 
+ * + * bytes cursor = 3; + * + * @param value The cursor to set. + * @return This builder for chaining. + */ + public Builder setCursor(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + cursor_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * A cursor that points to the position after the result entity.
+     * Set only when the `EntityResult` is part of a `QueryResultBatch` message.
+     * 
+ * + * bytes cursor = 3; + * + * @return This builder for chaining. + */ + public Builder clearCursor() { + bitField0_ = (bitField0_ & ~0x00000010); + cursor_ = getDefaultInstance().getCursor(); + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.EntityResult) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.EntityResult) + private static final com.google.datastore.v1.EntityResult DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.EntityResult(); + } + + public static com.google.datastore.v1.EntityResult getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public EntityResult 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.datastore.v1.EntityResult getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityResultOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityResultOrBuilder.java new file mode 100644 index 000000000000..de6af24cbafc --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/EntityResultOrBuilder.java @@ -0,0 +1,190 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface EntityResultOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.EntityResult) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The resulting entity.
+   * 
+ * + * .google.datastore.v1.Entity entity = 1; + * + * @return Whether the entity field is set. + */ + boolean hasEntity(); + + /** + * + * + *
+   * The resulting entity.
+   * 
+ * + * .google.datastore.v1.Entity entity = 1; + * + * @return The entity. + */ + com.google.datastore.v1.Entity getEntity(); + + /** + * + * + *
+   * The resulting entity.
+   * 
+ * + * .google.datastore.v1.Entity entity = 1; + */ + com.google.datastore.v1.EntityOrBuilder getEntityOrBuilder(); + + /** + * + * + *
+   * The version of the entity, a strictly positive number that monotonically
+   * increases with changes to the entity.
+   *
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   *
+   * For [missing][google.datastore.v1.LookupResponse.missing] entities in
+   * `LookupResponse`, this is the version of the snapshot that was used to look
+   * up the entity, and it is always set except for eventually consistent reads.
+   * 
+ * + * int64 version = 4; + * + * @return The version. + */ + long getVersion(); + + /** + * + * + *
+   * The time at which the entity was created.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 6; + * + * @return Whether the createTime field is set. + */ + boolean hasCreateTime(); + + /** + * + * + *
+   * The time at which the entity was created.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 6; + * + * @return The createTime. + */ + com.google.protobuf.Timestamp getCreateTime(); + + /** + * + * + *
+   * The time at which the entity was created.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 6; + */ + com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder(); + + /** + * + * + *
+   * The time at which the entity was last changed.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 5; + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + + /** + * + * + *
+   * The time at which the entity was last changed.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 5; + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + + /** + * + * + *
+   * The time at which the entity was last changed.
+   * This field is set for
+   * [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results.
+   * If this entity is missing, this field will not be set.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 5; + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + /** + * + * + *
+   * A cursor that points to the position after the result entity.
+   * Set only when the `EntityResult` is part of a `QueryResultBatch` message.
+   * 
+ * + * bytes cursor = 3; + * + * @return The cursor. + */ + com.google.protobuf.ByteString getCursor(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExecutionStats.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExecutionStats.java new file mode 100644 index 000000000000..1cd6d50b1ae7 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExecutionStats.java @@ -0,0 +1,1339 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * Execution statistics for the query.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.ExecutionStats} + */ +public final class ExecutionStats extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.ExecutionStats) + ExecutionStatsOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ExecutionStats.newBuilder() to construct. + private ExecutionStats(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExecutionStats() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExecutionStats(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExecutionStats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExecutionStats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ExecutionStats.class, + com.google.datastore.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.datastore.v1.ExecutionStats)) { + return super.equals(obj); + } + com.google.datastore.v1.ExecutionStats other = (com.google.datastore.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.datastore.v1.ExecutionStats parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.ExecutionStats parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.ExecutionStats parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ExecutionStats parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.ExecutionStats parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ExecutionStats parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ExecutionStats parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ExecutionStats parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ExecutionStats parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ExecutionStats parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Execution statistics for the query.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.ExecutionStats} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.ExecutionStats) + com.google.datastore.v1.ExecutionStatsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExecutionStats_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExecutionStats_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ExecutionStats.class, + com.google.datastore.v1.ExecutionStats.Builder.class); + } + + // Construct using com.google.datastore.v1.ExecutionStats.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getExecutionDurationFieldBuilder(); + getDebugStatsFieldBuilder(); + } + } + + @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.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExecutionStats_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.ExecutionStats getDefaultInstanceForType() { + return com.google.datastore.v1.ExecutionStats.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.ExecutionStats build() { + com.google.datastore.v1.ExecutionStats result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.ExecutionStats buildPartial() { + com.google.datastore.v1.ExecutionStats result = + new com.google.datastore.v1.ExecutionStats(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.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 clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.ExecutionStats) { + return mergeFrom((com.google.datastore.v1.ExecutionStats) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.ExecutionStats other) { + if (other == com.google.datastore.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( + getExecutionDurationFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 32: + { + readOperations_ = input.readInt64(); + bitField0_ |= 0x00000004; + break; + } // case 32 + case 42: + { + input.readMessage(getDebugStatsFieldBuilder().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.SingleFieldBuilderV3< + 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 getExecutionDurationFieldBuilder().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.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + getExecutionDurationFieldBuilder() { + if (executionDurationBuilder_ == null) { + executionDurationBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + 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.SingleFieldBuilderV3< + 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 getDebugStatsFieldBuilder().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.SingleFieldBuilderV3< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder> + getDebugStatsFieldBuilder() { + if (debugStatsBuilder_ == null) { + debugStatsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder>( + getDebugStats(), getParentForChildren(), isClean()); + debugStats_ = null; + } + return debugStatsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.ExecutionStats) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.ExecutionStats) + private static final com.google.datastore.v1.ExecutionStats DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.ExecutionStats(); + } + + public static com.google.datastore.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.datastore.v1.ExecutionStats getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExecutionStatsOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExecutionStatsOrBuilder.java new file mode 100644 index 000000000000..4c4d256b37d4 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExecutionStatsOrBuilder.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! +// source: google/datastore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface ExecutionStatsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.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-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainMetrics.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainMetrics.java new file mode 100644 index 000000000000..41ece50d4421 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainMetrics.java @@ -0,0 +1,1040 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * Explain metrics for the query.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.ExplainMetrics} + */ +public final class ExplainMetrics extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.ExplainMetrics) + ExplainMetricsOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ExplainMetrics.newBuilder() to construct. + private ExplainMetrics(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExplainMetrics() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExplainMetrics(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExplainMetrics_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExplainMetrics_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ExplainMetrics.class, + com.google.datastore.v1.ExplainMetrics.Builder.class); + } + + private int bitField0_; + public static final int PLAN_SUMMARY_FIELD_NUMBER = 1; + private com.google.datastore.v1.PlanSummary planSummary_; + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.datastore.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.datastore.v1.PlanSummary plan_summary = 1; + * + * @return The planSummary. + */ + @java.lang.Override + public com.google.datastore.v1.PlanSummary getPlanSummary() { + return planSummary_ == null + ? com.google.datastore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.datastore.v1.PlanSummary plan_summary = 1; + */ + @java.lang.Override + public com.google.datastore.v1.PlanSummaryOrBuilder getPlanSummaryOrBuilder() { + return planSummary_ == null + ? com.google.datastore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } + + public static final int EXECUTION_STATS_FIELD_NUMBER = 2; + private com.google.datastore.v1.ExecutionStats executionStats_; + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.datastore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.datastore.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.datastore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + * + * @return The executionStats. + */ + @java.lang.Override + public com.google.datastore.v1.ExecutionStats getExecutionStats() { + return executionStats_ == null + ? com.google.datastore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.datastore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + */ + @java.lang.Override + public com.google.datastore.v1.ExecutionStatsOrBuilder getExecutionStatsOrBuilder() { + return executionStats_ == null + ? com.google.datastore.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.datastore.v1.ExplainMetrics)) { + return super.equals(obj); + } + com.google.datastore.v1.ExplainMetrics other = (com.google.datastore.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.datastore.v1.ExplainMetrics parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.ExplainMetrics parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.ExplainMetrics parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ExplainMetrics parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.ExplainMetrics parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ExplainMetrics parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ExplainMetrics parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ExplainMetrics parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ExplainMetrics parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ExplainMetrics parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Explain metrics for the query.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.ExplainMetrics} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.ExplainMetrics) + com.google.datastore.v1.ExplainMetricsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExplainMetrics_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExplainMetrics_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ExplainMetrics.class, + com.google.datastore.v1.ExplainMetrics.Builder.class); + } + + // Construct using com.google.datastore.v1.ExplainMetrics.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPlanSummaryFieldBuilder(); + getExecutionStatsFieldBuilder(); + } + } + + @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.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExplainMetrics_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.ExplainMetrics getDefaultInstanceForType() { + return com.google.datastore.v1.ExplainMetrics.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.ExplainMetrics build() { + com.google.datastore.v1.ExplainMetrics result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.ExplainMetrics buildPartial() { + com.google.datastore.v1.ExplainMetrics result = + new com.google.datastore.v1.ExplainMetrics(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.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 clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.ExplainMetrics) { + return mergeFrom((com.google.datastore.v1.ExplainMetrics) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.ExplainMetrics other) { + if (other == com.google.datastore.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(getPlanSummaryFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getExecutionStatsFieldBuilder().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.datastore.v1.PlanSummary planSummary_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PlanSummary, + com.google.datastore.v1.PlanSummary.Builder, + com.google.datastore.v1.PlanSummaryOrBuilder> + planSummaryBuilder_; + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.datastore.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.datastore.v1.PlanSummary plan_summary = 1; + * + * @return The planSummary. + */ + public com.google.datastore.v1.PlanSummary getPlanSummary() { + if (planSummaryBuilder_ == null) { + return planSummary_ == null + ? com.google.datastore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } else { + return planSummaryBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.datastore.v1.PlanSummary plan_summary = 1; + */ + public Builder setPlanSummary(com.google.datastore.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.datastore.v1.PlanSummary plan_summary = 1; + */ + public Builder setPlanSummary(com.google.datastore.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.datastore.v1.PlanSummary plan_summary = 1; + */ + public Builder mergePlanSummary(com.google.datastore.v1.PlanSummary value) { + if (planSummaryBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && planSummary_ != null + && planSummary_ != com.google.datastore.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.datastore.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.datastore.v1.PlanSummary plan_summary = 1; + */ + public com.google.datastore.v1.PlanSummary.Builder getPlanSummaryBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getPlanSummaryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.datastore.v1.PlanSummary plan_summary = 1; + */ + public com.google.datastore.v1.PlanSummaryOrBuilder getPlanSummaryOrBuilder() { + if (planSummaryBuilder_ != null) { + return planSummaryBuilder_.getMessageOrBuilder(); + } else { + return planSummary_ == null + ? com.google.datastore.v1.PlanSummary.getDefaultInstance() + : planSummary_; + } + } + + /** + * + * + *
+     * Planning phase information for the query.
+     * 
+ * + * .google.datastore.v1.PlanSummary plan_summary = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PlanSummary, + com.google.datastore.v1.PlanSummary.Builder, + com.google.datastore.v1.PlanSummaryOrBuilder> + getPlanSummaryFieldBuilder() { + if (planSummaryBuilder_ == null) { + planSummaryBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PlanSummary, + com.google.datastore.v1.PlanSummary.Builder, + com.google.datastore.v1.PlanSummaryOrBuilder>( + getPlanSummary(), getParentForChildren(), isClean()); + planSummary_ = null; + } + return planSummaryBuilder_; + } + + private com.google.datastore.v1.ExecutionStats executionStats_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExecutionStats, + com.google.datastore.v1.ExecutionStats.Builder, + com.google.datastore.v1.ExecutionStatsOrBuilder> + executionStatsBuilder_; + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.datastore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.datastore.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.datastore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + * + * @return The executionStats. + */ + public com.google.datastore.v1.ExecutionStats getExecutionStats() { + if (executionStatsBuilder_ == null) { + return executionStats_ == null + ? com.google.datastore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } else { + return executionStatsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.datastore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + */ + public Builder setExecutionStats(com.google.datastore.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.datastore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + */ + public Builder setExecutionStats( + com.google.datastore.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.datastore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + */ + public Builder mergeExecutionStats(com.google.datastore.v1.ExecutionStats value) { + if (executionStatsBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && executionStats_ != null + && executionStats_ != com.google.datastore.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.datastore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.datastore.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.datastore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + */ + public com.google.datastore.v1.ExecutionStats.Builder getExecutionStatsBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getExecutionStatsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.datastore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + */ + public com.google.datastore.v1.ExecutionStatsOrBuilder getExecutionStatsOrBuilder() { + if (executionStatsBuilder_ != null) { + return executionStatsBuilder_.getMessageOrBuilder(); + } else { + return executionStats_ == null + ? com.google.datastore.v1.ExecutionStats.getDefaultInstance() + : executionStats_; + } + } + + /** + * + * + *
+     * Aggregated stats from the execution of the query. Only present when
+     * [ExplainOptions.analyze][google.datastore.v1.ExplainOptions.analyze] is set
+     * to true.
+     * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExecutionStats, + com.google.datastore.v1.ExecutionStats.Builder, + com.google.datastore.v1.ExecutionStatsOrBuilder> + getExecutionStatsFieldBuilder() { + if (executionStatsBuilder_ == null) { + executionStatsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExecutionStats, + com.google.datastore.v1.ExecutionStats.Builder, + com.google.datastore.v1.ExecutionStatsOrBuilder>( + getExecutionStats(), getParentForChildren(), isClean()); + executionStats_ = null; + } + return executionStatsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.ExplainMetrics) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.ExplainMetrics) + private static final com.google.datastore.v1.ExplainMetrics DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.ExplainMetrics(); + } + + public static com.google.datastore.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.datastore.v1.ExplainMetrics getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainMetricsOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainMetricsOrBuilder.java new file mode 100644 index 000000000000..c49c3827c1a0 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainMetricsOrBuilder.java @@ -0,0 +1,106 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface ExplainMetricsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.ExplainMetrics) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.datastore.v1.PlanSummary plan_summary = 1; + * + * @return Whether the planSummary field is set. + */ + boolean hasPlanSummary(); + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.datastore.v1.PlanSummary plan_summary = 1; + * + * @return The planSummary. + */ + com.google.datastore.v1.PlanSummary getPlanSummary(); + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * .google.datastore.v1.PlanSummary plan_summary = 1; + */ + com.google.datastore.v1.PlanSummaryOrBuilder getPlanSummaryOrBuilder(); + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.datastore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.datastore.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.datastore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + * + * @return The executionStats. + */ + com.google.datastore.v1.ExecutionStats getExecutionStats(); + + /** + * + * + *
+   * Aggregated stats from the execution of the query. Only present when
+   * [ExplainOptions.analyze][google.datastore.v1.ExplainOptions.analyze] is set
+   * to true.
+   * 
+ * + * .google.datastore.v1.ExecutionStats execution_stats = 2; + */ + com.google.datastore.v1.ExecutionStatsOrBuilder getExecutionStatsOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainOptions.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainOptions.java new file mode 100644 index 000000000000..17239c1c7caf --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainOptions.java @@ -0,0 +1,563 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * Explain options for the query.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.ExplainOptions} + */ +public final class ExplainOptions extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.ExplainOptions) + ExplainOptionsOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ExplainOptions.newBuilder() to construct. + private ExplainOptions(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ExplainOptions() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ExplainOptions(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExplainOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExplainOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ExplainOptions.class, + com.google.datastore.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.datastore.v1.ExplainOptions)) { + return super.equals(obj); + } + com.google.datastore.v1.ExplainOptions other = (com.google.datastore.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.datastore.v1.ExplainOptions parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.ExplainOptions parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.ExplainOptions parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ExplainOptions parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.ExplainOptions parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ExplainOptions parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ExplainOptions parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ExplainOptions parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ExplainOptions parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ExplainOptions parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Explain options for the query.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.ExplainOptions} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.ExplainOptions) + com.google.datastore.v1.ExplainOptionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExplainOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExplainOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ExplainOptions.class, + com.google.datastore.v1.ExplainOptions.Builder.class); + } + + // Construct using com.google.datastore.v1.ExplainOptions.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_ExplainOptions_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.ExplainOptions getDefaultInstanceForType() { + return com.google.datastore.v1.ExplainOptions.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.ExplainOptions build() { + com.google.datastore.v1.ExplainOptions result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.ExplainOptions buildPartial() { + com.google.datastore.v1.ExplainOptions result = + new com.google.datastore.v1.ExplainOptions(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.ExplainOptions result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.analyze_ = analyze_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.ExplainOptions) { + return mergeFrom((com.google.datastore.v1.ExplainOptions) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.ExplainOptions other) { + if (other == com.google.datastore.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; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.ExplainOptions) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.ExplainOptions) + private static final com.google.datastore.v1.ExplainOptions DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.ExplainOptions(); + } + + public static com.google.datastore.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.datastore.v1.ExplainOptions getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainOptionsOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainOptionsOrBuilder.java new file mode 100644 index 000000000000..6f32190d5b39 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ExplainOptionsOrBuilder.java @@ -0,0 +1,45 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface ExplainOptionsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.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-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Filter.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Filter.java new file mode 100644 index 000000000000..c0a7db151704 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Filter.java @@ -0,0 +1,1132 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A holder for any type of filter.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.Filter} + */ +public final class Filter extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.Filter) + FilterOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Filter.newBuilder() to construct. + private Filter(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Filter() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Filter(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto.internal_static_google_datastore_v1_Filter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Filter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Filter.class, com.google.datastore.v1.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), + PROPERTY_FILTER(2), + 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 PROPERTY_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.datastore.v1.CompositeFilter composite_filter = 1; + * + * @return Whether the compositeFilter field is set. + */ + @java.lang.Override + public boolean hasCompositeFilter() { + return filterTypeCase_ == 1; + } + + /** + * + * + *
+   * A composite filter.
+   * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + * + * @return The compositeFilter. + */ + @java.lang.Override + public com.google.datastore.v1.CompositeFilter getCompositeFilter() { + if (filterTypeCase_ == 1) { + return (com.google.datastore.v1.CompositeFilter) filterType_; + } + return com.google.datastore.v1.CompositeFilter.getDefaultInstance(); + } + + /** + * + * + *
+   * A composite filter.
+   * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + */ + @java.lang.Override + public com.google.datastore.v1.CompositeFilterOrBuilder getCompositeFilterOrBuilder() { + if (filterTypeCase_ == 1) { + return (com.google.datastore.v1.CompositeFilter) filterType_; + } + return com.google.datastore.v1.CompositeFilter.getDefaultInstance(); + } + + public static final int PROPERTY_FILTER_FIELD_NUMBER = 2; + + /** + * + * + *
+   * A filter on a property.
+   * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + * + * @return Whether the propertyFilter field is set. + */ + @java.lang.Override + public boolean hasPropertyFilter() { + return filterTypeCase_ == 2; + } + + /** + * + * + *
+   * A filter on a property.
+   * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + * + * @return The propertyFilter. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyFilter getPropertyFilter() { + if (filterTypeCase_ == 2) { + return (com.google.datastore.v1.PropertyFilter) filterType_; + } + return com.google.datastore.v1.PropertyFilter.getDefaultInstance(); + } + + /** + * + * + *
+   * A filter on a property.
+   * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyFilterOrBuilder getPropertyFilterOrBuilder() { + if (filterTypeCase_ == 2) { + return (com.google.datastore.v1.PropertyFilter) filterType_; + } + return com.google.datastore.v1.PropertyFilter.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.datastore.v1.CompositeFilter) filterType_); + } + if (filterTypeCase_ == 2) { + output.writeMessage(2, (com.google.datastore.v1.PropertyFilter) 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.datastore.v1.CompositeFilter) filterType_); + } + if (filterTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.datastore.v1.PropertyFilter) 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.datastore.v1.Filter)) { + return super.equals(obj); + } + com.google.datastore.v1.Filter other = (com.google.datastore.v1.Filter) obj; + + if (!getFilterTypeCase().equals(other.getFilterTypeCase())) return false; + switch (filterTypeCase_) { + case 1: + if (!getCompositeFilter().equals(other.getCompositeFilter())) return false; + break; + case 2: + if (!getPropertyFilter().equals(other.getPropertyFilter())) 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) + PROPERTY_FILTER_FIELD_NUMBER; + hash = (53 * hash) + getPropertyFilter().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.Filter parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.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.datastore.v1.Filter parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.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.datastore.v1.Filter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Filter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Filter parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Filter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Filter parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Filter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Filter parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Filter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A holder for any type of filter.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.Filter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.Filter) + com.google.datastore.v1.FilterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Filter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Filter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Filter.class, com.google.datastore.v1.Filter.Builder.class); + } + + // Construct using com.google.datastore.v1.Filter.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (compositeFilterBuilder_ != null) { + compositeFilterBuilder_.clear(); + } + if (propertyFilterBuilder_ != null) { + propertyFilterBuilder_.clear(); + } + filterTypeCase_ = 0; + filterType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Filter_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.Filter getDefaultInstanceForType() { + return com.google.datastore.v1.Filter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.Filter build() { + com.google.datastore.v1.Filter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.Filter buildPartial() { + com.google.datastore.v1.Filter result = new com.google.datastore.v1.Filter(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.Filter result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.datastore.v1.Filter result) { + result.filterTypeCase_ = filterTypeCase_; + result.filterType_ = this.filterType_; + if (filterTypeCase_ == 1 && compositeFilterBuilder_ != null) { + result.filterType_ = compositeFilterBuilder_.build(); + } + if (filterTypeCase_ == 2 && propertyFilterBuilder_ != null) { + result.filterType_ = propertyFilterBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.Filter) { + return mergeFrom((com.google.datastore.v1.Filter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.Filter other) { + if (other == com.google.datastore.v1.Filter.getDefaultInstance()) return this; + switch (other.getFilterTypeCase()) { + case COMPOSITE_FILTER: + { + mergeCompositeFilter(other.getCompositeFilter()); + break; + } + case PROPERTY_FILTER: + { + mergePropertyFilter(other.getPropertyFilter()); + 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(getCompositeFilterFieldBuilder().getBuilder(), extensionRegistry); + filterTypeCase_ = 1; + break; + } // case 10 + case 18: + { + input.readMessage(getPropertyFilterFieldBuilder().getBuilder(), extensionRegistry); + filterTypeCase_ = 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 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.SingleFieldBuilderV3< + com.google.datastore.v1.CompositeFilter, + com.google.datastore.v1.CompositeFilter.Builder, + com.google.datastore.v1.CompositeFilterOrBuilder> + compositeFilterBuilder_; + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + * + * @return Whether the compositeFilter field is set. + */ + @java.lang.Override + public boolean hasCompositeFilter() { + return filterTypeCase_ == 1; + } + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + * + * @return The compositeFilter. + */ + @java.lang.Override + public com.google.datastore.v1.CompositeFilter getCompositeFilter() { + if (compositeFilterBuilder_ == null) { + if (filterTypeCase_ == 1) { + return (com.google.datastore.v1.CompositeFilter) filterType_; + } + return com.google.datastore.v1.CompositeFilter.getDefaultInstance(); + } else { + if (filterTypeCase_ == 1) { + return compositeFilterBuilder_.getMessage(); + } + return com.google.datastore.v1.CompositeFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + */ + public Builder setCompositeFilter(com.google.datastore.v1.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.datastore.v1.CompositeFilter composite_filter = 1; + */ + public Builder setCompositeFilter( + com.google.datastore.v1.CompositeFilter.Builder builderForValue) { + if (compositeFilterBuilder_ == null) { + filterType_ = builderForValue.build(); + onChanged(); + } else { + compositeFilterBuilder_.setMessage(builderForValue.build()); + } + filterTypeCase_ = 1; + return this; + } + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + */ + public Builder mergeCompositeFilter(com.google.datastore.v1.CompositeFilter value) { + if (compositeFilterBuilder_ == null) { + if (filterTypeCase_ == 1 + && filterType_ != com.google.datastore.v1.CompositeFilter.getDefaultInstance()) { + filterType_ = + com.google.datastore.v1.CompositeFilter.newBuilder( + (com.google.datastore.v1.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.datastore.v1.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.datastore.v1.CompositeFilter composite_filter = 1; + */ + public com.google.datastore.v1.CompositeFilter.Builder getCompositeFilterBuilder() { + return getCompositeFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + */ + @java.lang.Override + public com.google.datastore.v1.CompositeFilterOrBuilder getCompositeFilterOrBuilder() { + if ((filterTypeCase_ == 1) && (compositeFilterBuilder_ != null)) { + return compositeFilterBuilder_.getMessageOrBuilder(); + } else { + if (filterTypeCase_ == 1) { + return (com.google.datastore.v1.CompositeFilter) filterType_; + } + return com.google.datastore.v1.CompositeFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A composite filter.
+     * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.CompositeFilter, + com.google.datastore.v1.CompositeFilter.Builder, + com.google.datastore.v1.CompositeFilterOrBuilder> + getCompositeFilterFieldBuilder() { + if (compositeFilterBuilder_ == null) { + if (!(filterTypeCase_ == 1)) { + filterType_ = com.google.datastore.v1.CompositeFilter.getDefaultInstance(); + } + compositeFilterBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.CompositeFilter, + com.google.datastore.v1.CompositeFilter.Builder, + com.google.datastore.v1.CompositeFilterOrBuilder>( + (com.google.datastore.v1.CompositeFilter) filterType_, + getParentForChildren(), + isClean()); + filterType_ = null; + } + filterTypeCase_ = 1; + onChanged(); + return compositeFilterBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyFilter, + com.google.datastore.v1.PropertyFilter.Builder, + com.google.datastore.v1.PropertyFilterOrBuilder> + propertyFilterBuilder_; + + /** + * + * + *
+     * A filter on a property.
+     * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + * + * @return Whether the propertyFilter field is set. + */ + @java.lang.Override + public boolean hasPropertyFilter() { + return filterTypeCase_ == 2; + } + + /** + * + * + *
+     * A filter on a property.
+     * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + * + * @return The propertyFilter. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyFilter getPropertyFilter() { + if (propertyFilterBuilder_ == null) { + if (filterTypeCase_ == 2) { + return (com.google.datastore.v1.PropertyFilter) filterType_; + } + return com.google.datastore.v1.PropertyFilter.getDefaultInstance(); + } else { + if (filterTypeCase_ == 2) { + return propertyFilterBuilder_.getMessage(); + } + return com.google.datastore.v1.PropertyFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A filter on a property.
+     * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + */ + public Builder setPropertyFilter(com.google.datastore.v1.PropertyFilter value) { + if (propertyFilterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + filterType_ = value; + onChanged(); + } else { + propertyFilterBuilder_.setMessage(value); + } + filterTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A filter on a property.
+     * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + */ + public Builder setPropertyFilter( + com.google.datastore.v1.PropertyFilter.Builder builderForValue) { + if (propertyFilterBuilder_ == null) { + filterType_ = builderForValue.build(); + onChanged(); + } else { + propertyFilterBuilder_.setMessage(builderForValue.build()); + } + filterTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A filter on a property.
+     * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + */ + public Builder mergePropertyFilter(com.google.datastore.v1.PropertyFilter value) { + if (propertyFilterBuilder_ == null) { + if (filterTypeCase_ == 2 + && filterType_ != com.google.datastore.v1.PropertyFilter.getDefaultInstance()) { + filterType_ = + com.google.datastore.v1.PropertyFilter.newBuilder( + (com.google.datastore.v1.PropertyFilter) filterType_) + .mergeFrom(value) + .buildPartial(); + } else { + filterType_ = value; + } + onChanged(); + } else { + if (filterTypeCase_ == 2) { + propertyFilterBuilder_.mergeFrom(value); + } else { + propertyFilterBuilder_.setMessage(value); + } + } + filterTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A filter on a property.
+     * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + */ + public Builder clearPropertyFilter() { + if (propertyFilterBuilder_ == null) { + if (filterTypeCase_ == 2) { + filterTypeCase_ = 0; + filterType_ = null; + onChanged(); + } + } else { + if (filterTypeCase_ == 2) { + filterTypeCase_ = 0; + filterType_ = null; + } + propertyFilterBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A filter on a property.
+     * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + */ + public com.google.datastore.v1.PropertyFilter.Builder getPropertyFilterBuilder() { + return getPropertyFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A filter on a property.
+     * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyFilterOrBuilder getPropertyFilterOrBuilder() { + if ((filterTypeCase_ == 2) && (propertyFilterBuilder_ != null)) { + return propertyFilterBuilder_.getMessageOrBuilder(); + } else { + if (filterTypeCase_ == 2) { + return (com.google.datastore.v1.PropertyFilter) filterType_; + } + return com.google.datastore.v1.PropertyFilter.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A filter on a property.
+     * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyFilter, + com.google.datastore.v1.PropertyFilter.Builder, + com.google.datastore.v1.PropertyFilterOrBuilder> + getPropertyFilterFieldBuilder() { + if (propertyFilterBuilder_ == null) { + if (!(filterTypeCase_ == 2)) { + filterType_ = com.google.datastore.v1.PropertyFilter.getDefaultInstance(); + } + propertyFilterBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyFilter, + com.google.datastore.v1.PropertyFilter.Builder, + com.google.datastore.v1.PropertyFilterOrBuilder>( + (com.google.datastore.v1.PropertyFilter) filterType_, + getParentForChildren(), + isClean()); + filterType_ = null; + } + filterTypeCase_ = 2; + onChanged(); + return propertyFilterBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.Filter) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.Filter) + private static final com.google.datastore.v1.Filter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.Filter(); + } + + public static com.google.datastore.v1.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.datastore.v1.Filter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FilterOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FilterOrBuilder.java new file mode 100644 index 000000000000..acd6a9ef16a9 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FilterOrBuilder.java @@ -0,0 +1,102 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface FilterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.Filter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A composite filter.
+   * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + * + * @return Whether the compositeFilter field is set. + */ + boolean hasCompositeFilter(); + + /** + * + * + *
+   * A composite filter.
+   * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + * + * @return The compositeFilter. + */ + com.google.datastore.v1.CompositeFilter getCompositeFilter(); + + /** + * + * + *
+   * A composite filter.
+   * 
+ * + * .google.datastore.v1.CompositeFilter composite_filter = 1; + */ + com.google.datastore.v1.CompositeFilterOrBuilder getCompositeFilterOrBuilder(); + + /** + * + * + *
+   * A filter on a property.
+   * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + * + * @return Whether the propertyFilter field is set. + */ + boolean hasPropertyFilter(); + + /** + * + * + *
+   * A filter on a property.
+   * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + * + * @return The propertyFilter. + */ + com.google.datastore.v1.PropertyFilter getPropertyFilter(); + + /** + * + * + *
+   * A filter on a property.
+   * 
+ * + * .google.datastore.v1.PropertyFilter property_filter = 2; + */ + com.google.datastore.v1.PropertyFilterOrBuilder getPropertyFilterOrBuilder(); + + com.google.datastore.v1.Filter.FilterTypeCase getFilterTypeCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearest.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearest.java new file mode 100644 index 000000000000..99b606853c0c --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearest.java @@ -0,0 +1,2339 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * 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.datastore.v1.FindNearest} + */ +public final class FindNearest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.FindNearest) + FindNearestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use FindNearest.newBuilder() to construct. + private FindNearest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private FindNearest() { + distanceMeasure_ = 0; + distanceResultProperty_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new FindNearest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_FindNearest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_FindNearest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.FindNearest.class, + com.google.datastore.v1.FindNearest.Builder.class); + } + + /** + * + * + *
+   * The distance measure to use when comparing vectors.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.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), + ; + + /** + * + * + *
+     * 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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.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.datastore.v1.FindNearest.DistanceMeasure) + } + + private int bitField0_; + public static final int VECTOR_PROPERTY_FIELD_NUMBER = 1; + private com.google.datastore.v1.PropertyReference vectorProperty_; + + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorProperty field is set. + */ + @java.lang.Override + public boolean hasVectorProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorProperty. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReference getVectorProperty() { + return vectorProperty_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : vectorProperty_; + } + + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReferenceOrBuilder getVectorPropertyOrBuilder() { + return vectorProperty_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : vectorProperty_; + } + + public static final int QUERY_VECTOR_FIELD_NUMBER = 2; + private com.google.datastore.v1.Value queryVector_; + + /** + * + * + *
+   * Required. The query vector that we are searching on. Must be a vector of no
+   * more than 2048 dimensions.
+   * 
+ * + * .google.datastore.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.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + @java.lang.Override + public com.google.datastore.v1.Value getQueryVector() { + return queryVector_ == null ? com.google.datastore.v1.Value.getDefaultInstance() : queryVector_; + } + + /** + * + * + *
+   * Required. The query vector that we are searching on. Must be a vector of no
+   * more than 2048 dimensions.
+   * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getQueryVectorOrBuilder() { + return queryVector_ == null ? com.google.datastore.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.datastore.v1.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.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + @java.lang.Override + public com.google.datastore.v1.FindNearest.DistanceMeasure getDistanceMeasure() { + com.google.datastore.v1.FindNearest.DistanceMeasure result = + com.google.datastore.v1.FindNearest.DistanceMeasure.forNumber(distanceMeasure_); + return result == null + ? com.google.datastore.v1.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 100.
+   * 
+ * + * .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 100.
+   * 
+ * + * .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 100.
+   * 
+ * + * .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_PROPERTY_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private volatile java.lang.Object distanceResultProperty_ = ""; + + /** + * + * + *
+   * Optional. Optional name of the field to output the result of the vector
+   * distance calculation. Must conform to [entity
+   * property][google.datastore.v1.Entity.properties] limitations.
+   * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The distanceResultProperty. + */ + @java.lang.Override + public java.lang.String getDistanceResultProperty() { + java.lang.Object ref = distanceResultProperty_; + 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(); + distanceResultProperty_ = s; + return s; + } + } + + /** + * + * + *
+   * Optional. Optional name of the field to output the result of the vector
+   * distance calculation. Must conform to [entity
+   * property][google.datastore.v1.Entity.properties] limitations.
+   * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for distanceResultProperty. + */ + @java.lang.Override + public com.google.protobuf.ByteString getDistanceResultPropertyBytes() { + java.lang.Object ref = distanceResultProperty_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + distanceResultProperty_ = 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, getVectorProperty()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getQueryVector()); + } + if (distanceMeasure_ + != com.google.datastore.v1.FindNearest.DistanceMeasure.DISTANCE_MEASURE_UNSPECIFIED + .getNumber()) { + output.writeEnum(3, distanceMeasure_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getLimit()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(distanceResultProperty_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 5, distanceResultProperty_); + } + 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, getVectorProperty()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getQueryVector()); + } + if (distanceMeasure_ + != com.google.datastore.v1.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.GeneratedMessageV3.isStringEmpty(distanceResultProperty_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(5, distanceResultProperty_); + } + 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.datastore.v1.FindNearest)) { + return super.equals(obj); + } + com.google.datastore.v1.FindNearest other = (com.google.datastore.v1.FindNearest) obj; + + if (hasVectorProperty() != other.hasVectorProperty()) return false; + if (hasVectorProperty()) { + if (!getVectorProperty().equals(other.getVectorProperty())) 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 (!getDistanceResultProperty().equals(other.getDistanceResultProperty())) 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 (hasVectorProperty()) { + hash = (37 * hash) + VECTOR_PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getVectorProperty().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_PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getDistanceResultProperty().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.datastore.v1.FindNearest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.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.datastore.v1.FindNearest parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.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.datastore.v1.FindNearest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.FindNearest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.FindNearest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.FindNearest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.FindNearest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.FindNearest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.FindNearest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.FindNearest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.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.GeneratedMessageV3.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.datastore.v1.FindNearest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.FindNearest) + com.google.datastore.v1.FindNearestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_FindNearest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_FindNearest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.FindNearest.class, + com.google.datastore.v1.FindNearest.Builder.class); + } + + // Construct using com.google.datastore.v1.FindNearest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getVectorPropertyFieldBuilder(); + getQueryVectorFieldBuilder(); + getLimitFieldBuilder(); + getDistanceThresholdFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + vectorProperty_ = null; + if (vectorPropertyBuilder_ != null) { + vectorPropertyBuilder_.dispose(); + vectorPropertyBuilder_ = null; + } + queryVector_ = null; + if (queryVectorBuilder_ != null) { + queryVectorBuilder_.dispose(); + queryVectorBuilder_ = null; + } + distanceMeasure_ = 0; + limit_ = null; + if (limitBuilder_ != null) { + limitBuilder_.dispose(); + limitBuilder_ = null; + } + distanceResultProperty_ = ""; + distanceThreshold_ = null; + if (distanceThresholdBuilder_ != null) { + distanceThresholdBuilder_.dispose(); + distanceThresholdBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_FindNearest_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.FindNearest getDefaultInstanceForType() { + return com.google.datastore.v1.FindNearest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.FindNearest build() { + com.google.datastore.v1.FindNearest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.FindNearest buildPartial() { + com.google.datastore.v1.FindNearest result = new com.google.datastore.v1.FindNearest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.FindNearest result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.vectorProperty_ = + vectorPropertyBuilder_ == null ? vectorProperty_ : vectorPropertyBuilder_.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.distanceResultProperty_ = distanceResultProperty_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.distanceThreshold_ = + distanceThresholdBuilder_ == null + ? distanceThreshold_ + : distanceThresholdBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.FindNearest) { + return mergeFrom((com.google.datastore.v1.FindNearest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.FindNearest other) { + if (other == com.google.datastore.v1.FindNearest.getDefaultInstance()) return this; + if (other.hasVectorProperty()) { + mergeVectorProperty(other.getVectorProperty()); + } + if (other.hasQueryVector()) { + mergeQueryVector(other.getQueryVector()); + } + if (other.distanceMeasure_ != 0) { + setDistanceMeasureValue(other.getDistanceMeasureValue()); + } + if (other.hasLimit()) { + mergeLimit(other.getLimit()); + } + if (!other.getDistanceResultProperty().isEmpty()) { + distanceResultProperty_ = other.distanceResultProperty_; + 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(getVectorPropertyFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getQueryVectorFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 24: + { + distanceMeasure_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 24 + case 34: + { + input.readMessage(getLimitFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 42: + { + distanceResultProperty_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 50: + { + input.readMessage( + getDistanceThresholdFieldBuilder().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.datastore.v1.PropertyReference vectorProperty_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + vectorPropertyBuilder_; + + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorProperty field is set. + */ + public boolean hasVectorProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorProperty. + */ + public com.google.datastore.v1.PropertyReference getVectorProperty() { + if (vectorPropertyBuilder_ == null) { + return vectorProperty_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : vectorProperty_; + } else { + return vectorPropertyBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setVectorProperty(com.google.datastore.v1.PropertyReference value) { + if (vectorPropertyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + vectorProperty_ = value; + } else { + vectorPropertyBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setVectorProperty( + com.google.datastore.v1.PropertyReference.Builder builderForValue) { + if (vectorPropertyBuilder_ == null) { + vectorProperty_ = builderForValue.build(); + } else { + vectorPropertyBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeVectorProperty(com.google.datastore.v1.PropertyReference value) { + if (vectorPropertyBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && vectorProperty_ != null + && vectorProperty_ != com.google.datastore.v1.PropertyReference.getDefaultInstance()) { + getVectorPropertyBuilder().mergeFrom(value); + } else { + vectorProperty_ = value; + } + } else { + vectorPropertyBuilder_.mergeFrom(value); + } + if (vectorProperty_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearVectorProperty() { + bitField0_ = (bitField0_ & ~0x00000001); + vectorProperty_ = null; + if (vectorPropertyBuilder_ != null) { + vectorPropertyBuilder_.dispose(); + vectorPropertyBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.PropertyReference.Builder getVectorPropertyBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getVectorPropertyFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.PropertyReferenceOrBuilder getVectorPropertyOrBuilder() { + if (vectorPropertyBuilder_ != null) { + return vectorPropertyBuilder_.getMessageOrBuilder(); + } else { + return vectorProperty_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : vectorProperty_; + } + } + + /** + * + * + *
+     * Required. An indexed vector property to search upon. Only documents which
+     * contain vectors whose dimensionality match the query_vector can be
+     * returned.
+     * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + getVectorPropertyFieldBuilder() { + if (vectorPropertyBuilder_ == null) { + vectorPropertyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder>( + getVectorProperty(), getParentForChildren(), isClean()); + vectorProperty_ = null; + } + return vectorPropertyBuilder_; + } + + private com.google.datastore.v1.Value queryVector_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + queryVectorBuilder_; + + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.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.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + public com.google.datastore.v1.Value getQueryVector() { + if (queryVectorBuilder_ == null) { + return queryVector_ == null + ? com.google.datastore.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.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setQueryVector(com.google.datastore.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.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setQueryVector(com.google.datastore.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.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeQueryVector(com.google.datastore.v1.Value value) { + if (queryVectorBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && queryVector_ != null + && queryVector_ != com.google.datastore.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.datastore.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.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Value.Builder getQueryVectorBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getQueryVectorFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.ValueOrBuilder getQueryVectorOrBuilder() { + if (queryVectorBuilder_ != null) { + return queryVectorBuilder_.getMessageOrBuilder(); + } else { + return queryVector_ == null + ? com.google.datastore.v1.Value.getDefaultInstance() + : queryVector_; + } + } + + /** + * + * + *
+     * Required. The query vector that we are searching on. Must be a vector of no
+     * more than 2048 dimensions.
+     * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getQueryVectorFieldBuilder() { + if (queryVectorBuilder_ == null) { + queryVectorBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + getQueryVector(), getParentForChildren(), isClean()); + queryVector_ = null; + } + return queryVectorBuilder_; + } + + private int distanceMeasure_ = 0; + + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.datastore.v1.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.datastore.v1.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.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + @java.lang.Override + public com.google.datastore.v1.FindNearest.DistanceMeasure getDistanceMeasure() { + com.google.datastore.v1.FindNearest.DistanceMeasure result = + com.google.datastore.v1.FindNearest.DistanceMeasure.forNumber(distanceMeasure_); + return result == null + ? com.google.datastore.v1.FindNearest.DistanceMeasure.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * Required. The Distance Measure to use, required.
+     * 
+ * + * + * .google.datastore.v1.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.datastore.v1.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.datastore.v1.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.SingleFieldBuilderV3< + 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 100.
+     * 
+ * + * .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 100.
+     * 
+ * + * .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 100.
+     * 
+ * + * .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 100.
+     * 
+ * + * .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 100.
+     * 
+ * + * .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 100.
+     * 
+ * + * .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 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + public com.google.protobuf.Int32Value.Builder getLimitBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getLimitFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Required. The number of nearest neighbors to return. Must be a positive
+     * integer of no more than 100.
+     * 
+ * + * .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 100.
+     * 
+ * + * .google.protobuf.Int32Value limit = 4 [(.google.api.field_behavior) = REQUIRED]; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + getLimitFieldBuilder() { + if (limitBuilder_ == null) { + limitBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder>( + getLimit(), getParentForChildren(), isClean()); + limit_ = null; + } + return limitBuilder_; + } + + private java.lang.Object distanceResultProperty_ = ""; + + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [entity
+     * property][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The distanceResultProperty. + */ + public java.lang.String getDistanceResultProperty() { + java.lang.Object ref = distanceResultProperty_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + distanceResultProperty_ = 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 [entity
+     * property][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for distanceResultProperty. + */ + public com.google.protobuf.ByteString getDistanceResultPropertyBytes() { + java.lang.Object ref = distanceResultProperty_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + distanceResultProperty_ = 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 [entity
+     * property][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The distanceResultProperty to set. + * @return This builder for chaining. + */ + public Builder setDistanceResultProperty(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + distanceResultProperty_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [entity
+     * property][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearDistanceResultProperty() { + distanceResultProperty_ = getDefaultInstance().getDistanceResultProperty(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. Optional name of the field to output the result of the vector
+     * distance calculation. Must conform to [entity
+     * property][google.datastore.v1.Entity.properties] limitations.
+     * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for distanceResultProperty to set. + * @return This builder for chaining. + */ + public Builder setDistanceResultPropertyBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + distanceResultProperty_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + private com.google.protobuf.DoubleValue distanceThreshold_; + private com.google.protobuf.SingleFieldBuilderV3< + 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 getDistanceThresholdFieldBuilder().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.SingleFieldBuilderV3< + com.google.protobuf.DoubleValue, + com.google.protobuf.DoubleValue.Builder, + com.google.protobuf.DoubleValueOrBuilder> + getDistanceThresholdFieldBuilder() { + if (distanceThresholdBuilder_ == null) { + distanceThresholdBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.DoubleValue, + com.google.protobuf.DoubleValue.Builder, + com.google.protobuf.DoubleValueOrBuilder>( + getDistanceThreshold(), getParentForChildren(), isClean()); + distanceThreshold_ = null; + } + return distanceThresholdBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.FindNearest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.FindNearest) + private static final com.google.datastore.v1.FindNearest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.FindNearest(); + } + + public static com.google.datastore.v1.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.datastore.v1.FindNearest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearestOrBuilder.java new file mode 100644 index 000000000000..f4c8408ba14d --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/FindNearestOrBuilder.java @@ -0,0 +1,279 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface FindNearestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.FindNearest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the vectorProperty field is set. + */ + boolean hasVectorProperty(); + + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The vectorProperty. + */ + com.google.datastore.v1.PropertyReference getVectorProperty(); + + /** + * + * + *
+   * Required. An indexed vector property to search upon. Only documents which
+   * contain vectors whose dimensionality match the query_vector can be
+   * returned.
+   * 
+ * + * + * .google.datastore.v1.PropertyReference vector_property = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.v1.PropertyReferenceOrBuilder getVectorPropertyOrBuilder(); + + /** + * + * + *
+   * Required. The query vector that we are searching on. Must be a vector of no
+   * more than 2048 dimensions.
+   * 
+ * + * .google.datastore.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.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The queryVector. + */ + com.google.datastore.v1.Value getQueryVector(); + + /** + * + * + *
+   * Required. The query vector that we are searching on. Must be a vector of no
+   * more than 2048 dimensions.
+   * 
+ * + * .google.datastore.v1.Value query_vector = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.v1.ValueOrBuilder getQueryVectorOrBuilder(); + + /** + * + * + *
+   * Required. The Distance Measure to use, required.
+   * 
+ * + * + * .google.datastore.v1.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.datastore.v1.FindNearest.DistanceMeasure distance_measure = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The distanceMeasure. + */ + com.google.datastore.v1.FindNearest.DistanceMeasure getDistanceMeasure(); + + /** + * + * + *
+   * Required. The number of nearest neighbors to return. Must be a positive
+   * integer of no more than 100.
+   * 
+ * + * .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 100.
+   * 
+ * + * .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 100.
+   * 
+ * + * .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 [entity
+   * property][google.datastore.v1.Entity.properties] limitations.
+   * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The distanceResultProperty. + */ + java.lang.String getDistanceResultProperty(); + + /** + * + * + *
+   * Optional. Optional name of the field to output the result of the vector
+   * distance calculation. Must conform to [entity
+   * property][google.datastore.v1.Entity.properties] limitations.
+   * 
+ * + * string distance_result_property = 5 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for distanceResultProperty. + */ + com.google.protobuf.ByteString getDistanceResultPropertyBytes(); + + /** + * + * + *
+   * 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(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQuery.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQuery.java new file mode 100644 index 000000000000..4da9e332fb5c --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQuery.java @@ -0,0 +1,1850 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A [GQL
+ * query](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+ * 
+ * + * Protobuf type {@code google.datastore.v1.GqlQuery} + */ +public final class GqlQuery extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.GqlQuery) + GqlQueryOrBuilder { + private static final long serialVersionUID = 0L; + + // Use GqlQuery.newBuilder() to construct. + private GqlQuery(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private GqlQuery() { + queryString_ = ""; + positionalBindings_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GqlQuery(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQuery_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + @java.lang.Override + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 5: + return internalGetNamedBindings(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.GqlQuery.class, com.google.datastore.v1.GqlQuery.Builder.class); + } + + public static final int QUERY_STRING_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object queryString_ = ""; + + /** + * + * + *
+   * A string of the format described
+   * [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+   * 
+ * + * string query_string = 1; + * + * @return The queryString. + */ + @java.lang.Override + public java.lang.String getQueryString() { + java.lang.Object ref = queryString_; + 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(); + queryString_ = s; + return s; + } + } + + /** + * + * + *
+   * A string of the format described
+   * [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+   * 
+ * + * string query_string = 1; + * + * @return The bytes for queryString. + */ + @java.lang.Override + public com.google.protobuf.ByteString getQueryStringBytes() { + java.lang.Object ref = queryString_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + queryString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ALLOW_LITERALS_FIELD_NUMBER = 2; + private boolean allowLiterals_ = false; + + /** + * + * + *
+   * When false, the query string must not contain any literals and instead must
+   * bind all values. For example,
+   * `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while
+   * `SELECT * FROM Kind WHERE a = @value` is.
+   * 
+ * + * bool allow_literals = 2; + * + * @return The allowLiterals. + */ + @java.lang.Override + public boolean getAllowLiterals() { + return allowLiterals_; + } + + public static final int NAMED_BINDINGS_FIELD_NUMBER = 5; + + private static final class NamedBindingsDefaultEntryHolder { + static final com.google.protobuf.MapEntry< + java.lang.String, com.google.datastore.v1.GqlQueryParameter> + defaultEntry = + com.google.protobuf.MapEntry + .newDefaultInstance( + com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQuery_NamedBindingsEntry_descriptor, + com.google.protobuf.WireFormat.FieldType.STRING, + "", + com.google.protobuf.WireFormat.FieldType.MESSAGE, + com.google.datastore.v1.GqlQueryParameter.getDefaultInstance()); + } + + @SuppressWarnings("serial") + private com.google.protobuf.MapField + namedBindings_; + + private com.google.protobuf.MapField + internalGetNamedBindings() { + if (namedBindings_ == null) { + return com.google.protobuf.MapField.emptyMapField( + NamedBindingsDefaultEntryHolder.defaultEntry); + } + return namedBindings_; + } + + public int getNamedBindingsCount() { + return internalGetNamedBindings().getMap().size(); + } + + /** + * + * + *
+   * For each non-reserved named binding site in the query string, there must be
+   * a named parameter with that name, but not necessarily the inverse.
+   *
+   * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+   * `__.*__`, and must not be `""`.
+   * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + @java.lang.Override + public boolean containsNamedBindings(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetNamedBindings().getMap().containsKey(key); + } + + /** Use {@link #getNamedBindingsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map + getNamedBindings() { + return getNamedBindingsMap(); + } + + /** + * + * + *
+   * For each non-reserved named binding site in the query string, there must be
+   * a named parameter with that name, but not necessarily the inverse.
+   *
+   * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+   * `__.*__`, and must not be `""`.
+   * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + @java.lang.Override + public java.util.Map + getNamedBindingsMap() { + return internalGetNamedBindings().getMap(); + } + + /** + * + * + *
+   * For each non-reserved named binding site in the query string, there must be
+   * a named parameter with that name, but not necessarily the inverse.
+   *
+   * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+   * `__.*__`, and must not be `""`.
+   * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + @java.lang.Override + public /* nullable */ com.google.datastore.v1.GqlQueryParameter getNamedBindingsOrDefault( + java.lang.String key, + /* nullable */ + com.google.datastore.v1.GqlQueryParameter defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetNamedBindings().getMap(); + return map.containsKey(key) ? map.get(key) : defaultValue; + } + + /** + * + * + *
+   * For each non-reserved named binding site in the query string, there must be
+   * a named parameter with that name, but not necessarily the inverse.
+   *
+   * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+   * `__.*__`, and must not be `""`.
+   * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + @java.lang.Override + public com.google.datastore.v1.GqlQueryParameter getNamedBindingsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetNamedBindings().getMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return map.get(key); + } + + public static final int POSITIONAL_BINDINGS_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private java.util.List positionalBindings_; + + /** + * + * + *
+   * Numbered binding site @1 references the first numbered parameter,
+   * effectively using 1-based indexing, rather than the usual 0.
+   *
+   * For each binding site numbered i in `query_string`, there must be an i-th
+   * numbered parameter. The inverse must also be true.
+   * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + @java.lang.Override + public java.util.List getPositionalBindingsList() { + return positionalBindings_; + } + + /** + * + * + *
+   * Numbered binding site @1 references the first numbered parameter,
+   * effectively using 1-based indexing, rather than the usual 0.
+   *
+   * For each binding site numbered i in `query_string`, there must be an i-th
+   * numbered parameter. The inverse must also be true.
+   * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + @java.lang.Override + public java.util.List + getPositionalBindingsOrBuilderList() { + return positionalBindings_; + } + + /** + * + * + *
+   * Numbered binding site @1 references the first numbered parameter,
+   * effectively using 1-based indexing, rather than the usual 0.
+   *
+   * For each binding site numbered i in `query_string`, there must be an i-th
+   * numbered parameter. The inverse must also be true.
+   * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + @java.lang.Override + public int getPositionalBindingsCount() { + return positionalBindings_.size(); + } + + /** + * + * + *
+   * Numbered binding site @1 references the first numbered parameter,
+   * effectively using 1-based indexing, rather than the usual 0.
+   *
+   * For each binding site numbered i in `query_string`, there must be an i-th
+   * numbered parameter. The inverse must also be true.
+   * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + @java.lang.Override + public com.google.datastore.v1.GqlQueryParameter getPositionalBindings(int index) { + return positionalBindings_.get(index); + } + + /** + * + * + *
+   * Numbered binding site @1 references the first numbered parameter,
+   * effectively using 1-based indexing, rather than the usual 0.
+   *
+   * For each binding site numbered i in `query_string`, there must be an i-th
+   * numbered parameter. The inverse must also be true.
+   * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + @java.lang.Override + public com.google.datastore.v1.GqlQueryParameterOrBuilder getPositionalBindingsOrBuilder( + int index) { + return positionalBindings_.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.GeneratedMessageV3.isStringEmpty(queryString_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, queryString_); + } + if (allowLiterals_ != false) { + output.writeBool(2, allowLiterals_); + } + for (int i = 0; i < positionalBindings_.size(); i++) { + output.writeMessage(4, positionalBindings_.get(i)); + } + com.google.protobuf.GeneratedMessageV3.serializeStringMapTo( + output, internalGetNamedBindings(), NamedBindingsDefaultEntryHolder.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.GeneratedMessageV3.isStringEmpty(queryString_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, queryString_); + } + if (allowLiterals_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(2, allowLiterals_); + } + for (int i = 0; i < positionalBindings_.size(); i++) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize(4, positionalBindings_.get(i)); + } + for (java.util.Map.Entry entry : + internalGetNamedBindings().getMap().entrySet()) { + com.google.protobuf.MapEntry + namedBindings__ = + NamedBindingsDefaultEntryHolder.defaultEntry + .newBuilderForType() + .setKey(entry.getKey()) + .setValue(entry.getValue()) + .build(); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, namedBindings__); + } + 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.datastore.v1.GqlQuery)) { + return super.equals(obj); + } + com.google.datastore.v1.GqlQuery other = (com.google.datastore.v1.GqlQuery) obj; + + if (!getQueryString().equals(other.getQueryString())) return false; + if (getAllowLiterals() != other.getAllowLiterals()) return false; + if (!internalGetNamedBindings().equals(other.internalGetNamedBindings())) return false; + if (!getPositionalBindingsList().equals(other.getPositionalBindingsList())) 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) + QUERY_STRING_FIELD_NUMBER; + hash = (53 * hash) + getQueryString().hashCode(); + hash = (37 * hash) + ALLOW_LITERALS_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getAllowLiterals()); + if (!internalGetNamedBindings().getMap().isEmpty()) { + hash = (37 * hash) + NAMED_BINDINGS_FIELD_NUMBER; + hash = (53 * hash) + internalGetNamedBindings().hashCode(); + } + if (getPositionalBindingsCount() > 0) { + hash = (37 * hash) + POSITIONAL_BINDINGS_FIELD_NUMBER; + hash = (53 * hash) + getPositionalBindingsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.GqlQuery parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.GqlQuery parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.GqlQuery parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.GqlQuery 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.datastore.v1.GqlQuery parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.GqlQuery parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.GqlQuery parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.GqlQuery parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.GqlQuery parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.GqlQuery parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.GqlQuery parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.GqlQuery parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.GqlQuery 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A [GQL
+   * query](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+   * 
+ * + * Protobuf type {@code google.datastore.v1.GqlQuery} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.GqlQuery) + com.google.datastore.v1.GqlQueryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQuery_descriptor; + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMapFieldReflection( + int number) { + switch (number) { + case 5: + return internalGetNamedBindings(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @SuppressWarnings({"rawtypes"}) + protected com.google.protobuf.MapFieldReflectionAccessor internalGetMutableMapFieldReflection( + int number) { + switch (number) { + case 5: + return internalGetMutableNamedBindings(); + default: + throw new RuntimeException("Invalid map field number: " + number); + } + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQuery_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.GqlQuery.class, + com.google.datastore.v1.GqlQuery.Builder.class); + } + + // Construct using com.google.datastore.v1.GqlQuery.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + queryString_ = ""; + allowLiterals_ = false; + internalGetMutableNamedBindings().clear(); + if (positionalBindingsBuilder_ == null) { + positionalBindings_ = java.util.Collections.emptyList(); + } else { + positionalBindings_ = null; + positionalBindingsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQuery_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.GqlQuery getDefaultInstanceForType() { + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.GqlQuery build() { + com.google.datastore.v1.GqlQuery result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.GqlQuery buildPartial() { + com.google.datastore.v1.GqlQuery result = new com.google.datastore.v1.GqlQuery(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.GqlQuery result) { + if (positionalBindingsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + positionalBindings_ = java.util.Collections.unmodifiableList(positionalBindings_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.positionalBindings_ = positionalBindings_; + } else { + result.positionalBindings_ = positionalBindingsBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.GqlQuery result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.queryString_ = queryString_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.allowLiterals_ = allowLiterals_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.namedBindings_ = + internalGetNamedBindings().build(NamedBindingsDefaultEntryHolder.defaultEntry); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.GqlQuery) { + return mergeFrom((com.google.datastore.v1.GqlQuery) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.GqlQuery other) { + if (other == com.google.datastore.v1.GqlQuery.getDefaultInstance()) return this; + if (!other.getQueryString().isEmpty()) { + queryString_ = other.queryString_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.getAllowLiterals() != false) { + setAllowLiterals(other.getAllowLiterals()); + } + internalGetMutableNamedBindings().mergeFrom(other.internalGetNamedBindings()); + bitField0_ |= 0x00000004; + if (positionalBindingsBuilder_ == null) { + if (!other.positionalBindings_.isEmpty()) { + if (positionalBindings_.isEmpty()) { + positionalBindings_ = other.positionalBindings_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensurePositionalBindingsIsMutable(); + positionalBindings_.addAll(other.positionalBindings_); + } + onChanged(); + } + } else { + if (!other.positionalBindings_.isEmpty()) { + if (positionalBindingsBuilder_.isEmpty()) { + positionalBindingsBuilder_.dispose(); + positionalBindingsBuilder_ = null; + positionalBindings_ = other.positionalBindings_; + bitField0_ = (bitField0_ & ~0x00000008); + positionalBindingsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getPositionalBindingsFieldBuilder() + : null; + } else { + positionalBindingsBuilder_.addAllMessages(other.positionalBindings_); + } + } + } + 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: + { + queryString_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + allowLiterals_ = input.readBool(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 34: + { + com.google.datastore.v1.GqlQueryParameter m = + input.readMessage( + com.google.datastore.v1.GqlQueryParameter.parser(), extensionRegistry); + if (positionalBindingsBuilder_ == null) { + ensurePositionalBindingsIsMutable(); + positionalBindings_.add(m); + } else { + positionalBindingsBuilder_.addMessage(m); + } + break; + } // case 34 + case 42: + { + com.google.protobuf.MapEntry< + java.lang.String, com.google.datastore.v1.GqlQueryParameter> + namedBindings__ = + input.readMessage( + NamedBindingsDefaultEntryHolder.defaultEntry.getParserForType(), + extensionRegistry); + internalGetMutableNamedBindings() + .ensureBuilderMap() + .put(namedBindings__.getKey(), namedBindings__.getValue()); + bitField0_ |= 0x00000004; + 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 queryString_ = ""; + + /** + * + * + *
+     * A string of the format described
+     * [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+     * 
+ * + * string query_string = 1; + * + * @return The queryString. + */ + public java.lang.String getQueryString() { + java.lang.Object ref = queryString_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + queryString_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * A string of the format described
+     * [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+     * 
+ * + * string query_string = 1; + * + * @return The bytes for queryString. + */ + public com.google.protobuf.ByteString getQueryStringBytes() { + java.lang.Object ref = queryString_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + queryString_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * A string of the format described
+     * [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+     * 
+ * + * string query_string = 1; + * + * @param value The queryString to set. + * @return This builder for chaining. + */ + public Builder setQueryString(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + queryString_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * A string of the format described
+     * [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+     * 
+ * + * string query_string = 1; + * + * @return This builder for chaining. + */ + public Builder clearQueryString() { + queryString_ = getDefaultInstance().getQueryString(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * A string of the format described
+     * [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+     * 
+ * + * string query_string = 1; + * + * @param value The bytes for queryString to set. + * @return This builder for chaining. + */ + public Builder setQueryStringBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + queryString_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private boolean allowLiterals_; + + /** + * + * + *
+     * When false, the query string must not contain any literals and instead must
+     * bind all values. For example,
+     * `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while
+     * `SELECT * FROM Kind WHERE a = @value` is.
+     * 
+ * + * bool allow_literals = 2; + * + * @return The allowLiterals. + */ + @java.lang.Override + public boolean getAllowLiterals() { + return allowLiterals_; + } + + /** + * + * + *
+     * When false, the query string must not contain any literals and instead must
+     * bind all values. For example,
+     * `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while
+     * `SELECT * FROM Kind WHERE a = @value` is.
+     * 
+ * + * bool allow_literals = 2; + * + * @param value The allowLiterals to set. + * @return This builder for chaining. + */ + public Builder setAllowLiterals(boolean value) { + + allowLiterals_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * When false, the query string must not contain any literals and instead must
+     * bind all values. For example,
+     * `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while
+     * `SELECT * FROM Kind WHERE a = @value` is.
+     * 
+ * + * bool allow_literals = 2; + * + * @return This builder for chaining. + */ + public Builder clearAllowLiterals() { + bitField0_ = (bitField0_ & ~0x00000002); + allowLiterals_ = false; + onChanged(); + return this; + } + + private static final class NamedBindingsConverter + implements com.google.protobuf.MapFieldBuilder.Converter< + java.lang.String, + com.google.datastore.v1.GqlQueryParameterOrBuilder, + com.google.datastore.v1.GqlQueryParameter> { + @java.lang.Override + public com.google.datastore.v1.GqlQueryParameter build( + com.google.datastore.v1.GqlQueryParameterOrBuilder val) { + if (val instanceof com.google.datastore.v1.GqlQueryParameter) { + return (com.google.datastore.v1.GqlQueryParameter) val; + } + return ((com.google.datastore.v1.GqlQueryParameter.Builder) val).build(); + } + + @java.lang.Override + public com.google.protobuf.MapEntry< + java.lang.String, com.google.datastore.v1.GqlQueryParameter> + defaultEntry() { + return NamedBindingsDefaultEntryHolder.defaultEntry; + } + } + ; + + private static final NamedBindingsConverter namedBindingsConverter = + new NamedBindingsConverter(); + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.datastore.v1.GqlQueryParameterOrBuilder, + com.google.datastore.v1.GqlQueryParameter, + com.google.datastore.v1.GqlQueryParameter.Builder> + namedBindings_; + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.datastore.v1.GqlQueryParameterOrBuilder, + com.google.datastore.v1.GqlQueryParameter, + com.google.datastore.v1.GqlQueryParameter.Builder> + internalGetNamedBindings() { + if (namedBindings_ == null) { + return new com.google.protobuf.MapFieldBuilder<>(namedBindingsConverter); + } + return namedBindings_; + } + + private com.google.protobuf.MapFieldBuilder< + java.lang.String, + com.google.datastore.v1.GqlQueryParameterOrBuilder, + com.google.datastore.v1.GqlQueryParameter, + com.google.datastore.v1.GqlQueryParameter.Builder> + internalGetMutableNamedBindings() { + if (namedBindings_ == null) { + namedBindings_ = new com.google.protobuf.MapFieldBuilder<>(namedBindingsConverter); + } + bitField0_ |= 0x00000004; + onChanged(); + return namedBindings_; + } + + public int getNamedBindingsCount() { + return internalGetNamedBindings().ensureBuilderMap().size(); + } + + /** + * + * + *
+     * For each non-reserved named binding site in the query string, there must be
+     * a named parameter with that name, but not necessarily the inverse.
+     *
+     * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+     * `__.*__`, and must not be `""`.
+     * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + @java.lang.Override + public boolean containsNamedBindings(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + return internalGetNamedBindings().ensureBuilderMap().containsKey(key); + } + + /** Use {@link #getNamedBindingsMap()} instead. */ + @java.lang.Override + @java.lang.Deprecated + public java.util.Map + getNamedBindings() { + return getNamedBindingsMap(); + } + + /** + * + * + *
+     * For each non-reserved named binding site in the query string, there must be
+     * a named parameter with that name, but not necessarily the inverse.
+     *
+     * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+     * `__.*__`, and must not be `""`.
+     * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + @java.lang.Override + public java.util.Map + getNamedBindingsMap() { + return internalGetNamedBindings().getImmutableMap(); + } + + /** + * + * + *
+     * For each non-reserved named binding site in the query string, there must be
+     * a named parameter with that name, but not necessarily the inverse.
+     *
+     * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+     * `__.*__`, and must not be `""`.
+     * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + @java.lang.Override + public /* nullable */ com.google.datastore.v1.GqlQueryParameter getNamedBindingsOrDefault( + java.lang.String key, + /* nullable */ + com.google.datastore.v1.GqlQueryParameter defaultValue) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableNamedBindings().ensureBuilderMap(); + return map.containsKey(key) ? namedBindingsConverter.build(map.get(key)) : defaultValue; + } + + /** + * + * + *
+     * For each non-reserved named binding site in the query string, there must be
+     * a named parameter with that name, but not necessarily the inverse.
+     *
+     * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+     * `__.*__`, and must not be `""`.
+     * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + @java.lang.Override + public com.google.datastore.v1.GqlQueryParameter getNamedBindingsOrThrow(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + java.util.Map map = + internalGetMutableNamedBindings().ensureBuilderMap(); + if (!map.containsKey(key)) { + throw new java.lang.IllegalArgumentException(); + } + return namedBindingsConverter.build(map.get(key)); + } + + public Builder clearNamedBindings() { + bitField0_ = (bitField0_ & ~0x00000004); + internalGetMutableNamedBindings().clear(); + return this; + } + + /** + * + * + *
+     * For each non-reserved named binding site in the query string, there must be
+     * a named parameter with that name, but not necessarily the inverse.
+     *
+     * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+     * `__.*__`, and must not be `""`.
+     * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + public Builder removeNamedBindings(java.lang.String key) { + if (key == null) { + throw new NullPointerException("map key"); + } + internalGetMutableNamedBindings().ensureBuilderMap().remove(key); + return this; + } + + /** Use alternate mutation accessors instead. */ + @java.lang.Deprecated + public java.util.Map + getMutableNamedBindings() { + bitField0_ |= 0x00000004; + return internalGetMutableNamedBindings().ensureMessageMap(); + } + + /** + * + * + *
+     * For each non-reserved named binding site in the query string, there must be
+     * a named parameter with that name, but not necessarily the inverse.
+     *
+     * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+     * `__.*__`, and must not be `""`.
+     * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + public Builder putNamedBindings( + java.lang.String key, com.google.datastore.v1.GqlQueryParameter value) { + if (key == null) { + throw new NullPointerException("map key"); + } + if (value == null) { + throw new NullPointerException("map value"); + } + internalGetMutableNamedBindings().ensureBuilderMap().put(key, value); + bitField0_ |= 0x00000004; + return this; + } + + /** + * + * + *
+     * For each non-reserved named binding site in the query string, there must be
+     * a named parameter with that name, but not necessarily the inverse.
+     *
+     * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+     * `__.*__`, and must not be `""`.
+     * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + public Builder putAllNamedBindings( + java.util.Map values) { + for (java.util.Map.Entry e : + values.entrySet()) { + if (e.getKey() == null || e.getValue() == null) { + throw new NullPointerException(); + } + } + internalGetMutableNamedBindings().ensureBuilderMap().putAll(values); + bitField0_ |= 0x00000004; + return this; + } + + /** + * + * + *
+     * For each non-reserved named binding site in the query string, there must be
+     * a named parameter with that name, but not necessarily the inverse.
+     *
+     * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+     * `__.*__`, and must not be `""`.
+     * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + public com.google.datastore.v1.GqlQueryParameter.Builder putNamedBindingsBuilderIfAbsent( + java.lang.String key) { + java.util.Map + builderMap = internalGetMutableNamedBindings().ensureBuilderMap(); + com.google.datastore.v1.GqlQueryParameterOrBuilder entry = builderMap.get(key); + if (entry == null) { + entry = com.google.datastore.v1.GqlQueryParameter.newBuilder(); + builderMap.put(key, entry); + } + if (entry instanceof com.google.datastore.v1.GqlQueryParameter) { + entry = ((com.google.datastore.v1.GqlQueryParameter) entry).toBuilder(); + builderMap.put(key, entry); + } + return (com.google.datastore.v1.GqlQueryParameter.Builder) entry; + } + + private java.util.List positionalBindings_ = + java.util.Collections.emptyList(); + + private void ensurePositionalBindingsIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + positionalBindings_ = + new java.util.ArrayList(positionalBindings_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.GqlQueryParameter, + com.google.datastore.v1.GqlQueryParameter.Builder, + com.google.datastore.v1.GqlQueryParameterOrBuilder> + positionalBindingsBuilder_; + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public java.util.List getPositionalBindingsList() { + if (positionalBindingsBuilder_ == null) { + return java.util.Collections.unmodifiableList(positionalBindings_); + } else { + return positionalBindingsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public int getPositionalBindingsCount() { + if (positionalBindingsBuilder_ == null) { + return positionalBindings_.size(); + } else { + return positionalBindingsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public com.google.datastore.v1.GqlQueryParameter getPositionalBindings(int index) { + if (positionalBindingsBuilder_ == null) { + return positionalBindings_.get(index); + } else { + return positionalBindingsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public Builder setPositionalBindings( + int index, com.google.datastore.v1.GqlQueryParameter value) { + if (positionalBindingsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePositionalBindingsIsMutable(); + positionalBindings_.set(index, value); + onChanged(); + } else { + positionalBindingsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public Builder setPositionalBindings( + int index, com.google.datastore.v1.GqlQueryParameter.Builder builderForValue) { + if (positionalBindingsBuilder_ == null) { + ensurePositionalBindingsIsMutable(); + positionalBindings_.set(index, builderForValue.build()); + onChanged(); + } else { + positionalBindingsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public Builder addPositionalBindings(com.google.datastore.v1.GqlQueryParameter value) { + if (positionalBindingsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePositionalBindingsIsMutable(); + positionalBindings_.add(value); + onChanged(); + } else { + positionalBindingsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public Builder addPositionalBindings( + int index, com.google.datastore.v1.GqlQueryParameter value) { + if (positionalBindingsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePositionalBindingsIsMutable(); + positionalBindings_.add(index, value); + onChanged(); + } else { + positionalBindingsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public Builder addPositionalBindings( + com.google.datastore.v1.GqlQueryParameter.Builder builderForValue) { + if (positionalBindingsBuilder_ == null) { + ensurePositionalBindingsIsMutable(); + positionalBindings_.add(builderForValue.build()); + onChanged(); + } else { + positionalBindingsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public Builder addPositionalBindings( + int index, com.google.datastore.v1.GqlQueryParameter.Builder builderForValue) { + if (positionalBindingsBuilder_ == null) { + ensurePositionalBindingsIsMutable(); + positionalBindings_.add(index, builderForValue.build()); + onChanged(); + } else { + positionalBindingsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public Builder addAllPositionalBindings( + java.lang.Iterable values) { + if (positionalBindingsBuilder_ == null) { + ensurePositionalBindingsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, positionalBindings_); + onChanged(); + } else { + positionalBindingsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public Builder clearPositionalBindings() { + if (positionalBindingsBuilder_ == null) { + positionalBindings_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + positionalBindingsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public Builder removePositionalBindings(int index) { + if (positionalBindingsBuilder_ == null) { + ensurePositionalBindingsIsMutable(); + positionalBindings_.remove(index); + onChanged(); + } else { + positionalBindingsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public com.google.datastore.v1.GqlQueryParameter.Builder getPositionalBindingsBuilder( + int index) { + return getPositionalBindingsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public com.google.datastore.v1.GqlQueryParameterOrBuilder getPositionalBindingsOrBuilder( + int index) { + if (positionalBindingsBuilder_ == null) { + return positionalBindings_.get(index); + } else { + return positionalBindingsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public java.util.List + getPositionalBindingsOrBuilderList() { + if (positionalBindingsBuilder_ != null) { + return positionalBindingsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(positionalBindings_); + } + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public com.google.datastore.v1.GqlQueryParameter.Builder addPositionalBindingsBuilder() { + return getPositionalBindingsFieldBuilder() + .addBuilder(com.google.datastore.v1.GqlQueryParameter.getDefaultInstance()); + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public com.google.datastore.v1.GqlQueryParameter.Builder addPositionalBindingsBuilder( + int index) { + return getPositionalBindingsFieldBuilder() + .addBuilder(index, com.google.datastore.v1.GqlQueryParameter.getDefaultInstance()); + } + + /** + * + * + *
+     * Numbered binding site @1 references the first numbered parameter,
+     * effectively using 1-based indexing, rather than the usual 0.
+     *
+     * For each binding site numbered i in `query_string`, there must be an i-th
+     * numbered parameter. The inverse must also be true.
+     * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + public java.util.List + getPositionalBindingsBuilderList() { + return getPositionalBindingsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.GqlQueryParameter, + com.google.datastore.v1.GqlQueryParameter.Builder, + com.google.datastore.v1.GqlQueryParameterOrBuilder> + getPositionalBindingsFieldBuilder() { + if (positionalBindingsBuilder_ == null) { + positionalBindingsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.GqlQueryParameter, + com.google.datastore.v1.GqlQueryParameter.Builder, + com.google.datastore.v1.GqlQueryParameterOrBuilder>( + positionalBindings_, + ((bitField0_ & 0x00000008) != 0), + getParentForChildren(), + isClean()); + positionalBindings_ = null; + } + return positionalBindingsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.GqlQuery) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.GqlQuery) + private static final com.google.datastore.v1.GqlQuery DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.GqlQuery(); + } + + public static com.google.datastore.v1.GqlQuery getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GqlQuery 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.datastore.v1.GqlQuery getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryOrBuilder.java new file mode 100644 index 000000000000..8ab95e172501 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryOrBuilder.java @@ -0,0 +1,229 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface GqlQueryOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.GqlQuery) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A string of the format described
+   * [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+   * 
+ * + * string query_string = 1; + * + * @return The queryString. + */ + java.lang.String getQueryString(); + + /** + * + * + *
+   * A string of the format described
+   * [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference).
+   * 
+ * + * string query_string = 1; + * + * @return The bytes for queryString. + */ + com.google.protobuf.ByteString getQueryStringBytes(); + + /** + * + * + *
+   * When false, the query string must not contain any literals and instead must
+   * bind all values. For example,
+   * `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while
+   * `SELECT * FROM Kind WHERE a = @value` is.
+   * 
+ * + * bool allow_literals = 2; + * + * @return The allowLiterals. + */ + boolean getAllowLiterals(); + + /** + * + * + *
+   * For each non-reserved named binding site in the query string, there must be
+   * a named parameter with that name, but not necessarily the inverse.
+   *
+   * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+   * `__.*__`, and must not be `""`.
+   * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + int getNamedBindingsCount(); + + /** + * + * + *
+   * For each non-reserved named binding site in the query string, there must be
+   * a named parameter with that name, but not necessarily the inverse.
+   *
+   * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+   * `__.*__`, and must not be `""`.
+   * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + boolean containsNamedBindings(java.lang.String key); + + /** Use {@link #getNamedBindingsMap()} instead. */ + @java.lang.Deprecated + java.util.Map getNamedBindings(); + + /** + * + * + *
+   * For each non-reserved named binding site in the query string, there must be
+   * a named parameter with that name, but not necessarily the inverse.
+   *
+   * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+   * `__.*__`, and must not be `""`.
+   * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + java.util.Map getNamedBindingsMap(); + + /** + * + * + *
+   * For each non-reserved named binding site in the query string, there must be
+   * a named parameter with that name, but not necessarily the inverse.
+   *
+   * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+   * `__.*__`, and must not be `""`.
+   * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + /* nullable */ + com.google.datastore.v1.GqlQueryParameter getNamedBindingsOrDefault( + java.lang.String key, + /* nullable */ + com.google.datastore.v1.GqlQueryParameter defaultValue); + + /** + * + * + *
+   * For each non-reserved named binding site in the query string, there must be
+   * a named parameter with that name, but not necessarily the inverse.
+   *
+   * Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex
+   * `__.*__`, and must not be `""`.
+   * 
+ * + * map<string, .google.datastore.v1.GqlQueryParameter> named_bindings = 5; + */ + com.google.datastore.v1.GqlQueryParameter getNamedBindingsOrThrow(java.lang.String key); + + /** + * + * + *
+   * Numbered binding site @1 references the first numbered parameter,
+   * effectively using 1-based indexing, rather than the usual 0.
+   *
+   * For each binding site numbered i in `query_string`, there must be an i-th
+   * numbered parameter. The inverse must also be true.
+   * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + java.util.List getPositionalBindingsList(); + + /** + * + * + *
+   * Numbered binding site @1 references the first numbered parameter,
+   * effectively using 1-based indexing, rather than the usual 0.
+   *
+   * For each binding site numbered i in `query_string`, there must be an i-th
+   * numbered parameter. The inverse must also be true.
+   * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + com.google.datastore.v1.GqlQueryParameter getPositionalBindings(int index); + + /** + * + * + *
+   * Numbered binding site @1 references the first numbered parameter,
+   * effectively using 1-based indexing, rather than the usual 0.
+   *
+   * For each binding site numbered i in `query_string`, there must be an i-th
+   * numbered parameter. The inverse must also be true.
+   * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + int getPositionalBindingsCount(); + + /** + * + * + *
+   * Numbered binding site @1 references the first numbered parameter,
+   * effectively using 1-based indexing, rather than the usual 0.
+   *
+   * For each binding site numbered i in `query_string`, there must be an i-th
+   * numbered parameter. The inverse must also be true.
+   * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + java.util.List + getPositionalBindingsOrBuilderList(); + + /** + * + * + *
+   * Numbered binding site @1 references the first numbered parameter,
+   * effectively using 1-based indexing, rather than the usual 0.
+   *
+   * For each binding site numbered i in `query_string`, there must be an i-th
+   * numbered parameter. The inverse must also be true.
+   * 
+ * + * repeated .google.datastore.v1.GqlQueryParameter positional_bindings = 4; + */ + com.google.datastore.v1.GqlQueryParameterOrBuilder getPositionalBindingsOrBuilder(int index); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameter.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameter.java new file mode 100644 index 000000000000..69a6fab1f7e6 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameter.java @@ -0,0 +1,975 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A binding parameter for a GQL query.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.GqlQueryParameter} + */ +public final class GqlQueryParameter extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.GqlQueryParameter) + GqlQueryParameterOrBuilder { + private static final long serialVersionUID = 0L; + + // Use GqlQueryParameter.newBuilder() to construct. + private GqlQueryParameter(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private GqlQueryParameter() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GqlQueryParameter(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQueryParameter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQueryParameter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.GqlQueryParameter.class, + com.google.datastore.v1.GqlQueryParameter.Builder.class); + } + + private int parameterTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object parameterType_; + + public enum ParameterTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + VALUE(2), + CURSOR(3), + PARAMETERTYPE_NOT_SET(0); + private final int value; + + private ParameterTypeCase(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 ParameterTypeCase valueOf(int value) { + return forNumber(value); + } + + public static ParameterTypeCase forNumber(int value) { + switch (value) { + case 2: + return VALUE; + case 3: + return CURSOR; + case 0: + return PARAMETERTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ParameterTypeCase getParameterTypeCase() { + return ParameterTypeCase.forNumber(parameterTypeCase_); + } + + public static final int VALUE_FIELD_NUMBER = 2; + + /** + * + * + *
+   * A value parameter.
+   * 
+ * + * .google.datastore.v1.Value value = 2; + * + * @return Whether the value field is set. + */ + @java.lang.Override + public boolean hasValue() { + return parameterTypeCase_ == 2; + } + + /** + * + * + *
+   * A value parameter.
+   * 
+ * + * .google.datastore.v1.Value value = 2; + * + * @return The value. + */ + @java.lang.Override + public com.google.datastore.v1.Value getValue() { + if (parameterTypeCase_ == 2) { + return (com.google.datastore.v1.Value) parameterType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + /** + * + * + *
+   * A value parameter.
+   * 
+ * + * .google.datastore.v1.Value value = 2; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getValueOrBuilder() { + if (parameterTypeCase_ == 2) { + return (com.google.datastore.v1.Value) parameterType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + public static final int CURSOR_FIELD_NUMBER = 3; + + /** + * + * + *
+   * A query cursor. Query cursors are returned in query
+   * result batches.
+   * 
+ * + * bytes cursor = 3; + * + * @return Whether the cursor field is set. + */ + @java.lang.Override + public boolean hasCursor() { + return parameterTypeCase_ == 3; + } + + /** + * + * + *
+   * A query cursor. Query cursors are returned in query
+   * result batches.
+   * 
+ * + * bytes cursor = 3; + * + * @return The cursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getCursor() { + if (parameterTypeCase_ == 3) { + return (com.google.protobuf.ByteString) parameterType_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + 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 (parameterTypeCase_ == 2) { + output.writeMessage(2, (com.google.datastore.v1.Value) parameterType_); + } + if (parameterTypeCase_ == 3) { + output.writeBytes(3, (com.google.protobuf.ByteString) parameterType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (parameterTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.datastore.v1.Value) parameterType_); + } + if (parameterTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 3, (com.google.protobuf.ByteString) parameterType_); + } + 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.datastore.v1.GqlQueryParameter)) { + return super.equals(obj); + } + com.google.datastore.v1.GqlQueryParameter other = + (com.google.datastore.v1.GqlQueryParameter) obj; + + if (!getParameterTypeCase().equals(other.getParameterTypeCase())) return false; + switch (parameterTypeCase_) { + case 2: + if (!getValue().equals(other.getValue())) return false; + break; + case 3: + if (!getCursor().equals(other.getCursor())) 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 (parameterTypeCase_) { + case 2: + hash = (37 * hash) + VALUE_FIELD_NUMBER; + hash = (53 * hash) + getValue().hashCode(); + break; + case 3: + hash = (37 * hash) + CURSOR_FIELD_NUMBER; + hash = (53 * hash) + getCursor().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.GqlQueryParameter parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.GqlQueryParameter parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.GqlQueryParameter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.GqlQueryParameter 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.datastore.v1.GqlQueryParameter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.GqlQueryParameter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.GqlQueryParameter parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.GqlQueryParameter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.GqlQueryParameter parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.GqlQueryParameter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.GqlQueryParameter parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.GqlQueryParameter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.GqlQueryParameter 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A binding parameter for a GQL query.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.GqlQueryParameter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.GqlQueryParameter) + com.google.datastore.v1.GqlQueryParameterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQueryParameter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQueryParameter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.GqlQueryParameter.class, + com.google.datastore.v1.GqlQueryParameter.Builder.class); + } + + // Construct using com.google.datastore.v1.GqlQueryParameter.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (valueBuilder_ != null) { + valueBuilder_.clear(); + } + parameterTypeCase_ = 0; + parameterType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_GqlQueryParameter_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.GqlQueryParameter getDefaultInstanceForType() { + return com.google.datastore.v1.GqlQueryParameter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.GqlQueryParameter build() { + com.google.datastore.v1.GqlQueryParameter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.GqlQueryParameter buildPartial() { + com.google.datastore.v1.GqlQueryParameter result = + new com.google.datastore.v1.GqlQueryParameter(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.GqlQueryParameter result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.datastore.v1.GqlQueryParameter result) { + result.parameterTypeCase_ = parameterTypeCase_; + result.parameterType_ = this.parameterType_; + if (parameterTypeCase_ == 2 && valueBuilder_ != null) { + result.parameterType_ = valueBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.GqlQueryParameter) { + return mergeFrom((com.google.datastore.v1.GqlQueryParameter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.GqlQueryParameter other) { + if (other == com.google.datastore.v1.GqlQueryParameter.getDefaultInstance()) return this; + switch (other.getParameterTypeCase()) { + case VALUE: + { + mergeValue(other.getValue()); + break; + } + case CURSOR: + { + setCursor(other.getCursor()); + break; + } + case PARAMETERTYPE_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(getValueFieldBuilder().getBuilder(), extensionRegistry); + parameterTypeCase_ = 2; + break; + } // case 18 + case 26: + { + parameterType_ = input.readBytes(); + parameterTypeCase_ = 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 parameterTypeCase_ = 0; + private java.lang.Object parameterType_; + + public ParameterTypeCase getParameterTypeCase() { + return ParameterTypeCase.forNumber(parameterTypeCase_); + } + + public Builder clearParameterType() { + parameterTypeCase_ = 0; + parameterType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + valueBuilder_; + + /** + * + * + *
+     * A value parameter.
+     * 
+ * + * .google.datastore.v1.Value value = 2; + * + * @return Whether the value field is set. + */ + @java.lang.Override + public boolean hasValue() { + return parameterTypeCase_ == 2; + } + + /** + * + * + *
+     * A value parameter.
+     * 
+ * + * .google.datastore.v1.Value value = 2; + * + * @return The value. + */ + @java.lang.Override + public com.google.datastore.v1.Value getValue() { + if (valueBuilder_ == null) { + if (parameterTypeCase_ == 2) { + return (com.google.datastore.v1.Value) parameterType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } else { + if (parameterTypeCase_ == 2) { + return valueBuilder_.getMessage(); + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A value parameter.
+     * 
+ * + * .google.datastore.v1.Value value = 2; + */ + public Builder setValue(com.google.datastore.v1.Value value) { + if (valueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + parameterType_ = value; + onChanged(); + } else { + valueBuilder_.setMessage(value); + } + parameterTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A value parameter.
+     * 
+ * + * .google.datastore.v1.Value value = 2; + */ + public Builder setValue(com.google.datastore.v1.Value.Builder builderForValue) { + if (valueBuilder_ == null) { + parameterType_ = builderForValue.build(); + onChanged(); + } else { + valueBuilder_.setMessage(builderForValue.build()); + } + parameterTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A value parameter.
+     * 
+ * + * .google.datastore.v1.Value value = 2; + */ + public Builder mergeValue(com.google.datastore.v1.Value value) { + if (valueBuilder_ == null) { + if (parameterTypeCase_ == 2 + && parameterType_ != com.google.datastore.v1.Value.getDefaultInstance()) { + parameterType_ = + com.google.datastore.v1.Value.newBuilder( + (com.google.datastore.v1.Value) parameterType_) + .mergeFrom(value) + .buildPartial(); + } else { + parameterType_ = value; + } + onChanged(); + } else { + if (parameterTypeCase_ == 2) { + valueBuilder_.mergeFrom(value); + } else { + valueBuilder_.setMessage(value); + } + } + parameterTypeCase_ = 2; + return this; + } + + /** + * + * + *
+     * A value parameter.
+     * 
+ * + * .google.datastore.v1.Value value = 2; + */ + public Builder clearValue() { + if (valueBuilder_ == null) { + if (parameterTypeCase_ == 2) { + parameterTypeCase_ = 0; + parameterType_ = null; + onChanged(); + } + } else { + if (parameterTypeCase_ == 2) { + parameterTypeCase_ = 0; + parameterType_ = null; + } + valueBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A value parameter.
+     * 
+ * + * .google.datastore.v1.Value value = 2; + */ + public com.google.datastore.v1.Value.Builder getValueBuilder() { + return getValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A value parameter.
+     * 
+ * + * .google.datastore.v1.Value value = 2; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getValueOrBuilder() { + if ((parameterTypeCase_ == 2) && (valueBuilder_ != null)) { + return valueBuilder_.getMessageOrBuilder(); + } else { + if (parameterTypeCase_ == 2) { + return (com.google.datastore.v1.Value) parameterType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A value parameter.
+     * 
+ * + * .google.datastore.v1.Value value = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getValueFieldBuilder() { + if (valueBuilder_ == null) { + if (!(parameterTypeCase_ == 2)) { + parameterType_ = com.google.datastore.v1.Value.getDefaultInstance(); + } + valueBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + (com.google.datastore.v1.Value) parameterType_, getParentForChildren(), isClean()); + parameterType_ = null; + } + parameterTypeCase_ = 2; + onChanged(); + return valueBuilder_; + } + + /** + * + * + *
+     * A query cursor. Query cursors are returned in query
+     * result batches.
+     * 
+ * + * bytes cursor = 3; + * + * @return Whether the cursor field is set. + */ + public boolean hasCursor() { + return parameterTypeCase_ == 3; + } + + /** + * + * + *
+     * A query cursor. Query cursors are returned in query
+     * result batches.
+     * 
+ * + * bytes cursor = 3; + * + * @return The cursor. + */ + public com.google.protobuf.ByteString getCursor() { + if (parameterTypeCase_ == 3) { + return (com.google.protobuf.ByteString) parameterType_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * A query cursor. Query cursors are returned in query
+     * result batches.
+     * 
+ * + * bytes cursor = 3; + * + * @param value The cursor to set. + * @return This builder for chaining. + */ + public Builder setCursor(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + parameterTypeCase_ = 3; + parameterType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * A query cursor. Query cursors are returned in query
+     * result batches.
+     * 
+ * + * bytes cursor = 3; + * + * @return This builder for chaining. + */ + public Builder clearCursor() { + if (parameterTypeCase_ == 3) { + parameterTypeCase_ = 0; + parameterType_ = null; + onChanged(); + } + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.GqlQueryParameter) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.GqlQueryParameter) + private static final com.google.datastore.v1.GqlQueryParameter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.GqlQueryParameter(); + } + + public static com.google.datastore.v1.GqlQueryParameter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GqlQueryParameter 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.datastore.v1.GqlQueryParameter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameterOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameterOrBuilder.java new file mode 100644 index 000000000000..896cd02f4bd2 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/GqlQueryParameterOrBuilder.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! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface GqlQueryParameterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.GqlQueryParameter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A value parameter.
+   * 
+ * + * .google.datastore.v1.Value value = 2; + * + * @return Whether the value field is set. + */ + boolean hasValue(); + + /** + * + * + *
+   * A value parameter.
+   * 
+ * + * .google.datastore.v1.Value value = 2; + * + * @return The value. + */ + com.google.datastore.v1.Value getValue(); + + /** + * + * + *
+   * A value parameter.
+   * 
+ * + * .google.datastore.v1.Value value = 2; + */ + com.google.datastore.v1.ValueOrBuilder getValueOrBuilder(); + + /** + * + * + *
+   * A query cursor. Query cursors are returned in query
+   * result batches.
+   * 
+ * + * bytes cursor = 3; + * + * @return Whether the cursor field is set. + */ + boolean hasCursor(); + + /** + * + * + *
+   * A query cursor. Query cursors are returned in query
+   * result batches.
+   * 
+ * + * bytes cursor = 3; + * + * @return The cursor. + */ + com.google.protobuf.ByteString getCursor(); + + com.google.datastore.v1.GqlQueryParameter.ParameterTypeCase getParameterTypeCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Key.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Key.java new file mode 100644 index 000000000000..152ae407948f --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Key.java @@ -0,0 +1,2994 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A unique identifier for an entity.
+ * If a key's partition ID or any of its path kinds or names are
+ * reserved/read-only, the key is reserved/read-only.
+ * A reserved/read-only key is forbidden in certain documented contexts.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.Key} + */ +public final class Key extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.Key) + KeyOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Key.newBuilder() to construct. + private Key(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Key() { + path_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Key(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto.internal_static_google_datastore_v1_Key_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Key_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Key.class, com.google.datastore.v1.Key.Builder.class); + } + + public interface PathElementOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.Key.PathElement) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The kind of the entity.
+     *
+     * A kind matching regex `__.*__` is reserved/read-only.
+     * A kind must not contain more than 1500 bytes when UTF-8 encoded.
+     * Cannot be `""`.
+     *
+     * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+     * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+     * bytes.
+     * 
+ * + * string kind = 1; + * + * @return The kind. + */ + java.lang.String getKind(); + + /** + * + * + *
+     * The kind of the entity.
+     *
+     * A kind matching regex `__.*__` is reserved/read-only.
+     * A kind must not contain more than 1500 bytes when UTF-8 encoded.
+     * Cannot be `""`.
+     *
+     * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+     * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+     * bytes.
+     * 
+ * + * string kind = 1; + * + * @return The bytes for kind. + */ + com.google.protobuf.ByteString getKindBytes(); + + /** + * + * + *
+     * The auto-allocated ID of the entity.
+     *
+     * Never equal to zero. Values less than zero are discouraged and may not
+     * be supported in the future.
+     * 
+ * + * int64 id = 2; + * + * @return Whether the id field is set. + */ + boolean hasId(); + + /** + * + * + *
+     * The auto-allocated ID of the entity.
+     *
+     * Never equal to zero. Values less than zero are discouraged and may not
+     * be supported in the future.
+     * 
+ * + * int64 id = 2; + * + * @return The id. + */ + long getId(); + + /** + * + * + *
+     * The name of the entity.
+     *
+     * A name matching regex `__.*__` is reserved/read-only.
+     * A name must not be more than 1500 bytes when UTF-8 encoded.
+     * Cannot be `""`.
+     *
+     * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+     * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+     * bytes.
+     * 
+ * + * string name = 3; + * + * @return Whether the name field is set. + */ + boolean hasName(); + + /** + * + * + *
+     * The name of the entity.
+     *
+     * A name matching regex `__.*__` is reserved/read-only.
+     * A name must not be more than 1500 bytes when UTF-8 encoded.
+     * Cannot be `""`.
+     *
+     * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+     * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+     * bytes.
+     * 
+ * + * string name = 3; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+     * The name of the entity.
+     *
+     * A name matching regex `__.*__` is reserved/read-only.
+     * A name must not be more than 1500 bytes when UTF-8 encoded.
+     * Cannot be `""`.
+     *
+     * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+     * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+     * bytes.
+     * 
+ * + * string name = 3; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + com.google.datastore.v1.Key.PathElement.IdTypeCase getIdTypeCase(); + } + + /** + * + * + *
+   * A (kind, ID/name) pair used to construct a key path.
+   *
+   * If either name or ID is set, the element is complete.
+   * If neither is set, the element is incomplete.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.Key.PathElement} + */ + public static final class PathElement extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.Key.PathElement) + PathElementOrBuilder { + private static final long serialVersionUID = 0L; + + // Use PathElement.newBuilder() to construct. + private PathElement(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PathElement() { + kind_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PathElement(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Key_PathElement_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Key_PathElement_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Key.PathElement.class, + com.google.datastore.v1.Key.PathElement.Builder.class); + } + + private int idTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object idType_; + + public enum IdTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + ID(2), + NAME(3), + IDTYPE_NOT_SET(0); + private final int value; + + private IdTypeCase(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 IdTypeCase valueOf(int value) { + return forNumber(value); + } + + public static IdTypeCase forNumber(int value) { + switch (value) { + case 2: + return ID; + case 3: + return NAME; + case 0: + return IDTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public IdTypeCase getIdTypeCase() { + return IdTypeCase.forNumber(idTypeCase_); + } + + public static final int KIND_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object kind_ = ""; + + /** + * + * + *
+     * The kind of the entity.
+     *
+     * A kind matching regex `__.*__` is reserved/read-only.
+     * A kind must not contain more than 1500 bytes when UTF-8 encoded.
+     * Cannot be `""`.
+     *
+     * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+     * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+     * bytes.
+     * 
+ * + * string kind = 1; + * + * @return The kind. + */ + @java.lang.Override + public java.lang.String getKind() { + java.lang.Object ref = kind_; + 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(); + kind_ = s; + return s; + } + } + + /** + * + * + *
+     * The kind of the entity.
+     *
+     * A kind matching regex `__.*__` is reserved/read-only.
+     * A kind must not contain more than 1500 bytes when UTF-8 encoded.
+     * Cannot be `""`.
+     *
+     * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+     * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+     * bytes.
+     * 
+ * + * string kind = 1; + * + * @return The bytes for kind. + */ + @java.lang.Override + public com.google.protobuf.ByteString getKindBytes() { + java.lang.Object ref = kind_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + kind_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int ID_FIELD_NUMBER = 2; + + /** + * + * + *
+     * The auto-allocated ID of the entity.
+     *
+     * Never equal to zero. Values less than zero are discouraged and may not
+     * be supported in the future.
+     * 
+ * + * int64 id = 2; + * + * @return Whether the id field is set. + */ + @java.lang.Override + public boolean hasId() { + return idTypeCase_ == 2; + } + + /** + * + * + *
+     * The auto-allocated ID of the entity.
+     *
+     * Never equal to zero. Values less than zero are discouraged and may not
+     * be supported in the future.
+     * 
+ * + * int64 id = 2; + * + * @return The id. + */ + @java.lang.Override + public long getId() { + if (idTypeCase_ == 2) { + return (java.lang.Long) idType_; + } + return 0L; + } + + public static final int NAME_FIELD_NUMBER = 3; + + /** + * + * + *
+     * The name of the entity.
+     *
+     * A name matching regex `__.*__` is reserved/read-only.
+     * A name must not be more than 1500 bytes when UTF-8 encoded.
+     * Cannot be `""`.
+     *
+     * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+     * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+     * bytes.
+     * 
+ * + * string name = 3; + * + * @return Whether the name field is set. + */ + public boolean hasName() { + return idTypeCase_ == 3; + } + + /** + * + * + *
+     * The name of the entity.
+     *
+     * A name matching regex `__.*__` is reserved/read-only.
+     * A name must not be more than 1500 bytes when UTF-8 encoded.
+     * Cannot be `""`.
+     *
+     * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+     * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+     * bytes.
+     * 
+ * + * string name = 3; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = ""; + if (idTypeCase_ == 3) { + ref = idType_; + } + 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 (idTypeCase_ == 3) { + idType_ = s; + } + return s; + } + } + + /** + * + * + *
+     * The name of the entity.
+     *
+     * A name matching regex `__.*__` is reserved/read-only.
+     * A name must not be more than 1500 bytes when UTF-8 encoded.
+     * Cannot be `""`.
+     *
+     * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+     * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+     * bytes.
+     * 
+ * + * string name = 3; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = ""; + if (idTypeCase_ == 3) { + ref = idType_; + } + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (idTypeCase_ == 3) { + idType_ = 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.GeneratedMessageV3.isStringEmpty(kind_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, kind_); + } + if (idTypeCase_ == 2) { + output.writeInt64(2, (long) ((java.lang.Long) idType_)); + } + if (idTypeCase_ == 3) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, idType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(kind_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, kind_); + } + if (idTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeInt64Size( + 2, (long) ((java.lang.Long) idType_)); + } + if (idTypeCase_ == 3) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, idType_); + } + 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.datastore.v1.Key.PathElement)) { + return super.equals(obj); + } + com.google.datastore.v1.Key.PathElement other = (com.google.datastore.v1.Key.PathElement) obj; + + if (!getKind().equals(other.getKind())) return false; + if (!getIdTypeCase().equals(other.getIdTypeCase())) return false; + switch (idTypeCase_) { + case 2: + if (getId() != other.getId()) return false; + break; + case 3: + if (!getName().equals(other.getName())) 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) + KIND_FIELD_NUMBER; + hash = (53 * hash) + getKind().hashCode(); + switch (idTypeCase_) { + case 2: + hash = (37 * hash) + ID_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getId()); + break; + case 3: + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.Key.PathElement parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Key.PathElement parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Key.PathElement parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Key.PathElement 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.datastore.v1.Key.PathElement parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Key.PathElement parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Key.PathElement parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Key.PathElement parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Key.PathElement parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Key.PathElement parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Key.PathElement parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Key.PathElement parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.Key.PathElement 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * A (kind, ID/name) pair used to construct a key path.
+     *
+     * If either name or ID is set, the element is complete.
+     * If neither is set, the element is incomplete.
+     * 
+ * + * Protobuf type {@code google.datastore.v1.Key.PathElement} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.Key.PathElement) + com.google.datastore.v1.Key.PathElementOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Key_PathElement_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Key_PathElement_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Key.PathElement.class, + com.google.datastore.v1.Key.PathElement.Builder.class); + } + + // Construct using com.google.datastore.v1.Key.PathElement.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + kind_ = ""; + idTypeCase_ = 0; + idType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Key_PathElement_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.Key.PathElement getDefaultInstanceForType() { + return com.google.datastore.v1.Key.PathElement.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.Key.PathElement build() { + com.google.datastore.v1.Key.PathElement result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.Key.PathElement buildPartial() { + com.google.datastore.v1.Key.PathElement result = + new com.google.datastore.v1.Key.PathElement(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.Key.PathElement result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.kind_ = kind_; + } + } + + private void buildPartialOneofs(com.google.datastore.v1.Key.PathElement result) { + result.idTypeCase_ = idTypeCase_; + result.idType_ = this.idType_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.Key.PathElement) { + return mergeFrom((com.google.datastore.v1.Key.PathElement) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.Key.PathElement other) { + if (other == com.google.datastore.v1.Key.PathElement.getDefaultInstance()) return this; + if (!other.getKind().isEmpty()) { + kind_ = other.kind_; + bitField0_ |= 0x00000001; + onChanged(); + } + switch (other.getIdTypeCase()) { + case ID: + { + setId(other.getId()); + break; + } + case NAME: + { + idTypeCase_ = 3; + idType_ = other.idType_; + onChanged(); + break; + } + case IDTYPE_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: + { + kind_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + idType_ = input.readInt64(); + idTypeCase_ = 2; + break; + } // case 16 + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + idTypeCase_ = 3; + idType_ = 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 idTypeCase_ = 0; + private java.lang.Object idType_; + + public IdTypeCase getIdTypeCase() { + return IdTypeCase.forNumber(idTypeCase_); + } + + public Builder clearIdType() { + idTypeCase_ = 0; + idType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object kind_ = ""; + + /** + * + * + *
+       * The kind of the entity.
+       *
+       * A kind matching regex `__.*__` is reserved/read-only.
+       * A kind must not contain more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string kind = 1; + * + * @return The kind. + */ + public java.lang.String getKind() { + java.lang.Object ref = kind_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + kind_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * The kind of the entity.
+       *
+       * A kind matching regex `__.*__` is reserved/read-only.
+       * A kind must not contain more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string kind = 1; + * + * @return The bytes for kind. + */ + public com.google.protobuf.ByteString getKindBytes() { + java.lang.Object ref = kind_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + kind_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * The kind of the entity.
+       *
+       * A kind matching regex `__.*__` is reserved/read-only.
+       * A kind must not contain more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string kind = 1; + * + * @param value The kind to set. + * @return This builder for chaining. + */ + public Builder setKind(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + kind_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The kind of the entity.
+       *
+       * A kind matching regex `__.*__` is reserved/read-only.
+       * A kind must not contain more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string kind = 1; + * + * @return This builder for chaining. + */ + public Builder clearKind() { + kind_ = getDefaultInstance().getKind(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+       * The kind of the entity.
+       *
+       * A kind matching regex `__.*__` is reserved/read-only.
+       * A kind must not contain more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string kind = 1; + * + * @param value The bytes for kind to set. + * @return This builder for chaining. + */ + public Builder setKindBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + kind_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The auto-allocated ID of the entity.
+       *
+       * Never equal to zero. Values less than zero are discouraged and may not
+       * be supported in the future.
+       * 
+ * + * int64 id = 2; + * + * @return Whether the id field is set. + */ + public boolean hasId() { + return idTypeCase_ == 2; + } + + /** + * + * + *
+       * The auto-allocated ID of the entity.
+       *
+       * Never equal to zero. Values less than zero are discouraged and may not
+       * be supported in the future.
+       * 
+ * + * int64 id = 2; + * + * @return The id. + */ + public long getId() { + if (idTypeCase_ == 2) { + return (java.lang.Long) idType_; + } + return 0L; + } + + /** + * + * + *
+       * The auto-allocated ID of the entity.
+       *
+       * Never equal to zero. Values less than zero are discouraged and may not
+       * be supported in the future.
+       * 
+ * + * int64 id = 2; + * + * @param value The id to set. + * @return This builder for chaining. + */ + public Builder setId(long value) { + + idTypeCase_ = 2; + idType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+       * The auto-allocated ID of the entity.
+       *
+       * Never equal to zero. Values less than zero are discouraged and may not
+       * be supported in the future.
+       * 
+ * + * int64 id = 2; + * + * @return This builder for chaining. + */ + public Builder clearId() { + if (idTypeCase_ == 2) { + idTypeCase_ = 0; + idType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * The name of the entity.
+       *
+       * A name matching regex `__.*__` is reserved/read-only.
+       * A name must not be more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string name = 3; + * + * @return Whether the name field is set. + */ + @java.lang.Override + public boolean hasName() { + return idTypeCase_ == 3; + } + + /** + * + * + *
+       * The name of the entity.
+       *
+       * A name matching regex `__.*__` is reserved/read-only.
+       * A name must not be more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string name = 3; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = ""; + if (idTypeCase_ == 3) { + ref = idType_; + } + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + if (idTypeCase_ == 3) { + idType_ = s; + } + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+       * The name of the entity.
+       *
+       * A name matching regex `__.*__` is reserved/read-only.
+       * A name must not be more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string name = 3; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = ""; + if (idTypeCase_ == 3) { + ref = idType_; + } + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + if (idTypeCase_ == 3) { + idType_ = b; + } + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+       * The name of the entity.
+       *
+       * A name matching regex `__.*__` is reserved/read-only.
+       * A name must not be more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string name = 3; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + idTypeCase_ = 3; + idType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+       * The name of the entity.
+       *
+       * A name matching regex `__.*__` is reserved/read-only.
+       * A name must not be more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string name = 3; + * + * @return This builder for chaining. + */ + public Builder clearName() { + if (idTypeCase_ == 3) { + idTypeCase_ = 0; + idType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * The name of the entity.
+       *
+       * A name matching regex `__.*__` is reserved/read-only.
+       * A name must not be more than 1500 bytes when UTF-8 encoded.
+       * Cannot be `""`.
+       *
+       * Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are
+       * encoded as `__bytes<X>__` where `<X>` is the base-64 encoding of the
+       * bytes.
+       * 
+ * + * string name = 3; + * + * @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); + idTypeCase_ = 3; + idType_ = value; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.Key.PathElement) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.Key.PathElement) + private static final com.google.datastore.v1.Key.PathElement DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.Key.PathElement(); + } + + public static com.google.datastore.v1.Key.PathElement getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PathElement 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.datastore.v1.Key.PathElement getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + private int bitField0_; + public static final int PARTITION_ID_FIELD_NUMBER = 1; + private com.google.datastore.v1.PartitionId partitionId_; + + /** + * + * + *
+   * Entities are partitioned into subsets, currently identified by a project
+   * ID and namespace ID.
+   * Queries are scoped to a single partition.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + * + * @return Whether the partitionId field is set. + */ + @java.lang.Override + public boolean hasPartitionId() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Entities are partitioned into subsets, currently identified by a project
+   * ID and namespace ID.
+   * Queries are scoped to a single partition.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + * + * @return The partitionId. + */ + @java.lang.Override + public com.google.datastore.v1.PartitionId getPartitionId() { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } + + /** + * + * + *
+   * Entities are partitioned into subsets, currently identified by a project
+   * ID and namespace ID.
+   * Queries are scoped to a single partition.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + */ + @java.lang.Override + public com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder() { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } + + public static final int PATH_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List path_; + + /** + * + * + *
+   * The entity path.
+   * An entity path consists of one or more elements composed of a kind and a
+   * string or numerical identifier, which identify entities. The first
+   * element identifies a _root entity_, the second element identifies
+   * a _child_ of the root entity, the third element identifies a child of the
+   * second entity, and so forth. The entities identified by all prefixes of
+   * the path are called the element's _ancestors_.
+   *
+   * An entity path is always fully complete: *all* of the entity's ancestors
+   * are required to be in the path along with the entity identifier itself.
+   * The only exception is that in some documented cases, the identifier in the
+   * last path element (for the entity) itself may be omitted. For example,
+   * the last path element of the key of `Mutation.insert` may have no
+   * identifier.
+   *
+   * A path can never be empty, and a path can have at most 100 elements.
+   * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + @java.lang.Override + public java.util.List getPathList() { + return path_; + } + + /** + * + * + *
+   * The entity path.
+   * An entity path consists of one or more elements composed of a kind and a
+   * string or numerical identifier, which identify entities. The first
+   * element identifies a _root entity_, the second element identifies
+   * a _child_ of the root entity, the third element identifies a child of the
+   * second entity, and so forth. The entities identified by all prefixes of
+   * the path are called the element's _ancestors_.
+   *
+   * An entity path is always fully complete: *all* of the entity's ancestors
+   * are required to be in the path along with the entity identifier itself.
+   * The only exception is that in some documented cases, the identifier in the
+   * last path element (for the entity) itself may be omitted. For example,
+   * the last path element of the key of `Mutation.insert` may have no
+   * identifier.
+   *
+   * A path can never be empty, and a path can have at most 100 elements.
+   * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + @java.lang.Override + public java.util.List + getPathOrBuilderList() { + return path_; + } + + /** + * + * + *
+   * The entity path.
+   * An entity path consists of one or more elements composed of a kind and a
+   * string or numerical identifier, which identify entities. The first
+   * element identifies a _root entity_, the second element identifies
+   * a _child_ of the root entity, the third element identifies a child of the
+   * second entity, and so forth. The entities identified by all prefixes of
+   * the path are called the element's _ancestors_.
+   *
+   * An entity path is always fully complete: *all* of the entity's ancestors
+   * are required to be in the path along with the entity identifier itself.
+   * The only exception is that in some documented cases, the identifier in the
+   * last path element (for the entity) itself may be omitted. For example,
+   * the last path element of the key of `Mutation.insert` may have no
+   * identifier.
+   *
+   * A path can never be empty, and a path can have at most 100 elements.
+   * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + @java.lang.Override + public int getPathCount() { + return path_.size(); + } + + /** + * + * + *
+   * The entity path.
+   * An entity path consists of one or more elements composed of a kind and a
+   * string or numerical identifier, which identify entities. The first
+   * element identifies a _root entity_, the second element identifies
+   * a _child_ of the root entity, the third element identifies a child of the
+   * second entity, and so forth. The entities identified by all prefixes of
+   * the path are called the element's _ancestors_.
+   *
+   * An entity path is always fully complete: *all* of the entity's ancestors
+   * are required to be in the path along with the entity identifier itself.
+   * The only exception is that in some documented cases, the identifier in the
+   * last path element (for the entity) itself may be omitted. For example,
+   * the last path element of the key of `Mutation.insert` may have no
+   * identifier.
+   *
+   * A path can never be empty, and a path can have at most 100 elements.
+   * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + @java.lang.Override + public com.google.datastore.v1.Key.PathElement getPath(int index) { + return path_.get(index); + } + + /** + * + * + *
+   * The entity path.
+   * An entity path consists of one or more elements composed of a kind and a
+   * string or numerical identifier, which identify entities. The first
+   * element identifies a _root entity_, the second element identifies
+   * a _child_ of the root entity, the third element identifies a child of the
+   * second entity, and so forth. The entities identified by all prefixes of
+   * the path are called the element's _ancestors_.
+   *
+   * An entity path is always fully complete: *all* of the entity's ancestors
+   * are required to be in the path along with the entity identifier itself.
+   * The only exception is that in some documented cases, the identifier in the
+   * last path element (for the entity) itself may be omitted. For example,
+   * the last path element of the key of `Mutation.insert` may have no
+   * identifier.
+   *
+   * A path can never be empty, and a path can have at most 100 elements.
+   * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + @java.lang.Override + public com.google.datastore.v1.Key.PathElementOrBuilder getPathOrBuilder(int index) { + return path_.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, getPartitionId()); + } + for (int i = 0; i < path_.size(); i++) { + output.writeMessage(2, path_.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, getPartitionId()); + } + for (int i = 0; i < path_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, path_.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.datastore.v1.Key)) { + return super.equals(obj); + } + com.google.datastore.v1.Key other = (com.google.datastore.v1.Key) obj; + + if (hasPartitionId() != other.hasPartitionId()) return false; + if (hasPartitionId()) { + if (!getPartitionId().equals(other.getPartitionId())) return false; + } + if (!getPathList().equals(other.getPathList())) 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 (hasPartitionId()) { + hash = (37 * hash) + PARTITION_ID_FIELD_NUMBER; + hash = (53 * hash) + getPartitionId().hashCode(); + } + if (getPathCount() > 0) { + hash = (37 * hash) + PATH_FIELD_NUMBER; + hash = (53 * hash) + getPathList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.Key parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Key parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Key parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Key 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.datastore.v1.Key parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Key parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Key parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Key parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Key parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Key parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Key parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Key parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.Key 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A unique identifier for an entity.
+   * If a key's partition ID or any of its path kinds or names are
+   * reserved/read-only, the key is reserved/read-only.
+   * A reserved/read-only key is forbidden in certain documented contexts.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.Key} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.Key) + com.google.datastore.v1.KeyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto.internal_static_google_datastore_v1_Key_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Key_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Key.class, com.google.datastore.v1.Key.Builder.class); + } + + // Construct using com.google.datastore.v1.Key.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPartitionIdFieldBuilder(); + getPathFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + partitionId_ = null; + if (partitionIdBuilder_ != null) { + partitionIdBuilder_.dispose(); + partitionIdBuilder_ = null; + } + if (pathBuilder_ == null) { + path_ = java.util.Collections.emptyList(); + } else { + path_ = null; + pathBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.EntityProto.internal_static_google_datastore_v1_Key_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.Key getDefaultInstanceForType() { + return com.google.datastore.v1.Key.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.Key build() { + com.google.datastore.v1.Key result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.Key buildPartial() { + com.google.datastore.v1.Key result = new com.google.datastore.v1.Key(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.Key result) { + if (pathBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + path_ = java.util.Collections.unmodifiableList(path_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.path_ = path_; + } else { + result.path_ = pathBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.Key result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.partitionId_ = + partitionIdBuilder_ == null ? partitionId_ : partitionIdBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.Key) { + return mergeFrom((com.google.datastore.v1.Key) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.Key other) { + if (other == com.google.datastore.v1.Key.getDefaultInstance()) return this; + if (other.hasPartitionId()) { + mergePartitionId(other.getPartitionId()); + } + if (pathBuilder_ == null) { + if (!other.path_.isEmpty()) { + if (path_.isEmpty()) { + path_ = other.path_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensurePathIsMutable(); + path_.addAll(other.path_); + } + onChanged(); + } + } else { + if (!other.path_.isEmpty()) { + if (pathBuilder_.isEmpty()) { + pathBuilder_.dispose(); + pathBuilder_ = null; + path_ = other.path_; + bitField0_ = (bitField0_ & ~0x00000002); + pathBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getPathFieldBuilder() + : null; + } else { + pathBuilder_.addAllMessages(other.path_); + } + } + } + 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(getPartitionIdFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + com.google.datastore.v1.Key.PathElement m = + input.readMessage( + com.google.datastore.v1.Key.PathElement.parser(), extensionRegistry); + if (pathBuilder_ == null) { + ensurePathIsMutable(); + path_.add(m); + } else { + pathBuilder_.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.datastore.v1.PartitionId partitionId_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PartitionId, + com.google.datastore.v1.PartitionId.Builder, + com.google.datastore.v1.PartitionIdOrBuilder> + partitionIdBuilder_; + + /** + * + * + *
+     * Entities are partitioned into subsets, currently identified by a project
+     * ID and namespace ID.
+     * Queries are scoped to a single partition.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + * + * @return Whether the partitionId field is set. + */ + public boolean hasPartitionId() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Entities are partitioned into subsets, currently identified by a project
+     * ID and namespace ID.
+     * Queries are scoped to a single partition.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + * + * @return The partitionId. + */ + public com.google.datastore.v1.PartitionId getPartitionId() { + if (partitionIdBuilder_ == null) { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } else { + return partitionIdBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Entities are partitioned into subsets, currently identified by a project
+     * ID and namespace ID.
+     * Queries are scoped to a single partition.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + */ + public Builder setPartitionId(com.google.datastore.v1.PartitionId value) { + if (partitionIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + partitionId_ = value; + } else { + partitionIdBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, currently identified by a project
+     * ID and namespace ID.
+     * Queries are scoped to a single partition.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + */ + public Builder setPartitionId(com.google.datastore.v1.PartitionId.Builder builderForValue) { + if (partitionIdBuilder_ == null) { + partitionId_ = builderForValue.build(); + } else { + partitionIdBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, currently identified by a project
+     * ID and namespace ID.
+     * Queries are scoped to a single partition.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + */ + public Builder mergePartitionId(com.google.datastore.v1.PartitionId value) { + if (partitionIdBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && partitionId_ != null + && partitionId_ != com.google.datastore.v1.PartitionId.getDefaultInstance()) { + getPartitionIdBuilder().mergeFrom(value); + } else { + partitionId_ = value; + } + } else { + partitionIdBuilder_.mergeFrom(value); + } + if (partitionId_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, currently identified by a project
+     * ID and namespace ID.
+     * Queries are scoped to a single partition.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + */ + public Builder clearPartitionId() { + bitField0_ = (bitField0_ & ~0x00000001); + partitionId_ = null; + if (partitionIdBuilder_ != null) { + partitionIdBuilder_.dispose(); + partitionIdBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, currently identified by a project
+     * ID and namespace ID.
+     * Queries are scoped to a single partition.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + */ + public com.google.datastore.v1.PartitionId.Builder getPartitionIdBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getPartitionIdFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Entities are partitioned into subsets, currently identified by a project
+     * ID and namespace ID.
+     * Queries are scoped to a single partition.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + */ + public com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder() { + if (partitionIdBuilder_ != null) { + return partitionIdBuilder_.getMessageOrBuilder(); + } else { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } + } + + /** + * + * + *
+     * Entities are partitioned into subsets, currently identified by a project
+     * ID and namespace ID.
+     * Queries are scoped to a single partition.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PartitionId, + com.google.datastore.v1.PartitionId.Builder, + com.google.datastore.v1.PartitionIdOrBuilder> + getPartitionIdFieldBuilder() { + if (partitionIdBuilder_ == null) { + partitionIdBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PartitionId, + com.google.datastore.v1.PartitionId.Builder, + com.google.datastore.v1.PartitionIdOrBuilder>( + getPartitionId(), getParentForChildren(), isClean()); + partitionId_ = null; + } + return partitionIdBuilder_; + } + + private java.util.List path_ = + java.util.Collections.emptyList(); + + private void ensurePathIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + path_ = new java.util.ArrayList(path_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key.PathElement, + com.google.datastore.v1.Key.PathElement.Builder, + com.google.datastore.v1.Key.PathElementOrBuilder> + pathBuilder_; + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public java.util.List getPathList() { + if (pathBuilder_ == null) { + return java.util.Collections.unmodifiableList(path_); + } else { + return pathBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public int getPathCount() { + if (pathBuilder_ == null) { + return path_.size(); + } else { + return pathBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public com.google.datastore.v1.Key.PathElement getPath(int index) { + if (pathBuilder_ == null) { + return path_.get(index); + } else { + return pathBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public Builder setPath(int index, com.google.datastore.v1.Key.PathElement value) { + if (pathBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePathIsMutable(); + path_.set(index, value); + onChanged(); + } else { + pathBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public Builder setPath( + int index, com.google.datastore.v1.Key.PathElement.Builder builderForValue) { + if (pathBuilder_ == null) { + ensurePathIsMutable(); + path_.set(index, builderForValue.build()); + onChanged(); + } else { + pathBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public Builder addPath(com.google.datastore.v1.Key.PathElement value) { + if (pathBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePathIsMutable(); + path_.add(value); + onChanged(); + } else { + pathBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public Builder addPath(int index, com.google.datastore.v1.Key.PathElement value) { + if (pathBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePathIsMutable(); + path_.add(index, value); + onChanged(); + } else { + pathBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public Builder addPath(com.google.datastore.v1.Key.PathElement.Builder builderForValue) { + if (pathBuilder_ == null) { + ensurePathIsMutable(); + path_.add(builderForValue.build()); + onChanged(); + } else { + pathBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public Builder addPath( + int index, com.google.datastore.v1.Key.PathElement.Builder builderForValue) { + if (pathBuilder_ == null) { + ensurePathIsMutable(); + path_.add(index, builderForValue.build()); + onChanged(); + } else { + pathBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public Builder addAllPath( + java.lang.Iterable values) { + if (pathBuilder_ == null) { + ensurePathIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, path_); + onChanged(); + } else { + pathBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public Builder clearPath() { + if (pathBuilder_ == null) { + path_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + pathBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public Builder removePath(int index) { + if (pathBuilder_ == null) { + ensurePathIsMutable(); + path_.remove(index); + onChanged(); + } else { + pathBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public com.google.datastore.v1.Key.PathElement.Builder getPathBuilder(int index) { + return getPathFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public com.google.datastore.v1.Key.PathElementOrBuilder getPathOrBuilder(int index) { + if (pathBuilder_ == null) { + return path_.get(index); + } else { + return pathBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public java.util.List + getPathOrBuilderList() { + if (pathBuilder_ != null) { + return pathBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(path_); + } + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public com.google.datastore.v1.Key.PathElement.Builder addPathBuilder() { + return getPathFieldBuilder() + .addBuilder(com.google.datastore.v1.Key.PathElement.getDefaultInstance()); + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public com.google.datastore.v1.Key.PathElement.Builder addPathBuilder(int index) { + return getPathFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Key.PathElement.getDefaultInstance()); + } + + /** + * + * + *
+     * The entity path.
+     * An entity path consists of one or more elements composed of a kind and a
+     * string or numerical identifier, which identify entities. The first
+     * element identifies a _root entity_, the second element identifies
+     * a _child_ of the root entity, the third element identifies a child of the
+     * second entity, and so forth. The entities identified by all prefixes of
+     * the path are called the element's _ancestors_.
+     *
+     * An entity path is always fully complete: *all* of the entity's ancestors
+     * are required to be in the path along with the entity identifier itself.
+     * The only exception is that in some documented cases, the identifier in the
+     * last path element (for the entity) itself may be omitted. For example,
+     * the last path element of the key of `Mutation.insert` may have no
+     * identifier.
+     *
+     * A path can never be empty, and a path can have at most 100 elements.
+     * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + public java.util.List getPathBuilderList() { + return getPathFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key.PathElement, + com.google.datastore.v1.Key.PathElement.Builder, + com.google.datastore.v1.Key.PathElementOrBuilder> + getPathFieldBuilder() { + if (pathBuilder_ == null) { + pathBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key.PathElement, + com.google.datastore.v1.Key.PathElement.Builder, + com.google.datastore.v1.Key.PathElementOrBuilder>( + path_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + path_ = null; + } + return pathBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.Key) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.Key) + private static final com.google.datastore.v1.Key DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.Key(); + } + + public static com.google.datastore.v1.Key getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Key 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.datastore.v1.Key getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KeyOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KeyOrBuilder.java new file mode 100644 index 000000000000..c22132f7971e --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KeyOrBuilder.java @@ -0,0 +1,199 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface KeyOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.Key) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Entities are partitioned into subsets, currently identified by a project
+   * ID and namespace ID.
+   * Queries are scoped to a single partition.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + * + * @return Whether the partitionId field is set. + */ + boolean hasPartitionId(); + + /** + * + * + *
+   * Entities are partitioned into subsets, currently identified by a project
+   * ID and namespace ID.
+   * Queries are scoped to a single partition.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + * + * @return The partitionId. + */ + com.google.datastore.v1.PartitionId getPartitionId(); + + /** + * + * + *
+   * Entities are partitioned into subsets, currently identified by a project
+   * ID and namespace ID.
+   * Queries are scoped to a single partition.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 1; + */ + com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder(); + + /** + * + * + *
+   * The entity path.
+   * An entity path consists of one or more elements composed of a kind and a
+   * string or numerical identifier, which identify entities. The first
+   * element identifies a _root entity_, the second element identifies
+   * a _child_ of the root entity, the third element identifies a child of the
+   * second entity, and so forth. The entities identified by all prefixes of
+   * the path are called the element's _ancestors_.
+   *
+   * An entity path is always fully complete: *all* of the entity's ancestors
+   * are required to be in the path along with the entity identifier itself.
+   * The only exception is that in some documented cases, the identifier in the
+   * last path element (for the entity) itself may be omitted. For example,
+   * the last path element of the key of `Mutation.insert` may have no
+   * identifier.
+   *
+   * A path can never be empty, and a path can have at most 100 elements.
+   * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + java.util.List getPathList(); + + /** + * + * + *
+   * The entity path.
+   * An entity path consists of one or more elements composed of a kind and a
+   * string or numerical identifier, which identify entities. The first
+   * element identifies a _root entity_, the second element identifies
+   * a _child_ of the root entity, the third element identifies a child of the
+   * second entity, and so forth. The entities identified by all prefixes of
+   * the path are called the element's _ancestors_.
+   *
+   * An entity path is always fully complete: *all* of the entity's ancestors
+   * are required to be in the path along with the entity identifier itself.
+   * The only exception is that in some documented cases, the identifier in the
+   * last path element (for the entity) itself may be omitted. For example,
+   * the last path element of the key of `Mutation.insert` may have no
+   * identifier.
+   *
+   * A path can never be empty, and a path can have at most 100 elements.
+   * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + com.google.datastore.v1.Key.PathElement getPath(int index); + + /** + * + * + *
+   * The entity path.
+   * An entity path consists of one or more elements composed of a kind and a
+   * string or numerical identifier, which identify entities. The first
+   * element identifies a _root entity_, the second element identifies
+   * a _child_ of the root entity, the third element identifies a child of the
+   * second entity, and so forth. The entities identified by all prefixes of
+   * the path are called the element's _ancestors_.
+   *
+   * An entity path is always fully complete: *all* of the entity's ancestors
+   * are required to be in the path along with the entity identifier itself.
+   * The only exception is that in some documented cases, the identifier in the
+   * last path element (for the entity) itself may be omitted. For example,
+   * the last path element of the key of `Mutation.insert` may have no
+   * identifier.
+   *
+   * A path can never be empty, and a path can have at most 100 elements.
+   * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + int getPathCount(); + + /** + * + * + *
+   * The entity path.
+   * An entity path consists of one or more elements composed of a kind and a
+   * string or numerical identifier, which identify entities. The first
+   * element identifies a _root entity_, the second element identifies
+   * a _child_ of the root entity, the third element identifies a child of the
+   * second entity, and so forth. The entities identified by all prefixes of
+   * the path are called the element's _ancestors_.
+   *
+   * An entity path is always fully complete: *all* of the entity's ancestors
+   * are required to be in the path along with the entity identifier itself.
+   * The only exception is that in some documented cases, the identifier in the
+   * last path element (for the entity) itself may be omitted. For example,
+   * the last path element of the key of `Mutation.insert` may have no
+   * identifier.
+   *
+   * A path can never be empty, and a path can have at most 100 elements.
+   * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + java.util.List getPathOrBuilderList(); + + /** + * + * + *
+   * The entity path.
+   * An entity path consists of one or more elements composed of a kind and a
+   * string or numerical identifier, which identify entities. The first
+   * element identifies a _root entity_, the second element identifies
+   * a _child_ of the root entity, the third element identifies a child of the
+   * second entity, and so forth. The entities identified by all prefixes of
+   * the path are called the element's _ancestors_.
+   *
+   * An entity path is always fully complete: *all* of the entity's ancestors
+   * are required to be in the path along with the entity identifier itself.
+   * The only exception is that in some documented cases, the identifier in the
+   * last path element (for the entity) itself may be omitted. For example,
+   * the last path element of the key of `Mutation.insert` may have no
+   * identifier.
+   *
+   * A path can never be empty, and a path can have at most 100 elements.
+   * 
+ * + * repeated .google.datastore.v1.Key.PathElement path = 2; + */ + com.google.datastore.v1.Key.PathElementOrBuilder getPathOrBuilder(int index); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpression.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpression.java new file mode 100644 index 000000000000..c0e5c0a083bc --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpression.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! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A representation of a kind.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.KindExpression} + */ +public final class KindExpression extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.KindExpression) + KindExpressionOrBuilder { + private static final long serialVersionUID = 0L; + + // Use KindExpression.newBuilder() to construct. + private KindExpression(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private KindExpression() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new KindExpression(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_KindExpression_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_KindExpression_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.KindExpression.class, + com.google.datastore.v1.KindExpression.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * The name of the kind.
+   * 
+ * + * 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 name of the kind.
+   * 
+ * + * 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; + } + } + + 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.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.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.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.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.datastore.v1.KindExpression)) { + return super.equals(obj); + } + com.google.datastore.v1.KindExpression other = (com.google.datastore.v1.KindExpression) 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.datastore.v1.KindExpression parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.KindExpression parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.KindExpression parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.KindExpression 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.datastore.v1.KindExpression parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.KindExpression parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.KindExpression parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.KindExpression parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.KindExpression parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.KindExpression parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.KindExpression parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.KindExpression parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.KindExpression 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A representation of a kind.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.KindExpression} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.KindExpression) + com.google.datastore.v1.KindExpressionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_KindExpression_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_KindExpression_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.KindExpression.class, + com.google.datastore.v1.KindExpression.Builder.class); + } + + // Construct using com.google.datastore.v1.KindExpression.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.v1.QueryProto + .internal_static_google_datastore_v1_KindExpression_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.KindExpression getDefaultInstanceForType() { + return com.google.datastore.v1.KindExpression.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.KindExpression build() { + com.google.datastore.v1.KindExpression result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.KindExpression buildPartial() { + com.google.datastore.v1.KindExpression result = + new com.google.datastore.v1.KindExpression(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.KindExpression result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.KindExpression) { + return mergeFrom((com.google.datastore.v1.KindExpression) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.KindExpression other) { + if (other == com.google.datastore.v1.KindExpression.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_ = ""; + + /** + * + * + *
+     * The name of the kind.
+     * 
+ * + * 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 name of the kind.
+     * 
+ * + * 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 name of the kind.
+     * 
+ * + * 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 name of the kind.
+     * 
+ * + * string name = 1; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The name of the kind.
+     * 
+ * + * 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; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.KindExpression) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.KindExpression) + private static final com.google.datastore.v1.KindExpression DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.KindExpression(); + } + + public static com.google.datastore.v1.KindExpression getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public KindExpression 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.datastore.v1.KindExpression getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpressionOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpressionOrBuilder.java new file mode 100644 index 000000000000..665248cbc11d --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/KindExpressionOrBuilder.java @@ -0,0 +1,52 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface KindExpressionOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.KindExpression) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The name of the kind.
+   * 
+ * + * string name = 1; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * The name of the kind.
+   * 
+ * + * string name = 1; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequest.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequest.java new file mode 100644 index 000000000000..4f7a85bbad2c --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequest.java @@ -0,0 +1,2003 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The request for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.LookupRequest} + */ +public final class LookupRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.LookupRequest) + LookupRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use LookupRequest.newBuilder() to construct. + private LookupRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private LookupRequest() { + projectId_ = ""; + databaseId_ = ""; + keys_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new LookupRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_LookupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_LookupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.LookupRequest.class, + com.google.datastore.v1.LookupRequest.Builder.class); + } + + private int bitField0_; + public static final int PROJECT_ID_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 9; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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 READ_OPTIONS_FIELD_NUMBER = 1; + private com.google.datastore.v1.ReadOptions readOptions_; + + /** + * + * + *
+   * The options for this lookup request.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return Whether the readOptions field is set. + */ + @java.lang.Override + public boolean hasReadOptions() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The options for this lookup request.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return The readOptions. + */ + @java.lang.Override + public com.google.datastore.v1.ReadOptions getReadOptions() { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } + + /** + * + * + *
+   * The options for this lookup request.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + @java.lang.Override + public com.google.datastore.v1.ReadOptionsOrBuilder getReadOptionsOrBuilder() { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } + + public static final int KEYS_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private java.util.List keys_; + + /** + * + * + *
+   * Required. Keys of entities to look up.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public java.util.List getKeysList() { + return keys_; + } + + /** + * + * + *
+   * Required. Keys of entities to look up.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public java.util.List getKeysOrBuilderList() { + return keys_; + } + + /** + * + * + *
+   * Required. Keys of entities to look up.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public int getKeysCount() { + return keys_.size(); + } + + /** + * + * + *
+   * Required. Keys of entities to look up.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.v1.Key getKeys(int index) { + return keys_.get(index); + } + + /** + * + * + *
+   * Required. Keys of entities to look up.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index) { + return keys_.get(index); + } + + public static final int PROPERTY_MASK_FIELD_NUMBER = 5; + private com.google.datastore.v1.PropertyMask propertyMask_; + + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return Whether the propertyMask field is set. + */ + @java.lang.Override + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return The propertyMask. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMask getPropertyMask() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + + 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, getReadOptions()); + } + for (int i = 0; i < keys_.size(); i++) { + output.writeMessage(3, keys_.get(i)); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(5, getPropertyMask()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, databaseId_); + } + 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, getReadOptions()); + } + for (int i = 0; i < keys_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, keys_.get(i)); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, getPropertyMask()); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, 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.datastore.v1.LookupRequest)) { + return super.equals(obj); + } + com.google.datastore.v1.LookupRequest other = (com.google.datastore.v1.LookupRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (hasReadOptions() != other.hasReadOptions()) return false; + if (hasReadOptions()) { + if (!getReadOptions().equals(other.getReadOptions())) return false; + } + if (!getKeysList().equals(other.getKeysList())) return false; + if (hasPropertyMask() != other.hasPropertyMask()) return false; + if (hasPropertyMask()) { + if (!getPropertyMask().equals(other.getPropertyMask())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + if (hasReadOptions()) { + hash = (37 * hash) + READ_OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + getReadOptions().hashCode(); + } + if (getKeysCount() > 0) { + hash = (37 * hash) + KEYS_FIELD_NUMBER; + hash = (53 * hash) + getKeysList().hashCode(); + } + if (hasPropertyMask()) { + hash = (37 * hash) + PROPERTY_MASK_FIELD_NUMBER; + hash = (53 * hash) + getPropertyMask().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.LookupRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.LookupRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.LookupRequest parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.LookupRequest 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.datastore.v1.LookupRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.LookupRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.LookupRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.LookupRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.LookupRequest parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.LookupRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.LookupRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.LookupRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.LookupRequest 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.LookupRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.LookupRequest) + com.google.datastore.v1.LookupRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_LookupRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_LookupRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.LookupRequest.class, + com.google.datastore.v1.LookupRequest.Builder.class); + } + + // Construct using com.google.datastore.v1.LookupRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getReadOptionsFieldBuilder(); + getKeysFieldBuilder(); + getPropertyMaskFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + databaseId_ = ""; + readOptions_ = null; + if (readOptionsBuilder_ != null) { + readOptionsBuilder_.dispose(); + readOptionsBuilder_ = null; + } + if (keysBuilder_ == null) { + keys_ = java.util.Collections.emptyList(); + } else { + keys_ = null; + keysBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_LookupRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.LookupRequest getDefaultInstanceForType() { + return com.google.datastore.v1.LookupRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.LookupRequest build() { + com.google.datastore.v1.LookupRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.LookupRequest buildPartial() { + com.google.datastore.v1.LookupRequest result = + new com.google.datastore.v1.LookupRequest(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.LookupRequest result) { + if (keysBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + keys_ = java.util.Collections.unmodifiableList(keys_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.keys_ = keys_; + } else { + result.keys_ = keysBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.LookupRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.readOptions_ = + readOptionsBuilder_ == null ? readOptions_ : readOptionsBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.propertyMask_ = + propertyMaskBuilder_ == null ? propertyMask_ : propertyMaskBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.LookupRequest) { + return mergeFrom((com.google.datastore.v1.LookupRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.LookupRequest other) { + if (other == com.google.datastore.v1.LookupRequest.getDefaultInstance()) return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.hasReadOptions()) { + mergeReadOptions(other.getReadOptions()); + } + if (keysBuilder_ == null) { + if (!other.keys_.isEmpty()) { + if (keys_.isEmpty()) { + keys_ = other.keys_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureKeysIsMutable(); + keys_.addAll(other.keys_); + } + onChanged(); + } + } else { + if (!other.keys_.isEmpty()) { + if (keysBuilder_.isEmpty()) { + keysBuilder_.dispose(); + keysBuilder_ = null; + keys_ = other.keys_; + bitField0_ = (bitField0_ & ~0x00000008); + keysBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getKeysFieldBuilder() + : null; + } else { + keysBuilder_.addAllMessages(other.keys_); + } + } + } + if (other.hasPropertyMask()) { + mergePropertyMask(other.getPropertyMask()); + } + 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(getReadOptionsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 10 + case 26: + { + com.google.datastore.v1.Key m = + input.readMessage(com.google.datastore.v1.Key.parser(), extensionRegistry); + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(m); + } else { + keysBuilder_.addMessage(m); + } + break; + } // case 26 + case 42: + { + input.readMessage(getPropertyMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000010; + break; + } // case 42 + case 66: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 66 + case 74: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + 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 java.lang.Object projectId_ = ""; + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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.datastore.v1.ReadOptions readOptions_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ReadOptions, + com.google.datastore.v1.ReadOptions.Builder, + com.google.datastore.v1.ReadOptionsOrBuilder> + readOptionsBuilder_; + + /** + * + * + *
+     * The options for this lookup request.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return Whether the readOptions field is set. + */ + public boolean hasReadOptions() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The options for this lookup request.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return The readOptions. + */ + public com.google.datastore.v1.ReadOptions getReadOptions() { + if (readOptionsBuilder_ == null) { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } else { + return readOptionsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The options for this lookup request.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder setReadOptions(com.google.datastore.v1.ReadOptions value) { + if (readOptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readOptions_ = value; + } else { + readOptionsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for this lookup request.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder setReadOptions(com.google.datastore.v1.ReadOptions.Builder builderForValue) { + if (readOptionsBuilder_ == null) { + readOptions_ = builderForValue.build(); + } else { + readOptionsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for this lookup request.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder mergeReadOptions(com.google.datastore.v1.ReadOptions value) { + if (readOptionsBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && readOptions_ != null + && readOptions_ != com.google.datastore.v1.ReadOptions.getDefaultInstance()) { + getReadOptionsBuilder().mergeFrom(value); + } else { + readOptions_ = value; + } + } else { + readOptionsBuilder_.mergeFrom(value); + } + if (readOptions_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The options for this lookup request.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder clearReadOptions() { + bitField0_ = (bitField0_ & ~0x00000004); + readOptions_ = null; + if (readOptionsBuilder_ != null) { + readOptionsBuilder_.dispose(); + readOptionsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for this lookup request.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public com.google.datastore.v1.ReadOptions.Builder getReadOptionsBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getReadOptionsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The options for this lookup request.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public com.google.datastore.v1.ReadOptionsOrBuilder getReadOptionsOrBuilder() { + if (readOptionsBuilder_ != null) { + return readOptionsBuilder_.getMessageOrBuilder(); + } else { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } + } + + /** + * + * + *
+     * The options for this lookup request.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ReadOptions, + com.google.datastore.v1.ReadOptions.Builder, + com.google.datastore.v1.ReadOptionsOrBuilder> + getReadOptionsFieldBuilder() { + if (readOptionsBuilder_ == null) { + readOptionsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ReadOptions, + com.google.datastore.v1.ReadOptions.Builder, + com.google.datastore.v1.ReadOptionsOrBuilder>( + getReadOptions(), getParentForChildren(), isClean()); + readOptions_ = null; + } + return readOptionsBuilder_; + } + + private java.util.List keys_ = java.util.Collections.emptyList(); + + private void ensureKeysIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + keys_ = new java.util.ArrayList(keys_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + keysBuilder_; + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getKeysList() { + if (keysBuilder_ == null) { + return java.util.Collections.unmodifiableList(keys_); + } else { + return keysBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public int getKeysCount() { + if (keysBuilder_ == null) { + return keys_.size(); + } else { + return keysBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key getKeys(int index) { + if (keysBuilder_ == null) { + return keys_.get(index); + } else { + return keysBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setKeys(int index, com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.set(index, value); + onChanged(); + } else { + keysBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setKeys(int index, com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.set(index, builderForValue.build()); + onChanged(); + } else { + keysBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.add(value); + onChanged(); + } else { + keysBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(int index, com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.add(index, value); + onChanged(); + } else { + keysBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(builderForValue.build()); + onChanged(); + } else { + keysBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(int index, com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(index, builderForValue.build()); + onChanged(); + } else { + keysBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addAllKeys(java.lang.Iterable values) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, keys_); + onChanged(); + } else { + keysBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearKeys() { + if (keysBuilder_ == null) { + keys_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + keysBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder removeKeys(int index) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.remove(index); + onChanged(); + } else { + keysBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key.Builder getKeysBuilder(int index) { + return getKeysFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index) { + if (keysBuilder_ == null) { + return keys_.get(index); + } else { + return keysBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getKeysOrBuilderList() { + if (keysBuilder_ != null) { + return keysBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(keys_); + } + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key.Builder addKeysBuilder() { + return getKeysFieldBuilder().addBuilder(com.google.datastore.v1.Key.getDefaultInstance()); + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key.Builder addKeysBuilder(int index) { + return getKeysFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Key.getDefaultInstance()); + } + + /** + * + * + *
+     * Required. Keys of entities to look up.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getKeysBuilderList() { + return getKeysFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + getKeysFieldBuilder() { + if (keysBuilder_ == null) { + keysBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder>( + keys_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean()); + keys_ = null; + } + return keysBuilder_; + } + + private com.google.datastore.v1.PropertyMask propertyMask_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + propertyMaskBuilder_; + + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return Whether the propertyMask field is set. + */ + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return The propertyMask. + */ + public com.google.datastore.v1.PropertyMask getPropertyMask() { + if (propertyMaskBuilder_ == null) { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } else { + return propertyMaskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + propertyMask_ = value; + } else { + propertyMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask.Builder builderForValue) { + if (propertyMaskBuilder_ == null) { + propertyMask_ = builderForValue.build(); + } else { + propertyMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public Builder mergePropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0) + && propertyMask_ != null + && propertyMask_ != com.google.datastore.v1.PropertyMask.getDefaultInstance()) { + getPropertyMaskBuilder().mergeFrom(value); + } else { + propertyMask_ = value; + } + } else { + propertyMaskBuilder_.mergeFrom(value); + } + if (propertyMask_ != null) { + bitField0_ |= 0x00000010; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public Builder clearPropertyMask() { + bitField0_ = (bitField0_ & ~0x00000010); + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public com.google.datastore.v1.PropertyMask.Builder getPropertyMaskBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return getPropertyMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + if (propertyMaskBuilder_ != null) { + return propertyMaskBuilder_.getMessageOrBuilder(); + } else { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + } + + /** + * + * + *
+     * The properties to return. Defaults to returning all properties.
+     *
+     * If this field is set and an entity has a property not referenced in the
+     * mask, it will be absent from [LookupResponse.found.entity.properties][].
+     *
+     * The entity's key is always returned.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + getPropertyMaskFieldBuilder() { + if (propertyMaskBuilder_ == null) { + propertyMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder>( + getPropertyMask(), getParentForChildren(), isClean()); + propertyMask_ = null; + } + return propertyMaskBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.LookupRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.LookupRequest) + private static final com.google.datastore.v1.LookupRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.LookupRequest(); + } + + public static com.google.datastore.v1.LookupRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public LookupRequest 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.datastore.v1.LookupRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequestOrBuilder.java new file mode 100644 index 000000000000..5ade8e4aab06 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupRequestOrBuilder.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! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface LookupRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.LookupRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * The options for this lookup request.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return Whether the readOptions field is set. + */ + boolean hasReadOptions(); + + /** + * + * + *
+   * The options for this lookup request.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return The readOptions. + */ + com.google.datastore.v1.ReadOptions getReadOptions(); + + /** + * + * + *
+   * The options for this lookup request.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + com.google.datastore.v1.ReadOptionsOrBuilder getReadOptionsOrBuilder(); + + /** + * + * + *
+   * Required. Keys of entities to look up.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + java.util.List getKeysList(); + + /** + * + * + *
+   * Required. Keys of entities to look up.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.v1.Key getKeys(int index); + + /** + * + * + *
+   * Required. Keys of entities to look up.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + int getKeysCount(); + + /** + * + * + *
+   * Required. Keys of entities to look up.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + java.util.List getKeysOrBuilderList(); + + /** + * + * + *
+   * Required. Keys of entities to look up.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index); + + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return Whether the propertyMask field is set. + */ + boolean hasPropertyMask(); + + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + * + * @return The propertyMask. + */ + com.google.datastore.v1.PropertyMask getPropertyMask(); + + /** + * + * + *
+   * The properties to return. Defaults to returning all properties.
+   *
+   * If this field is set and an entity has a property not referenced in the
+   * mask, it will be absent from [LookupResponse.found.entity.properties][].
+   *
+   * The entity's key is always returned.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 5; + */ + com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponse.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponse.java new file mode 100644 index 000000000000..e3e2dbf56ace --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponse.java @@ -0,0 +1,2517 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The response for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.LookupResponse} + */ +public final class LookupResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.LookupResponse) + LookupResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use LookupResponse.newBuilder() to construct. + private LookupResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private LookupResponse() { + found_ = java.util.Collections.emptyList(); + missing_ = java.util.Collections.emptyList(); + deferred_ = java.util.Collections.emptyList(); + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new LookupResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_LookupResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_LookupResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.LookupResponse.class, + com.google.datastore.v1.LookupResponse.Builder.class); + } + + private int bitField0_; + public static final int FOUND_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List found_; + + /** + * + * + *
+   * Entities found as `ResultType.FULL` entities. The order of results in this
+   * field is undefined and has no relation to the order of the keys in the
+   * input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + @java.lang.Override + public java.util.List getFoundList() { + return found_; + } + + /** + * + * + *
+   * Entities found as `ResultType.FULL` entities. The order of results in this
+   * field is undefined and has no relation to the order of the keys in the
+   * input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + @java.lang.Override + public java.util.List + getFoundOrBuilderList() { + return found_; + } + + /** + * + * + *
+   * Entities found as `ResultType.FULL` entities. The order of results in this
+   * field is undefined and has no relation to the order of the keys in the
+   * input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + @java.lang.Override + public int getFoundCount() { + return found_.size(); + } + + /** + * + * + *
+   * Entities found as `ResultType.FULL` entities. The order of results in this
+   * field is undefined and has no relation to the order of the keys in the
+   * input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + @java.lang.Override + public com.google.datastore.v1.EntityResult getFound(int index) { + return found_.get(index); + } + + /** + * + * + *
+   * Entities found as `ResultType.FULL` entities. The order of results in this
+   * field is undefined and has no relation to the order of the keys in the
+   * input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + @java.lang.Override + public com.google.datastore.v1.EntityResultOrBuilder getFoundOrBuilder(int index) { + return found_.get(index); + } + + public static final int MISSING_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List missing_; + + /** + * + * + *
+   * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+   * in this field is undefined and has no relation to the order of the keys
+   * in the input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + @java.lang.Override + public java.util.List getMissingList() { + return missing_; + } + + /** + * + * + *
+   * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+   * in this field is undefined and has no relation to the order of the keys
+   * in the input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + @java.lang.Override + public java.util.List + getMissingOrBuilderList() { + return missing_; + } + + /** + * + * + *
+   * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+   * in this field is undefined and has no relation to the order of the keys
+   * in the input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + @java.lang.Override + public int getMissingCount() { + return missing_.size(); + } + + /** + * + * + *
+   * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+   * in this field is undefined and has no relation to the order of the keys
+   * in the input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + @java.lang.Override + public com.google.datastore.v1.EntityResult getMissing(int index) { + return missing_.get(index); + } + + /** + * + * + *
+   * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+   * in this field is undefined and has no relation to the order of the keys
+   * in the input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + @java.lang.Override + public com.google.datastore.v1.EntityResultOrBuilder getMissingOrBuilder(int index) { + return missing_.get(index); + } + + public static final int DEFERRED_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private java.util.List deferred_; + + /** + * + * + *
+   * A list of keys that were not looked up due to resource constraints. The
+   * order of results in this field is undefined and has no relation to the
+   * order of the keys in the input.
+   * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + @java.lang.Override + public java.util.List getDeferredList() { + return deferred_; + } + + /** + * + * + *
+   * A list of keys that were not looked up due to resource constraints. The
+   * order of results in this field is undefined and has no relation to the
+   * order of the keys in the input.
+   * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + @java.lang.Override + public java.util.List getDeferredOrBuilderList() { + return deferred_; + } + + /** + * + * + *
+   * A list of keys that were not looked up due to resource constraints. The
+   * order of results in this field is undefined and has no relation to the
+   * order of the keys in the input.
+   * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + @java.lang.Override + public int getDeferredCount() { + return deferred_.size(); + } + + /** + * + * + *
+   * A list of keys that were not looked up due to resource constraints. The
+   * order of results in this field is undefined and has no relation to the
+   * order of the keys in the input.
+   * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + @java.lang.Override + public com.google.datastore.v1.Key getDeferred(int index) { + return deferred_.get(index); + } + + /** + * + * + *
+   * A list of keys that were not looked up due to resource constraints. The
+   * order of results in this field is undefined and has no relation to the
+   * order of the keys in the input.
+   * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getDeferredOrBuilder(int index) { + return deferred_.get(index); + } + + public static final int TRANSACTION_FIELD_NUMBER = 5; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * The identifier of the transaction that was started as part of this Lookup
+   * request.
+   *
+   * Set only when
+   * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+   * was set in
+   * [LookupRequest.read_options][google.datastore.v1.LookupRequest.read_options].
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + public static final int READ_TIME_FIELD_NUMBER = 7; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * The time at which these entities were read or found missing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The time at which these entities were read or found missing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @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 these entities were read or found missing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + @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 { + for (int i = 0; i < found_.size(); i++) { + output.writeMessage(1, found_.get(i)); + } + for (int i = 0; i < missing_.size(); i++) { + output.writeMessage(2, missing_.get(i)); + } + for (int i = 0; i < deferred_.size(); i++) { + output.writeMessage(3, deferred_.get(i)); + } + if (!transaction_.isEmpty()) { + output.writeBytes(5, transaction_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(7, getReadTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < found_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, found_.get(i)); + } + for (int i = 0; i < missing_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, missing_.get(i)); + } + for (int i = 0; i < deferred_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, deferred_.get(i)); + } + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(5, transaction_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, 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.datastore.v1.LookupResponse)) { + return super.equals(obj); + } + com.google.datastore.v1.LookupResponse other = (com.google.datastore.v1.LookupResponse) obj; + + if (!getFoundList().equals(other.getFoundList())) return false; + if (!getMissingList().equals(other.getMissingList())) return false; + if (!getDeferredList().equals(other.getDeferredList())) 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 (!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 (getFoundCount() > 0) { + hash = (37 * hash) + FOUND_FIELD_NUMBER; + hash = (53 * hash) + getFoundList().hashCode(); + } + if (getMissingCount() > 0) { + hash = (37 * hash) + MISSING_FIELD_NUMBER; + hash = (53 * hash) + getMissingList().hashCode(); + } + if (getDeferredCount() > 0) { + hash = (37 * hash) + DEFERRED_FIELD_NUMBER; + hash = (53 * hash) + getDeferredList().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(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.LookupResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.LookupResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.LookupResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.LookupResponse 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.datastore.v1.LookupResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.LookupResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.LookupResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.LookupResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.LookupResponse parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.LookupResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.LookupResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.LookupResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.LookupResponse 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.LookupResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.LookupResponse) + com.google.datastore.v1.LookupResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_LookupResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_LookupResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.LookupResponse.class, + com.google.datastore.v1.LookupResponse.Builder.class); + } + + // Construct using com.google.datastore.v1.LookupResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getFoundFieldBuilder(); + getMissingFieldBuilder(); + getDeferredFieldBuilder(); + getReadTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (foundBuilder_ == null) { + found_ = java.util.Collections.emptyList(); + } else { + found_ = null; + foundBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + if (missingBuilder_ == null) { + missing_ = java.util.Collections.emptyList(); + } else { + missing_ = null; + missingBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + if (deferredBuilder_ == null) { + deferred_ = java.util.Collections.emptyList(); + } else { + deferred_ = null; + deferredBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + transaction_ = 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.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_LookupResponse_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.LookupResponse getDefaultInstanceForType() { + return com.google.datastore.v1.LookupResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.LookupResponse build() { + com.google.datastore.v1.LookupResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.LookupResponse buildPartial() { + com.google.datastore.v1.LookupResponse result = + new com.google.datastore.v1.LookupResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.LookupResponse result) { + if (foundBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + found_ = java.util.Collections.unmodifiableList(found_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.found_ = found_; + } else { + result.found_ = foundBuilder_.build(); + } + if (missingBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + missing_ = java.util.Collections.unmodifiableList(missing_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.missing_ = missing_; + } else { + result.missing_ = missingBuilder_.build(); + } + if (deferredBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0)) { + deferred_ = java.util.Collections.unmodifiableList(deferred_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.deferred_ = deferred_; + } else { + result.deferred_ = deferredBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.LookupResponse result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000008) != 0)) { + result.transaction_ = transaction_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000010) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.LookupResponse) { + return mergeFrom((com.google.datastore.v1.LookupResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.LookupResponse other) { + if (other == com.google.datastore.v1.LookupResponse.getDefaultInstance()) return this; + if (foundBuilder_ == null) { + if (!other.found_.isEmpty()) { + if (found_.isEmpty()) { + found_ = other.found_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureFoundIsMutable(); + found_.addAll(other.found_); + } + onChanged(); + } + } else { + if (!other.found_.isEmpty()) { + if (foundBuilder_.isEmpty()) { + foundBuilder_.dispose(); + foundBuilder_ = null; + found_ = other.found_; + bitField0_ = (bitField0_ & ~0x00000001); + foundBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getFoundFieldBuilder() + : null; + } else { + foundBuilder_.addAllMessages(other.found_); + } + } + } + if (missingBuilder_ == null) { + if (!other.missing_.isEmpty()) { + if (missing_.isEmpty()) { + missing_ = other.missing_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureMissingIsMutable(); + missing_.addAll(other.missing_); + } + onChanged(); + } + } else { + if (!other.missing_.isEmpty()) { + if (missingBuilder_.isEmpty()) { + missingBuilder_.dispose(); + missingBuilder_ = null; + missing_ = other.missing_; + bitField0_ = (bitField0_ & ~0x00000002); + missingBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getMissingFieldBuilder() + : null; + } else { + missingBuilder_.addAllMessages(other.missing_); + } + } + } + if (deferredBuilder_ == null) { + if (!other.deferred_.isEmpty()) { + if (deferred_.isEmpty()) { + deferred_ = other.deferred_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureDeferredIsMutable(); + deferred_.addAll(other.deferred_); + } + onChanged(); + } + } else { + if (!other.deferred_.isEmpty()) { + if (deferredBuilder_.isEmpty()) { + deferredBuilder_.dispose(); + deferredBuilder_ = null; + deferred_ = other.deferred_; + bitField0_ = (bitField0_ & ~0x00000004); + deferredBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getDeferredFieldBuilder() + : null; + } else { + deferredBuilder_.addAllMessages(other.deferred_); + } + } + } + if (other.getTransaction() != com.google.protobuf.ByteString.EMPTY) { + setTransaction(other.getTransaction()); + } + 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: + { + com.google.datastore.v1.EntityResult m = + input.readMessage( + com.google.datastore.v1.EntityResult.parser(), extensionRegistry); + if (foundBuilder_ == null) { + ensureFoundIsMutable(); + found_.add(m); + } else { + foundBuilder_.addMessage(m); + } + break; + } // case 10 + case 18: + { + com.google.datastore.v1.EntityResult m = + input.readMessage( + com.google.datastore.v1.EntityResult.parser(), extensionRegistry); + if (missingBuilder_ == null) { + ensureMissingIsMutable(); + missing_.add(m); + } else { + missingBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + com.google.datastore.v1.Key m = + input.readMessage(com.google.datastore.v1.Key.parser(), extensionRegistry); + if (deferredBuilder_ == null) { + ensureDeferredIsMutable(); + deferred_.add(m); + } else { + deferredBuilder_.addMessage(m); + } + break; + } // case 26 + case 42: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000008; + break; + } // case 42 + case 58: + { + input.readMessage(getReadTimeFieldBuilder().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 java.util.List found_ = + java.util.Collections.emptyList(); + + private void ensureFoundIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + found_ = new java.util.ArrayList(found_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.EntityResult, + com.google.datastore.v1.EntityResult.Builder, + com.google.datastore.v1.EntityResultOrBuilder> + foundBuilder_; + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public java.util.List getFoundList() { + if (foundBuilder_ == null) { + return java.util.Collections.unmodifiableList(found_); + } else { + return foundBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public int getFoundCount() { + if (foundBuilder_ == null) { + return found_.size(); + } else { + return foundBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public com.google.datastore.v1.EntityResult getFound(int index) { + if (foundBuilder_ == null) { + return found_.get(index); + } else { + return foundBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public Builder setFound(int index, com.google.datastore.v1.EntityResult value) { + if (foundBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFoundIsMutable(); + found_.set(index, value); + onChanged(); + } else { + foundBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public Builder setFound( + int index, com.google.datastore.v1.EntityResult.Builder builderForValue) { + if (foundBuilder_ == null) { + ensureFoundIsMutable(); + found_.set(index, builderForValue.build()); + onChanged(); + } else { + foundBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public Builder addFound(com.google.datastore.v1.EntityResult value) { + if (foundBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFoundIsMutable(); + found_.add(value); + onChanged(); + } else { + foundBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public Builder addFound(int index, com.google.datastore.v1.EntityResult value) { + if (foundBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureFoundIsMutable(); + found_.add(index, value); + onChanged(); + } else { + foundBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public Builder addFound(com.google.datastore.v1.EntityResult.Builder builderForValue) { + if (foundBuilder_ == null) { + ensureFoundIsMutable(); + found_.add(builderForValue.build()); + onChanged(); + } else { + foundBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public Builder addFound( + int index, com.google.datastore.v1.EntityResult.Builder builderForValue) { + if (foundBuilder_ == null) { + ensureFoundIsMutable(); + found_.add(index, builderForValue.build()); + onChanged(); + } else { + foundBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public Builder addAllFound( + java.lang.Iterable values) { + if (foundBuilder_ == null) { + ensureFoundIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, found_); + onChanged(); + } else { + foundBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public Builder clearFound() { + if (foundBuilder_ == null) { + found_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + foundBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public Builder removeFound(int index) { + if (foundBuilder_ == null) { + ensureFoundIsMutable(); + found_.remove(index); + onChanged(); + } else { + foundBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public com.google.datastore.v1.EntityResult.Builder getFoundBuilder(int index) { + return getFoundFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public com.google.datastore.v1.EntityResultOrBuilder getFoundOrBuilder(int index) { + if (foundBuilder_ == null) { + return found_.get(index); + } else { + return foundBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public java.util.List + getFoundOrBuilderList() { + if (foundBuilder_ != null) { + return foundBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(found_); + } + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public com.google.datastore.v1.EntityResult.Builder addFoundBuilder() { + return getFoundFieldBuilder() + .addBuilder(com.google.datastore.v1.EntityResult.getDefaultInstance()); + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public com.google.datastore.v1.EntityResult.Builder addFoundBuilder(int index) { + return getFoundFieldBuilder() + .addBuilder(index, com.google.datastore.v1.EntityResult.getDefaultInstance()); + } + + /** + * + * + *
+     * Entities found as `ResultType.FULL` entities. The order of results in this
+     * field is undefined and has no relation to the order of the keys in the
+     * input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + public java.util.List getFoundBuilderList() { + return getFoundFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.EntityResult, + com.google.datastore.v1.EntityResult.Builder, + com.google.datastore.v1.EntityResultOrBuilder> + getFoundFieldBuilder() { + if (foundBuilder_ == null) { + foundBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.EntityResult, + com.google.datastore.v1.EntityResult.Builder, + com.google.datastore.v1.EntityResultOrBuilder>( + found_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + found_ = null; + } + return foundBuilder_; + } + + private java.util.List missing_ = + java.util.Collections.emptyList(); + + private void ensureMissingIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + missing_ = new java.util.ArrayList(missing_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.EntityResult, + com.google.datastore.v1.EntityResult.Builder, + com.google.datastore.v1.EntityResultOrBuilder> + missingBuilder_; + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public java.util.List getMissingList() { + if (missingBuilder_ == null) { + return java.util.Collections.unmodifiableList(missing_); + } else { + return missingBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public int getMissingCount() { + if (missingBuilder_ == null) { + return missing_.size(); + } else { + return missingBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public com.google.datastore.v1.EntityResult getMissing(int index) { + if (missingBuilder_ == null) { + return missing_.get(index); + } else { + return missingBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public Builder setMissing(int index, com.google.datastore.v1.EntityResult value) { + if (missingBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMissingIsMutable(); + missing_.set(index, value); + onChanged(); + } else { + missingBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public Builder setMissing( + int index, com.google.datastore.v1.EntityResult.Builder builderForValue) { + if (missingBuilder_ == null) { + ensureMissingIsMutable(); + missing_.set(index, builderForValue.build()); + onChanged(); + } else { + missingBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public Builder addMissing(com.google.datastore.v1.EntityResult value) { + if (missingBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMissingIsMutable(); + missing_.add(value); + onChanged(); + } else { + missingBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public Builder addMissing(int index, com.google.datastore.v1.EntityResult value) { + if (missingBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureMissingIsMutable(); + missing_.add(index, value); + onChanged(); + } else { + missingBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public Builder addMissing(com.google.datastore.v1.EntityResult.Builder builderForValue) { + if (missingBuilder_ == null) { + ensureMissingIsMutable(); + missing_.add(builderForValue.build()); + onChanged(); + } else { + missingBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public Builder addMissing( + int index, com.google.datastore.v1.EntityResult.Builder builderForValue) { + if (missingBuilder_ == null) { + ensureMissingIsMutable(); + missing_.add(index, builderForValue.build()); + onChanged(); + } else { + missingBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public Builder addAllMissing( + java.lang.Iterable values) { + if (missingBuilder_ == null) { + ensureMissingIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, missing_); + onChanged(); + } else { + missingBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public Builder clearMissing() { + if (missingBuilder_ == null) { + missing_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + missingBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public Builder removeMissing(int index) { + if (missingBuilder_ == null) { + ensureMissingIsMutable(); + missing_.remove(index); + onChanged(); + } else { + missingBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public com.google.datastore.v1.EntityResult.Builder getMissingBuilder(int index) { + return getMissingFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public com.google.datastore.v1.EntityResultOrBuilder getMissingOrBuilder(int index) { + if (missingBuilder_ == null) { + return missing_.get(index); + } else { + return missingBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public java.util.List + getMissingOrBuilderList() { + if (missingBuilder_ != null) { + return missingBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(missing_); + } + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public com.google.datastore.v1.EntityResult.Builder addMissingBuilder() { + return getMissingFieldBuilder() + .addBuilder(com.google.datastore.v1.EntityResult.getDefaultInstance()); + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public com.google.datastore.v1.EntityResult.Builder addMissingBuilder(int index) { + return getMissingFieldBuilder() + .addBuilder(index, com.google.datastore.v1.EntityResult.getDefaultInstance()); + } + + /** + * + * + *
+     * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+     * in this field is undefined and has no relation to the order of the keys
+     * in the input.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + public java.util.List getMissingBuilderList() { + return getMissingFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.EntityResult, + com.google.datastore.v1.EntityResult.Builder, + com.google.datastore.v1.EntityResultOrBuilder> + getMissingFieldBuilder() { + if (missingBuilder_ == null) { + missingBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.EntityResult, + com.google.datastore.v1.EntityResult.Builder, + com.google.datastore.v1.EntityResultOrBuilder>( + missing_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + missing_ = null; + } + return missingBuilder_; + } + + private java.util.List deferred_ = + java.util.Collections.emptyList(); + + private void ensureDeferredIsMutable() { + if (!((bitField0_ & 0x00000004) != 0)) { + deferred_ = new java.util.ArrayList(deferred_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + deferredBuilder_; + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public java.util.List getDeferredList() { + if (deferredBuilder_ == null) { + return java.util.Collections.unmodifiableList(deferred_); + } else { + return deferredBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public int getDeferredCount() { + if (deferredBuilder_ == null) { + return deferred_.size(); + } else { + return deferredBuilder_.getCount(); + } + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public com.google.datastore.v1.Key getDeferred(int index) { + if (deferredBuilder_ == null) { + return deferred_.get(index); + } else { + return deferredBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public Builder setDeferred(int index, com.google.datastore.v1.Key value) { + if (deferredBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDeferredIsMutable(); + deferred_.set(index, value); + onChanged(); + } else { + deferredBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public Builder setDeferred(int index, com.google.datastore.v1.Key.Builder builderForValue) { + if (deferredBuilder_ == null) { + ensureDeferredIsMutable(); + deferred_.set(index, builderForValue.build()); + onChanged(); + } else { + deferredBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public Builder addDeferred(com.google.datastore.v1.Key value) { + if (deferredBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDeferredIsMutable(); + deferred_.add(value); + onChanged(); + } else { + deferredBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public Builder addDeferred(int index, com.google.datastore.v1.Key value) { + if (deferredBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDeferredIsMutable(); + deferred_.add(index, value); + onChanged(); + } else { + deferredBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public Builder addDeferred(com.google.datastore.v1.Key.Builder builderForValue) { + if (deferredBuilder_ == null) { + ensureDeferredIsMutable(); + deferred_.add(builderForValue.build()); + onChanged(); + } else { + deferredBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public Builder addDeferred(int index, com.google.datastore.v1.Key.Builder builderForValue) { + if (deferredBuilder_ == null) { + ensureDeferredIsMutable(); + deferred_.add(index, builderForValue.build()); + onChanged(); + } else { + deferredBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public Builder addAllDeferred( + java.lang.Iterable values) { + if (deferredBuilder_ == null) { + ensureDeferredIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, deferred_); + onChanged(); + } else { + deferredBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public Builder clearDeferred() { + if (deferredBuilder_ == null) { + deferred_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + deferredBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public Builder removeDeferred(int index) { + if (deferredBuilder_ == null) { + ensureDeferredIsMutable(); + deferred_.remove(index); + onChanged(); + } else { + deferredBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public com.google.datastore.v1.Key.Builder getDeferredBuilder(int index) { + return getDeferredFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public com.google.datastore.v1.KeyOrBuilder getDeferredOrBuilder(int index) { + if (deferredBuilder_ == null) { + return deferred_.get(index); + } else { + return deferredBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public java.util.List + getDeferredOrBuilderList() { + if (deferredBuilder_ != null) { + return deferredBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(deferred_); + } + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public com.google.datastore.v1.Key.Builder addDeferredBuilder() { + return getDeferredFieldBuilder().addBuilder(com.google.datastore.v1.Key.getDefaultInstance()); + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public com.google.datastore.v1.Key.Builder addDeferredBuilder(int index) { + return getDeferredFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Key.getDefaultInstance()); + } + + /** + * + * + *
+     * A list of keys that were not looked up due to resource constraints. The
+     * order of results in this field is undefined and has no relation to the
+     * order of the keys in the input.
+     * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + public java.util.List getDeferredBuilderList() { + return getDeferredFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + getDeferredFieldBuilder() { + if (deferredBuilder_ == null) { + deferredBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder>( + deferred_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean()); + deferred_ = null; + } + return deferredBuilder_; + } + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * The identifier of the transaction that was started as part of this Lookup
+     * request.
+     *
+     * Set only when
+     * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+     * was set in
+     * [LookupRequest.read_options][google.datastore.v1.LookupRequest.read_options].
+     * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * The identifier of the transaction that was started as part of this Lookup
+     * request.
+     *
+     * Set only when
+     * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+     * was set in
+     * [LookupRequest.read_options][google.datastore.v1.LookupRequest.read_options].
+     * 
+ * + * 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(); + } + transaction_ = value; + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The identifier of the transaction that was started as part of this Lookup
+     * request.
+     *
+     * Set only when
+     * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+     * was set in
+     * [LookupRequest.read_options][google.datastore.v1.LookupRequest.read_options].
+     * 
+ * + * bytes transaction = 5; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000008); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * The time at which these entities were read or found missing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000010) != 0); + } + + /** + * + * + *
+     * The time at which these entities were read or found missing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @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 these entities were read or found missing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + 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 time at which these entities were read or found missing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + 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 time at which these entities were read or found missing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + 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 time at which these entities were read or found missing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000010); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The time at which these entities were read or found missing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000010; + onChanged(); + return getReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The time at which these entities were read or found missing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + 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 these entities were read or found missing.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.LookupResponse) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.LookupResponse) + private static final com.google.datastore.v1.LookupResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.LookupResponse(); + } + + public static com.google.datastore.v1.LookupResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public LookupResponse 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.datastore.v1.LookupResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponseOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponseOrBuilder.java new file mode 100644 index 000000000000..929916c68eee --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/LookupResponseOrBuilder.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! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface LookupResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.LookupResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Entities found as `ResultType.FULL` entities. The order of results in this
+   * field is undefined and has no relation to the order of the keys in the
+   * input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + java.util.List getFoundList(); + + /** + * + * + *
+   * Entities found as `ResultType.FULL` entities. The order of results in this
+   * field is undefined and has no relation to the order of the keys in the
+   * input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + com.google.datastore.v1.EntityResult getFound(int index); + + /** + * + * + *
+   * Entities found as `ResultType.FULL` entities. The order of results in this
+   * field is undefined and has no relation to the order of the keys in the
+   * input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + int getFoundCount(); + + /** + * + * + *
+   * Entities found as `ResultType.FULL` entities. The order of results in this
+   * field is undefined and has no relation to the order of the keys in the
+   * input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + java.util.List getFoundOrBuilderList(); + + /** + * + * + *
+   * Entities found as `ResultType.FULL` entities. The order of results in this
+   * field is undefined and has no relation to the order of the keys in the
+   * input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult found = 1; + */ + com.google.datastore.v1.EntityResultOrBuilder getFoundOrBuilder(int index); + + /** + * + * + *
+   * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+   * in this field is undefined and has no relation to the order of the keys
+   * in the input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + java.util.List getMissingList(); + + /** + * + * + *
+   * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+   * in this field is undefined and has no relation to the order of the keys
+   * in the input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + com.google.datastore.v1.EntityResult getMissing(int index); + + /** + * + * + *
+   * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+   * in this field is undefined and has no relation to the order of the keys
+   * in the input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + int getMissingCount(); + + /** + * + * + *
+   * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+   * in this field is undefined and has no relation to the order of the keys
+   * in the input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + java.util.List getMissingOrBuilderList(); + + /** + * + * + *
+   * Entities not found as `ResultType.KEY_ONLY` entities. The order of results
+   * in this field is undefined and has no relation to the order of the keys
+   * in the input.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult missing = 2; + */ + com.google.datastore.v1.EntityResultOrBuilder getMissingOrBuilder(int index); + + /** + * + * + *
+   * A list of keys that were not looked up due to resource constraints. The
+   * order of results in this field is undefined and has no relation to the
+   * order of the keys in the input.
+   * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + java.util.List getDeferredList(); + + /** + * + * + *
+   * A list of keys that were not looked up due to resource constraints. The
+   * order of results in this field is undefined and has no relation to the
+   * order of the keys in the input.
+   * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + com.google.datastore.v1.Key getDeferred(int index); + + /** + * + * + *
+   * A list of keys that were not looked up due to resource constraints. The
+   * order of results in this field is undefined and has no relation to the
+   * order of the keys in the input.
+   * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + int getDeferredCount(); + + /** + * + * + *
+   * A list of keys that were not looked up due to resource constraints. The
+   * order of results in this field is undefined and has no relation to the
+   * order of the keys in the input.
+   * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + java.util.List getDeferredOrBuilderList(); + + /** + * + * + *
+   * A list of keys that were not looked up due to resource constraints. The
+   * order of results in this field is undefined and has no relation to the
+   * order of the keys in the input.
+   * 
+ * + * repeated .google.datastore.v1.Key deferred = 3; + */ + com.google.datastore.v1.KeyOrBuilder getDeferredOrBuilder(int index); + + /** + * + * + *
+   * The identifier of the transaction that was started as part of this Lookup
+   * request.
+   *
+   * Set only when
+   * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+   * was set in
+   * [LookupRequest.read_options][google.datastore.v1.LookupRequest.read_options].
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * The time at which these entities were read or found missing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * The time at which these entities were read or found missing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * The time at which these entities were read or found missing.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 7; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Mutation.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Mutation.java new file mode 100644 index 000000000000..0242260b90c4 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Mutation.java @@ -0,0 +1,3739 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A mutation to apply to an entity.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.Mutation} + */ +public final class Mutation extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.Mutation) + MutationOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Mutation.newBuilder() to construct. + private Mutation(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Mutation() { + conflictResolutionStrategy_ = 0; + propertyTransforms_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Mutation(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_Mutation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_Mutation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Mutation.class, com.google.datastore.v1.Mutation.Builder.class); + } + + /** + * + * + *
+   * The possible ways to resolve a conflict detected in a mutation.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.Mutation.ConflictResolutionStrategy} + */ + public enum ConflictResolutionStrategy implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. Defaults to `SERVER_VALUE`.
+     * 
+ * + * STRATEGY_UNSPECIFIED = 0; + */ + STRATEGY_UNSPECIFIED(0), + /** + * + * + *
+     * The server entity is kept.
+     * 
+ * + * SERVER_VALUE = 1; + */ + SERVER_VALUE(1), + /** + * + * + *
+     * The whole commit request fails.
+     * 
+ * + * FAIL = 3; + */ + FAIL(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified. Defaults to `SERVER_VALUE`.
+     * 
+ * + * STRATEGY_UNSPECIFIED = 0; + */ + public static final int STRATEGY_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * The server entity is kept.
+     * 
+ * + * SERVER_VALUE = 1; + */ + public static final int SERVER_VALUE_VALUE = 1; + + /** + * + * + *
+     * The whole commit request fails.
+     * 
+ * + * FAIL = 3; + */ + public static final int FAIL_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 ConflictResolutionStrategy 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 ConflictResolutionStrategy forNumber(int value) { + switch (value) { + case 0: + return STRATEGY_UNSPECIFIED; + case 1: + return SERVER_VALUE; + case 3: + return FAIL; + 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 ConflictResolutionStrategy findValueByNumber(int number) { + return ConflictResolutionStrategy.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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.Mutation.getDescriptor().getEnumTypes().get(0); + } + + private static final ConflictResolutionStrategy[] VALUES = values(); + + public static ConflictResolutionStrategy 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 ConflictResolutionStrategy(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.v1.Mutation.ConflictResolutionStrategy) + } + + 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 { + INSERT(4), + UPDATE(5), + UPSERT(6), + DELETE(7), + 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 4: + return INSERT; + case 5: + return UPDATE; + case 6: + return UPSERT; + case 7: + return DELETE; + case 0: + return OPERATION_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public OperationCase getOperationCase() { + return OperationCase.forNumber(operationCase_); + } + + private int conflictDetectionStrategyCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object conflictDetectionStrategy_; + + public enum ConflictDetectionStrategyCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + BASE_VERSION(8), + UPDATE_TIME(11), + CONFLICTDETECTIONSTRATEGY_NOT_SET(0); + private final int value; + + private ConflictDetectionStrategyCase(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 ConflictDetectionStrategyCase valueOf(int value) { + return forNumber(value); + } + + public static ConflictDetectionStrategyCase forNumber(int value) { + switch (value) { + case 8: + return BASE_VERSION; + case 11: + return UPDATE_TIME; + case 0: + return CONFLICTDETECTIONSTRATEGY_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConflictDetectionStrategyCase getConflictDetectionStrategyCase() { + return ConflictDetectionStrategyCase.forNumber(conflictDetectionStrategyCase_); + } + + public static final int INSERT_FIELD_NUMBER = 4; + + /** + * + * + *
+   * The entity to insert. The entity must not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity insert = 4; + * + * @return Whether the insert field is set. + */ + @java.lang.Override + public boolean hasInsert() { + return operationCase_ == 4; + } + + /** + * + * + *
+   * The entity to insert. The entity must not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity insert = 4; + * + * @return The insert. + */ + @java.lang.Override + public com.google.datastore.v1.Entity getInsert() { + if (operationCase_ == 4) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + + /** + * + * + *
+   * The entity to insert. The entity must not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity insert = 4; + */ + @java.lang.Override + public com.google.datastore.v1.EntityOrBuilder getInsertOrBuilder() { + if (operationCase_ == 4) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + + public static final int UPDATE_FIELD_NUMBER = 5; + + /** + * + * + *
+   * The entity to update. The entity must already exist.
+   * Must have a complete key path.
+   * 
+ * + * .google.datastore.v1.Entity update = 5; + * + * @return Whether the update field is set. + */ + @java.lang.Override + public boolean hasUpdate() { + return operationCase_ == 5; + } + + /** + * + * + *
+   * The entity to update. The entity must already exist.
+   * Must have a complete key path.
+   * 
+ * + * .google.datastore.v1.Entity update = 5; + * + * @return The update. + */ + @java.lang.Override + public com.google.datastore.v1.Entity getUpdate() { + if (operationCase_ == 5) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + + /** + * + * + *
+   * The entity to update. The entity must already exist.
+   * Must have a complete key path.
+   * 
+ * + * .google.datastore.v1.Entity update = 5; + */ + @java.lang.Override + public com.google.datastore.v1.EntityOrBuilder getUpdateOrBuilder() { + if (operationCase_ == 5) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + + public static final int UPSERT_FIELD_NUMBER = 6; + + /** + * + * + *
+   * The entity to upsert. The entity may or may not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity upsert = 6; + * + * @return Whether the upsert field is set. + */ + @java.lang.Override + public boolean hasUpsert() { + return operationCase_ == 6; + } + + /** + * + * + *
+   * The entity to upsert. The entity may or may not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity upsert = 6; + * + * @return The upsert. + */ + @java.lang.Override + public com.google.datastore.v1.Entity getUpsert() { + if (operationCase_ == 6) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + + /** + * + * + *
+   * The entity to upsert. The entity may or may not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity upsert = 6; + */ + @java.lang.Override + public com.google.datastore.v1.EntityOrBuilder getUpsertOrBuilder() { + if (operationCase_ == 6) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + + public static final int DELETE_FIELD_NUMBER = 7; + + /** + * + * + *
+   * The key of the entity to delete. The entity may or may not already exist.
+   * Must have a complete key path and must not be reserved/read-only.
+   * 
+ * + * .google.datastore.v1.Key delete = 7; + * + * @return Whether the delete field is set. + */ + @java.lang.Override + public boolean hasDelete() { + return operationCase_ == 7; + } + + /** + * + * + *
+   * The key of the entity to delete. The entity may or may not already exist.
+   * Must have a complete key path and must not be reserved/read-only.
+   * 
+ * + * .google.datastore.v1.Key delete = 7; + * + * @return The delete. + */ + @java.lang.Override + public com.google.datastore.v1.Key getDelete() { + if (operationCase_ == 7) { + return (com.google.datastore.v1.Key) operation_; + } + return com.google.datastore.v1.Key.getDefaultInstance(); + } + + /** + * + * + *
+   * The key of the entity to delete. The entity may or may not already exist.
+   * Must have a complete key path and must not be reserved/read-only.
+   * 
+ * + * .google.datastore.v1.Key delete = 7; + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getDeleteOrBuilder() { + if (operationCase_ == 7) { + return (com.google.datastore.v1.Key) operation_; + } + return com.google.datastore.v1.Key.getDefaultInstance(); + } + + public static final int BASE_VERSION_FIELD_NUMBER = 8; + + /** + * + * + *
+   * The version of the entity that this mutation is being applied
+   * to. If this does not match the current version on the server, the
+   * mutation conflicts.
+   * 
+ * + * int64 base_version = 8; + * + * @return Whether the baseVersion field is set. + */ + @java.lang.Override + public boolean hasBaseVersion() { + return conflictDetectionStrategyCase_ == 8; + } + + /** + * + * + *
+   * The version of the entity that this mutation is being applied
+   * to. If this does not match the current version on the server, the
+   * mutation conflicts.
+   * 
+ * + * int64 base_version = 8; + * + * @return The baseVersion. + */ + @java.lang.Override + public long getBaseVersion() { + if (conflictDetectionStrategyCase_ == 8) { + return (java.lang.Long) conflictDetectionStrategy_; + } + return 0L; + } + + public static final int UPDATE_TIME_FIELD_NUMBER = 11; + + /** + * + * + *
+   * The update time of the entity that this mutation is being applied
+   * to. If this does not match the current update time on the server, the
+   * mutation conflicts.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 11; + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return conflictDetectionStrategyCase_ == 11; + } + + /** + * + * + *
+   * The update time of the entity that this mutation is being applied
+   * to. If this does not match the current update time on the server, the
+   * mutation conflicts.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 11; + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + if (conflictDetectionStrategyCase_ == 11) { + return (com.google.protobuf.Timestamp) conflictDetectionStrategy_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * The update time of the entity that this mutation is being applied
+   * to. If this does not match the current update time on the server, the
+   * mutation conflicts.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 11; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (conflictDetectionStrategyCase_ == 11) { + return (com.google.protobuf.Timestamp) conflictDetectionStrategy_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + public static final int CONFLICT_RESOLUTION_STRATEGY_FIELD_NUMBER = 10; + private int conflictResolutionStrategy_ = 0; + + /** + * + * + *
+   * The strategy to use when a conflict is detected. Defaults to
+   * `SERVER_VALUE`.
+   * If this is set, then `conflict_detection_strategy` must also be set.
+   * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The enum numeric value on the wire for conflictResolutionStrategy. + */ + @java.lang.Override + public int getConflictResolutionStrategyValue() { + return conflictResolutionStrategy_; + } + + /** + * + * + *
+   * The strategy to use when a conflict is detected. Defaults to
+   * `SERVER_VALUE`.
+   * If this is set, then `conflict_detection_strategy` must also be set.
+   * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The conflictResolutionStrategy. + */ + @java.lang.Override + public com.google.datastore.v1.Mutation.ConflictResolutionStrategy + getConflictResolutionStrategy() { + com.google.datastore.v1.Mutation.ConflictResolutionStrategy result = + com.google.datastore.v1.Mutation.ConflictResolutionStrategy.forNumber( + conflictResolutionStrategy_); + return result == null + ? com.google.datastore.v1.Mutation.ConflictResolutionStrategy.UNRECOGNIZED + : result; + } + + public static final int PROPERTY_MASK_FIELD_NUMBER = 9; + private com.google.datastore.v1.PropertyMask propertyMask_; + + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return Whether the propertyMask field is set. + */ + @java.lang.Override + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return The propertyMask. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMask getPropertyMask() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + + public static final int PROPERTY_TRANSFORMS_FIELD_NUMBER = 12; + + @SuppressWarnings("serial") + private java.util.List propertyTransforms_; + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List getPropertyTransformsList() { + return propertyTransforms_; + } + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public java.util.List + getPropertyTransformsOrBuilderList() { + return propertyTransforms_; + } + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public int getPropertyTransformsCount() { + return propertyTransforms_.size(); + } + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.datastore.v1.PropertyTransform getPropertyTransforms(int index) { + return propertyTransforms_.get(index); + } + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.datastore.v1.PropertyTransformOrBuilder getPropertyTransformsOrBuilder( + int index) { + return propertyTransforms_.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 (operationCase_ == 4) { + output.writeMessage(4, (com.google.datastore.v1.Entity) operation_); + } + if (operationCase_ == 5) { + output.writeMessage(5, (com.google.datastore.v1.Entity) operation_); + } + if (operationCase_ == 6) { + output.writeMessage(6, (com.google.datastore.v1.Entity) operation_); + } + if (operationCase_ == 7) { + output.writeMessage(7, (com.google.datastore.v1.Key) operation_); + } + if (conflictDetectionStrategyCase_ == 8) { + output.writeInt64(8, (long) ((java.lang.Long) conflictDetectionStrategy_)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(9, getPropertyMask()); + } + if (conflictResolutionStrategy_ + != com.google.datastore.v1.Mutation.ConflictResolutionStrategy.STRATEGY_UNSPECIFIED + .getNumber()) { + output.writeEnum(10, conflictResolutionStrategy_); + } + if (conflictDetectionStrategyCase_ == 11) { + output.writeMessage(11, (com.google.protobuf.Timestamp) conflictDetectionStrategy_); + } + for (int i = 0; i < propertyTransforms_.size(); i++) { + output.writeMessage(12, propertyTransforms_.get(i)); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (operationCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.datastore.v1.Entity) operation_); + } + if (operationCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 5, (com.google.datastore.v1.Entity) operation_); + } + if (operationCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.datastore.v1.Entity) operation_); + } + if (operationCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.datastore.v1.Key) operation_); + } + if (conflictDetectionStrategyCase_ == 8) { + size += + com.google.protobuf.CodedOutputStream.computeInt64Size( + 8, (long) ((java.lang.Long) conflictDetectionStrategy_)); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, getPropertyMask()); + } + if (conflictResolutionStrategy_ + != com.google.datastore.v1.Mutation.ConflictResolutionStrategy.STRATEGY_UNSPECIFIED + .getNumber()) { + size += + com.google.protobuf.CodedOutputStream.computeEnumSize(10, conflictResolutionStrategy_); + } + if (conflictDetectionStrategyCase_ == 11) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 11, (com.google.protobuf.Timestamp) conflictDetectionStrategy_); + } + for (int i = 0; i < propertyTransforms_.size(); i++) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize(12, propertyTransforms_.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.datastore.v1.Mutation)) { + return super.equals(obj); + } + com.google.datastore.v1.Mutation other = (com.google.datastore.v1.Mutation) obj; + + if (conflictResolutionStrategy_ != other.conflictResolutionStrategy_) return false; + if (hasPropertyMask() != other.hasPropertyMask()) return false; + if (hasPropertyMask()) { + if (!getPropertyMask().equals(other.getPropertyMask())) return false; + } + if (!getPropertyTransformsList().equals(other.getPropertyTransformsList())) return false; + if (!getOperationCase().equals(other.getOperationCase())) return false; + switch (operationCase_) { + case 4: + if (!getInsert().equals(other.getInsert())) return false; + break; + case 5: + if (!getUpdate().equals(other.getUpdate())) return false; + break; + case 6: + if (!getUpsert().equals(other.getUpsert())) return false; + break; + case 7: + if (!getDelete().equals(other.getDelete())) return false; + break; + case 0: + default: + } + if (!getConflictDetectionStrategyCase().equals(other.getConflictDetectionStrategyCase())) + return false; + switch (conflictDetectionStrategyCase_) { + case 8: + if (getBaseVersion() != other.getBaseVersion()) return false; + break; + case 11: + 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(); + hash = (37 * hash) + CONFLICT_RESOLUTION_STRATEGY_FIELD_NUMBER; + hash = (53 * hash) + conflictResolutionStrategy_; + if (hasPropertyMask()) { + hash = (37 * hash) + PROPERTY_MASK_FIELD_NUMBER; + hash = (53 * hash) + getPropertyMask().hashCode(); + } + if (getPropertyTransformsCount() > 0) { + hash = (37 * hash) + PROPERTY_TRANSFORMS_FIELD_NUMBER; + hash = (53 * hash) + getPropertyTransformsList().hashCode(); + } + switch (operationCase_) { + case 4: + hash = (37 * hash) + INSERT_FIELD_NUMBER; + hash = (53 * hash) + getInsert().hashCode(); + break; + case 5: + hash = (37 * hash) + UPDATE_FIELD_NUMBER; + hash = (53 * hash) + getUpdate().hashCode(); + break; + case 6: + hash = (37 * hash) + UPSERT_FIELD_NUMBER; + hash = (53 * hash) + getUpsert().hashCode(); + break; + case 7: + hash = (37 * hash) + DELETE_FIELD_NUMBER; + hash = (53 * hash) + getDelete().hashCode(); + break; + case 0: + default: + } + switch (conflictDetectionStrategyCase_) { + case 8: + hash = (37 * hash) + BASE_VERSION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getBaseVersion()); + break; + case 11: + 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.datastore.v1.Mutation parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Mutation parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Mutation parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Mutation 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.datastore.v1.Mutation parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Mutation parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Mutation parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Mutation parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Mutation parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Mutation parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Mutation parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Mutation parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.Mutation 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A mutation to apply to an entity.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.Mutation} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.Mutation) + com.google.datastore.v1.MutationOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_Mutation_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_Mutation_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Mutation.class, + com.google.datastore.v1.Mutation.Builder.class); + } + + // Construct using com.google.datastore.v1.Mutation.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPropertyMaskFieldBuilder(); + getPropertyTransformsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (insertBuilder_ != null) { + insertBuilder_.clear(); + } + if (updateBuilder_ != null) { + updateBuilder_.clear(); + } + if (upsertBuilder_ != null) { + upsertBuilder_.clear(); + } + if (deleteBuilder_ != null) { + deleteBuilder_.clear(); + } + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.clear(); + } + conflictResolutionStrategy_ = 0; + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } + if (propertyTransformsBuilder_ == null) { + propertyTransforms_ = java.util.Collections.emptyList(); + } else { + propertyTransforms_ = null; + propertyTransformsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000100); + operationCase_ = 0; + operation_ = null; + conflictDetectionStrategyCase_ = 0; + conflictDetectionStrategy_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_Mutation_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.Mutation getDefaultInstanceForType() { + return com.google.datastore.v1.Mutation.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.Mutation build() { + com.google.datastore.v1.Mutation result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.Mutation buildPartial() { + com.google.datastore.v1.Mutation result = new com.google.datastore.v1.Mutation(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.Mutation result) { + if (propertyTransformsBuilder_ == null) { + if (((bitField0_ & 0x00000100) != 0)) { + propertyTransforms_ = java.util.Collections.unmodifiableList(propertyTransforms_); + bitField0_ = (bitField0_ & ~0x00000100); + } + result.propertyTransforms_ = propertyTransforms_; + } else { + result.propertyTransforms_ = propertyTransformsBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.Mutation result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000040) != 0)) { + result.conflictResolutionStrategy_ = conflictResolutionStrategy_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000080) != 0)) { + result.propertyMask_ = + propertyMaskBuilder_ == null ? propertyMask_ : propertyMaskBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.datastore.v1.Mutation result) { + result.operationCase_ = operationCase_; + result.operation_ = this.operation_; + if (operationCase_ == 4 && insertBuilder_ != null) { + result.operation_ = insertBuilder_.build(); + } + if (operationCase_ == 5 && updateBuilder_ != null) { + result.operation_ = updateBuilder_.build(); + } + if (operationCase_ == 6 && upsertBuilder_ != null) { + result.operation_ = upsertBuilder_.build(); + } + if (operationCase_ == 7 && deleteBuilder_ != null) { + result.operation_ = deleteBuilder_.build(); + } + result.conflictDetectionStrategyCase_ = conflictDetectionStrategyCase_; + result.conflictDetectionStrategy_ = this.conflictDetectionStrategy_; + if (conflictDetectionStrategyCase_ == 11 && updateTimeBuilder_ != null) { + result.conflictDetectionStrategy_ = updateTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.Mutation) { + return mergeFrom((com.google.datastore.v1.Mutation) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.Mutation other) { + if (other == com.google.datastore.v1.Mutation.getDefaultInstance()) return this; + if (other.conflictResolutionStrategy_ != 0) { + setConflictResolutionStrategyValue(other.getConflictResolutionStrategyValue()); + } + if (other.hasPropertyMask()) { + mergePropertyMask(other.getPropertyMask()); + } + if (propertyTransformsBuilder_ == null) { + if (!other.propertyTransforms_.isEmpty()) { + if (propertyTransforms_.isEmpty()) { + propertyTransforms_ = other.propertyTransforms_; + bitField0_ = (bitField0_ & ~0x00000100); + } else { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.addAll(other.propertyTransforms_); + } + onChanged(); + } + } else { + if (!other.propertyTransforms_.isEmpty()) { + if (propertyTransformsBuilder_.isEmpty()) { + propertyTransformsBuilder_.dispose(); + propertyTransformsBuilder_ = null; + propertyTransforms_ = other.propertyTransforms_; + bitField0_ = (bitField0_ & ~0x00000100); + propertyTransformsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getPropertyTransformsFieldBuilder() + : null; + } else { + propertyTransformsBuilder_.addAllMessages(other.propertyTransforms_); + } + } + } + switch (other.getOperationCase()) { + case INSERT: + { + mergeInsert(other.getInsert()); + break; + } + case UPDATE: + { + mergeUpdate(other.getUpdate()); + break; + } + case UPSERT: + { + mergeUpsert(other.getUpsert()); + break; + } + case DELETE: + { + mergeDelete(other.getDelete()); + break; + } + case OPERATION_NOT_SET: + { + break; + } + } + switch (other.getConflictDetectionStrategyCase()) { + case BASE_VERSION: + { + setBaseVersion(other.getBaseVersion()); + break; + } + case UPDATE_TIME: + { + mergeUpdateTime(other.getUpdateTime()); + break; + } + case CONFLICTDETECTIONSTRATEGY_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 34: + { + input.readMessage(getInsertFieldBuilder().getBuilder(), extensionRegistry); + operationCase_ = 4; + break; + } // case 34 + case 42: + { + input.readMessage(getUpdateFieldBuilder().getBuilder(), extensionRegistry); + operationCase_ = 5; + break; + } // case 42 + case 50: + { + input.readMessage(getUpsertFieldBuilder().getBuilder(), extensionRegistry); + operationCase_ = 6; + break; + } // case 50 + case 58: + { + input.readMessage(getDeleteFieldBuilder().getBuilder(), extensionRegistry); + operationCase_ = 7; + break; + } // case 58 + case 64: + { + conflictDetectionStrategy_ = input.readInt64(); + conflictDetectionStrategyCase_ = 8; + break; + } // case 64 + case 74: + { + input.readMessage(getPropertyMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000080; + break; + } // case 74 + case 80: + { + conflictResolutionStrategy_ = input.readEnum(); + bitField0_ |= 0x00000040; + break; + } // case 80 + case 90: + { + input.readMessage(getUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + conflictDetectionStrategyCase_ = 11; + break; + } // case 90 + case 98: + { + com.google.datastore.v1.PropertyTransform m = + input.readMessage( + com.google.datastore.v1.PropertyTransform.parser(), extensionRegistry); + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.add(m); + } else { + propertyTransformsBuilder_.addMessage(m); + } + 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 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 conflictDetectionStrategyCase_ = 0; + private java.lang.Object conflictDetectionStrategy_; + + public ConflictDetectionStrategyCase getConflictDetectionStrategyCase() { + return ConflictDetectionStrategyCase.forNumber(conflictDetectionStrategyCase_); + } + + public Builder clearConflictDetectionStrategy() { + conflictDetectionStrategyCase_ = 0; + conflictDetectionStrategy_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder> + insertBuilder_; + + /** + * + * + *
+     * The entity to insert. The entity must not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity insert = 4; + * + * @return Whether the insert field is set. + */ + @java.lang.Override + public boolean hasInsert() { + return operationCase_ == 4; + } + + /** + * + * + *
+     * The entity to insert. The entity must not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity insert = 4; + * + * @return The insert. + */ + @java.lang.Override + public com.google.datastore.v1.Entity getInsert() { + if (insertBuilder_ == null) { + if (operationCase_ == 4) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } else { + if (operationCase_ == 4) { + return insertBuilder_.getMessage(); + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The entity to insert. The entity must not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity insert = 4; + */ + public Builder setInsert(com.google.datastore.v1.Entity value) { + if (insertBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + operation_ = value; + onChanged(); + } else { + insertBuilder_.setMessage(value); + } + operationCase_ = 4; + return this; + } + + /** + * + * + *
+     * The entity to insert. The entity must not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity insert = 4; + */ + public Builder setInsert(com.google.datastore.v1.Entity.Builder builderForValue) { + if (insertBuilder_ == null) { + operation_ = builderForValue.build(); + onChanged(); + } else { + insertBuilder_.setMessage(builderForValue.build()); + } + operationCase_ = 4; + return this; + } + + /** + * + * + *
+     * The entity to insert. The entity must not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity insert = 4; + */ + public Builder mergeInsert(com.google.datastore.v1.Entity value) { + if (insertBuilder_ == null) { + if (operationCase_ == 4 + && operation_ != com.google.datastore.v1.Entity.getDefaultInstance()) { + operation_ = + com.google.datastore.v1.Entity.newBuilder((com.google.datastore.v1.Entity) operation_) + .mergeFrom(value) + .buildPartial(); + } else { + operation_ = value; + } + onChanged(); + } else { + if (operationCase_ == 4) { + insertBuilder_.mergeFrom(value); + } else { + insertBuilder_.setMessage(value); + } + } + operationCase_ = 4; + return this; + } + + /** + * + * + *
+     * The entity to insert. The entity must not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity insert = 4; + */ + public Builder clearInsert() { + if (insertBuilder_ == null) { + if (operationCase_ == 4) { + operationCase_ = 0; + operation_ = null; + onChanged(); + } + } else { + if (operationCase_ == 4) { + operationCase_ = 0; + operation_ = null; + } + insertBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The entity to insert. The entity must not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity insert = 4; + */ + public com.google.datastore.v1.Entity.Builder getInsertBuilder() { + return getInsertFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The entity to insert. The entity must not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity insert = 4; + */ + @java.lang.Override + public com.google.datastore.v1.EntityOrBuilder getInsertOrBuilder() { + if ((operationCase_ == 4) && (insertBuilder_ != null)) { + return insertBuilder_.getMessageOrBuilder(); + } else { + if (operationCase_ == 4) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The entity to insert. The entity must not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity insert = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder> + getInsertFieldBuilder() { + if (insertBuilder_ == null) { + if (!(operationCase_ == 4)) { + operation_ = com.google.datastore.v1.Entity.getDefaultInstance(); + } + insertBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder>( + (com.google.datastore.v1.Entity) operation_, getParentForChildren(), isClean()); + operation_ = null; + } + operationCase_ = 4; + onChanged(); + return insertBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder> + updateBuilder_; + + /** + * + * + *
+     * The entity to update. The entity must already exist.
+     * Must have a complete key path.
+     * 
+ * + * .google.datastore.v1.Entity update = 5; + * + * @return Whether the update field is set. + */ + @java.lang.Override + public boolean hasUpdate() { + return operationCase_ == 5; + } + + /** + * + * + *
+     * The entity to update. The entity must already exist.
+     * Must have a complete key path.
+     * 
+ * + * .google.datastore.v1.Entity update = 5; + * + * @return The update. + */ + @java.lang.Override + public com.google.datastore.v1.Entity getUpdate() { + if (updateBuilder_ == null) { + if (operationCase_ == 5) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } else { + if (operationCase_ == 5) { + return updateBuilder_.getMessage(); + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The entity to update. The entity must already exist.
+     * Must have a complete key path.
+     * 
+ * + * .google.datastore.v1.Entity update = 5; + */ + public Builder setUpdate(com.google.datastore.v1.Entity value) { + if (updateBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + operation_ = value; + onChanged(); + } else { + updateBuilder_.setMessage(value); + } + operationCase_ = 5; + return this; + } + + /** + * + * + *
+     * The entity to update. The entity must already exist.
+     * Must have a complete key path.
+     * 
+ * + * .google.datastore.v1.Entity update = 5; + */ + public Builder setUpdate(com.google.datastore.v1.Entity.Builder builderForValue) { + if (updateBuilder_ == null) { + operation_ = builderForValue.build(); + onChanged(); + } else { + updateBuilder_.setMessage(builderForValue.build()); + } + operationCase_ = 5; + return this; + } + + /** + * + * + *
+     * The entity to update. The entity must already exist.
+     * Must have a complete key path.
+     * 
+ * + * .google.datastore.v1.Entity update = 5; + */ + public Builder mergeUpdate(com.google.datastore.v1.Entity value) { + if (updateBuilder_ == null) { + if (operationCase_ == 5 + && operation_ != com.google.datastore.v1.Entity.getDefaultInstance()) { + operation_ = + com.google.datastore.v1.Entity.newBuilder((com.google.datastore.v1.Entity) operation_) + .mergeFrom(value) + .buildPartial(); + } else { + operation_ = value; + } + onChanged(); + } else { + if (operationCase_ == 5) { + updateBuilder_.mergeFrom(value); + } else { + updateBuilder_.setMessage(value); + } + } + operationCase_ = 5; + return this; + } + + /** + * + * + *
+     * The entity to update. The entity must already exist.
+     * Must have a complete key path.
+     * 
+ * + * .google.datastore.v1.Entity update = 5; + */ + public Builder clearUpdate() { + if (updateBuilder_ == null) { + if (operationCase_ == 5) { + operationCase_ = 0; + operation_ = null; + onChanged(); + } + } else { + if (operationCase_ == 5) { + operationCase_ = 0; + operation_ = null; + } + updateBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The entity to update. The entity must already exist.
+     * Must have a complete key path.
+     * 
+ * + * .google.datastore.v1.Entity update = 5; + */ + public com.google.datastore.v1.Entity.Builder getUpdateBuilder() { + return getUpdateFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The entity to update. The entity must already exist.
+     * Must have a complete key path.
+     * 
+ * + * .google.datastore.v1.Entity update = 5; + */ + @java.lang.Override + public com.google.datastore.v1.EntityOrBuilder getUpdateOrBuilder() { + if ((operationCase_ == 5) && (updateBuilder_ != null)) { + return updateBuilder_.getMessageOrBuilder(); + } else { + if (operationCase_ == 5) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The entity to update. The entity must already exist.
+     * Must have a complete key path.
+     * 
+ * + * .google.datastore.v1.Entity update = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder> + getUpdateFieldBuilder() { + if (updateBuilder_ == null) { + if (!(operationCase_ == 5)) { + operation_ = com.google.datastore.v1.Entity.getDefaultInstance(); + } + updateBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder>( + (com.google.datastore.v1.Entity) operation_, getParentForChildren(), isClean()); + operation_ = null; + } + operationCase_ = 5; + onChanged(); + return updateBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder> + upsertBuilder_; + + /** + * + * + *
+     * The entity to upsert. The entity may or may not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity upsert = 6; + * + * @return Whether the upsert field is set. + */ + @java.lang.Override + public boolean hasUpsert() { + return operationCase_ == 6; + } + + /** + * + * + *
+     * The entity to upsert. The entity may or may not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity upsert = 6; + * + * @return The upsert. + */ + @java.lang.Override + public com.google.datastore.v1.Entity getUpsert() { + if (upsertBuilder_ == null) { + if (operationCase_ == 6) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } else { + if (operationCase_ == 6) { + return upsertBuilder_.getMessage(); + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The entity to upsert. The entity may or may not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity upsert = 6; + */ + public Builder setUpsert(com.google.datastore.v1.Entity value) { + if (upsertBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + operation_ = value; + onChanged(); + } else { + upsertBuilder_.setMessage(value); + } + operationCase_ = 6; + return this; + } + + /** + * + * + *
+     * The entity to upsert. The entity may or may not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity upsert = 6; + */ + public Builder setUpsert(com.google.datastore.v1.Entity.Builder builderForValue) { + if (upsertBuilder_ == null) { + operation_ = builderForValue.build(); + onChanged(); + } else { + upsertBuilder_.setMessage(builderForValue.build()); + } + operationCase_ = 6; + return this; + } + + /** + * + * + *
+     * The entity to upsert. The entity may or may not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity upsert = 6; + */ + public Builder mergeUpsert(com.google.datastore.v1.Entity value) { + if (upsertBuilder_ == null) { + if (operationCase_ == 6 + && operation_ != com.google.datastore.v1.Entity.getDefaultInstance()) { + operation_ = + com.google.datastore.v1.Entity.newBuilder((com.google.datastore.v1.Entity) operation_) + .mergeFrom(value) + .buildPartial(); + } else { + operation_ = value; + } + onChanged(); + } else { + if (operationCase_ == 6) { + upsertBuilder_.mergeFrom(value); + } else { + upsertBuilder_.setMessage(value); + } + } + operationCase_ = 6; + return this; + } + + /** + * + * + *
+     * The entity to upsert. The entity may or may not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity upsert = 6; + */ + public Builder clearUpsert() { + if (upsertBuilder_ == null) { + if (operationCase_ == 6) { + operationCase_ = 0; + operation_ = null; + onChanged(); + } + } else { + if (operationCase_ == 6) { + operationCase_ = 0; + operation_ = null; + } + upsertBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The entity to upsert. The entity may or may not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity upsert = 6; + */ + public com.google.datastore.v1.Entity.Builder getUpsertBuilder() { + return getUpsertFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The entity to upsert. The entity may or may not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity upsert = 6; + */ + @java.lang.Override + public com.google.datastore.v1.EntityOrBuilder getUpsertOrBuilder() { + if ((operationCase_ == 6) && (upsertBuilder_ != null)) { + return upsertBuilder_.getMessageOrBuilder(); + } else { + if (operationCase_ == 6) { + return (com.google.datastore.v1.Entity) operation_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The entity to upsert. The entity may or may not already exist.
+     * The entity key's final path element may be incomplete.
+     * 
+ * + * .google.datastore.v1.Entity upsert = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder> + getUpsertFieldBuilder() { + if (upsertBuilder_ == null) { + if (!(operationCase_ == 6)) { + operation_ = com.google.datastore.v1.Entity.getDefaultInstance(); + } + upsertBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder>( + (com.google.datastore.v1.Entity) operation_, getParentForChildren(), isClean()); + operation_ = null; + } + operationCase_ = 6; + onChanged(); + return upsertBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + deleteBuilder_; + + /** + * + * + *
+     * The key of the entity to delete. The entity may or may not already exist.
+     * Must have a complete key path and must not be reserved/read-only.
+     * 
+ * + * .google.datastore.v1.Key delete = 7; + * + * @return Whether the delete field is set. + */ + @java.lang.Override + public boolean hasDelete() { + return operationCase_ == 7; + } + + /** + * + * + *
+     * The key of the entity to delete. The entity may or may not already exist.
+     * Must have a complete key path and must not be reserved/read-only.
+     * 
+ * + * .google.datastore.v1.Key delete = 7; + * + * @return The delete. + */ + @java.lang.Override + public com.google.datastore.v1.Key getDelete() { + if (deleteBuilder_ == null) { + if (operationCase_ == 7) { + return (com.google.datastore.v1.Key) operation_; + } + return com.google.datastore.v1.Key.getDefaultInstance(); + } else { + if (operationCase_ == 7) { + return deleteBuilder_.getMessage(); + } + return com.google.datastore.v1.Key.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The key of the entity to delete. The entity may or may not already exist.
+     * Must have a complete key path and must not be reserved/read-only.
+     * 
+ * + * .google.datastore.v1.Key delete = 7; + */ + public Builder setDelete(com.google.datastore.v1.Key value) { + if (deleteBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + operation_ = value; + onChanged(); + } else { + deleteBuilder_.setMessage(value); + } + operationCase_ = 7; + return this; + } + + /** + * + * + *
+     * The key of the entity to delete. The entity may or may not already exist.
+     * Must have a complete key path and must not be reserved/read-only.
+     * 
+ * + * .google.datastore.v1.Key delete = 7; + */ + public Builder setDelete(com.google.datastore.v1.Key.Builder builderForValue) { + if (deleteBuilder_ == null) { + operation_ = builderForValue.build(); + onChanged(); + } else { + deleteBuilder_.setMessage(builderForValue.build()); + } + operationCase_ = 7; + return this; + } + + /** + * + * + *
+     * The key of the entity to delete. The entity may or may not already exist.
+     * Must have a complete key path and must not be reserved/read-only.
+     * 
+ * + * .google.datastore.v1.Key delete = 7; + */ + public Builder mergeDelete(com.google.datastore.v1.Key value) { + if (deleteBuilder_ == null) { + if (operationCase_ == 7 && operation_ != com.google.datastore.v1.Key.getDefaultInstance()) { + operation_ = + com.google.datastore.v1.Key.newBuilder((com.google.datastore.v1.Key) operation_) + .mergeFrom(value) + .buildPartial(); + } else { + operation_ = value; + } + onChanged(); + } else { + if (operationCase_ == 7) { + deleteBuilder_.mergeFrom(value); + } else { + deleteBuilder_.setMessage(value); + } + } + operationCase_ = 7; + return this; + } + + /** + * + * + *
+     * The key of the entity to delete. The entity may or may not already exist.
+     * Must have a complete key path and must not be reserved/read-only.
+     * 
+ * + * .google.datastore.v1.Key delete = 7; + */ + public Builder clearDelete() { + if (deleteBuilder_ == null) { + if (operationCase_ == 7) { + operationCase_ = 0; + operation_ = null; + onChanged(); + } + } else { + if (operationCase_ == 7) { + operationCase_ = 0; + operation_ = null; + } + deleteBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The key of the entity to delete. The entity may or may not already exist.
+     * Must have a complete key path and must not be reserved/read-only.
+     * 
+ * + * .google.datastore.v1.Key delete = 7; + */ + public com.google.datastore.v1.Key.Builder getDeleteBuilder() { + return getDeleteFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The key of the entity to delete. The entity may or may not already exist.
+     * Must have a complete key path and must not be reserved/read-only.
+     * 
+ * + * .google.datastore.v1.Key delete = 7; + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getDeleteOrBuilder() { + if ((operationCase_ == 7) && (deleteBuilder_ != null)) { + return deleteBuilder_.getMessageOrBuilder(); + } else { + if (operationCase_ == 7) { + return (com.google.datastore.v1.Key) operation_; + } + return com.google.datastore.v1.Key.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The key of the entity to delete. The entity may or may not already exist.
+     * Must have a complete key path and must not be reserved/read-only.
+     * 
+ * + * .google.datastore.v1.Key delete = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + getDeleteFieldBuilder() { + if (deleteBuilder_ == null) { + if (!(operationCase_ == 7)) { + operation_ = com.google.datastore.v1.Key.getDefaultInstance(); + } + deleteBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder>( + (com.google.datastore.v1.Key) operation_, getParentForChildren(), isClean()); + operation_ = null; + } + operationCase_ = 7; + onChanged(); + return deleteBuilder_; + } + + /** + * + * + *
+     * The version of the entity that this mutation is being applied
+     * to. If this does not match the current version on the server, the
+     * mutation conflicts.
+     * 
+ * + * int64 base_version = 8; + * + * @return Whether the baseVersion field is set. + */ + public boolean hasBaseVersion() { + return conflictDetectionStrategyCase_ == 8; + } + + /** + * + * + *
+     * The version of the entity that this mutation is being applied
+     * to. If this does not match the current version on the server, the
+     * mutation conflicts.
+     * 
+ * + * int64 base_version = 8; + * + * @return The baseVersion. + */ + public long getBaseVersion() { + if (conflictDetectionStrategyCase_ == 8) { + return (java.lang.Long) conflictDetectionStrategy_; + } + return 0L; + } + + /** + * + * + *
+     * The version of the entity that this mutation is being applied
+     * to. If this does not match the current version on the server, the
+     * mutation conflicts.
+     * 
+ * + * int64 base_version = 8; + * + * @param value The baseVersion to set. + * @return This builder for chaining. + */ + public Builder setBaseVersion(long value) { + + conflictDetectionStrategyCase_ = 8; + conflictDetectionStrategy_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * The version of the entity that this mutation is being applied
+     * to. If this does not match the current version on the server, the
+     * mutation conflicts.
+     * 
+ * + * int64 base_version = 8; + * + * @return This builder for chaining. + */ + public Builder clearBaseVersion() { + if (conflictDetectionStrategyCase_ == 8) { + conflictDetectionStrategyCase_ = 0; + conflictDetectionStrategy_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + + /** + * + * + *
+     * The update time of the entity that this mutation is being applied
+     * to. If this does not match the current update time on the server, the
+     * mutation conflicts.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 11; + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return conflictDetectionStrategyCase_ == 11; + } + + /** + * + * + *
+     * The update time of the entity that this mutation is being applied
+     * to. If this does not match the current update time on the server, the
+     * mutation conflicts.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 11; + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + if (updateTimeBuilder_ == null) { + if (conflictDetectionStrategyCase_ == 11) { + return (com.google.protobuf.Timestamp) conflictDetectionStrategy_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (conflictDetectionStrategyCase_ == 11) { + return updateTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The update time of the entity that this mutation is being applied
+     * to. If this does not match the current update time on the server, the
+     * mutation conflicts.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 11; + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + conflictDetectionStrategy_ = value; + onChanged(); + } else { + updateTimeBuilder_.setMessage(value); + } + conflictDetectionStrategyCase_ = 11; + return this; + } + + /** + * + * + *
+     * The update time of the entity that this mutation is being applied
+     * to. If this does not match the current update time on the server, the
+     * mutation conflicts.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 11; + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (updateTimeBuilder_ == null) { + conflictDetectionStrategy_ = builderForValue.build(); + onChanged(); + } else { + updateTimeBuilder_.setMessage(builderForValue.build()); + } + conflictDetectionStrategyCase_ = 11; + return this; + } + + /** + * + * + *
+     * The update time of the entity that this mutation is being applied
+     * to. If this does not match the current update time on the server, the
+     * mutation conflicts.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 11; + */ + public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (conflictDetectionStrategyCase_ == 11 + && conflictDetectionStrategy_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + conflictDetectionStrategy_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) conflictDetectionStrategy_) + .mergeFrom(value) + .buildPartial(); + } else { + conflictDetectionStrategy_ = value; + } + onChanged(); + } else { + if (conflictDetectionStrategyCase_ == 11) { + updateTimeBuilder_.mergeFrom(value); + } else { + updateTimeBuilder_.setMessage(value); + } + } + conflictDetectionStrategyCase_ = 11; + return this; + } + + /** + * + * + *
+     * The update time of the entity that this mutation is being applied
+     * to. If this does not match the current update time on the server, the
+     * mutation conflicts.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 11; + */ + public Builder clearUpdateTime() { + if (updateTimeBuilder_ == null) { + if (conflictDetectionStrategyCase_ == 11) { + conflictDetectionStrategyCase_ = 0; + conflictDetectionStrategy_ = null; + onChanged(); + } + } else { + if (conflictDetectionStrategyCase_ == 11) { + conflictDetectionStrategyCase_ = 0; + conflictDetectionStrategy_ = null; + } + updateTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The update time of the entity that this mutation is being applied
+     * to. If this does not match the current update time on the server, the
+     * mutation conflicts.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 11; + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + return getUpdateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The update time of the entity that this mutation is being applied
+     * to. If this does not match the current update time on the server, the
+     * mutation conflicts.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 11; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if ((conflictDetectionStrategyCase_ == 11) && (updateTimeBuilder_ != null)) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + if (conflictDetectionStrategyCase_ == 11) { + return (com.google.protobuf.Timestamp) conflictDetectionStrategy_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The update time of the entity that this mutation is being applied
+     * to. If this does not match the current update time on the server, the
+     * mutation conflicts.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 11; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + if (!(conflictDetectionStrategyCase_ == 11)) { + conflictDetectionStrategy_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) conflictDetectionStrategy_, + getParentForChildren(), + isClean()); + conflictDetectionStrategy_ = null; + } + conflictDetectionStrategyCase_ = 11; + onChanged(); + return updateTimeBuilder_; + } + + private int conflictResolutionStrategy_ = 0; + + /** + * + * + *
+     * The strategy to use when a conflict is detected. Defaults to
+     * `SERVER_VALUE`.
+     * If this is set, then `conflict_detection_strategy` must also be set.
+     * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The enum numeric value on the wire for conflictResolutionStrategy. + */ + @java.lang.Override + public int getConflictResolutionStrategyValue() { + return conflictResolutionStrategy_; + } + + /** + * + * + *
+     * The strategy to use when a conflict is detected. Defaults to
+     * `SERVER_VALUE`.
+     * If this is set, then `conflict_detection_strategy` must also be set.
+     * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @param value The enum numeric value on the wire for conflictResolutionStrategy to set. + * @return This builder for chaining. + */ + public Builder setConflictResolutionStrategyValue(int value) { + conflictResolutionStrategy_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The strategy to use when a conflict is detected. Defaults to
+     * `SERVER_VALUE`.
+     * If this is set, then `conflict_detection_strategy` must also be set.
+     * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The conflictResolutionStrategy. + */ + @java.lang.Override + public com.google.datastore.v1.Mutation.ConflictResolutionStrategy + getConflictResolutionStrategy() { + com.google.datastore.v1.Mutation.ConflictResolutionStrategy result = + com.google.datastore.v1.Mutation.ConflictResolutionStrategy.forNumber( + conflictResolutionStrategy_); + return result == null + ? com.google.datastore.v1.Mutation.ConflictResolutionStrategy.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * The strategy to use when a conflict is detected. Defaults to
+     * `SERVER_VALUE`.
+     * If this is set, then `conflict_detection_strategy` must also be set.
+     * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @param value The conflictResolutionStrategy to set. + * @return This builder for chaining. + */ + public Builder setConflictResolutionStrategy( + com.google.datastore.v1.Mutation.ConflictResolutionStrategy value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000040; + conflictResolutionStrategy_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The strategy to use when a conflict is detected. Defaults to
+     * `SERVER_VALUE`.
+     * If this is set, then `conflict_detection_strategy` must also be set.
+     * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return This builder for chaining. + */ + public Builder clearConflictResolutionStrategy() { + bitField0_ = (bitField0_ & ~0x00000040); + conflictResolutionStrategy_ = 0; + onChanged(); + return this; + } + + private com.google.datastore.v1.PropertyMask propertyMask_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + propertyMaskBuilder_; + + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return Whether the propertyMask field is set. + */ + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000080) != 0); + } + + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return The propertyMask. + */ + public com.google.datastore.v1.PropertyMask getPropertyMask() { + if (propertyMaskBuilder_ == null) { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } else { + return propertyMaskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + propertyMask_ = value; + } else { + propertyMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask.Builder builderForValue) { + if (propertyMaskBuilder_ == null) { + propertyMask_ = builderForValue.build(); + } else { + propertyMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public Builder mergePropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (((bitField0_ & 0x00000080) != 0) + && propertyMask_ != null + && propertyMask_ != com.google.datastore.v1.PropertyMask.getDefaultInstance()) { + getPropertyMaskBuilder().mergeFrom(value); + } else { + propertyMask_ = value; + } + } else { + propertyMaskBuilder_.mergeFrom(value); + } + if (propertyMask_ != null) { + bitField0_ |= 0x00000080; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public Builder clearPropertyMask() { + bitField0_ = (bitField0_ & ~0x00000080); + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public com.google.datastore.v1.PropertyMask.Builder getPropertyMaskBuilder() { + bitField0_ |= 0x00000080; + onChanged(); + return getPropertyMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + if (propertyMaskBuilder_ != null) { + return propertyMaskBuilder_.getMessageOrBuilder(); + } else { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + } + + /** + * + * + *
+     * The properties to write in this mutation.
+     * None of the properties in the mask may have a reserved name, except for
+     * `__key__`.
+     * This field is ignored for `delete`.
+     *
+     * If the entity already exists, only properties referenced in the mask are
+     * updated, others are left untouched.
+     * Properties referenced in the mask but not in the entity are deleted.
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + getPropertyMaskFieldBuilder() { + if (propertyMaskBuilder_ == null) { + propertyMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder>( + getPropertyMask(), getParentForChildren(), isClean()); + propertyMask_ = null; + } + return propertyMaskBuilder_; + } + + private java.util.List propertyTransforms_ = + java.util.Collections.emptyList(); + + private void ensurePropertyTransformsIsMutable() { + if (!((bitField0_ & 0x00000100) != 0)) { + propertyTransforms_ = + new java.util.ArrayList(propertyTransforms_); + bitField0_ |= 0x00000100; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyTransform, + com.google.datastore.v1.PropertyTransform.Builder, + com.google.datastore.v1.PropertyTransformOrBuilder> + propertyTransformsBuilder_; + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List getPropertyTransformsList() { + if (propertyTransformsBuilder_ == null) { + return java.util.Collections.unmodifiableList(propertyTransforms_); + } else { + return propertyTransformsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public int getPropertyTransformsCount() { + if (propertyTransformsBuilder_ == null) { + return propertyTransforms_.size(); + } else { + return propertyTransformsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.PropertyTransform getPropertyTransforms(int index) { + if (propertyTransformsBuilder_ == null) { + return propertyTransforms_.get(index); + } else { + return propertyTransformsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setPropertyTransforms( + int index, com.google.datastore.v1.PropertyTransform value) { + if (propertyTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropertyTransformsIsMutable(); + propertyTransforms_.set(index, value); + onChanged(); + } else { + propertyTransformsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setPropertyTransforms( + int index, com.google.datastore.v1.PropertyTransform.Builder builderForValue) { + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.set(index, builderForValue.build()); + onChanged(); + } else { + propertyTransformsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addPropertyTransforms(com.google.datastore.v1.PropertyTransform value) { + if (propertyTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropertyTransformsIsMutable(); + propertyTransforms_.add(value); + onChanged(); + } else { + propertyTransformsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addPropertyTransforms( + int index, com.google.datastore.v1.PropertyTransform value) { + if (propertyTransformsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePropertyTransformsIsMutable(); + propertyTransforms_.add(index, value); + onChanged(); + } else { + propertyTransformsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addPropertyTransforms( + com.google.datastore.v1.PropertyTransform.Builder builderForValue) { + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.add(builderForValue.build()); + onChanged(); + } else { + propertyTransformsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addPropertyTransforms( + int index, com.google.datastore.v1.PropertyTransform.Builder builderForValue) { + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.add(index, builderForValue.build()); + onChanged(); + } else { + propertyTransformsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder addAllPropertyTransforms( + java.lang.Iterable values) { + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, propertyTransforms_); + onChanged(); + } else { + propertyTransformsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearPropertyTransforms() { + if (propertyTransformsBuilder_ == null) { + propertyTransforms_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000100); + onChanged(); + } else { + propertyTransformsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder removePropertyTransforms(int index) { + if (propertyTransformsBuilder_ == null) { + ensurePropertyTransformsIsMutable(); + propertyTransforms_.remove(index); + onChanged(); + } else { + propertyTransformsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.PropertyTransform.Builder getPropertyTransformsBuilder( + int index) { + return getPropertyTransformsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.PropertyTransformOrBuilder getPropertyTransformsOrBuilder( + int index) { + if (propertyTransformsBuilder_ == null) { + return propertyTransforms_.get(index); + } else { + return propertyTransformsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List + getPropertyTransformsOrBuilderList() { + if (propertyTransformsBuilder_ != null) { + return propertyTransformsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(propertyTransforms_); + } + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.PropertyTransform.Builder addPropertyTransformsBuilder() { + return getPropertyTransformsFieldBuilder() + .addBuilder(com.google.datastore.v1.PropertyTransform.getDefaultInstance()); + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.PropertyTransform.Builder addPropertyTransformsBuilder( + int index) { + return getPropertyTransformsFieldBuilder() + .addBuilder(index, com.google.datastore.v1.PropertyTransform.getDefaultInstance()); + } + + /** + * + * + *
+     * Optional. The transforms to perform on the entity.
+     *
+     * This field can be set only when the operation is `insert`, `update`,
+     * or `upsert`. If present, the transforms are be applied to the entity
+     * regardless of the property mask, in order, after the operation.
+     * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public java.util.List + getPropertyTransformsBuilderList() { + return getPropertyTransformsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyTransform, + com.google.datastore.v1.PropertyTransform.Builder, + com.google.datastore.v1.PropertyTransformOrBuilder> + getPropertyTransformsFieldBuilder() { + if (propertyTransformsBuilder_ == null) { + propertyTransformsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyTransform, + com.google.datastore.v1.PropertyTransform.Builder, + com.google.datastore.v1.PropertyTransformOrBuilder>( + propertyTransforms_, + ((bitField0_ & 0x00000100) != 0), + getParentForChildren(), + isClean()); + propertyTransforms_ = null; + } + return propertyTransformsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.Mutation) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.Mutation) + private static final com.google.datastore.v1.Mutation DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.Mutation(); + } + + public static com.google.datastore.v1.Mutation getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Mutation 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.datastore.v1.Mutation getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationOrBuilder.java new file mode 100644 index 000000000000..8e5c1a1c7d98 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationOrBuilder.java @@ -0,0 +1,441 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface MutationOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.Mutation) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The entity to insert. The entity must not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity insert = 4; + * + * @return Whether the insert field is set. + */ + boolean hasInsert(); + + /** + * + * + *
+   * The entity to insert. The entity must not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity insert = 4; + * + * @return The insert. + */ + com.google.datastore.v1.Entity getInsert(); + + /** + * + * + *
+   * The entity to insert. The entity must not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity insert = 4; + */ + com.google.datastore.v1.EntityOrBuilder getInsertOrBuilder(); + + /** + * + * + *
+   * The entity to update. The entity must already exist.
+   * Must have a complete key path.
+   * 
+ * + * .google.datastore.v1.Entity update = 5; + * + * @return Whether the update field is set. + */ + boolean hasUpdate(); + + /** + * + * + *
+   * The entity to update. The entity must already exist.
+   * Must have a complete key path.
+   * 
+ * + * .google.datastore.v1.Entity update = 5; + * + * @return The update. + */ + com.google.datastore.v1.Entity getUpdate(); + + /** + * + * + *
+   * The entity to update. The entity must already exist.
+   * Must have a complete key path.
+   * 
+ * + * .google.datastore.v1.Entity update = 5; + */ + com.google.datastore.v1.EntityOrBuilder getUpdateOrBuilder(); + + /** + * + * + *
+   * The entity to upsert. The entity may or may not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity upsert = 6; + * + * @return Whether the upsert field is set. + */ + boolean hasUpsert(); + + /** + * + * + *
+   * The entity to upsert. The entity may or may not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity upsert = 6; + * + * @return The upsert. + */ + com.google.datastore.v1.Entity getUpsert(); + + /** + * + * + *
+   * The entity to upsert. The entity may or may not already exist.
+   * The entity key's final path element may be incomplete.
+   * 
+ * + * .google.datastore.v1.Entity upsert = 6; + */ + com.google.datastore.v1.EntityOrBuilder getUpsertOrBuilder(); + + /** + * + * + *
+   * The key of the entity to delete. The entity may or may not already exist.
+   * Must have a complete key path and must not be reserved/read-only.
+   * 
+ * + * .google.datastore.v1.Key delete = 7; + * + * @return Whether the delete field is set. + */ + boolean hasDelete(); + + /** + * + * + *
+   * The key of the entity to delete. The entity may or may not already exist.
+   * Must have a complete key path and must not be reserved/read-only.
+   * 
+ * + * .google.datastore.v1.Key delete = 7; + * + * @return The delete. + */ + com.google.datastore.v1.Key getDelete(); + + /** + * + * + *
+   * The key of the entity to delete. The entity may or may not already exist.
+   * Must have a complete key path and must not be reserved/read-only.
+   * 
+ * + * .google.datastore.v1.Key delete = 7; + */ + com.google.datastore.v1.KeyOrBuilder getDeleteOrBuilder(); + + /** + * + * + *
+   * The version of the entity that this mutation is being applied
+   * to. If this does not match the current version on the server, the
+   * mutation conflicts.
+   * 
+ * + * int64 base_version = 8; + * + * @return Whether the baseVersion field is set. + */ + boolean hasBaseVersion(); + + /** + * + * + *
+   * The version of the entity that this mutation is being applied
+   * to. If this does not match the current version on the server, the
+   * mutation conflicts.
+   * 
+ * + * int64 base_version = 8; + * + * @return The baseVersion. + */ + long getBaseVersion(); + + /** + * + * + *
+   * The update time of the entity that this mutation is being applied
+   * to. If this does not match the current update time on the server, the
+   * mutation conflicts.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 11; + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + + /** + * + * + *
+   * The update time of the entity that this mutation is being applied
+   * to. If this does not match the current update time on the server, the
+   * mutation conflicts.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 11; + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + + /** + * + * + *
+   * The update time of the entity that this mutation is being applied
+   * to. If this does not match the current update time on the server, the
+   * mutation conflicts.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 11; + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + /** + * + * + *
+   * The strategy to use when a conflict is detected. Defaults to
+   * `SERVER_VALUE`.
+   * If this is set, then `conflict_detection_strategy` must also be set.
+   * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The enum numeric value on the wire for conflictResolutionStrategy. + */ + int getConflictResolutionStrategyValue(); + + /** + * + * + *
+   * The strategy to use when a conflict is detected. Defaults to
+   * `SERVER_VALUE`.
+   * If this is set, then `conflict_detection_strategy` must also be set.
+   * 
+ * + * + * .google.datastore.v1.Mutation.ConflictResolutionStrategy conflict_resolution_strategy = 10; + * + * + * @return The conflictResolutionStrategy. + */ + com.google.datastore.v1.Mutation.ConflictResolutionStrategy getConflictResolutionStrategy(); + + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return Whether the propertyMask field is set. + */ + boolean hasPropertyMask(); + + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + * + * @return The propertyMask. + */ + com.google.datastore.v1.PropertyMask getPropertyMask(); + + /** + * + * + *
+   * The properties to write in this mutation.
+   * None of the properties in the mask may have a reserved name, except for
+   * `__key__`.
+   * This field is ignored for `delete`.
+   *
+   * If the entity already exists, only properties referenced in the mask are
+   * updated, others are left untouched.
+   * Properties referenced in the mask but not in the entity are deleted.
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 9; + */ + com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder(); + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List getPropertyTransformsList(); + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.datastore.v1.PropertyTransform getPropertyTransforms(int index); + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + int getPropertyTransformsCount(); + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + java.util.List + getPropertyTransformsOrBuilderList(); + + /** + * + * + *
+   * Optional. The transforms to perform on the entity.
+   *
+   * This field can be set only when the operation is `insert`, `update`,
+   * or `upsert`. If present, the transforms are be applied to the entity
+   * regardless of the property mask, in order, after the operation.
+   * 
+ * + * + * repeated .google.datastore.v1.PropertyTransform property_transforms = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.datastore.v1.PropertyTransformOrBuilder getPropertyTransformsOrBuilder(int index); + + com.google.datastore.v1.Mutation.OperationCase getOperationCase(); + + com.google.datastore.v1.Mutation.ConflictDetectionStrategyCase getConflictDetectionStrategyCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResult.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResult.java new file mode 100644 index 000000000000..f3c63d99cb2e --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResult.java @@ -0,0 +1,2102 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The result of applying a mutation.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.MutationResult} + */ +public final class MutationResult extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.MutationResult) + MutationResultOrBuilder { + private static final long serialVersionUID = 0L; + + // Use MutationResult.newBuilder() to construct. + private MutationResult(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private MutationResult() { + transformResults_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new MutationResult(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_MutationResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_MutationResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.MutationResult.class, + com.google.datastore.v1.MutationResult.Builder.class); + } + + private int bitField0_; + public static final int KEY_FIELD_NUMBER = 3; + private com.google.datastore.v1.Key key_; + + /** + * + * + *
+   * The automatically allocated key.
+   * Set only when the mutation allocated a key.
+   * 
+ * + * .google.datastore.v1.Key key = 3; + * + * @return Whether the key field is set. + */ + @java.lang.Override + public boolean hasKey() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The automatically allocated key.
+   * Set only when the mutation allocated a key.
+   * 
+ * + * .google.datastore.v1.Key key = 3; + * + * @return The key. + */ + @java.lang.Override + public com.google.datastore.v1.Key getKey() { + return key_ == null ? com.google.datastore.v1.Key.getDefaultInstance() : key_; + } + + /** + * + * + *
+   * The automatically allocated key.
+   * Set only when the mutation allocated a key.
+   * 
+ * + * .google.datastore.v1.Key key = 3; + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getKeyOrBuilder() { + return key_ == null ? com.google.datastore.v1.Key.getDefaultInstance() : key_; + } + + public static final int VERSION_FIELD_NUMBER = 4; + private long version_ = 0L; + + /** + * + * + *
+   * The version of the entity on the server after processing the mutation. If
+   * the mutation doesn't change anything on the server, then the version will
+   * be the version of the current entity or, if no entity is present, a version
+   * that is strictly greater than the version of any previous entity and less
+   * than the version of any possible future entity.
+   * 
+ * + * int64 version = 4; + * + * @return The version. + */ + @java.lang.Override + public long getVersion() { + return version_; + } + + public static final int CREATE_TIME_FIELD_NUMBER = 7; + private com.google.protobuf.Timestamp createTime_; + + /** + * + * + *
+   * The create time of the entity. This field will not be set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 7; + * + * @return Whether the createTime field is set. + */ + @java.lang.Override + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The create time of the entity. This field will not be set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 7; + * + * @return The createTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getCreateTime() { + return createTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : createTime_; + } + + /** + * + * + *
+   * The create time of the entity. This field will not be set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 7; + */ + @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_; + + /** + * + * + *
+   * The update time of the entity on the server after processing the mutation.
+   * If the mutation doesn't change anything on the server, then the timestamp
+   * will be the update timestamp of the current entity. This field will not be
+   * set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6; + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * The update time of the entity on the server after processing the mutation.
+   * If the mutation doesn't change anything on the server, then the timestamp
+   * will be the update timestamp of the current entity. This field will not be
+   * set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6; + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + /** + * + * + *
+   * The update time of the entity on the server after processing the mutation.
+   * If the mutation doesn't change anything on the server, then the timestamp
+   * will be the update timestamp of the current entity. This field will not be
+   * set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6; + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + public static final int CONFLICT_DETECTED_FIELD_NUMBER = 5; + private boolean conflictDetected_ = false; + + /** + * + * + *
+   * Whether a conflict was detected for this mutation. Always false when a
+   * conflict detection strategy field is not set in the mutation.
+   * 
+ * + * bool conflict_detected = 5; + * + * @return The conflictDetected. + */ + @java.lang.Override + public boolean getConflictDetected() { + return conflictDetected_; + } + + public static final int TRANSFORM_RESULTS_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private java.util.List transformResults_; + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + @java.lang.Override + public java.util.List getTransformResultsList() { + return transformResults_; + } + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + @java.lang.Override + public java.util.List + getTransformResultsOrBuilderList() { + return transformResults_; + } + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + @java.lang.Override + public int getTransformResultsCount() { + return transformResults_.size(); + } + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + @java.lang.Override + public com.google.datastore.v1.Value getTransformResults(int index) { + return transformResults_.get(index); + } + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + @java.lang.Override + public com.google.datastore.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(3, getKey()); + } + if (version_ != 0L) { + output.writeInt64(4, version_); + } + if (conflictDetected_ != false) { + output.writeBool(5, conflictDetected_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(6, getUpdateTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(7, getCreateTime()); + } + for (int i = 0; i < transformResults_.size(); i++) { + output.writeMessage(8, 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(3, getKey()); + } + if (version_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(4, version_); + } + if (conflictDetected_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(5, conflictDetected_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getUpdateTime()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(7, getCreateTime()); + } + for (int i = 0; i < transformResults_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, 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.datastore.v1.MutationResult)) { + return super.equals(obj); + } + com.google.datastore.v1.MutationResult other = (com.google.datastore.v1.MutationResult) obj; + + if (hasKey() != other.hasKey()) return false; + if (hasKey()) { + if (!getKey().equals(other.getKey())) return false; + } + if (getVersion() != other.getVersion()) 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 (getConflictDetected() != other.getConflictDetected()) 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 (hasKey()) { + hash = (37 * hash) + KEY_FIELD_NUMBER; + hash = (53 * hash) + getKey().hashCode(); + } + hash = (37 * hash) + VERSION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getVersion()); + 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) + CONFLICT_DETECTED_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getConflictDetected()); + 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.datastore.v1.MutationResult parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.MutationResult parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.MutationResult parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.MutationResult 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.datastore.v1.MutationResult parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.MutationResult parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.MutationResult parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.MutationResult parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.MutationResult parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.MutationResult parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.MutationResult parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.MutationResult parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.MutationResult 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The result of applying a mutation.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.MutationResult} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.MutationResult) + com.google.datastore.v1.MutationResultOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_MutationResult_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_MutationResult_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.MutationResult.class, + com.google.datastore.v1.MutationResult.Builder.class); + } + + // Construct using com.google.datastore.v1.MutationResult.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getKeyFieldBuilder(); + getCreateTimeFieldBuilder(); + getUpdateTimeFieldBuilder(); + getTransformResultsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + key_ = null; + if (keyBuilder_ != null) { + keyBuilder_.dispose(); + keyBuilder_ = null; + } + version_ = 0L; + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + conflictDetected_ = false; + if (transformResultsBuilder_ == null) { + transformResults_ = java.util.Collections.emptyList(); + } else { + transformResults_ = null; + transformResultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000020); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_MutationResult_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.MutationResult getDefaultInstanceForType() { + return com.google.datastore.v1.MutationResult.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.MutationResult build() { + com.google.datastore.v1.MutationResult result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.MutationResult buildPartial() { + com.google.datastore.v1.MutationResult result = + new com.google.datastore.v1.MutationResult(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.MutationResult result) { + if (transformResultsBuilder_ == null) { + if (((bitField0_ & 0x00000020) != 0)) { + transformResults_ = java.util.Collections.unmodifiableList(transformResults_); + bitField0_ = (bitField0_ & ~0x00000020); + } + result.transformResults_ = transformResults_; + } else { + result.transformResults_ = transformResultsBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.MutationResult result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.key_ = keyBuilder_ == null ? key_ : keyBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.version_ = version_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.createTime_ = createTimeBuilder_ == null ? createTime_ : createTimeBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.updateTime_ = updateTimeBuilder_ == null ? updateTime_ : updateTimeBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.conflictDetected_ = conflictDetected_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.MutationResult) { + return mergeFrom((com.google.datastore.v1.MutationResult) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.MutationResult other) { + if (other == com.google.datastore.v1.MutationResult.getDefaultInstance()) return this; + if (other.hasKey()) { + mergeKey(other.getKey()); + } + if (other.getVersion() != 0L) { + setVersion(other.getVersion()); + } + if (other.hasCreateTime()) { + mergeCreateTime(other.getCreateTime()); + } + if (other.hasUpdateTime()) { + mergeUpdateTime(other.getUpdateTime()); + } + if (other.getConflictDetected() != false) { + setConflictDetected(other.getConflictDetected()); + } + if (transformResultsBuilder_ == null) { + if (!other.transformResults_.isEmpty()) { + if (transformResults_.isEmpty()) { + transformResults_ = other.transformResults_; + bitField0_ = (bitField0_ & ~0x00000020); + } else { + ensureTransformResultsIsMutable(); + transformResults_.addAll(other.transformResults_); + } + onChanged(); + } + } else { + if (!other.transformResults_.isEmpty()) { + if (transformResultsBuilder_.isEmpty()) { + transformResultsBuilder_.dispose(); + transformResultsBuilder_ = null; + transformResults_ = other.transformResults_; + bitField0_ = (bitField0_ & ~0x00000020); + transformResultsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getTransformResultsFieldBuilder() + : 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 26: + { + input.readMessage(getKeyFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 26 + case 32: + { + version_ = input.readInt64(); + bitField0_ |= 0x00000002; + break; + } // case 32 + case 40: + { + conflictDetected_ = input.readBool(); + bitField0_ |= 0x00000010; + break; + } // case 40 + case 50: + { + input.readMessage(getUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 50 + case 58: + { + input.readMessage(getCreateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 58 + case 66: + { + com.google.datastore.v1.Value m = + input.readMessage(com.google.datastore.v1.Value.parser(), extensionRegistry); + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.add(m); + } else { + transformResultsBuilder_.addMessage(m); + } + 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.datastore.v1.Key key_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + keyBuilder_; + + /** + * + * + *
+     * The automatically allocated key.
+     * Set only when the mutation allocated a key.
+     * 
+ * + * .google.datastore.v1.Key key = 3; + * + * @return Whether the key field is set. + */ + public boolean hasKey() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The automatically allocated key.
+     * Set only when the mutation allocated a key.
+     * 
+ * + * .google.datastore.v1.Key key = 3; + * + * @return The key. + */ + public com.google.datastore.v1.Key getKey() { + if (keyBuilder_ == null) { + return key_ == null ? com.google.datastore.v1.Key.getDefaultInstance() : key_; + } else { + return keyBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The automatically allocated key.
+     * Set only when the mutation allocated a key.
+     * 
+ * + * .google.datastore.v1.Key key = 3; + */ + public Builder setKey(com.google.datastore.v1.Key value) { + if (keyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + key_ = value; + } else { + keyBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The automatically allocated key.
+     * Set only when the mutation allocated a key.
+     * 
+ * + * .google.datastore.v1.Key key = 3; + */ + public Builder setKey(com.google.datastore.v1.Key.Builder builderForValue) { + if (keyBuilder_ == null) { + key_ = builderForValue.build(); + } else { + keyBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The automatically allocated key.
+     * Set only when the mutation allocated a key.
+     * 
+ * + * .google.datastore.v1.Key key = 3; + */ + public Builder mergeKey(com.google.datastore.v1.Key value) { + if (keyBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && key_ != null + && key_ != com.google.datastore.v1.Key.getDefaultInstance()) { + getKeyBuilder().mergeFrom(value); + } else { + key_ = value; + } + } else { + keyBuilder_.mergeFrom(value); + } + if (key_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The automatically allocated key.
+     * Set only when the mutation allocated a key.
+     * 
+ * + * .google.datastore.v1.Key key = 3; + */ + public Builder clearKey() { + bitField0_ = (bitField0_ & ~0x00000001); + key_ = null; + if (keyBuilder_ != null) { + keyBuilder_.dispose(); + keyBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The automatically allocated key.
+     * Set only when the mutation allocated a key.
+     * 
+ * + * .google.datastore.v1.Key key = 3; + */ + public com.google.datastore.v1.Key.Builder getKeyBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getKeyFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The automatically allocated key.
+     * Set only when the mutation allocated a key.
+     * 
+ * + * .google.datastore.v1.Key key = 3; + */ + public com.google.datastore.v1.KeyOrBuilder getKeyOrBuilder() { + if (keyBuilder_ != null) { + return keyBuilder_.getMessageOrBuilder(); + } else { + return key_ == null ? com.google.datastore.v1.Key.getDefaultInstance() : key_; + } + } + + /** + * + * + *
+     * The automatically allocated key.
+     * Set only when the mutation allocated a key.
+     * 
+ * + * .google.datastore.v1.Key key = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + getKeyFieldBuilder() { + if (keyBuilder_ == null) { + keyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder>(getKey(), getParentForChildren(), isClean()); + key_ = null; + } + return keyBuilder_; + } + + private long version_; + + /** + * + * + *
+     * The version of the entity on the server after processing the mutation. If
+     * the mutation doesn't change anything on the server, then the version will
+     * be the version of the current entity or, if no entity is present, a version
+     * that is strictly greater than the version of any previous entity and less
+     * than the version of any possible future entity.
+     * 
+ * + * int64 version = 4; + * + * @return The version. + */ + @java.lang.Override + public long getVersion() { + return version_; + } + + /** + * + * + *
+     * The version of the entity on the server after processing the mutation. If
+     * the mutation doesn't change anything on the server, then the version will
+     * be the version of the current entity or, if no entity is present, a version
+     * that is strictly greater than the version of any previous entity and less
+     * than the version of any possible future entity.
+     * 
+ * + * int64 version = 4; + * + * @param value The version to set. + * @return This builder for chaining. + */ + public Builder setVersion(long value) { + + version_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The version of the entity on the server after processing the mutation. If
+     * the mutation doesn't change anything on the server, then the version will
+     * be the version of the current entity or, if no entity is present, a version
+     * that is strictly greater than the version of any previous entity and less
+     * than the version of any possible future entity.
+     * 
+ * + * int64 version = 4; + * + * @return This builder for chaining. + */ + public Builder clearVersion() { + bitField0_ = (bitField0_ & ~0x00000002); + version_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp createTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + createTimeBuilder_; + + /** + * + * + *
+     * The create time of the entity. This field will not be set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 7; + * + * @return Whether the createTime field is set. + */ + public boolean hasCreateTime() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The create time of the entity. This field will not be set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 7; + * + * @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(); + } + } + + /** + * + * + *
+     * The create time of the entity. This field will not be set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 7; + */ + 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; + } + + /** + * + * + *
+     * The create time of the entity. This field will not be set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 7; + */ + 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; + } + + /** + * + * + *
+     * The create time of the entity. This field will not be set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 7; + */ + 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; + } + + /** + * + * + *
+     * The create time of the entity. This field will not be set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 7; + */ + public Builder clearCreateTime() { + bitField0_ = (bitField0_ & ~0x00000004); + createTime_ = null; + if (createTimeBuilder_ != null) { + createTimeBuilder_.dispose(); + createTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The create time of the entity. This field will not be set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 7; + */ + public com.google.protobuf.Timestamp.Builder getCreateTimeBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getCreateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The create time of the entity. This field will not be set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 7; + */ + public com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder() { + if (createTimeBuilder_ != null) { + return createTimeBuilder_.getMessageOrBuilder(); + } else { + return createTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : createTime_; + } + } + + /** + * + * + *
+     * The create time of the entity. This field will not be set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp create_time = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getCreateTimeFieldBuilder() { + if (createTimeBuilder_ == null) { + createTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + 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.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + updateTimeBuilder_; + + /** + * + * + *
+     * The update time of the entity on the server after processing the mutation.
+     * If the mutation doesn't change anything on the server, then the timestamp
+     * will be the update timestamp of the current entity. This field will not be
+     * set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 6; + * + * @return Whether the updateTime field is set. + */ + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * The update time of the entity on the server after processing the mutation.
+     * If the mutation doesn't change anything on the server, then the timestamp
+     * will be the update timestamp of the current entity. This field will not be
+     * set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 6; + * + * @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 update time of the entity on the server after processing the mutation.
+     * If the mutation doesn't change anything on the server, then the timestamp
+     * will be the update timestamp of the current entity. This field will not be
+     * set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 6; + */ + 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; + } + + /** + * + * + *
+     * The update time of the entity on the server after processing the mutation.
+     * If the mutation doesn't change anything on the server, then the timestamp
+     * will be the update timestamp of the current entity. This field will not be
+     * set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 6; + */ + 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; + } + + /** + * + * + *
+     * The update time of the entity on the server after processing the mutation.
+     * If the mutation doesn't change anything on the server, then the timestamp
+     * will be the update timestamp of the current entity. This field will not be
+     * set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 6; + */ + 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; + } + + /** + * + * + *
+     * The update time of the entity on the server after processing the mutation.
+     * If the mutation doesn't change anything on the server, then the timestamp
+     * will be the update timestamp of the current entity. This field will not be
+     * set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 6; + */ + public Builder clearUpdateTime() { + bitField0_ = (bitField0_ & ~0x00000008); + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The update time of the entity on the server after processing the mutation.
+     * If the mutation doesn't change anything on the server, then the timestamp
+     * will be the update timestamp of the current entity. This field will not be
+     * set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 6; + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getUpdateTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The update time of the entity on the server after processing the mutation.
+     * If the mutation doesn't change anything on the server, then the timestamp
+     * will be the update timestamp of the current entity. This field will not be
+     * set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 6; + */ + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (updateTimeBuilder_ != null) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } + } + + /** + * + * + *
+     * The update time of the entity on the server after processing the mutation.
+     * If the mutation doesn't change anything on the server, then the timestamp
+     * will be the update timestamp of the current entity. This field will not be
+     * set after a 'delete'.
+     * 
+ * + * .google.protobuf.Timestamp update_time = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getUpdateTimeFieldBuilder() { + if (updateTimeBuilder_ == null) { + updateTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getUpdateTime(), getParentForChildren(), isClean()); + updateTime_ = null; + } + return updateTimeBuilder_; + } + + private boolean conflictDetected_; + + /** + * + * + *
+     * Whether a conflict was detected for this mutation. Always false when a
+     * conflict detection strategy field is not set in the mutation.
+     * 
+ * + * bool conflict_detected = 5; + * + * @return The conflictDetected. + */ + @java.lang.Override + public boolean getConflictDetected() { + return conflictDetected_; + } + + /** + * + * + *
+     * Whether a conflict was detected for this mutation. Always false when a
+     * conflict detection strategy field is not set in the mutation.
+     * 
+ * + * bool conflict_detected = 5; + * + * @param value The conflictDetected to set. + * @return This builder for chaining. + */ + public Builder setConflictDetected(boolean value) { + + conflictDetected_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * Whether a conflict was detected for this mutation. Always false when a
+     * conflict detection strategy field is not set in the mutation.
+     * 
+ * + * bool conflict_detected = 5; + * + * @return This builder for chaining. + */ + public Builder clearConflictDetected() { + bitField0_ = (bitField0_ & ~0x00000010); + conflictDetected_ = false; + onChanged(); + return this; + } + + private java.util.List transformResults_ = + java.util.Collections.emptyList(); + + private void ensureTransformResultsIsMutable() { + if (!((bitField0_ & 0x00000020) != 0)) { + transformResults_ = + new java.util.ArrayList(transformResults_); + bitField0_ |= 0x00000020; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + transformResultsBuilder_; + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public java.util.List getTransformResultsList() { + if (transformResultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(transformResults_); + } else { + return transformResultsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public int getTransformResultsCount() { + if (transformResultsBuilder_ == null) { + return transformResults_.size(); + } else { + return transformResultsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public com.google.datastore.v1.Value getTransformResults(int index) { + if (transformResultsBuilder_ == null) { + return transformResults_.get(index); + } else { + return transformResultsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder setTransformResults(int index, com.google.datastore.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
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder setTransformResults( + int index, com.google.datastore.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
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder addTransformResults(com.google.datastore.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
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder addTransformResults(int index, com.google.datastore.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
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder addTransformResults(com.google.datastore.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
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder addTransformResults( + int index, com.google.datastore.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
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + 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
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder clearTransformResults() { + if (transformResultsBuilder_ == null) { + transformResults_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000020); + onChanged(); + } else { + transformResultsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public Builder removeTransformResults(int index) { + if (transformResultsBuilder_ == null) { + ensureTransformResultsIsMutable(); + transformResults_.remove(index); + onChanged(); + } else { + transformResultsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public com.google.datastore.v1.Value.Builder getTransformResultsBuilder(int index) { + return getTransformResultsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public com.google.datastore.v1.ValueOrBuilder getTransformResultsOrBuilder(int index) { + if (transformResultsBuilder_ == null) { + return transformResults_.get(index); + } else { + return transformResultsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public java.util.List + getTransformResultsOrBuilderList() { + if (transformResultsBuilder_ != null) { + return transformResultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(transformResults_); + } + } + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public com.google.datastore.v1.Value.Builder addTransformResultsBuilder() { + return getTransformResultsFieldBuilder() + .addBuilder(com.google.datastore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public com.google.datastore.v1.Value.Builder addTransformResultsBuilder(int index) { + return getTransformResultsFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Value.getDefaultInstance()); + } + + /** + * + * + *
+     * The results of applying each
+     * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+     * order of the request.
+     * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + public java.util.List getTransformResultsBuilderList() { + return getTransformResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getTransformResultsFieldBuilder() { + if (transformResultsBuilder_ == null) { + transformResultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + transformResults_, + ((bitField0_ & 0x00000020) != 0), + getParentForChildren(), + isClean()); + transformResults_ = null; + } + return transformResultsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.MutationResult) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.MutationResult) + private static final com.google.datastore.v1.MutationResult DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.MutationResult(); + } + + public static com.google.datastore.v1.MutationResult getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public MutationResult 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.datastore.v1.MutationResult getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResultOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResultOrBuilder.java new file mode 100644 index 000000000000..eee55b02d7be --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/MutationResultOrBuilder.java @@ -0,0 +1,246 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface MutationResultOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.MutationResult) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The automatically allocated key.
+   * Set only when the mutation allocated a key.
+   * 
+ * + * .google.datastore.v1.Key key = 3; + * + * @return Whether the key field is set. + */ + boolean hasKey(); + + /** + * + * + *
+   * The automatically allocated key.
+   * Set only when the mutation allocated a key.
+   * 
+ * + * .google.datastore.v1.Key key = 3; + * + * @return The key. + */ + com.google.datastore.v1.Key getKey(); + + /** + * + * + *
+   * The automatically allocated key.
+   * Set only when the mutation allocated a key.
+   * 
+ * + * .google.datastore.v1.Key key = 3; + */ + com.google.datastore.v1.KeyOrBuilder getKeyOrBuilder(); + + /** + * + * + *
+   * The version of the entity on the server after processing the mutation. If
+   * the mutation doesn't change anything on the server, then the version will
+   * be the version of the current entity or, if no entity is present, a version
+   * that is strictly greater than the version of any previous entity and less
+   * than the version of any possible future entity.
+   * 
+ * + * int64 version = 4; + * + * @return The version. + */ + long getVersion(); + + /** + * + * + *
+   * The create time of the entity. This field will not be set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 7; + * + * @return Whether the createTime field is set. + */ + boolean hasCreateTime(); + + /** + * + * + *
+   * The create time of the entity. This field will not be set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 7; + * + * @return The createTime. + */ + com.google.protobuf.Timestamp getCreateTime(); + + /** + * + * + *
+   * The create time of the entity. This field will not be set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp create_time = 7; + */ + com.google.protobuf.TimestampOrBuilder getCreateTimeOrBuilder(); + + /** + * + * + *
+   * The update time of the entity on the server after processing the mutation.
+   * If the mutation doesn't change anything on the server, then the timestamp
+   * will be the update timestamp of the current entity. This field will not be
+   * set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6; + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + + /** + * + * + *
+   * The update time of the entity on the server after processing the mutation.
+   * If the mutation doesn't change anything on the server, then the timestamp
+   * will be the update timestamp of the current entity. This field will not be
+   * set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6; + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + + /** + * + * + *
+   * The update time of the entity on the server after processing the mutation.
+   * If the mutation doesn't change anything on the server, then the timestamp
+   * will be the update timestamp of the current entity. This field will not be
+   * set after a 'delete'.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 6; + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + /** + * + * + *
+   * Whether a conflict was detected for this mutation. Always false when a
+   * conflict detection strategy field is not set in the mutation.
+   * 
+ * + * bool conflict_detected = 5; + * + * @return The conflictDetected. + */ + boolean getConflictDetected(); + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + java.util.List getTransformResultsList(); + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + com.google.datastore.v1.Value getTransformResults(int index); + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + int getTransformResultsCount(); + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + java.util.List + getTransformResultsOrBuilderList(); + + /** + * + * + *
+   * The results of applying each
+   * [PropertyTransform][google.datastore.v1.PropertyTransform], in the same
+   * order of the request.
+   * 
+ * + * repeated .google.datastore.v1.Value transform_results = 8; + */ + com.google.datastore.v1.ValueOrBuilder getTransformResultsOrBuilder(int index); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionId.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionId.java new file mode 100644 index 000000000000..f321eade7cc7 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionId.java @@ -0,0 +1,1053 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A partition ID identifies a grouping of entities. The grouping is always
+ * by project and namespace, however the namespace ID may be empty.
+ *
+ * A partition ID contains several dimensions:
+ * project ID and namespace ID.
+ *
+ * Partition dimensions:
+ *
+ * - May be `""`.
+ * - Must be valid UTF-8 bytes.
+ * - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}`
+ * If the value of any dimension matches regex `__.*__`, the partition is
+ * reserved/read-only.
+ * A reserved/read-only partition ID is forbidden in certain documented
+ * contexts.
+ *
+ * Foreign partition IDs (in which the project ID does
+ * not match the context project ID ) are discouraged.
+ * Reads and writes of foreign partition IDs may fail if the project is not in
+ * an active state.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.PartitionId} + */ +public final class PartitionId extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.PartitionId) + PartitionIdOrBuilder { + private static final long serialVersionUID = 0L; + + // Use PartitionId.newBuilder() to construct. + private PartitionId(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PartitionId() { + projectId_ = ""; + databaseId_ = ""; + namespaceId_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PartitionId(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_PartitionId_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_PartitionId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PartitionId.class, + com.google.datastore.v1.PartitionId.Builder.class); + } + + public static final int PROJECT_ID_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * The ID of the project to which the entities belong.
+   * 
+ * + * string project_id = 2; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * The ID of the project to which the entities belong.
+   * 
+ * + * string project_id = 2; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * If not empty, the ID of the database to which the entities
+   * belong.
+   * 
+ * + * string database_id = 3; + * + * @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; + } + } + + /** + * + * + *
+   * If not empty, the ID of the database to which the entities
+   * belong.
+   * 
+ * + * string database_id = 3; + * + * @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 NAMESPACE_ID_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object namespaceId_ = ""; + + /** + * + * + *
+   * If not empty, the ID of the namespace to which the entities belong.
+   * 
+ * + * string namespace_id = 4; + * + * @return The namespaceId. + */ + @java.lang.Override + public java.lang.String getNamespaceId() { + java.lang.Object ref = namespaceId_; + 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(); + namespaceId_ = s; + return s; + } + } + + /** + * + * + *
+   * If not empty, the ID of the namespace to which the entities belong.
+   * 
+ * + * string namespace_id = 4; + * + * @return The bytes for namespaceId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNamespaceIdBytes() { + java.lang.Object ref = namespaceId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + namespaceId_ = 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.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 3, databaseId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(namespaceId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, namespaceId_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(3, databaseId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(namespaceId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, namespaceId_); + } + 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.datastore.v1.PartitionId)) { + return super.equals(obj); + } + com.google.datastore.v1.PartitionId other = (com.google.datastore.v1.PartitionId) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (!getNamespaceId().equals(other.getNamespaceId())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + hash = (37 * hash) + NAMESPACE_ID_FIELD_NUMBER; + hash = (53 * hash) + getNamespaceId().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.PartitionId parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PartitionId parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PartitionId parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PartitionId 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.datastore.v1.PartitionId parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PartitionId parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PartitionId parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PartitionId parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PartitionId parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PartitionId parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PartitionId parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PartitionId parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.PartitionId 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A partition ID identifies a grouping of entities. The grouping is always
+   * by project and namespace, however the namespace ID may be empty.
+   *
+   * A partition ID contains several dimensions:
+   * project ID and namespace ID.
+   *
+   * Partition dimensions:
+   *
+   * - May be `""`.
+   * - Must be valid UTF-8 bytes.
+   * - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}`
+   * If the value of any dimension matches regex `__.*__`, the partition is
+   * reserved/read-only.
+   * A reserved/read-only partition ID is forbidden in certain documented
+   * contexts.
+   *
+   * Foreign partition IDs (in which the project ID does
+   * not match the context project ID ) are discouraged.
+   * Reads and writes of foreign partition IDs may fail if the project is not in
+   * an active state.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.PartitionId} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.PartitionId) + com.google.datastore.v1.PartitionIdOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_PartitionId_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_PartitionId_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PartitionId.class, + com.google.datastore.v1.PartitionId.Builder.class); + } + + // Construct using com.google.datastore.v1.PartitionId.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + databaseId_ = ""; + namespaceId_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_PartitionId_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.PartitionId getDefaultInstanceForType() { + return com.google.datastore.v1.PartitionId.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.PartitionId build() { + com.google.datastore.v1.PartitionId result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.PartitionId buildPartial() { + com.google.datastore.v1.PartitionId result = new com.google.datastore.v1.PartitionId(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.PartitionId result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.namespaceId_ = namespaceId_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.PartitionId) { + return mergeFrom((com.google.datastore.v1.PartitionId) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.PartitionId other) { + if (other == com.google.datastore.v1.PartitionId.getDefaultInstance()) return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (!other.getNamespaceId().isEmpty()) { + namespaceId_ = other.namespaceId_; + 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 18: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 18 + case 26: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 34: + { + namespaceId_ = input.readStringRequireUtf8(); + 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 projectId_ = ""; + + /** + * + * + *
+     * The ID of the project to which the entities belong.
+     * 
+ * + * string project_id = 2; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * The ID of the project to which the entities belong.
+     * 
+ * + * string project_id = 2; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * The ID of the project to which the entities belong.
+     * 
+ * + * string project_id = 2; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the project to which the entities belong.
+     * 
+ * + * string project_id = 2; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the project to which the entities belong.
+     * 
+ * + * string project_id = 2; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * If not empty, the ID of the database to which the entities
+     * belong.
+     * 
+ * + * string database_id = 3; + * + * @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; + } + } + + /** + * + * + *
+     * If not empty, the ID of the database to which the entities
+     * belong.
+     * 
+ * + * string database_id = 3; + * + * @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; + } + } + + /** + * + * + *
+     * If not empty, the ID of the database to which the entities
+     * belong.
+     * 
+ * + * string database_id = 3; + * + * @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; + } + + /** + * + * + *
+     * If not empty, the ID of the database to which the entities
+     * belong.
+     * 
+ * + * string database_id = 3; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * If not empty, the ID of the database to which the entities
+     * belong.
+     * 
+ * + * string database_id = 3; + * + * @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 namespaceId_ = ""; + + /** + * + * + *
+     * If not empty, the ID of the namespace to which the entities belong.
+     * 
+ * + * string namespace_id = 4; + * + * @return The namespaceId. + */ + public java.lang.String getNamespaceId() { + java.lang.Object ref = namespaceId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + namespaceId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * If not empty, the ID of the namespace to which the entities belong.
+     * 
+ * + * string namespace_id = 4; + * + * @return The bytes for namespaceId. + */ + public com.google.protobuf.ByteString getNamespaceIdBytes() { + java.lang.Object ref = namespaceId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + namespaceId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * If not empty, the ID of the namespace to which the entities belong.
+     * 
+ * + * string namespace_id = 4; + * + * @param value The namespaceId to set. + * @return This builder for chaining. + */ + public Builder setNamespaceId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + namespaceId_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * If not empty, the ID of the namespace to which the entities belong.
+     * 
+ * + * string namespace_id = 4; + * + * @return This builder for chaining. + */ + public Builder clearNamespaceId() { + namespaceId_ = getDefaultInstance().getNamespaceId(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + + /** + * + * + *
+     * If not empty, the ID of the namespace to which the entities belong.
+     * 
+ * + * string namespace_id = 4; + * + * @param value The bytes for namespaceId to set. + * @return This builder for chaining. + */ + public Builder setNamespaceIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + namespaceId_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.PartitionId) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.PartitionId) + private static final com.google.datastore.v1.PartitionId DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.PartitionId(); + } + + public static com.google.datastore.v1.PartitionId getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PartitionId 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.datastore.v1.PartitionId getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionIdOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionIdOrBuilder.java new file mode 100644 index 000000000000..1dbb6bc7dbc8 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PartitionIdOrBuilder.java @@ -0,0 +1,106 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface PartitionIdOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.PartitionId) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The ID of the project to which the entities belong.
+   * 
+ * + * string project_id = 2; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * The ID of the project to which the entities belong.
+   * 
+ * + * string project_id = 2; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * If not empty, the ID of the database to which the entities
+   * belong.
+   * 
+ * + * string database_id = 3; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * If not empty, the ID of the database to which the entities
+   * belong.
+   * 
+ * + * string database_id = 3; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * If not empty, the ID of the namespace to which the entities belong.
+   * 
+ * + * string namespace_id = 4; + * + * @return The namespaceId. + */ + java.lang.String getNamespaceId(); + + /** + * + * + *
+   * If not empty, the ID of the namespace to which the entities belong.
+   * 
+ * + * string namespace_id = 4; + * + * @return The bytes for namespaceId. + */ + com.google.protobuf.ByteString getNamespaceIdBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummary.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummary.java new file mode 100644 index 000000000000..b3399cbd1d98 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummary.java @@ -0,0 +1,1043 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * Planning phase information for the query.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.PlanSummary} + */ +public final class PlanSummary extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.PlanSummary) + PlanSummaryOrBuilder { + private static final long serialVersionUID = 0L; + + // Use PlanSummary.newBuilder() to construct. + private PlanSummary(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PlanSummary() { + indexesUsed_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PlanSummary(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_PlanSummary_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_PlanSummary_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PlanSummary.class, + com.google.datastore.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.datastore.v1.PlanSummary)) { + return super.equals(obj); + } + com.google.datastore.v1.PlanSummary other = (com.google.datastore.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.datastore.v1.PlanSummary parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.PlanSummary parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.PlanSummary parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PlanSummary parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PlanSummary parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PlanSummary parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PlanSummary parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PlanSummary parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PlanSummary parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PlanSummary parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Planning phase information for the query.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.PlanSummary} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.PlanSummary) + com.google.datastore.v1.PlanSummaryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_PlanSummary_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_PlanSummary_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PlanSummary.class, + com.google.datastore.v1.PlanSummary.Builder.class); + } + + // Construct using com.google.datastore.v1.PlanSummary.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.v1.QueryProfileProto + .internal_static_google_datastore_v1_PlanSummary_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.PlanSummary getDefaultInstanceForType() { + return com.google.datastore.v1.PlanSummary.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.PlanSummary build() { + com.google.datastore.v1.PlanSummary result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.PlanSummary buildPartial() { + com.google.datastore.v1.PlanSummary result = new com.google.datastore.v1.PlanSummary(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.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.datastore.v1.PlanSummary result) { + int from_bitField0_ = bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.PlanSummary) { + return mergeFrom((com.google.datastore.v1.PlanSummary) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.PlanSummary other) { + if (other == com.google.datastore.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.GeneratedMessageV3.alwaysUseFieldBuilders + ? getIndexesUsedFieldBuilder() + : 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.RepeatedFieldBuilderV3< + 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 getIndexesUsedFieldBuilder().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 getIndexesUsedFieldBuilder() + .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 getIndexesUsedFieldBuilder() + .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 getIndexesUsedFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder> + getIndexesUsedFieldBuilder() { + if (indexesUsedBuilder_ == null) { + indexesUsedBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.protobuf.Struct, + com.google.protobuf.Struct.Builder, + com.google.protobuf.StructOrBuilder>( + indexesUsed_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + indexesUsed_ = null; + } + return indexesUsedBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.PlanSummary) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.PlanSummary) + private static final com.google.datastore.v1.PlanSummary DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.PlanSummary(); + } + + public static com.google.datastore.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.datastore.v1.PlanSummary getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummaryOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummaryOrBuilder.java new file mode 100644 index 000000000000..2692e5f4cff2 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PlanSummaryOrBuilder.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! +// source: google/datastore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface PlanSummaryOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.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-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Projection.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Projection.java new file mode 100644 index 000000000000..dca4ae0ff49f --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Projection.java @@ -0,0 +1,731 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A representation of a property in a projection.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.Projection} + */ +public final class Projection extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.Projection) + ProjectionOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Projection.newBuilder() to construct. + private Projection(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Projection() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Projection(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Projection_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Projection_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Projection.class, + com.google.datastore.v1.Projection.Builder.class); + } + + private int bitField0_; + public static final int PROPERTY_FIELD_NUMBER = 1; + private com.google.datastore.v1.PropertyReference property_; + + /** + * + * + *
+   * The property to project.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + @java.lang.Override + public boolean hasProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The property to project.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReference getProperty() { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + + /** + * + * + *
+   * The property to project.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder() { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + + 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, getProperty()); + } + 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, getProperty()); + } + 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.datastore.v1.Projection)) { + return super.equals(obj); + } + com.google.datastore.v1.Projection other = (com.google.datastore.v1.Projection) obj; + + if (hasProperty() != other.hasProperty()) return false; + if (hasProperty()) { + if (!getProperty().equals(other.getProperty())) 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 (hasProperty()) { + hash = (37 * hash) + PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getProperty().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.Projection parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.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.datastore.v1.Projection parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.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.datastore.v1.Projection parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Projection parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Projection parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Projection parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Projection parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Projection parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Projection parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Projection parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A representation of a property in a projection.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.Projection} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.Projection) + com.google.datastore.v1.ProjectionOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Projection_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Projection_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Projection.class, + com.google.datastore.v1.Projection.Builder.class); + } + + // Construct using com.google.datastore.v1.Projection.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPropertyFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + property_ = null; + if (propertyBuilder_ != null) { + propertyBuilder_.dispose(); + propertyBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Projection_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.Projection getDefaultInstanceForType() { + return com.google.datastore.v1.Projection.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.Projection build() { + com.google.datastore.v1.Projection result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.Projection buildPartial() { + com.google.datastore.v1.Projection result = new com.google.datastore.v1.Projection(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.Projection result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.property_ = propertyBuilder_ == null ? property_ : propertyBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.Projection) { + return mergeFrom((com.google.datastore.v1.Projection) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.Projection other) { + if (other == com.google.datastore.v1.Projection.getDefaultInstance()) return this; + if (other.hasProperty()) { + mergeProperty(other.getProperty()); + } + 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(getPropertyFieldBuilder().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.datastore.v1.PropertyReference property_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + propertyBuilder_; + + /** + * + * + *
+     * The property to project.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + public boolean hasProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The property to project.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + public com.google.datastore.v1.PropertyReference getProperty() { + if (propertyBuilder_ == null) { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } else { + return propertyBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The property to project.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder setProperty(com.google.datastore.v1.PropertyReference value) { + if (propertyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + property_ = value; + } else { + propertyBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The property to project.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder setProperty(com.google.datastore.v1.PropertyReference.Builder builderForValue) { + if (propertyBuilder_ == null) { + property_ = builderForValue.build(); + } else { + propertyBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The property to project.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder mergeProperty(com.google.datastore.v1.PropertyReference value) { + if (propertyBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && property_ != null + && property_ != com.google.datastore.v1.PropertyReference.getDefaultInstance()) { + getPropertyBuilder().mergeFrom(value); + } else { + property_ = value; + } + } else { + propertyBuilder_.mergeFrom(value); + } + if (property_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The property to project.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder clearProperty() { + bitField0_ = (bitField0_ & ~0x00000001); + property_ = null; + if (propertyBuilder_ != null) { + propertyBuilder_.dispose(); + propertyBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The property to project.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public com.google.datastore.v1.PropertyReference.Builder getPropertyBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getPropertyFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The property to project.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder() { + if (propertyBuilder_ != null) { + return propertyBuilder_.getMessageOrBuilder(); + } else { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + } + + /** + * + * + *
+     * The property to project.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + getPropertyFieldBuilder() { + if (propertyBuilder_ == null) { + propertyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder>( + getProperty(), getParentForChildren(), isClean()); + property_ = null; + } + return propertyBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.Projection) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.Projection) + private static final com.google.datastore.v1.Projection DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.Projection(); + } + + public static com.google.datastore.v1.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.datastore.v1.Projection getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ProjectionOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ProjectionOrBuilder.java new file mode 100644 index 000000000000..c3a7ccdd6b43 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ProjectionOrBuilder.java @@ -0,0 +1,63 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface ProjectionOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.Projection) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The property to project.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + boolean hasProperty(); + + /** + * + * + *
+   * The property to project.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + com.google.datastore.v1.PropertyReference getProperty(); + + /** + * + * + *
+   * The property to project.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilter.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilter.java new file mode 100644 index 000000000000..18ec7756c16a --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilter.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! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A filter on a specific property.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyFilter} + */ +public final class PropertyFilter extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.PropertyFilter) + PropertyFilterOrBuilder { + private static final long serialVersionUID = 0L; + + // Use PropertyFilter.newBuilder() to construct. + private PropertyFilter(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PropertyFilter() { + op_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PropertyFilter(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyFilter.class, + com.google.datastore.v1.PropertyFilter.Builder.class); + } + + /** + * + * + *
+   * A property filter operator.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.PropertyFilter.Operator} + */ + public enum Operator implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * OPERATOR_UNSPECIFIED = 0; + */ + OPERATOR_UNSPECIFIED(0), + /** + * + * + *
+     * The given `property` is less than the given `value`.
+     *
+     * Requires:
+     *
+     * * That `property` comes first in `order_by`.
+     * 
+ * + * LESS_THAN = 1; + */ + LESS_THAN(1), + /** + * + * + *
+     * The given `property` is less than or equal to the given `value`.
+     *
+     * Requires:
+     *
+     * * That `property` comes first in `order_by`.
+     * 
+ * + * LESS_THAN_OR_EQUAL = 2; + */ + LESS_THAN_OR_EQUAL(2), + /** + * + * + *
+     * The given `property` is greater than the given `value`.
+     *
+     * Requires:
+     *
+     * * That `property` comes first in `order_by`.
+     * 
+ * + * GREATER_THAN = 3; + */ + GREATER_THAN(3), + /** + * + * + *
+     * The given `property` is greater than or equal to the given `value`.
+     *
+     * Requires:
+     *
+     * * That `property` comes first in `order_by`.
+     * 
+ * + * GREATER_THAN_OR_EQUAL = 4; + */ + GREATER_THAN_OR_EQUAL(4), + /** + * + * + *
+     * The given `property` is equal to the given `value`.
+     * 
+ * + * EQUAL = 5; + */ + EQUAL(5), + /** + * + * + *
+     * The given `property` 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` is in the same query.
+     * 
+ * + * IN = 6; + */ + IN(6), + /** + * + * + *
+     * The given `property` is not equal to the given `value`.
+     *
+     * Requires:
+     *
+     * * No other `NOT_EQUAL` or `NOT_IN` is in the same query.
+     * * That `property` comes first in the `order_by`.
+     * 
+ * + * NOT_EQUAL = 9; + */ + NOT_EQUAL(9), + /** + * + * + *
+     * Limit the result set to the given entity and its descendants.
+     *
+     * Requires:
+     *
+     * * That `value` is an entity key.
+     * * All evaluated disjunctions must have the same `HAS_ANCESTOR` filter.
+     * 
+ * + * HAS_ANCESTOR = 11; + */ + HAS_ANCESTOR(11), + /** + * + * + *
+     * The value of the `property` is not in the given array.
+     *
+     * Requires:
+     *
+     * * That `value` is a non-empty `ArrayValue` with at most 10 values.
+     * * No other `OR`, `IN`, `NOT_IN`, `NOT_EQUAL` is in the same query.
+     * * That `field` comes first in the `order_by`.
+     * 
+ * + * NOT_IN = 13; + */ + NOT_IN(13), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * OPERATOR_UNSPECIFIED = 0; + */ + public static final int OPERATOR_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * The given `property` is less than the given `value`.
+     *
+     * Requires:
+     *
+     * * That `property` comes first in `order_by`.
+     * 
+ * + * LESS_THAN = 1; + */ + public static final int LESS_THAN_VALUE = 1; + + /** + * + * + *
+     * The given `property` is less than or equal to the given `value`.
+     *
+     * Requires:
+     *
+     * * That `property` comes first in `order_by`.
+     * 
+ * + * LESS_THAN_OR_EQUAL = 2; + */ + public static final int LESS_THAN_OR_EQUAL_VALUE = 2; + + /** + * + * + *
+     * The given `property` is greater than the given `value`.
+     *
+     * Requires:
+     *
+     * * That `property` comes first in `order_by`.
+     * 
+ * + * GREATER_THAN = 3; + */ + public static final int GREATER_THAN_VALUE = 3; + + /** + * + * + *
+     * The given `property` is greater than or equal to the given `value`.
+     *
+     * Requires:
+     *
+     * * That `property` comes first in `order_by`.
+     * 
+ * + * GREATER_THAN_OR_EQUAL = 4; + */ + public static final int GREATER_THAN_OR_EQUAL_VALUE = 4; + + /** + * + * + *
+     * The given `property` is equal to the given `value`.
+     * 
+ * + * EQUAL = 5; + */ + public static final int EQUAL_VALUE = 5; + + /** + * + * + *
+     * The given `property` 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` is in the same query.
+     * 
+ * + * IN = 6; + */ + public static final int IN_VALUE = 6; + + /** + * + * + *
+     * The given `property` is not equal to the given `value`.
+     *
+     * Requires:
+     *
+     * * No other `NOT_EQUAL` or `NOT_IN` is in the same query.
+     * * That `property` comes first in the `order_by`.
+     * 
+ * + * NOT_EQUAL = 9; + */ + public static final int NOT_EQUAL_VALUE = 9; + + /** + * + * + *
+     * Limit the result set to the given entity and its descendants.
+     *
+     * Requires:
+     *
+     * * That `value` is an entity key.
+     * * All evaluated disjunctions must have the same `HAS_ANCESTOR` filter.
+     * 
+ * + * HAS_ANCESTOR = 11; + */ + public static final int HAS_ANCESTOR_VALUE = 11; + + /** + * + * + *
+     * The value of the `property` is not in the given array.
+     *
+     * Requires:
+     *
+     * * That `value` is a non-empty `ArrayValue` with at most 10 values.
+     * * No other `OR`, `IN`, `NOT_IN`, `NOT_EQUAL` is in the same query.
+     * * That `field` comes first in the `order_by`.
+     * 
+ * + * NOT_IN = 13; + */ + public static final int NOT_IN_VALUE = 13; + + 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 IN; + case 9: + return NOT_EQUAL; + case 11: + return HAS_ANCESTOR; + case 13: + 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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.PropertyFilter.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.datastore.v1.PropertyFilter.Operator) + } + + private int bitField0_; + public static final int PROPERTY_FIELD_NUMBER = 1; + private com.google.datastore.v1.PropertyReference property_; + + /** + * + * + *
+   * The property to filter by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + @java.lang.Override + public boolean hasProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The property to filter by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReference getProperty() { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + + /** + * + * + *
+   * The property to filter by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder() { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + + public static final int OP_FIELD_NUMBER = 2; + private int op_ = 0; + + /** + * + * + *
+   * The operator to filter by.
+   * 
+ * + * .google.datastore.v1.PropertyFilter.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.datastore.v1.PropertyFilter.Operator op = 2; + * + * @return The op. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyFilter.Operator getOp() { + com.google.datastore.v1.PropertyFilter.Operator result = + com.google.datastore.v1.PropertyFilter.Operator.forNumber(op_); + return result == null ? com.google.datastore.v1.PropertyFilter.Operator.UNRECOGNIZED : result; + } + + public static final int VALUE_FIELD_NUMBER = 3; + private com.google.datastore.v1.Value value_; + + /** + * + * + *
+   * The value to compare the property to.
+   * 
+ * + * .google.datastore.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 the property to.
+   * 
+ * + * .google.datastore.v1.Value value = 3; + * + * @return The value. + */ + @java.lang.Override + public com.google.datastore.v1.Value getValue() { + return value_ == null ? com.google.datastore.v1.Value.getDefaultInstance() : value_; + } + + /** + * + * + *
+   * The value to compare the property to.
+   * 
+ * + * .google.datastore.v1.Value value = 3; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getValueOrBuilder() { + return value_ == null ? com.google.datastore.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, getProperty()); + } + if (op_ != com.google.datastore.v1.PropertyFilter.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, getProperty()); + } + if (op_ != com.google.datastore.v1.PropertyFilter.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.datastore.v1.PropertyFilter)) { + return super.equals(obj); + } + com.google.datastore.v1.PropertyFilter other = (com.google.datastore.v1.PropertyFilter) obj; + + if (hasProperty() != other.hasProperty()) return false; + if (hasProperty()) { + if (!getProperty().equals(other.getProperty())) 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 (hasProperty()) { + hash = (37 * hash) + PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getProperty().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.datastore.v1.PropertyFilter parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyFilter parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyFilter parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyFilter 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.datastore.v1.PropertyFilter parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyFilter parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyFilter parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyFilter parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyFilter parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyFilter parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyFilter parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyFilter parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.PropertyFilter 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A filter on a specific property.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyFilter} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.PropertyFilter) + com.google.datastore.v1.PropertyFilterOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyFilter_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyFilter_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyFilter.class, + com.google.datastore.v1.PropertyFilter.Builder.class); + } + + // Construct using com.google.datastore.v1.PropertyFilter.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPropertyFieldBuilder(); + getValueFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + property_ = null; + if (propertyBuilder_ != null) { + propertyBuilder_.dispose(); + propertyBuilder_ = 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.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyFilter_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyFilter getDefaultInstanceForType() { + return com.google.datastore.v1.PropertyFilter.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.PropertyFilter build() { + com.google.datastore.v1.PropertyFilter result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyFilter buildPartial() { + com.google.datastore.v1.PropertyFilter result = + new com.google.datastore.v1.PropertyFilter(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.PropertyFilter result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.property_ = propertyBuilder_ == null ? property_ : propertyBuilder_.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 clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.PropertyFilter) { + return mergeFrom((com.google.datastore.v1.PropertyFilter) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.PropertyFilter other) { + if (other == com.google.datastore.v1.PropertyFilter.getDefaultInstance()) return this; + if (other.hasProperty()) { + mergeProperty(other.getProperty()); + } + 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(getPropertyFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + op_ = input.readEnum(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 26: + { + input.readMessage(getValueFieldBuilder().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.datastore.v1.PropertyReference property_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + propertyBuilder_; + + /** + * + * + *
+     * The property to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + public boolean hasProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The property to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + public com.google.datastore.v1.PropertyReference getProperty() { + if (propertyBuilder_ == null) { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } else { + return propertyBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The property to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder setProperty(com.google.datastore.v1.PropertyReference value) { + if (propertyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + property_ = value; + } else { + propertyBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The property to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder setProperty(com.google.datastore.v1.PropertyReference.Builder builderForValue) { + if (propertyBuilder_ == null) { + property_ = builderForValue.build(); + } else { + propertyBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The property to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder mergeProperty(com.google.datastore.v1.PropertyReference value) { + if (propertyBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && property_ != null + && property_ != com.google.datastore.v1.PropertyReference.getDefaultInstance()) { + getPropertyBuilder().mergeFrom(value); + } else { + property_ = value; + } + } else { + propertyBuilder_.mergeFrom(value); + } + if (property_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The property to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder clearProperty() { + bitField0_ = (bitField0_ & ~0x00000001); + property_ = null; + if (propertyBuilder_ != null) { + propertyBuilder_.dispose(); + propertyBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The property to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public com.google.datastore.v1.PropertyReference.Builder getPropertyBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getPropertyFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The property to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder() { + if (propertyBuilder_ != null) { + return propertyBuilder_.getMessageOrBuilder(); + } else { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + } + + /** + * + * + *
+     * The property to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + getPropertyFieldBuilder() { + if (propertyBuilder_ == null) { + propertyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder>( + getProperty(), getParentForChildren(), isClean()); + property_ = null; + } + return propertyBuilder_; + } + + private int op_ = 0; + + /** + * + * + *
+     * The operator to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyFilter.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.datastore.v1.PropertyFilter.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.datastore.v1.PropertyFilter.Operator op = 2; + * + * @return The op. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyFilter.Operator getOp() { + com.google.datastore.v1.PropertyFilter.Operator result = + com.google.datastore.v1.PropertyFilter.Operator.forNumber(op_); + return result == null ? com.google.datastore.v1.PropertyFilter.Operator.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The operator to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyFilter.Operator op = 2; + * + * @param value The op to set. + * @return This builder for chaining. + */ + public Builder setOp(com.google.datastore.v1.PropertyFilter.Operator value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000002; + op_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The operator to filter by.
+     * 
+ * + * .google.datastore.v1.PropertyFilter.Operator op = 2; + * + * @return This builder for chaining. + */ + public Builder clearOp() { + bitField0_ = (bitField0_ & ~0x00000002); + op_ = 0; + onChanged(); + return this; + } + + private com.google.datastore.v1.Value value_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + valueBuilder_; + + /** + * + * + *
+     * The value to compare the property to.
+     * 
+ * + * .google.datastore.v1.Value value = 3; + * + * @return Whether the value field is set. + */ + public boolean hasValue() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The value to compare the property to.
+     * 
+ * + * .google.datastore.v1.Value value = 3; + * + * @return The value. + */ + public com.google.datastore.v1.Value getValue() { + if (valueBuilder_ == null) { + return value_ == null ? com.google.datastore.v1.Value.getDefaultInstance() : value_; + } else { + return valueBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The value to compare the property to.
+     * 
+ * + * .google.datastore.v1.Value value = 3; + */ + public Builder setValue(com.google.datastore.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 the property to.
+     * 
+ * + * .google.datastore.v1.Value value = 3; + */ + public Builder setValue(com.google.datastore.v1.Value.Builder builderForValue) { + if (valueBuilder_ == null) { + value_ = builderForValue.build(); + } else { + valueBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The value to compare the property to.
+     * 
+ * + * .google.datastore.v1.Value value = 3; + */ + public Builder mergeValue(com.google.datastore.v1.Value value) { + if (valueBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && value_ != null + && value_ != com.google.datastore.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 the property to.
+     * 
+ * + * .google.datastore.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 the property to.
+     * 
+ * + * .google.datastore.v1.Value value = 3; + */ + public com.google.datastore.v1.Value.Builder getValueBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The value to compare the property to.
+     * 
+ * + * .google.datastore.v1.Value value = 3; + */ + public com.google.datastore.v1.ValueOrBuilder getValueOrBuilder() { + if (valueBuilder_ != null) { + return valueBuilder_.getMessageOrBuilder(); + } else { + return value_ == null ? com.google.datastore.v1.Value.getDefaultInstance() : value_; + } + } + + /** + * + * + *
+     * The value to compare the property to.
+     * 
+ * + * .google.datastore.v1.Value value = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getValueFieldBuilder() { + if (valueBuilder_ == null) { + valueBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + getValue(), getParentForChildren(), isClean()); + value_ = null; + } + return valueBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.PropertyFilter) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.PropertyFilter) + private static final com.google.datastore.v1.PropertyFilter DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.PropertyFilter(); + } + + public static com.google.datastore.v1.PropertyFilter getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PropertyFilter 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.datastore.v1.PropertyFilter getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilterOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilterOrBuilder.java new file mode 100644 index 000000000000..ecfb5f3e0de7 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyFilterOrBuilder.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! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface PropertyFilterOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.PropertyFilter) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The property to filter by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + boolean hasProperty(); + + /** + * + * + *
+   * The property to filter by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + com.google.datastore.v1.PropertyReference getProperty(); + + /** + * + * + *
+   * The property to filter by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder(); + + /** + * + * + *
+   * The operator to filter by.
+   * 
+ * + * .google.datastore.v1.PropertyFilter.Operator op = 2; + * + * @return The enum numeric value on the wire for op. + */ + int getOpValue(); + + /** + * + * + *
+   * The operator to filter by.
+   * 
+ * + * .google.datastore.v1.PropertyFilter.Operator op = 2; + * + * @return The op. + */ + com.google.datastore.v1.PropertyFilter.Operator getOp(); + + /** + * + * + *
+   * The value to compare the property to.
+   * 
+ * + * .google.datastore.v1.Value value = 3; + * + * @return Whether the value field is set. + */ + boolean hasValue(); + + /** + * + * + *
+   * The value to compare the property to.
+   * 
+ * + * .google.datastore.v1.Value value = 3; + * + * @return The value. + */ + com.google.datastore.v1.Value getValue(); + + /** + * + * + *
+   * The value to compare the property to.
+   * 
+ * + * .google.datastore.v1.Value value = 3; + */ + com.google.datastore.v1.ValueOrBuilder getValueOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMask.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMask.java new file mode 100644 index 000000000000..a5ae3b9e1997 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMask.java @@ -0,0 +1,863 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The set of arbitrarily nested property paths used to restrict an operation to
+ * only a subset of properties in an entity.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyMask} + */ +public final class PropertyMask extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.PropertyMask) + PropertyMaskOrBuilder { + private static final long serialVersionUID = 0L; + + // Use PropertyMask.newBuilder() to construct. + private PropertyMask(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PropertyMask() { + paths_ = com.google.protobuf.LazyStringArrayList.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PropertyMask(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyMask_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyMask_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyMask.class, + com.google.datastore.v1.PropertyMask.Builder.class); + } + + public static final int PATHS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList paths_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @return A list containing the paths. + */ + public com.google.protobuf.ProtocolStringList getPathsList() { + return paths_; + } + + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @return The count of paths. + */ + public int getPathsCount() { + return paths_.size(); + } + + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @param index The index of the element to return. + * @return The paths at the given index. + */ + public java.lang.String getPaths(int index) { + return paths_.get(index); + } + + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @param index The index of the value to return. + * @return The bytes of the paths at the given index. + */ + public com.google.protobuf.ByteString getPathsBytes(int index) { + return paths_.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 < paths_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, paths_.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 < paths_.size(); i++) { + dataSize += computeStringSizeNoTag(paths_.getRaw(i)); + } + size += dataSize; + size += 1 * getPathsList().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.datastore.v1.PropertyMask)) { + return super.equals(obj); + } + com.google.datastore.v1.PropertyMask other = (com.google.datastore.v1.PropertyMask) obj; + + if (!getPathsList().equals(other.getPathsList())) 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 (getPathsCount() > 0) { + hash = (37 * hash) + PATHS_FIELD_NUMBER; + hash = (53 * hash) + getPathsList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.PropertyMask parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyMask parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyMask 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.datastore.v1.PropertyMask parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyMask parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyMask parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyMask parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyMask parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.PropertyMask 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The set of arbitrarily nested property paths used to restrict an operation to
+   * only a subset of properties in an entity.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyMask} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.PropertyMask) + com.google.datastore.v1.PropertyMaskOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyMask_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyMask_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyMask.class, + com.google.datastore.v1.PropertyMask.Builder.class); + } + + // Construct using com.google.datastore.v1.PropertyMask.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + paths_ = com.google.protobuf.LazyStringArrayList.emptyList(); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyMask_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyMask getDefaultInstanceForType() { + return com.google.datastore.v1.PropertyMask.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.PropertyMask build() { + com.google.datastore.v1.PropertyMask result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyMask buildPartial() { + com.google.datastore.v1.PropertyMask result = new com.google.datastore.v1.PropertyMask(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.PropertyMask result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + paths_.makeImmutable(); + result.paths_ = paths_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.PropertyMask) { + return mergeFrom((com.google.datastore.v1.PropertyMask) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.PropertyMask other) { + if (other == com.google.datastore.v1.PropertyMask.getDefaultInstance()) return this; + if (!other.paths_.isEmpty()) { + if (paths_.isEmpty()) { + paths_ = other.paths_; + bitField0_ |= 0x00000001; + } else { + ensurePathsIsMutable(); + paths_.addAll(other.paths_); + } + 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(); + ensurePathsIsMutable(); + paths_.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 paths_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensurePathsIsMutable() { + if (!paths_.isModifiable()) { + paths_ = new com.google.protobuf.LazyStringArrayList(paths_); + } + bitField0_ |= 0x00000001; + } + + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @return A list containing the paths. + */ + public com.google.protobuf.ProtocolStringList getPathsList() { + paths_.makeImmutable(); + return paths_; + } + + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @return The count of paths. + */ + public int getPathsCount() { + return paths_.size(); + } + + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param index The index of the element to return. + * @return The paths at the given index. + */ + public java.lang.String getPaths(int index) { + return paths_.get(index); + } + + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param index The index of the value to return. + * @return The bytes of the paths at the given index. + */ + public com.google.protobuf.ByteString getPathsBytes(int index) { + return paths_.getByteString(index); + } + + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param index The index to set the value at. + * @param value The paths to set. + * @return This builder for chaining. + */ + public Builder setPaths(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensurePathsIsMutable(); + paths_.set(index, value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param value The paths to add. + * @return This builder for chaining. + */ + public Builder addPaths(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensurePathsIsMutable(); + paths_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param values The paths to add. + * @return This builder for chaining. + */ + public Builder addAllPaths(java.lang.Iterable values) { + ensurePathsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, paths_); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @return This builder for chaining. + */ + public Builder clearPaths() { + paths_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + ; + onChanged(); + return this; + } + + /** + * + * + *
+     * The paths to the properties covered by this mask.
+     *
+     * A path is a list of property names separated by dots (`.`), for example
+     * `foo.bar` means the property `bar` inside the entity property `foo` inside
+     * the entity associated with this path.
+     *
+     * If a property name contains a dot `.` or a backslash `\`, then that
+     * name must be escaped.
+     *
+     * A path must not be empty, and may not reference a value inside an
+     * [array value][google.datastore.v1.Value.array_value].
+     * 
+ * + * repeated string paths = 1; + * + * @param value The bytes of the paths to add. + * @return This builder for chaining. + */ + public Builder addPathsBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensurePathsIsMutable(); + paths_.add(value); + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.PropertyMask) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.PropertyMask) + private static final com.google.datastore.v1.PropertyMask DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.PropertyMask(); + } + + public static com.google.datastore.v1.PropertyMask getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PropertyMask 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.datastore.v1.PropertyMask getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMaskOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMaskOrBuilder.java new file mode 100644 index 000000000000..3c237c5e60b8 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyMaskOrBuilder.java @@ -0,0 +1,120 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface PropertyMaskOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.PropertyMask) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @return A list containing the paths. + */ + java.util.List getPathsList(); + + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @return The count of paths. + */ + int getPathsCount(); + + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @param index The index of the element to return. + * @return The paths at the given index. + */ + java.lang.String getPaths(int index); + + /** + * + * + *
+   * The paths to the properties covered by this mask.
+   *
+   * A path is a list of property names separated by dots (`.`), for example
+   * `foo.bar` means the property `bar` inside the entity property `foo` inside
+   * the entity associated with this path.
+   *
+   * If a property name contains a dot `.` or a backslash `\`, then that
+   * name must be escaped.
+   *
+   * A path must not be empty, and may not reference a value inside an
+   * [array value][google.datastore.v1.Value.array_value].
+   * 
+ * + * repeated string paths = 1; + * + * @param index The index of the value to return. + * @return The bytes of the paths at the given index. + */ + com.google.protobuf.ByteString getPathsBytes(int index); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrder.java new file mode 100644 index 000000000000..141dacb7cc30 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrder.java @@ -0,0 +1,1049 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The desired order for a specific property.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyOrder} + */ +public final class PropertyOrder extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.PropertyOrder) + PropertyOrderOrBuilder { + private static final long serialVersionUID = 0L; + + // Use PropertyOrder.newBuilder() to construct. + private PropertyOrder(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PropertyOrder() { + direction_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PropertyOrder(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyOrder_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyOrder_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyOrder.class, + com.google.datastore.v1.PropertyOrder.Builder.class); + } + + /** + * + * + *
+   * The sort direction.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.PropertyOrder.Direction} + */ + public enum Direction implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * DIRECTION_UNSPECIFIED = 0; + */ + DIRECTION_UNSPECIFIED(0), + /** + * + * + *
+     * Ascending.
+     * 
+ * + * ASCENDING = 1; + */ + ASCENDING(1), + /** + * + * + *
+     * Descending.
+     * 
+ * + * DESCENDING = 2; + */ + DESCENDING(2), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * 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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.PropertyOrder.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.datastore.v1.PropertyOrder.Direction) + } + + private int bitField0_; + public static final int PROPERTY_FIELD_NUMBER = 1; + private com.google.datastore.v1.PropertyReference property_; + + /** + * + * + *
+   * The property to order by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + @java.lang.Override + public boolean hasProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The property to order by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReference getProperty() { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + + /** + * + * + *
+   * The property to order by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder() { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + + public static final int DIRECTION_FIELD_NUMBER = 2; + private int direction_ = 0; + + /** + * + * + *
+   * The direction to order by. Defaults to `ASCENDING`.
+   * 
+ * + * .google.datastore.v1.PropertyOrder.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.datastore.v1.PropertyOrder.Direction direction = 2; + * + * @return The direction. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyOrder.Direction getDirection() { + com.google.datastore.v1.PropertyOrder.Direction result = + com.google.datastore.v1.PropertyOrder.Direction.forNumber(direction_); + return result == null ? com.google.datastore.v1.PropertyOrder.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, getProperty()); + } + if (direction_ + != com.google.datastore.v1.PropertyOrder.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, getProperty()); + } + if (direction_ + != com.google.datastore.v1.PropertyOrder.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.datastore.v1.PropertyOrder)) { + return super.equals(obj); + } + com.google.datastore.v1.PropertyOrder other = (com.google.datastore.v1.PropertyOrder) obj; + + if (hasProperty() != other.hasProperty()) return false; + if (hasProperty()) { + if (!getProperty().equals(other.getProperty())) 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 (hasProperty()) { + hash = (37 * hash) + PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getProperty().hashCode(); + } + hash = (37 * hash) + DIRECTION_FIELD_NUMBER; + hash = (53 * hash) + direction_; + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.PropertyOrder parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyOrder parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyOrder parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyOrder 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.datastore.v1.PropertyOrder parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyOrder parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyOrder parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyOrder parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyOrder parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyOrder parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyOrder parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyOrder parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.PropertyOrder 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The desired order for a specific property.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyOrder} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.PropertyOrder) + com.google.datastore.v1.PropertyOrderOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyOrder_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyOrder_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyOrder.class, + com.google.datastore.v1.PropertyOrder.Builder.class); + } + + // Construct using com.google.datastore.v1.PropertyOrder.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPropertyFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + property_ = null; + if (propertyBuilder_ != null) { + propertyBuilder_.dispose(); + propertyBuilder_ = null; + } + direction_ = 0; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyOrder_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyOrder getDefaultInstanceForType() { + return com.google.datastore.v1.PropertyOrder.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.PropertyOrder build() { + com.google.datastore.v1.PropertyOrder result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyOrder buildPartial() { + com.google.datastore.v1.PropertyOrder result = + new com.google.datastore.v1.PropertyOrder(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.PropertyOrder result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.property_ = propertyBuilder_ == null ? property_ : propertyBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.direction_ = direction_; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.PropertyOrder) { + return mergeFrom((com.google.datastore.v1.PropertyOrder) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.PropertyOrder other) { + if (other == com.google.datastore.v1.PropertyOrder.getDefaultInstance()) return this; + if (other.hasProperty()) { + mergeProperty(other.getProperty()); + } + 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(getPropertyFieldBuilder().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.datastore.v1.PropertyReference property_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + propertyBuilder_; + + /** + * + * + *
+     * The property to order by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + public boolean hasProperty() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * The property to order by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + public com.google.datastore.v1.PropertyReference getProperty() { + if (propertyBuilder_ == null) { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } else { + return propertyBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The property to order by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder setProperty(com.google.datastore.v1.PropertyReference value) { + if (propertyBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + property_ = value; + } else { + propertyBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The property to order by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder setProperty(com.google.datastore.v1.PropertyReference.Builder builderForValue) { + if (propertyBuilder_ == null) { + property_ = builderForValue.build(); + } else { + propertyBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The property to order by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder mergeProperty(com.google.datastore.v1.PropertyReference value) { + if (propertyBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && property_ != null + && property_ != com.google.datastore.v1.PropertyReference.getDefaultInstance()) { + getPropertyBuilder().mergeFrom(value); + } else { + property_ = value; + } + } else { + propertyBuilder_.mergeFrom(value); + } + if (property_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The property to order by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public Builder clearProperty() { + bitField0_ = (bitField0_ & ~0x00000001); + property_ = null; + if (propertyBuilder_ != null) { + propertyBuilder_.dispose(); + propertyBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The property to order by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public com.google.datastore.v1.PropertyReference.Builder getPropertyBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getPropertyFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The property to order by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + public com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder() { + if (propertyBuilder_ != null) { + return propertyBuilder_.getMessageOrBuilder(); + } else { + return property_ == null + ? com.google.datastore.v1.PropertyReference.getDefaultInstance() + : property_; + } + } + + /** + * + * + *
+     * The property to order by.
+     * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + getPropertyFieldBuilder() { + if (propertyBuilder_ == null) { + propertyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder>( + getProperty(), getParentForChildren(), isClean()); + property_ = null; + } + return propertyBuilder_; + } + + private int direction_ = 0; + + /** + * + * + *
+     * The direction to order by. Defaults to `ASCENDING`.
+     * 
+ * + * .google.datastore.v1.PropertyOrder.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.datastore.v1.PropertyOrder.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.datastore.v1.PropertyOrder.Direction direction = 2; + * + * @return The direction. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyOrder.Direction getDirection() { + com.google.datastore.v1.PropertyOrder.Direction result = + com.google.datastore.v1.PropertyOrder.Direction.forNumber(direction_); + return result == null ? com.google.datastore.v1.PropertyOrder.Direction.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The direction to order by. Defaults to `ASCENDING`.
+     * 
+ * + * .google.datastore.v1.PropertyOrder.Direction direction = 2; + * + * @param value The direction to set. + * @return This builder for chaining. + */ + public Builder setDirection(com.google.datastore.v1.PropertyOrder.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.datastore.v1.PropertyOrder.Direction direction = 2; + * + * @return This builder for chaining. + */ + public Builder clearDirection() { + bitField0_ = (bitField0_ & ~0x00000002); + direction_ = 0; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.PropertyOrder) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.PropertyOrder) + private static final com.google.datastore.v1.PropertyOrder DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.PropertyOrder(); + } + + public static com.google.datastore.v1.PropertyOrder getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PropertyOrder 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.datastore.v1.PropertyOrder getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrderOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrderOrBuilder.java new file mode 100644 index 000000000000..ba2235830275 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyOrderOrBuilder.java @@ -0,0 +1,89 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface PropertyOrderOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.PropertyOrder) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The property to order by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return Whether the property field is set. + */ + boolean hasProperty(); + + /** + * + * + *
+   * The property to order by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + * + * @return The property. + */ + com.google.datastore.v1.PropertyReference getProperty(); + + /** + * + * + *
+   * The property to order by.
+   * 
+ * + * .google.datastore.v1.PropertyReference property = 1; + */ + com.google.datastore.v1.PropertyReferenceOrBuilder getPropertyOrBuilder(); + + /** + * + * + *
+   * The direction to order by. Defaults to `ASCENDING`.
+   * 
+ * + * .google.datastore.v1.PropertyOrder.Direction direction = 2; + * + * @return The enum numeric value on the wire for direction. + */ + int getDirectionValue(); + + /** + * + * + *
+   * The direction to order by. Defaults to `ASCENDING`.
+   * 
+ * + * .google.datastore.v1.PropertyOrder.Direction direction = 2; + * + * @return The direction. + */ + com.google.datastore.v1.PropertyOrder.Direction getDirection(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReference.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReference.java new file mode 100644 index 000000000000..8f95f901ce42 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReference.java @@ -0,0 +1,675 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A reference to a property relative to the kind expressions.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyReference} + */ +public final class PropertyReference extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.PropertyReference) + PropertyReferenceOrBuilder { + private static final long serialVersionUID = 0L; + + // Use PropertyReference.newBuilder() to construct. + private PropertyReference(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PropertyReference() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PropertyReference(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyReference_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyReference_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyReference.class, + com.google.datastore.v1.PropertyReference.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + + /** + * + * + *
+   * A reference to a property.
+   *
+   * Requires:
+   *
+   * * MUST be a dot-delimited (`.`) string of segments, where each segment
+   * conforms to [entity property name][google.datastore.v1.Entity.properties]
+   * limitations.
+   * 
+ * + * string name = 2; + * + * @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; + } + } + + /** + * + * + *
+   * A reference to a property.
+   *
+   * Requires:
+   *
+   * * MUST be a dot-delimited (`.`) string of segments, where each segment
+   * conforms to [entity property name][google.datastore.v1.Entity.properties]
+   * limitations.
+   * 
+ * + * string name = 2; + * + * @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.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, name_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, 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.datastore.v1.PropertyReference)) { + return super.equals(obj); + } + com.google.datastore.v1.PropertyReference other = + (com.google.datastore.v1.PropertyReference) 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.datastore.v1.PropertyReference parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyReference parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyReference parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyReference 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.datastore.v1.PropertyReference parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyReference parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyReference parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyReference parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyReference parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyReference parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyReference parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyReference parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.PropertyReference 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A reference to a property relative to the kind expressions.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyReference} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.PropertyReference) + com.google.datastore.v1.PropertyReferenceOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyReference_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyReference_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyReference.class, + com.google.datastore.v1.PropertyReference.Builder.class); + } + + // Construct using com.google.datastore.v1.PropertyReference.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.v1.QueryProto + .internal_static_google_datastore_v1_PropertyReference_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyReference getDefaultInstanceForType() { + return com.google.datastore.v1.PropertyReference.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.PropertyReference build() { + com.google.datastore.v1.PropertyReference result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyReference buildPartial() { + com.google.datastore.v1.PropertyReference result = + new com.google.datastore.v1.PropertyReference(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.PropertyReference result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.PropertyReference) { + return mergeFrom((com.google.datastore.v1.PropertyReference) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.PropertyReference other) { + if (other == com.google.datastore.v1.PropertyReference.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 18: + { + name_ = 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 name_ = ""; + + /** + * + * + *
+     * A reference to a property.
+     *
+     * Requires:
+     *
+     * * MUST be a dot-delimited (`.`) string of segments, where each segment
+     * conforms to [entity property name][google.datastore.v1.Entity.properties]
+     * limitations.
+     * 
+ * + * string name = 2; + * + * @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; + } + } + + /** + * + * + *
+     * A reference to a property.
+     *
+     * Requires:
+     *
+     * * MUST be a dot-delimited (`.`) string of segments, where each segment
+     * conforms to [entity property name][google.datastore.v1.Entity.properties]
+     * limitations.
+     * 
+ * + * string name = 2; + * + * @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; + } + } + + /** + * + * + *
+     * A reference to a property.
+     *
+     * Requires:
+     *
+     * * MUST be a dot-delimited (`.`) string of segments, where each segment
+     * conforms to [entity property name][google.datastore.v1.Entity.properties]
+     * limitations.
+     * 
+ * + * string name = 2; + * + * @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; + } + + /** + * + * + *
+     * A reference to a property.
+     *
+     * Requires:
+     *
+     * * MUST be a dot-delimited (`.`) string of segments, where each segment
+     * conforms to [entity property name][google.datastore.v1.Entity.properties]
+     * limitations.
+     * 
+ * + * string name = 2; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * A reference to a property.
+     *
+     * Requires:
+     *
+     * * MUST be a dot-delimited (`.`) string of segments, where each segment
+     * conforms to [entity property name][google.datastore.v1.Entity.properties]
+     * limitations.
+     * 
+ * + * string name = 2; + * + * @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; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.PropertyReference) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.PropertyReference) + private static final com.google.datastore.v1.PropertyReference DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.PropertyReference(); + } + + public static com.google.datastore.v1.PropertyReference getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PropertyReference 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.datastore.v1.PropertyReference getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReferenceOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReferenceOrBuilder.java new file mode 100644 index 000000000000..9dc18e7dc8ff --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyReferenceOrBuilder.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! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface PropertyReferenceOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.PropertyReference) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A reference to a property.
+   *
+   * Requires:
+   *
+   * * MUST be a dot-delimited (`.`) string of segments, where each segment
+   * conforms to [entity property name][google.datastore.v1.Entity.properties]
+   * limitations.
+   * 
+ * + * string name = 2; + * + * @return The name. + */ + java.lang.String getName(); + + /** + * + * + *
+   * A reference to a property.
+   *
+   * Requires:
+   *
+   * * MUST be a dot-delimited (`.`) string of segments, where each segment
+   * conforms to [entity property name][google.datastore.v1.Entity.properties]
+   * limitations.
+   * 
+ * + * string name = 2; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransform.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransform.java new file mode 100644 index 000000000000..32df3f0ae294 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransform.java @@ -0,0 +1,3276 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A transformation of an entity property.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyTransform} + */ +public final class PropertyTransform extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.PropertyTransform) + PropertyTransformOrBuilder { + private static final long serialVersionUID = 0L; + + // Use PropertyTransform.newBuilder() to construct. + private PropertyTransform(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PropertyTransform() { + property_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PropertyTransform(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyTransform_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyTransform_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyTransform.class, + com.google.datastore.v1.PropertyTransform.Builder.class); + } + + /** + * + * + *
+   * A value that is calculated by the server.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.PropertyTransform.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 properties (same or different entities)
+     * in a transaction, all the properties will get the same server timestamp.
+     * 
+ * + * REQUEST_TIME = 1; + */ + REQUEST_TIME(1), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * 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 properties (same or different entities)
+     * in a transaction, all the properties 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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.PropertyTransform.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.datastore.v1.PropertyTransform.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 PROPERTY_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object property_ = ""; + + /** + * + * + *
+   * Optional. The name of the property.
+   *
+   * Property paths (a list of property names separated by dots (`.`)) may be
+   * used to refer to properties inside entity values. For example `foo.bar`
+   * means the property `bar` inside the entity property `foo`.
+   *
+   * If a property name contains a dot `.` or a backlslash `\`, then that name
+   * must be escaped.
+   * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The property. + */ + @java.lang.Override + public java.lang.String getProperty() { + java.lang.Object ref = property_; + 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(); + property_ = s; + return s; + } + } + + /** + * + * + *
+   * Optional. The name of the property.
+   *
+   * Property paths (a list of property names separated by dots (`.`)) may be
+   * used to refer to properties inside entity values. For example `foo.bar`
+   * means the property `bar` inside the entity property `foo`.
+   *
+   * If a property name contains a dot `.` or a backlslash `\`, then that name
+   * must be escaped.
+   * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for property. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPropertyBytes() { + java.lang.Object ref = property_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + property_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SET_TO_SERVER_VALUE_FIELD_NUMBER = 2; + + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return Whether the setToServerValue field is set. + */ + public boolean hasSetToServerValue() { + return transformTypeCase_ == 2; + } + + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.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 property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return The setToServerValue. + */ + public com.google.datastore.v1.PropertyTransform.ServerValue getSetToServerValue() { + if (transformTypeCase_ == 2) { + com.google.datastore.v1.PropertyTransform.ServerValue result = + com.google.datastore.v1.PropertyTransform.ServerValue.forNumber( + (java.lang.Integer) transformType_); + return result == null + ? com.google.datastore.v1.PropertyTransform.ServerValue.UNRECOGNIZED + : result; + } + return com.google.datastore.v1.PropertyTransform.ServerValue.SERVER_VALUE_UNSPECIFIED; + } + + public static final int INCREMENT_FIELD_NUMBER = 3; + + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.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 property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + * + * @return The increment. + */ + @java.lang.Override + public com.google.datastore.v1.Value getIncrement() { + if (transformTypeCase_ == 3) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getIncrementOrBuilder() { + if (transformTypeCase_ == 3) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + public static final int MAXIMUM_FIELD_NUMBER = 4; + + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + * + * @return Whether the maximum field is set. + */ + @java.lang.Override + public boolean hasMaximum() { + return transformTypeCase_ == 4; + } + + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + * + * @return The maximum. + */ + @java.lang.Override + public com.google.datastore.v1.Value getMaximum() { + if (transformTypeCase_ == 4) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getMaximumOrBuilder() { + if (transformTypeCase_ == 4) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + public static final int MINIMUM_FIELD_NUMBER = 5; + + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + * + * @return Whether the minimum field is set. + */ + @java.lang.Override + public boolean hasMinimum() { + return transformTypeCase_ == 5; + } + + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + * + * @return The minimum. + */ + @java.lang.Override + public com.google.datastore.v1.Value getMinimum() { + if (transformTypeCase_ == 5) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getMinimumOrBuilder() { + if (transformTypeCase_ == 5) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + public static final int APPEND_MISSING_ELEMENTS_FIELD_NUMBER = 6; + + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property 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 the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return Whether the appendMissingElements field is set. + */ + @java.lang.Override + public boolean hasAppendMissingElements() { + return transformTypeCase_ == 6; + } + + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property 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 the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return The appendMissingElements. + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValue getAppendMissingElements() { + if (transformTypeCase_ == 6) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property 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 the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValueOrBuilder getAppendMissingElementsOrBuilder() { + if (transformTypeCase_ == 6) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + + public static final int REMOVE_ALL_FROM_ARRAY_FIELD_NUMBER = 7; + + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of 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 the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return Whether the removeAllFromArray field is set. + */ + @java.lang.Override + public boolean hasRemoveAllFromArray() { + return transformTypeCase_ == 7; + } + + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of 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 the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return The removeAllFromArray. + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValue getRemoveAllFromArray() { + if (transformTypeCase_ == 7) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of 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 the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValueOrBuilder getRemoveAllFromArrayOrBuilder() { + if (transformTypeCase_ == 7) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.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.GeneratedMessageV3.isStringEmpty(property_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, property_); + } + if (transformTypeCase_ == 2) { + output.writeEnum(2, ((java.lang.Integer) transformType_)); + } + if (transformTypeCase_ == 3) { + output.writeMessage(3, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 4) { + output.writeMessage(4, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 5) { + output.writeMessage(5, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 6) { + output.writeMessage(6, (com.google.datastore.v1.ArrayValue) transformType_); + } + if (transformTypeCase_ == 7) { + output.writeMessage(7, (com.google.datastore.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.GeneratedMessageV3.isStringEmpty(property_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, property_); + } + 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.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 5) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 5, (com.google.datastore.v1.Value) transformType_); + } + if (transformTypeCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.datastore.v1.ArrayValue) transformType_); + } + if (transformTypeCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.datastore.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.datastore.v1.PropertyTransform)) { + return super.equals(obj); + } + com.google.datastore.v1.PropertyTransform other = + (com.google.datastore.v1.PropertyTransform) obj; + + if (!getProperty().equals(other.getProperty())) 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) + PROPERTY_FIELD_NUMBER; + hash = (53 * hash) + getProperty().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.datastore.v1.PropertyTransform parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyTransform 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.datastore.v1.PropertyTransform parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyTransform parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyTransform parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.PropertyTransform parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.PropertyTransform 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A transformation of an entity property.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.PropertyTransform} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.PropertyTransform) + com.google.datastore.v1.PropertyTransformOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyTransform_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyTransform_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.PropertyTransform.class, + com.google.datastore.v1.PropertyTransform.Builder.class); + } + + // Construct using com.google.datastore.v1.PropertyTransform.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + property_ = ""; + 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.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_PropertyTransform_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyTransform getDefaultInstanceForType() { + return com.google.datastore.v1.PropertyTransform.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.PropertyTransform build() { + com.google.datastore.v1.PropertyTransform result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.PropertyTransform buildPartial() { + com.google.datastore.v1.PropertyTransform result = + new com.google.datastore.v1.PropertyTransform(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.PropertyTransform result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.property_ = property_; + } + } + + private void buildPartialOneofs(com.google.datastore.v1.PropertyTransform 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 clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.PropertyTransform) { + return mergeFrom((com.google.datastore.v1.PropertyTransform) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.PropertyTransform other) { + if (other == com.google.datastore.v1.PropertyTransform.getDefaultInstance()) return this; + if (!other.getProperty().isEmpty()) { + property_ = other.property_; + 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: + { + property_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + int rawValue = input.readEnum(); + transformTypeCase_ = 2; + transformType_ = rawValue; + break; + } // case 16 + case 26: + { + input.readMessage(getIncrementFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 3; + break; + } // case 26 + case 34: + { + input.readMessage(getMaximumFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 4; + break; + } // case 34 + case 42: + { + input.readMessage(getMinimumFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 5; + break; + } // case 42 + case 50: + { + input.readMessage( + getAppendMissingElementsFieldBuilder().getBuilder(), extensionRegistry); + transformTypeCase_ = 6; + break; + } // case 50 + case 58: + { + input.readMessage( + getRemoveAllFromArrayFieldBuilder().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 property_ = ""; + + /** + * + * + *
+     * Optional. The name of the property.
+     *
+     * Property paths (a list of property names separated by dots (`.`)) may be
+     * used to refer to properties inside entity values. For example `foo.bar`
+     * means the property `bar` inside the entity property `foo`.
+     *
+     * If a property name contains a dot `.` or a backlslash `\`, then that name
+     * must be escaped.
+     * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The property. + */ + public java.lang.String getProperty() { + java.lang.Object ref = property_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + property_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Optional. The name of the property.
+     *
+     * Property paths (a list of property names separated by dots (`.`)) may be
+     * used to refer to properties inside entity values. For example `foo.bar`
+     * means the property `bar` inside the entity property `foo`.
+     *
+     * If a property name contains a dot `.` or a backlslash `\`, then that name
+     * must be escaped.
+     * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for property. + */ + public com.google.protobuf.ByteString getPropertyBytes() { + java.lang.Object ref = property_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + property_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Optional. The name of the property.
+     *
+     * Property paths (a list of property names separated by dots (`.`)) may be
+     * used to refer to properties inside entity values. For example `foo.bar`
+     * means the property `bar` inside the entity property `foo`.
+     *
+     * If a property name contains a dot `.` or a backlslash `\`, then that name
+     * must be escaped.
+     * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The property to set. + * @return This builder for chaining. + */ + public Builder setProperty(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + property_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The name of the property.
+     *
+     * Property paths (a list of property names separated by dots (`.`)) may be
+     * used to refer to properties inside entity values. For example `foo.bar`
+     * means the property `bar` inside the entity property `foo`.
+     *
+     * If a property name contains a dot `.` or a backlslash `\`, then that name
+     * must be escaped.
+     * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearProperty() { + property_ = getDefaultInstance().getProperty(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Optional. The name of the property.
+     *
+     * Property paths (a list of property names separated by dots (`.`)) may be
+     * used to refer to properties inside entity values. For example `foo.bar`
+     * means the property `bar` inside the entity property `foo`.
+     *
+     * If a property name contains a dot `.` or a backlslash `\`, then that name
+     * must be escaped.
+     * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for property to set. + * @return This builder for chaining. + */ + public Builder setPropertyBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + property_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Sets the property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return Whether the setToServerValue field is set. + */ + @java.lang.Override + public boolean hasSetToServerValue() { + return transformTypeCase_ == 2; + } + + /** + * + * + *
+     * Sets the property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.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 property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.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 property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return The setToServerValue. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyTransform.ServerValue getSetToServerValue() { + if (transformTypeCase_ == 2) { + com.google.datastore.v1.PropertyTransform.ServerValue result = + com.google.datastore.v1.PropertyTransform.ServerValue.forNumber( + (java.lang.Integer) transformType_); + return result == null + ? com.google.datastore.v1.PropertyTransform.ServerValue.UNRECOGNIZED + : result; + } + return com.google.datastore.v1.PropertyTransform.ServerValue.SERVER_VALUE_UNSPECIFIED; + } + + /** + * + * + *
+     * Sets the property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @param value The setToServerValue to set. + * @return This builder for chaining. + */ + public Builder setSetToServerValue( + com.google.datastore.v1.PropertyTransform.ServerValue value) { + if (value == null) { + throw new NullPointerException(); + } + transformTypeCase_ = 2; + transformType_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * Sets the property to the given server value.
+     * 
+ * + * .google.datastore.v1.PropertyTransform.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.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + incrementBuilder_; + + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.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 property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + * + * @return The increment. + */ + @java.lang.Override + public com.google.datastore.v1.Value getIncrement() { + if (incrementBuilder_ == null) { + if (transformTypeCase_ == 3) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } else { + if (transformTypeCase_ == 3) { + return incrementBuilder_.getMessage(); + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + public Builder setIncrement(com.google.datastore.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 property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + public Builder setIncrement(com.google.datastore.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 property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + public Builder mergeIncrement(com.google.datastore.v1.Value value) { + if (incrementBuilder_ == null) { + if (transformTypeCase_ == 3 + && transformType_ != com.google.datastore.v1.Value.getDefaultInstance()) { + transformType_ = + com.google.datastore.v1.Value.newBuilder( + (com.google.datastore.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 property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.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 property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + public com.google.datastore.v1.Value.Builder getIncrementBuilder() { + return getIncrementFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getIncrementOrBuilder() { + if ((transformTypeCase_ == 3) && (incrementBuilder_ != null)) { + return incrementBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 3) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Adds the given value to the property's current value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If either of the given value or the current property value are doubles,
+     * both values will be interpreted as doubles. Double arithmetic and
+     * representation of double values follows IEEE 754 semantics.
+     * If there is positive/negative integer overflow, the property is resolved
+     * to the largest magnitude positive/negative integer.
+     * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getIncrementFieldBuilder() { + if (incrementBuilder_ == null) { + if (!(transformTypeCase_ == 3)) { + transformType_ = com.google.datastore.v1.Value.getDefaultInstance(); + } + incrementBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + (com.google.datastore.v1.Value) transformType_, getParentForChildren(), isClean()); + transformType_ = null; + } + transformTypeCase_ = 3; + onChanged(); + return incrementBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + maximumBuilder_; + + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + * + * @return Whether the maximum field is set. + */ + @java.lang.Override + public boolean hasMaximum() { + return transformTypeCase_ == 4; + } + + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + * + * @return The maximum. + */ + @java.lang.Override + public com.google.datastore.v1.Value getMaximum() { + if (maximumBuilder_ == null) { + if (transformTypeCase_ == 4) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } else { + if (transformTypeCase_ == 4) { + return maximumBuilder_.getMessage(); + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + */ + public Builder setMaximum(com.google.datastore.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 property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + */ + public Builder setMaximum(com.google.datastore.v1.Value.Builder builderForValue) { + if (maximumBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + maximumBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 4; + return this; + } + + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + */ + public Builder mergeMaximum(com.google.datastore.v1.Value value) { + if (maximumBuilder_ == null) { + if (transformTypeCase_ == 4 + && transformType_ != com.google.datastore.v1.Value.getDefaultInstance()) { + transformType_ = + com.google.datastore.v1.Value.newBuilder( + (com.google.datastore.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 property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property 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.datastore.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 property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + */ + public com.google.datastore.v1.Value.Builder getMaximumBuilder() { + return getMaximumFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getMaximumOrBuilder() { + if ((transformTypeCase_ == 4) && (maximumBuilder_ != null)) { + return maximumBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 4) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Sets the property to the maximum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the given value.
+     * If a maximum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the larger operand. If the operands are
+     * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getMaximumFieldBuilder() { + if (maximumBuilder_ == null) { + if (!(transformTypeCase_ == 4)) { + transformType_ = com.google.datastore.v1.Value.getDefaultInstance(); + } + maximumBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + (com.google.datastore.v1.Value) transformType_, getParentForChildren(), isClean()); + transformType_ = null; + } + transformTypeCase_ = 4; + onChanged(); + return maximumBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + minimumBuilder_; + + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + * + * @return Whether the minimum field is set. + */ + @java.lang.Override + public boolean hasMinimum() { + return transformTypeCase_ == 5; + } + + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + * + * @return The minimum. + */ + @java.lang.Override + public com.google.datastore.v1.Value getMinimum() { + if (minimumBuilder_ == null) { + if (transformTypeCase_ == 5) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } else { + if (transformTypeCase_ == 5) { + return minimumBuilder_.getMessage(); + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + */ + public Builder setMinimum(com.google.datastore.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 property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + */ + public Builder setMinimum(com.google.datastore.v1.Value.Builder builderForValue) { + if (minimumBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + minimumBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 5; + return this; + } + + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + */ + public Builder mergeMinimum(com.google.datastore.v1.Value value) { + if (minimumBuilder_ == null) { + if (transformTypeCase_ == 5 + && transformType_ != com.google.datastore.v1.Value.getDefaultInstance()) { + transformType_ = + com.google.datastore.v1.Value.newBuilder( + (com.google.datastore.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 property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property 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.datastore.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 property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + */ + public com.google.datastore.v1.Value.Builder getMinimumBuilder() { + return getMinimumFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + */ + @java.lang.Override + public com.google.datastore.v1.ValueOrBuilder getMinimumOrBuilder() { + if ((transformTypeCase_ == 5) && (minimumBuilder_ != null)) { + return minimumBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 5) { + return (com.google.datastore.v1.Value) transformType_; + } + return com.google.datastore.v1.Value.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Sets the property to the minimum of its current value and the given
+     * value.
+     *
+     * This must be an integer or a double value.
+     * If the property is not an integer or double, or if the property does not
+     * yet exist, the transformation will set the property to the input value.
+     * If a minimum operation is applied where the property and the input value
+     * are of mixed types (that is - one is an integer and one is a double)
+     * the property takes on the type of the smaller operand. If the operands
+     * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder> + getMinimumFieldBuilder() { + if (minimumBuilder_ == null) { + if (!(transformTypeCase_ == 5)) { + transformType_ = com.google.datastore.v1.Value.getDefaultInstance(); + } + minimumBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Value, + com.google.datastore.v1.Value.Builder, + com.google.datastore.v1.ValueOrBuilder>( + (com.google.datastore.v1.Value) transformType_, getParentForChildren(), isClean()); + transformType_ = null; + } + transformTypeCase_ = 5; + onChanged(); + return minimumBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder> + appendMissingElementsBuilder_; + + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property 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 the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return Whether the appendMissingElements field is set. + */ + @java.lang.Override + public boolean hasAppendMissingElements() { + return transformTypeCase_ == 6; + } + + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property 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 the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return The appendMissingElements. + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValue getAppendMissingElements() { + if (appendMissingElementsBuilder_ == null) { + if (transformTypeCase_ == 6) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } else { + if (transformTypeCase_ == 6) { + return appendMissingElementsBuilder_.getMessage(); + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property 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 the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder setAppendMissingElements(com.google.datastore.v1.ArrayValue value) { + if (appendMissingElementsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + appendMissingElementsBuilder_.setMessage(value); + } + transformTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property 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 the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder setAppendMissingElements( + com.google.datastore.v1.ArrayValue.Builder builderForValue) { + if (appendMissingElementsBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + appendMissingElementsBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property 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 the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + public Builder mergeAppendMissingElements(com.google.datastore.v1.ArrayValue value) { + if (appendMissingElementsBuilder_ == null) { + if (transformTypeCase_ == 6 + && transformType_ != com.google.datastore.v1.ArrayValue.getDefaultInstance()) { + transformType_ = + com.google.datastore.v1.ArrayValue.newBuilder( + (com.google.datastore.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; + } + + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property 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 the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.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; + } + + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property 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 the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + public com.google.datastore.v1.ArrayValue.Builder getAppendMissingElementsBuilder() { + return getAppendMissingElementsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property 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 the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValueOrBuilder getAppendMissingElementsOrBuilder() { + if ((transformTypeCase_ == 6) && (appendMissingElementsBuilder_ != null)) { + return appendMissingElementsBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 6) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Appends the given elements in order if they are not already present in
+     * the current property value.
+     * If the property is not an array, or if the property 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 the null value is equal to the null value.
+     * If the input contains multiple equivalent values, only the first will
+     * be considered.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder> + getAppendMissingElementsFieldBuilder() { + if (appendMissingElementsBuilder_ == null) { + if (!(transformTypeCase_ == 6)) { + transformType_ = com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + appendMissingElementsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder>( + (com.google.datastore.v1.ArrayValue) transformType_, + getParentForChildren(), + isClean()); + transformType_ = null; + } + transformTypeCase_ = 6; + onChanged(); + return appendMissingElementsBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder> + removeAllFromArrayBuilder_; + + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of 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 the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return Whether the removeAllFromArray field is set. + */ + @java.lang.Override + public boolean hasRemoveAllFromArray() { + return transformTypeCase_ == 7; + } + + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of 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 the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return The removeAllFromArray. + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValue getRemoveAllFromArray() { + if (removeAllFromArrayBuilder_ == null) { + if (transformTypeCase_ == 7) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } else { + if (transformTypeCase_ == 7) { + return removeAllFromArrayBuilder_.getMessage(); + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of 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 the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder setRemoveAllFromArray(com.google.datastore.v1.ArrayValue value) { + if (removeAllFromArrayBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + transformType_ = value; + onChanged(); + } else { + removeAllFromArrayBuilder_.setMessage(value); + } + transformTypeCase_ = 7; + return this; + } + + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of 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 the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder setRemoveAllFromArray( + com.google.datastore.v1.ArrayValue.Builder builderForValue) { + if (removeAllFromArrayBuilder_ == null) { + transformType_ = builderForValue.build(); + onChanged(); + } else { + removeAllFromArrayBuilder_.setMessage(builderForValue.build()); + } + transformTypeCase_ = 7; + return this; + } + + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of 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 the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + public Builder mergeRemoveAllFromArray(com.google.datastore.v1.ArrayValue value) { + if (removeAllFromArrayBuilder_ == null) { + if (transformTypeCase_ == 7 + && transformType_ != com.google.datastore.v1.ArrayValue.getDefaultInstance()) { + transformType_ = + com.google.datastore.v1.ArrayValue.newBuilder( + (com.google.datastore.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; + } + + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of 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 the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.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; + } + + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of 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 the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + public com.google.datastore.v1.ArrayValue.Builder getRemoveAllFromArrayBuilder() { + return getRemoveAllFromArrayFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of 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 the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValueOrBuilder getRemoveAllFromArrayOrBuilder() { + if ((transformTypeCase_ == 7) && (removeAllFromArrayBuilder_ != null)) { + return removeAllFromArrayBuilder_.getMessageOrBuilder(); + } else { + if (transformTypeCase_ == 7) { + return (com.google.datastore.v1.ArrayValue) transformType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Removes all of the given elements from the array in the property.
+     * If the property is not an array, or if the property does not yet exist,
+     * it is set to the empty array.
+     *
+     * Equivalent numbers of 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 the null value is equal to the null value.
+     * This will remove all equivalent values if there are duplicates.
+     *
+     * The corresponding transform result will be the null value.
+     * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder> + getRemoveAllFromArrayFieldBuilder() { + if (removeAllFromArrayBuilder_ == null) { + if (!(transformTypeCase_ == 7)) { + transformType_ = com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + removeAllFromArrayBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder>( + (com.google.datastore.v1.ArrayValue) transformType_, + getParentForChildren(), + isClean()); + transformType_ = null; + } + transformTypeCase_ = 7; + onChanged(); + return removeAllFromArrayBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.PropertyTransform) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.PropertyTransform) + private static final com.google.datastore.v1.PropertyTransform DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.PropertyTransform(); + } + + public static com.google.datastore.v1.PropertyTransform getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public PropertyTransform 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.datastore.v1.PropertyTransform getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransformOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransformOrBuilder.java new file mode 100644 index 000000000000..ae005e6ad68c --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/PropertyTransformOrBuilder.java @@ -0,0 +1,451 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface PropertyTransformOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.PropertyTransform) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Optional. The name of the property.
+   *
+   * Property paths (a list of property names separated by dots (`.`)) may be
+   * used to refer to properties inside entity values. For example `foo.bar`
+   * means the property `bar` inside the entity property `foo`.
+   *
+   * If a property name contains a dot `.` or a backlslash `\`, then that name
+   * must be escaped.
+   * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The property. + */ + java.lang.String getProperty(); + + /** + * + * + *
+   * Optional. The name of the property.
+   *
+   * Property paths (a list of property names separated by dots (`.`)) may be
+   * used to refer to properties inside entity values. For example `foo.bar`
+   * means the property `bar` inside the entity property `foo`.
+   *
+   * If a property name contains a dot `.` or a backlslash `\`, then that name
+   * must be escaped.
+   * 
+ * + * string property = 1 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for property. + */ + com.google.protobuf.ByteString getPropertyBytes(); + + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return Whether the setToServerValue field is set. + */ + boolean hasSetToServerValue(); + + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return The enum numeric value on the wire for setToServerValue. + */ + int getSetToServerValueValue(); + + /** + * + * + *
+   * Sets the property to the given server value.
+   * 
+ * + * .google.datastore.v1.PropertyTransform.ServerValue set_to_server_value = 2; + * + * @return The setToServerValue. + */ + com.google.datastore.v1.PropertyTransform.ServerValue getSetToServerValue(); + + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + * + * @return Whether the increment field is set. + */ + boolean hasIncrement(); + + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + * + * @return The increment. + */ + com.google.datastore.v1.Value getIncrement(); + + /** + * + * + *
+   * Adds the given value to the property's current value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If either of the given value or the current property value are doubles,
+   * both values will be interpreted as doubles. Double arithmetic and
+   * representation of double values follows IEEE 754 semantics.
+   * If there is positive/negative integer overflow, the property is resolved
+   * to the largest magnitude positive/negative integer.
+   * 
+ * + * .google.datastore.v1.Value increment = 3; + */ + com.google.datastore.v1.ValueOrBuilder getIncrementOrBuilder(); + + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + * + * @return Whether the maximum field is set. + */ + boolean hasMaximum(); + + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + * + * @return The maximum. + */ + com.google.datastore.v1.Value getMaximum(); + + /** + * + * + *
+   * Sets the property to the maximum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the given value.
+   * If a maximum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the larger operand. If the operands are
+   * equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value maximum = 4; + */ + com.google.datastore.v1.ValueOrBuilder getMaximumOrBuilder(); + + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + * + * @return Whether the minimum field is set. + */ + boolean hasMinimum(); + + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + * + * @return The minimum. + */ + com.google.datastore.v1.Value getMinimum(); + + /** + * + * + *
+   * Sets the property to the minimum of its current value and the given
+   * value.
+   *
+   * This must be an integer or a double value.
+   * If the property is not an integer or double, or if the property does not
+   * yet exist, the transformation will set the property to the input value.
+   * If a minimum operation is applied where the property and the input value
+   * are of mixed types (that is - one is an integer and one is a double)
+   * the property takes on the type of the smaller operand. If the operands
+   * are equivalent (e.g. 3 and 3.0), the property 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.datastore.v1.Value minimum = 5; + */ + com.google.datastore.v1.ValueOrBuilder getMinimumOrBuilder(); + + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property 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 the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return Whether the appendMissingElements field is set. + */ + boolean hasAppendMissingElements(); + + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property 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 the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + * + * @return The appendMissingElements. + */ + com.google.datastore.v1.ArrayValue getAppendMissingElements(); + + /** + * + * + *
+   * Appends the given elements in order if they are not already present in
+   * the current property value.
+   * If the property is not an array, or if the property 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 the null value is equal to the null value.
+   * If the input contains multiple equivalent values, only the first will
+   * be considered.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue append_missing_elements = 6; + */ + com.google.datastore.v1.ArrayValueOrBuilder getAppendMissingElementsOrBuilder(); + + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of 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 the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return Whether the removeAllFromArray field is set. + */ + boolean hasRemoveAllFromArray(); + + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of 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 the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + * + * @return The removeAllFromArray. + */ + com.google.datastore.v1.ArrayValue getRemoveAllFromArray(); + + /** + * + * + *
+   * Removes all of the given elements from the array in the property.
+   * If the property is not an array, or if the property does not yet exist,
+   * it is set to the empty array.
+   *
+   * Equivalent numbers of 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 the null value is equal to the null value.
+   * This will remove all equivalent values if there are duplicates.
+   *
+   * The corresponding transform result will be the null value.
+   * 
+ * + * .google.datastore.v1.ArrayValue remove_all_from_array = 7; + */ + com.google.datastore.v1.ArrayValueOrBuilder getRemoveAllFromArrayOrBuilder(); + + com.google.datastore.v1.PropertyTransform.TransformTypeCase getTransformTypeCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Query.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Query.java new file mode 100644 index 000000000000..f85c1d84f567 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Query.java @@ -0,0 +1,3956 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A query for entities.
+ *
+ * The query stages are executed in the following order:
+ * 1. kind
+ * 2. filter
+ * 3. projection
+ * 4. order + start_cursor + end_cursor
+ * 5. offset
+ * 6. limit
+ * 7. find_nearest
+ * 
+ * + * Protobuf type {@code google.datastore.v1.Query} + */ +public final class Query extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.Query) + QueryOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Query.newBuilder() to construct. + private Query(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Query() { + projection_ = java.util.Collections.emptyList(); + kind_ = java.util.Collections.emptyList(); + order_ = java.util.Collections.emptyList(); + distinctOn_ = java.util.Collections.emptyList(); + startCursor_ = com.google.protobuf.ByteString.EMPTY; + endCursor_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Query(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto.internal_static_google_datastore_v1_Query_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Query_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Query.class, com.google.datastore.v1.Query.Builder.class); + } + + private int bitField0_; + public static final int PROJECTION_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List projection_; + + /** + * + * + *
+   * The projection to return. Defaults to returning all properties.
+   * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + @java.lang.Override + public java.util.List getProjectionList() { + return projection_; + } + + /** + * + * + *
+   * The projection to return. Defaults to returning all properties.
+   * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + @java.lang.Override + public java.util.List + getProjectionOrBuilderList() { + return projection_; + } + + /** + * + * + *
+   * The projection to return. Defaults to returning all properties.
+   * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + @java.lang.Override + public int getProjectionCount() { + return projection_.size(); + } + + /** + * + * + *
+   * The projection to return. Defaults to returning all properties.
+   * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + @java.lang.Override + public com.google.datastore.v1.Projection getProjection(int index) { + return projection_.get(index); + } + + /** + * + * + *
+   * The projection to return. Defaults to returning all properties.
+   * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + @java.lang.Override + public com.google.datastore.v1.ProjectionOrBuilder getProjectionOrBuilder(int index) { + return projection_.get(index); + } + + public static final int KIND_FIELD_NUMBER = 3; + + @SuppressWarnings("serial") + private java.util.List kind_; + + /** + * + * + *
+   * The kinds to query (if empty, returns entities of all kinds).
+   * Currently at most 1 kind may be specified.
+   * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + @java.lang.Override + public java.util.List getKindList() { + return kind_; + } + + /** + * + * + *
+   * The kinds to query (if empty, returns entities of all kinds).
+   * Currently at most 1 kind may be specified.
+   * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + @java.lang.Override + public java.util.List + getKindOrBuilderList() { + return kind_; + } + + /** + * + * + *
+   * The kinds to query (if empty, returns entities of all kinds).
+   * Currently at most 1 kind may be specified.
+   * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + @java.lang.Override + public int getKindCount() { + return kind_.size(); + } + + /** + * + * + *
+   * The kinds to query (if empty, returns entities of all kinds).
+   * Currently at most 1 kind may be specified.
+   * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + @java.lang.Override + public com.google.datastore.v1.KindExpression getKind(int index) { + return kind_.get(index); + } + + /** + * + * + *
+   * The kinds to query (if empty, returns entities of all kinds).
+   * Currently at most 1 kind may be specified.
+   * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + @java.lang.Override + public com.google.datastore.v1.KindExpressionOrBuilder getKindOrBuilder(int index) { + return kind_.get(index); + } + + public static final int FILTER_FIELD_NUMBER = 4; + private com.google.datastore.v1.Filter filter_; + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.datastore.v1.Filter filter = 4; + * + * @return Whether the filter field is set. + */ + @java.lang.Override + public boolean hasFilter() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.datastore.v1.Filter filter = 4; + * + * @return The filter. + */ + @java.lang.Override + public com.google.datastore.v1.Filter getFilter() { + return filter_ == null ? com.google.datastore.v1.Filter.getDefaultInstance() : filter_; + } + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.datastore.v1.Filter filter = 4; + */ + @java.lang.Override + public com.google.datastore.v1.FilterOrBuilder getFilterOrBuilder() { + return filter_ == null ? com.google.datastore.v1.Filter.getDefaultInstance() : filter_; + } + + public static final int ORDER_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private java.util.List order_; + + /** + * + * + *
+   * The order to apply to the query results (if empty, order is unspecified).
+   * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + @java.lang.Override + public java.util.List getOrderList() { + return order_; + } + + /** + * + * + *
+   * The order to apply to the query results (if empty, order is unspecified).
+   * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + @java.lang.Override + public java.util.List + getOrderOrBuilderList() { + return order_; + } + + /** + * + * + *
+   * The order to apply to the query results (if empty, order is unspecified).
+   * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + @java.lang.Override + public int getOrderCount() { + return order_.size(); + } + + /** + * + * + *
+   * The order to apply to the query results (if empty, order is unspecified).
+   * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyOrder getOrder(int index) { + return order_.get(index); + } + + /** + * + * + *
+   * The order to apply to the query results (if empty, order is unspecified).
+   * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyOrderOrBuilder getOrderOrBuilder(int index) { + return order_.get(index); + } + + public static final int DISTINCT_ON_FIELD_NUMBER = 6; + + @SuppressWarnings("serial") + private java.util.List distinctOn_; + + /** + * + * + *
+   * The properties to make distinct. The query results will contain the first
+   * result for each distinct combination of values for the given properties
+   * (if empty, all results are returned).
+   *
+   * Requires:
+   *
+   * * If `order` is specified, the set of distinct on properties must appear
+   * before the non-distinct on properties in `order`.
+   * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + @java.lang.Override + public java.util.List getDistinctOnList() { + return distinctOn_; + } + + /** + * + * + *
+   * The properties to make distinct. The query results will contain the first
+   * result for each distinct combination of values for the given properties
+   * (if empty, all results are returned).
+   *
+   * Requires:
+   *
+   * * If `order` is specified, the set of distinct on properties must appear
+   * before the non-distinct on properties in `order`.
+   * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + @java.lang.Override + public java.util.List + getDistinctOnOrBuilderList() { + return distinctOn_; + } + + /** + * + * + *
+   * The properties to make distinct. The query results will contain the first
+   * result for each distinct combination of values for the given properties
+   * (if empty, all results are returned).
+   *
+   * Requires:
+   *
+   * * If `order` is specified, the set of distinct on properties must appear
+   * before the non-distinct on properties in `order`.
+   * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + @java.lang.Override + public int getDistinctOnCount() { + return distinctOn_.size(); + } + + /** + * + * + *
+   * The properties to make distinct. The query results will contain the first
+   * result for each distinct combination of values for the given properties
+   * (if empty, all results are returned).
+   *
+   * Requires:
+   *
+   * * If `order` is specified, the set of distinct on properties must appear
+   * before the non-distinct on properties in `order`.
+   * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReference getDistinctOn(int index) { + return distinctOn_.get(index); + } + + /** + * + * + *
+   * The properties to make distinct. The query results will contain the first
+   * result for each distinct combination of values for the given properties
+   * (if empty, all results are returned).
+   *
+   * Requires:
+   *
+   * * If `order` is specified, the set of distinct on properties must appear
+   * before the non-distinct on properties in `order`.
+   * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyReferenceOrBuilder getDistinctOnOrBuilder(int index) { + return distinctOn_.get(index); + } + + public static final int START_CURSOR_FIELD_NUMBER = 7; + private com.google.protobuf.ByteString startCursor_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * A starting point for the query results. Query cursors are
+   * returned in query result batches and
+   * [can only be used to continue the same
+   * query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
+   * 
+ * + * bytes start_cursor = 7; + * + * @return The startCursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getStartCursor() { + return startCursor_; + } + + public static final int END_CURSOR_FIELD_NUMBER = 8; + private com.google.protobuf.ByteString endCursor_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * An ending point for the query results. Query cursors are
+   * returned in query result batches and
+   * [can only be used to limit the same
+   * query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
+   * 
+ * + * bytes end_cursor = 8; + * + * @return The endCursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getEndCursor() { + return endCursor_; + } + + public static final int OFFSET_FIELD_NUMBER = 10; + private int offset_ = 0; + + /** + * + * + *
+   * The number of results to skip. Applies before limit, but after all other
+   * constraints. Optional. Must be >= 0 if specified.
+   * 
+ * + * int32 offset = 10; + * + * @return The offset. + */ + @java.lang.Override + public int getOffset() { + return offset_; + } + + public static final int LIMIT_FIELD_NUMBER = 12; + private com.google.protobuf.Int32Value limit_; + + /** + * + * + *
+   * The maximum number of results to return. Applies after all other
+   * constraints. Optional.
+   * Unspecified is interpreted as no limit.
+   * Must be >= 0 if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 12; + * + * @return Whether the limit field is set. + */ + @java.lang.Override + public boolean hasLimit() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The maximum number of results to return. Applies after all other
+   * constraints. Optional.
+   * Unspecified is interpreted as no limit.
+   * Must be >= 0 if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 12; + * + * @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. Optional.
+   * Unspecified is interpreted as no limit.
+   * Must be >= 0 if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 12; + */ + @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 = 13; + private com.google.datastore.v1.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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + @java.lang.Override + public boolean hasFindNearest() { + return ((bitField0_ & 0x00000004) != 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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + @java.lang.Override + public com.google.datastore.v1.FindNearest getFindNearest() { + return findNearest_ == null + ? com.google.datastore.v1.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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.datastore.v1.FindNearestOrBuilder getFindNearestOrBuilder() { + return findNearest_ == null + ? com.google.datastore.v1.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 { + for (int i = 0; i < projection_.size(); i++) { + output.writeMessage(2, projection_.get(i)); + } + for (int i = 0; i < kind_.size(); i++) { + output.writeMessage(3, kind_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(4, getFilter()); + } + for (int i = 0; i < order_.size(); i++) { + output.writeMessage(5, order_.get(i)); + } + for (int i = 0; i < distinctOn_.size(); i++) { + output.writeMessage(6, distinctOn_.get(i)); + } + if (!startCursor_.isEmpty()) { + output.writeBytes(7, startCursor_); + } + if (!endCursor_.isEmpty()) { + output.writeBytes(8, endCursor_); + } + if (offset_ != 0) { + output.writeInt32(10, offset_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(12, getLimit()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(13, getFindNearest()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < projection_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, projection_.get(i)); + } + for (int i = 0; i < kind_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, kind_.get(i)); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getFilter()); + } + for (int i = 0; i < order_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, order_.get(i)); + } + for (int i = 0; i < distinctOn_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, distinctOn_.get(i)); + } + if (!startCursor_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(7, startCursor_); + } + if (!endCursor_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(8, endCursor_); + } + if (offset_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(10, offset_); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(12, getLimit()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(13, 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.datastore.v1.Query)) { + return super.equals(obj); + } + com.google.datastore.v1.Query other = (com.google.datastore.v1.Query) obj; + + if (!getProjectionList().equals(other.getProjectionList())) return false; + if (!getKindList().equals(other.getKindList())) return false; + if (hasFilter() != other.hasFilter()) return false; + if (hasFilter()) { + if (!getFilter().equals(other.getFilter())) return false; + } + if (!getOrderList().equals(other.getOrderList())) return false; + if (!getDistinctOnList().equals(other.getDistinctOnList())) return false; + if (!getStartCursor().equals(other.getStartCursor())) return false; + if (!getEndCursor().equals(other.getEndCursor())) 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 (getProjectionCount() > 0) { + hash = (37 * hash) + PROJECTION_FIELD_NUMBER; + hash = (53 * hash) + getProjectionList().hashCode(); + } + if (getKindCount() > 0) { + hash = (37 * hash) + KIND_FIELD_NUMBER; + hash = (53 * hash) + getKindList().hashCode(); + } + if (hasFilter()) { + hash = (37 * hash) + FILTER_FIELD_NUMBER; + hash = (53 * hash) + getFilter().hashCode(); + } + if (getOrderCount() > 0) { + hash = (37 * hash) + ORDER_FIELD_NUMBER; + hash = (53 * hash) + getOrderList().hashCode(); + } + if (getDistinctOnCount() > 0) { + hash = (37 * hash) + DISTINCT_ON_FIELD_NUMBER; + hash = (53 * hash) + getDistinctOnList().hashCode(); + } + hash = (37 * hash) + START_CURSOR_FIELD_NUMBER; + hash = (53 * hash) + getStartCursor().hashCode(); + hash = (37 * hash) + END_CURSOR_FIELD_NUMBER; + hash = (53 * hash) + getEndCursor().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.datastore.v1.Query parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Query parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Query parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Query 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.datastore.v1.Query parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Query parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Query parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Query parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Query parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Query parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Query parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Query parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.Query 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A query for entities.
+   *
+   * The query stages are executed in the following order:
+   * 1. kind
+   * 2. filter
+   * 3. projection
+   * 4. order + start_cursor + end_cursor
+   * 5. offset
+   * 6. limit
+   * 7. find_nearest
+   * 
+ * + * Protobuf type {@code google.datastore.v1.Query} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.Query) + com.google.datastore.v1.QueryOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Query_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Query_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Query.class, com.google.datastore.v1.Query.Builder.class); + } + + // Construct using com.google.datastore.v1.Query.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getProjectionFieldBuilder(); + getKindFieldBuilder(); + getFilterFieldBuilder(); + getOrderFieldBuilder(); + getDistinctOnFieldBuilder(); + getLimitFieldBuilder(); + getFindNearestFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (projectionBuilder_ == null) { + projection_ = java.util.Collections.emptyList(); + } else { + projection_ = null; + projectionBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + if (kindBuilder_ == null) { + kind_ = java.util.Collections.emptyList(); + } else { + kind_ = null; + kindBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000002); + filter_ = null; + if (filterBuilder_ != null) { + filterBuilder_.dispose(); + filterBuilder_ = null; + } + if (orderBuilder_ == null) { + order_ = java.util.Collections.emptyList(); + } else { + order_ = null; + orderBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + if (distinctOnBuilder_ == null) { + distinctOn_ = java.util.Collections.emptyList(); + } else { + distinctOn_ = null; + distinctOnBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000010); + startCursor_ = com.google.protobuf.ByteString.EMPTY; + endCursor_ = com.google.protobuf.ByteString.EMPTY; + 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.datastore.v1.QueryProto + .internal_static_google_datastore_v1_Query_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.Query getDefaultInstanceForType() { + return com.google.datastore.v1.Query.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.Query build() { + com.google.datastore.v1.Query result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.Query buildPartial() { + com.google.datastore.v1.Query result = new com.google.datastore.v1.Query(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.Query result) { + if (projectionBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + projection_ = java.util.Collections.unmodifiableList(projection_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.projection_ = projection_; + } else { + result.projection_ = projectionBuilder_.build(); + } + if (kindBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0)) { + kind_ = java.util.Collections.unmodifiableList(kind_); + bitField0_ = (bitField0_ & ~0x00000002); + } + result.kind_ = kind_; + } else { + result.kind_ = kindBuilder_.build(); + } + if (orderBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + order_ = java.util.Collections.unmodifiableList(order_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.order_ = order_; + } else { + result.order_ = orderBuilder_.build(); + } + if (distinctOnBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0)) { + distinctOn_ = java.util.Collections.unmodifiableList(distinctOn_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.distinctOn_ = distinctOn_; + } else { + result.distinctOn_ = distinctOnBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.Query result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.filter_ = filterBuilder_ == null ? filter_ : filterBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.startCursor_ = startCursor_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.endCursor_ = endCursor_; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + result.offset_ = offset_; + } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.limit_ = limitBuilder_ == null ? limit_ : limitBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000200) != 0)) { + result.findNearest_ = + findNearestBuilder_ == null ? findNearest_ : findNearestBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.Query) { + return mergeFrom((com.google.datastore.v1.Query) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.Query other) { + if (other == com.google.datastore.v1.Query.getDefaultInstance()) return this; + if (projectionBuilder_ == null) { + if (!other.projection_.isEmpty()) { + if (projection_.isEmpty()) { + projection_ = other.projection_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureProjectionIsMutable(); + projection_.addAll(other.projection_); + } + onChanged(); + } + } else { + if (!other.projection_.isEmpty()) { + if (projectionBuilder_.isEmpty()) { + projectionBuilder_.dispose(); + projectionBuilder_ = null; + projection_ = other.projection_; + bitField0_ = (bitField0_ & ~0x00000001); + projectionBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getProjectionFieldBuilder() + : null; + } else { + projectionBuilder_.addAllMessages(other.projection_); + } + } + } + if (kindBuilder_ == null) { + if (!other.kind_.isEmpty()) { + if (kind_.isEmpty()) { + kind_ = other.kind_; + bitField0_ = (bitField0_ & ~0x00000002); + } else { + ensureKindIsMutable(); + kind_.addAll(other.kind_); + } + onChanged(); + } + } else { + if (!other.kind_.isEmpty()) { + if (kindBuilder_.isEmpty()) { + kindBuilder_.dispose(); + kindBuilder_ = null; + kind_ = other.kind_; + bitField0_ = (bitField0_ & ~0x00000002); + kindBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getKindFieldBuilder() + : null; + } else { + kindBuilder_.addAllMessages(other.kind_); + } + } + } + if (other.hasFilter()) { + mergeFilter(other.getFilter()); + } + if (orderBuilder_ == null) { + if (!other.order_.isEmpty()) { + if (order_.isEmpty()) { + order_ = other.order_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureOrderIsMutable(); + order_.addAll(other.order_); + } + onChanged(); + } + } else { + if (!other.order_.isEmpty()) { + if (orderBuilder_.isEmpty()) { + orderBuilder_.dispose(); + orderBuilder_ = null; + order_ = other.order_; + bitField0_ = (bitField0_ & ~0x00000008); + orderBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getOrderFieldBuilder() + : null; + } else { + orderBuilder_.addAllMessages(other.order_); + } + } + } + if (distinctOnBuilder_ == null) { + if (!other.distinctOn_.isEmpty()) { + if (distinctOn_.isEmpty()) { + distinctOn_ = other.distinctOn_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensureDistinctOnIsMutable(); + distinctOn_.addAll(other.distinctOn_); + } + onChanged(); + } + } else { + if (!other.distinctOn_.isEmpty()) { + if (distinctOnBuilder_.isEmpty()) { + distinctOnBuilder_.dispose(); + distinctOnBuilder_ = null; + distinctOn_ = other.distinctOn_; + bitField0_ = (bitField0_ & ~0x00000010); + distinctOnBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getDistinctOnFieldBuilder() + : null; + } else { + distinctOnBuilder_.addAllMessages(other.distinctOn_); + } + } + } + if (other.getStartCursor() != com.google.protobuf.ByteString.EMPTY) { + setStartCursor(other.getStartCursor()); + } + if (other.getEndCursor() != com.google.protobuf.ByteString.EMPTY) { + setEndCursor(other.getEndCursor()); + } + 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 18: + { + com.google.datastore.v1.Projection m = + input.readMessage( + com.google.datastore.v1.Projection.parser(), extensionRegistry); + if (projectionBuilder_ == null) { + ensureProjectionIsMutable(); + projection_.add(m); + } else { + projectionBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + com.google.datastore.v1.KindExpression m = + input.readMessage( + com.google.datastore.v1.KindExpression.parser(), extensionRegistry); + if (kindBuilder_ == null) { + ensureKindIsMutable(); + kind_.add(m); + } else { + kindBuilder_.addMessage(m); + } + break; + } // case 26 + case 34: + { + input.readMessage(getFilterFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 34 + case 42: + { + com.google.datastore.v1.PropertyOrder m = + input.readMessage( + com.google.datastore.v1.PropertyOrder.parser(), extensionRegistry); + if (orderBuilder_ == null) { + ensureOrderIsMutable(); + order_.add(m); + } else { + orderBuilder_.addMessage(m); + } + break; + } // case 42 + case 50: + { + com.google.datastore.v1.PropertyReference m = + input.readMessage( + com.google.datastore.v1.PropertyReference.parser(), extensionRegistry); + if (distinctOnBuilder_ == null) { + ensureDistinctOnIsMutable(); + distinctOn_.add(m); + } else { + distinctOnBuilder_.addMessage(m); + } + break; + } // case 50 + case 58: + { + startCursor_ = input.readBytes(); + bitField0_ |= 0x00000020; + break; + } // case 58 + case 66: + { + endCursor_ = input.readBytes(); + bitField0_ |= 0x00000040; + break; + } // case 66 + case 80: + { + offset_ = input.readInt32(); + bitField0_ |= 0x00000080; + break; + } // case 80 + case 98: + { + input.readMessage(getLimitFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000100; + break; + } // case 98 + case 106: + { + input.readMessage(getFindNearestFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000200; + break; + } // case 106 + 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 projection_ = + java.util.Collections.emptyList(); + + private void ensureProjectionIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + projection_ = new java.util.ArrayList(projection_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Projection, + com.google.datastore.v1.Projection.Builder, + com.google.datastore.v1.ProjectionOrBuilder> + projectionBuilder_; + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public java.util.List getProjectionList() { + if (projectionBuilder_ == null) { + return java.util.Collections.unmodifiableList(projection_); + } else { + return projectionBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public int getProjectionCount() { + if (projectionBuilder_ == null) { + return projection_.size(); + } else { + return projectionBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public com.google.datastore.v1.Projection getProjection(int index) { + if (projectionBuilder_ == null) { + return projection_.get(index); + } else { + return projectionBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public Builder setProjection(int index, com.google.datastore.v1.Projection value) { + if (projectionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProjectionIsMutable(); + projection_.set(index, value); + onChanged(); + } else { + projectionBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public Builder setProjection( + int index, com.google.datastore.v1.Projection.Builder builderForValue) { + if (projectionBuilder_ == null) { + ensureProjectionIsMutable(); + projection_.set(index, builderForValue.build()); + onChanged(); + } else { + projectionBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public Builder addProjection(com.google.datastore.v1.Projection value) { + if (projectionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProjectionIsMutable(); + projection_.add(value); + onChanged(); + } else { + projectionBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public Builder addProjection(int index, com.google.datastore.v1.Projection value) { + if (projectionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureProjectionIsMutable(); + projection_.add(index, value); + onChanged(); + } else { + projectionBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public Builder addProjection(com.google.datastore.v1.Projection.Builder builderForValue) { + if (projectionBuilder_ == null) { + ensureProjectionIsMutable(); + projection_.add(builderForValue.build()); + onChanged(); + } else { + projectionBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public Builder addProjection( + int index, com.google.datastore.v1.Projection.Builder builderForValue) { + if (projectionBuilder_ == null) { + ensureProjectionIsMutable(); + projection_.add(index, builderForValue.build()); + onChanged(); + } else { + projectionBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public Builder addAllProjection( + java.lang.Iterable values) { + if (projectionBuilder_ == null) { + ensureProjectionIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, projection_); + onChanged(); + } else { + projectionBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public Builder clearProjection() { + if (projectionBuilder_ == null) { + projection_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + projectionBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public Builder removeProjection(int index) { + if (projectionBuilder_ == null) { + ensureProjectionIsMutable(); + projection_.remove(index); + onChanged(); + } else { + projectionBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public com.google.datastore.v1.Projection.Builder getProjectionBuilder(int index) { + return getProjectionFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public com.google.datastore.v1.ProjectionOrBuilder getProjectionOrBuilder(int index) { + if (projectionBuilder_ == null) { + return projection_.get(index); + } else { + return projectionBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public java.util.List + getProjectionOrBuilderList() { + if (projectionBuilder_ != null) { + return projectionBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(projection_); + } + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public com.google.datastore.v1.Projection.Builder addProjectionBuilder() { + return getProjectionFieldBuilder() + .addBuilder(com.google.datastore.v1.Projection.getDefaultInstance()); + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public com.google.datastore.v1.Projection.Builder addProjectionBuilder(int index) { + return getProjectionFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Projection.getDefaultInstance()); + } + + /** + * + * + *
+     * The projection to return. Defaults to returning all properties.
+     * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + public java.util.List getProjectionBuilderList() { + return getProjectionFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Projection, + com.google.datastore.v1.Projection.Builder, + com.google.datastore.v1.ProjectionOrBuilder> + getProjectionFieldBuilder() { + if (projectionBuilder_ == null) { + projectionBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Projection, + com.google.datastore.v1.Projection.Builder, + com.google.datastore.v1.ProjectionOrBuilder>( + projection_, ((bitField0_ & 0x00000001) != 0), getParentForChildren(), isClean()); + projection_ = null; + } + return projectionBuilder_; + } + + private java.util.List kind_ = + java.util.Collections.emptyList(); + + private void ensureKindIsMutable() { + if (!((bitField0_ & 0x00000002) != 0)) { + kind_ = new java.util.ArrayList(kind_); + bitField0_ |= 0x00000002; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.KindExpression, + com.google.datastore.v1.KindExpression.Builder, + com.google.datastore.v1.KindExpressionOrBuilder> + kindBuilder_; + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public java.util.List getKindList() { + if (kindBuilder_ == null) { + return java.util.Collections.unmodifiableList(kind_); + } else { + return kindBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public int getKindCount() { + if (kindBuilder_ == null) { + return kind_.size(); + } else { + return kindBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public com.google.datastore.v1.KindExpression getKind(int index) { + if (kindBuilder_ == null) { + return kind_.get(index); + } else { + return kindBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public Builder setKind(int index, com.google.datastore.v1.KindExpression value) { + if (kindBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKindIsMutable(); + kind_.set(index, value); + onChanged(); + } else { + kindBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public Builder setKind( + int index, com.google.datastore.v1.KindExpression.Builder builderForValue) { + if (kindBuilder_ == null) { + ensureKindIsMutable(); + kind_.set(index, builderForValue.build()); + onChanged(); + } else { + kindBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public Builder addKind(com.google.datastore.v1.KindExpression value) { + if (kindBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKindIsMutable(); + kind_.add(value); + onChanged(); + } else { + kindBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public Builder addKind(int index, com.google.datastore.v1.KindExpression value) { + if (kindBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKindIsMutable(); + kind_.add(index, value); + onChanged(); + } else { + kindBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public Builder addKind(com.google.datastore.v1.KindExpression.Builder builderForValue) { + if (kindBuilder_ == null) { + ensureKindIsMutable(); + kind_.add(builderForValue.build()); + onChanged(); + } else { + kindBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public Builder addKind( + int index, com.google.datastore.v1.KindExpression.Builder builderForValue) { + if (kindBuilder_ == null) { + ensureKindIsMutable(); + kind_.add(index, builderForValue.build()); + onChanged(); + } else { + kindBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public Builder addAllKind( + java.lang.Iterable values) { + if (kindBuilder_ == null) { + ensureKindIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, kind_); + onChanged(); + } else { + kindBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public Builder clearKind() { + if (kindBuilder_ == null) { + kind_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + } else { + kindBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public Builder removeKind(int index) { + if (kindBuilder_ == null) { + ensureKindIsMutable(); + kind_.remove(index); + onChanged(); + } else { + kindBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public com.google.datastore.v1.KindExpression.Builder getKindBuilder(int index) { + return getKindFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public com.google.datastore.v1.KindExpressionOrBuilder getKindOrBuilder(int index) { + if (kindBuilder_ == null) { + return kind_.get(index); + } else { + return kindBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public java.util.List + getKindOrBuilderList() { + if (kindBuilder_ != null) { + return kindBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(kind_); + } + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public com.google.datastore.v1.KindExpression.Builder addKindBuilder() { + return getKindFieldBuilder() + .addBuilder(com.google.datastore.v1.KindExpression.getDefaultInstance()); + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public com.google.datastore.v1.KindExpression.Builder addKindBuilder(int index) { + return getKindFieldBuilder() + .addBuilder(index, com.google.datastore.v1.KindExpression.getDefaultInstance()); + } + + /** + * + * + *
+     * The kinds to query (if empty, returns entities of all kinds).
+     * Currently at most 1 kind may be specified.
+     * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + public java.util.List getKindBuilderList() { + return getKindFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.KindExpression, + com.google.datastore.v1.KindExpression.Builder, + com.google.datastore.v1.KindExpressionOrBuilder> + getKindFieldBuilder() { + if (kindBuilder_ == null) { + kindBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.KindExpression, + com.google.datastore.v1.KindExpression.Builder, + com.google.datastore.v1.KindExpressionOrBuilder>( + kind_, ((bitField0_ & 0x00000002) != 0), getParentForChildren(), isClean()); + kind_ = null; + } + return kindBuilder_; + } + + private com.google.datastore.v1.Filter filter_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Filter, + com.google.datastore.v1.Filter.Builder, + com.google.datastore.v1.FilterOrBuilder> + filterBuilder_; + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.datastore.v1.Filter filter = 4; + * + * @return Whether the filter field is set. + */ + public boolean hasFilter() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.datastore.v1.Filter filter = 4; + * + * @return The filter. + */ + public com.google.datastore.v1.Filter getFilter() { + if (filterBuilder_ == null) { + return filter_ == null ? com.google.datastore.v1.Filter.getDefaultInstance() : filter_; + } else { + return filterBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.datastore.v1.Filter filter = 4; + */ + public Builder setFilter(com.google.datastore.v1.Filter value) { + if (filterBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + filter_ = value; + } else { + filterBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.datastore.v1.Filter filter = 4; + */ + public Builder setFilter(com.google.datastore.v1.Filter.Builder builderForValue) { + if (filterBuilder_ == null) { + filter_ = builderForValue.build(); + } else { + filterBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.datastore.v1.Filter filter = 4; + */ + public Builder mergeFilter(com.google.datastore.v1.Filter value) { + if (filterBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && filter_ != null + && filter_ != com.google.datastore.v1.Filter.getDefaultInstance()) { + getFilterBuilder().mergeFrom(value); + } else { + filter_ = value; + } + } else { + filterBuilder_.mergeFrom(value); + } + if (filter_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.datastore.v1.Filter filter = 4; + */ + public Builder clearFilter() { + bitField0_ = (bitField0_ & ~0x00000004); + filter_ = null; + if (filterBuilder_ != null) { + filterBuilder_.dispose(); + filterBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.datastore.v1.Filter filter = 4; + */ + public com.google.datastore.v1.Filter.Builder getFilterBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getFilterFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.datastore.v1.Filter filter = 4; + */ + public com.google.datastore.v1.FilterOrBuilder getFilterOrBuilder() { + if (filterBuilder_ != null) { + return filterBuilder_.getMessageOrBuilder(); + } else { + return filter_ == null ? com.google.datastore.v1.Filter.getDefaultInstance() : filter_; + } + } + + /** + * + * + *
+     * The filter to apply.
+     * 
+ * + * .google.datastore.v1.Filter filter = 4; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Filter, + com.google.datastore.v1.Filter.Builder, + com.google.datastore.v1.FilterOrBuilder> + getFilterFieldBuilder() { + if (filterBuilder_ == null) { + filterBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Filter, + com.google.datastore.v1.Filter.Builder, + com.google.datastore.v1.FilterOrBuilder>( + getFilter(), getParentForChildren(), isClean()); + filter_ = null; + } + return filterBuilder_; + } + + private java.util.List order_ = + java.util.Collections.emptyList(); + + private void ensureOrderIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + order_ = new java.util.ArrayList(order_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyOrder, + com.google.datastore.v1.PropertyOrder.Builder, + com.google.datastore.v1.PropertyOrderOrBuilder> + orderBuilder_; + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public java.util.List getOrderList() { + if (orderBuilder_ == null) { + return java.util.Collections.unmodifiableList(order_); + } else { + return orderBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public int getOrderCount() { + if (orderBuilder_ == null) { + return order_.size(); + } else { + return orderBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public com.google.datastore.v1.PropertyOrder getOrder(int index) { + if (orderBuilder_ == null) { + return order_.get(index); + } else { + return orderBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public Builder setOrder(int index, com.google.datastore.v1.PropertyOrder value) { + if (orderBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOrderIsMutable(); + order_.set(index, value); + onChanged(); + } else { + orderBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public Builder setOrder( + int index, com.google.datastore.v1.PropertyOrder.Builder builderForValue) { + if (orderBuilder_ == null) { + ensureOrderIsMutable(); + order_.set(index, builderForValue.build()); + onChanged(); + } else { + orderBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public Builder addOrder(com.google.datastore.v1.PropertyOrder value) { + if (orderBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOrderIsMutable(); + order_.add(value); + onChanged(); + } else { + orderBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public Builder addOrder(int index, com.google.datastore.v1.PropertyOrder value) { + if (orderBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureOrderIsMutable(); + order_.add(index, value); + onChanged(); + } else { + orderBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public Builder addOrder(com.google.datastore.v1.PropertyOrder.Builder builderForValue) { + if (orderBuilder_ == null) { + ensureOrderIsMutable(); + order_.add(builderForValue.build()); + onChanged(); + } else { + orderBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public Builder addOrder( + int index, com.google.datastore.v1.PropertyOrder.Builder builderForValue) { + if (orderBuilder_ == null) { + ensureOrderIsMutable(); + order_.add(index, builderForValue.build()); + onChanged(); + } else { + orderBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public Builder addAllOrder( + java.lang.Iterable values) { + if (orderBuilder_ == null) { + ensureOrderIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, order_); + onChanged(); + } else { + orderBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public Builder clearOrder() { + if (orderBuilder_ == null) { + order_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + orderBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public Builder removeOrder(int index) { + if (orderBuilder_ == null) { + ensureOrderIsMutable(); + order_.remove(index); + onChanged(); + } else { + orderBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public com.google.datastore.v1.PropertyOrder.Builder getOrderBuilder(int index) { + return getOrderFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public com.google.datastore.v1.PropertyOrderOrBuilder getOrderOrBuilder(int index) { + if (orderBuilder_ == null) { + return order_.get(index); + } else { + return orderBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public java.util.List + getOrderOrBuilderList() { + if (orderBuilder_ != null) { + return orderBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(order_); + } + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public com.google.datastore.v1.PropertyOrder.Builder addOrderBuilder() { + return getOrderFieldBuilder() + .addBuilder(com.google.datastore.v1.PropertyOrder.getDefaultInstance()); + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public com.google.datastore.v1.PropertyOrder.Builder addOrderBuilder(int index) { + return getOrderFieldBuilder() + .addBuilder(index, com.google.datastore.v1.PropertyOrder.getDefaultInstance()); + } + + /** + * + * + *
+     * The order to apply to the query results (if empty, order is unspecified).
+     * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + public java.util.List getOrderBuilderList() { + return getOrderFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyOrder, + com.google.datastore.v1.PropertyOrder.Builder, + com.google.datastore.v1.PropertyOrderOrBuilder> + getOrderFieldBuilder() { + if (orderBuilder_ == null) { + orderBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyOrder, + com.google.datastore.v1.PropertyOrder.Builder, + com.google.datastore.v1.PropertyOrderOrBuilder>( + order_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean()); + order_ = null; + } + return orderBuilder_; + } + + private java.util.List distinctOn_ = + java.util.Collections.emptyList(); + + private void ensureDistinctOnIsMutable() { + if (!((bitField0_ & 0x00000010) != 0)) { + distinctOn_ = + new java.util.ArrayList(distinctOn_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + distinctOnBuilder_; + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public java.util.List getDistinctOnList() { + if (distinctOnBuilder_ == null) { + return java.util.Collections.unmodifiableList(distinctOn_); + } else { + return distinctOnBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public int getDistinctOnCount() { + if (distinctOnBuilder_ == null) { + return distinctOn_.size(); + } else { + return distinctOnBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public com.google.datastore.v1.PropertyReference getDistinctOn(int index) { + if (distinctOnBuilder_ == null) { + return distinctOn_.get(index); + } else { + return distinctOnBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public Builder setDistinctOn(int index, com.google.datastore.v1.PropertyReference value) { + if (distinctOnBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDistinctOnIsMutable(); + distinctOn_.set(index, value); + onChanged(); + } else { + distinctOnBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public Builder setDistinctOn( + int index, com.google.datastore.v1.PropertyReference.Builder builderForValue) { + if (distinctOnBuilder_ == null) { + ensureDistinctOnIsMutable(); + distinctOn_.set(index, builderForValue.build()); + onChanged(); + } else { + distinctOnBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public Builder addDistinctOn(com.google.datastore.v1.PropertyReference value) { + if (distinctOnBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDistinctOnIsMutable(); + distinctOn_.add(value); + onChanged(); + } else { + distinctOnBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public Builder addDistinctOn(int index, com.google.datastore.v1.PropertyReference value) { + if (distinctOnBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureDistinctOnIsMutable(); + distinctOn_.add(index, value); + onChanged(); + } else { + distinctOnBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public Builder addDistinctOn( + com.google.datastore.v1.PropertyReference.Builder builderForValue) { + if (distinctOnBuilder_ == null) { + ensureDistinctOnIsMutable(); + distinctOn_.add(builderForValue.build()); + onChanged(); + } else { + distinctOnBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public Builder addDistinctOn( + int index, com.google.datastore.v1.PropertyReference.Builder builderForValue) { + if (distinctOnBuilder_ == null) { + ensureDistinctOnIsMutable(); + distinctOn_.add(index, builderForValue.build()); + onChanged(); + } else { + distinctOnBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public Builder addAllDistinctOn( + java.lang.Iterable values) { + if (distinctOnBuilder_ == null) { + ensureDistinctOnIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, distinctOn_); + onChanged(); + } else { + distinctOnBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public Builder clearDistinctOn() { + if (distinctOnBuilder_ == null) { + distinctOn_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + distinctOnBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public Builder removeDistinctOn(int index) { + if (distinctOnBuilder_ == null) { + ensureDistinctOnIsMutable(); + distinctOn_.remove(index); + onChanged(); + } else { + distinctOnBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public com.google.datastore.v1.PropertyReference.Builder getDistinctOnBuilder(int index) { + return getDistinctOnFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public com.google.datastore.v1.PropertyReferenceOrBuilder getDistinctOnOrBuilder(int index) { + if (distinctOnBuilder_ == null) { + return distinctOn_.get(index); + } else { + return distinctOnBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public java.util.List + getDistinctOnOrBuilderList() { + if (distinctOnBuilder_ != null) { + return distinctOnBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(distinctOn_); + } + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public com.google.datastore.v1.PropertyReference.Builder addDistinctOnBuilder() { + return getDistinctOnFieldBuilder() + .addBuilder(com.google.datastore.v1.PropertyReference.getDefaultInstance()); + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public com.google.datastore.v1.PropertyReference.Builder addDistinctOnBuilder(int index) { + return getDistinctOnFieldBuilder() + .addBuilder(index, com.google.datastore.v1.PropertyReference.getDefaultInstance()); + } + + /** + * + * + *
+     * The properties to make distinct. The query results will contain the first
+     * result for each distinct combination of values for the given properties
+     * (if empty, all results are returned).
+     *
+     * Requires:
+     *
+     * * If `order` is specified, the set of distinct on properties must appear
+     * before the non-distinct on properties in `order`.
+     * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + public java.util.List + getDistinctOnBuilderList() { + return getDistinctOnFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder> + getDistinctOnFieldBuilder() { + if (distinctOnBuilder_ == null) { + distinctOnBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.PropertyReference, + com.google.datastore.v1.PropertyReference.Builder, + com.google.datastore.v1.PropertyReferenceOrBuilder>( + distinctOn_, ((bitField0_ & 0x00000010) != 0), getParentForChildren(), isClean()); + distinctOn_ = null; + } + return distinctOnBuilder_; + } + + private com.google.protobuf.ByteString startCursor_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * A starting point for the query results. Query cursors are
+     * returned in query result batches and
+     * [can only be used to continue the same
+     * query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
+     * 
+ * + * bytes start_cursor = 7; + * + * @return The startCursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getStartCursor() { + return startCursor_; + } + + /** + * + * + *
+     * A starting point for the query results. Query cursors are
+     * returned in query result batches and
+     * [can only be used to continue the same
+     * query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
+     * 
+ * + * bytes start_cursor = 7; + * + * @param value The startCursor to set. + * @return This builder for chaining. + */ + public Builder setStartCursor(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + startCursor_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * A starting point for the query results. Query cursors are
+     * returned in query result batches and
+     * [can only be used to continue the same
+     * query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
+     * 
+ * + * bytes start_cursor = 7; + * + * @return This builder for chaining. + */ + public Builder clearStartCursor() { + bitField0_ = (bitField0_ & ~0x00000020); + startCursor_ = getDefaultInstance().getStartCursor(); + onChanged(); + return this; + } + + private com.google.protobuf.ByteString endCursor_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * An ending point for the query results. Query cursors are
+     * returned in query result batches and
+     * [can only be used to limit the same
+     * query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
+     * 
+ * + * bytes end_cursor = 8; + * + * @return The endCursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getEndCursor() { + return endCursor_; + } + + /** + * + * + *
+     * An ending point for the query results. Query cursors are
+     * returned in query result batches and
+     * [can only be used to limit the same
+     * query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
+     * 
+ * + * bytes end_cursor = 8; + * + * @param value The endCursor to set. + * @return This builder for chaining. + */ + public Builder setEndCursor(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + endCursor_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * An ending point for the query results. Query cursors are
+     * returned in query result batches and
+     * [can only be used to limit the same
+     * query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
+     * 
+ * + * bytes end_cursor = 8; + * + * @return This builder for chaining. + */ + public Builder clearEndCursor() { + bitField0_ = (bitField0_ & ~0x00000040); + endCursor_ = getDefaultInstance().getEndCursor(); + onChanged(); + return this; + } + + private int offset_; + + /** + * + * + *
+     * The number of results to skip. Applies before limit, but after all other
+     * constraints. Optional. Must be >= 0 if specified.
+     * 
+ * + * int32 offset = 10; + * + * @return The offset. + */ + @java.lang.Override + public int getOffset() { + return offset_; + } + + /** + * + * + *
+     * The number of results to skip. Applies before limit, but after all other
+     * constraints. Optional. Must be >= 0 if specified.
+     * 
+ * + * int32 offset = 10; + * + * @param value The offset to set. + * @return This builder for chaining. + */ + public Builder setOffset(int value) { + + offset_ = value; + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of results to skip. Applies before limit, but after all other
+     * constraints. Optional. Must be >= 0 if specified.
+     * 
+ * + * int32 offset = 10; + * + * @return This builder for chaining. + */ + public Builder clearOffset() { + bitField0_ = (bitField0_ & ~0x00000080); + offset_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.Int32Value limit_; + private com.google.protobuf.SingleFieldBuilderV3< + 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. Optional.
+     * Unspecified is interpreted as no limit.
+     * Must be >= 0 if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 12; + * + * @return Whether the limit field is set. + */ + public boolean hasLimit() { + return ((bitField0_ & 0x00000100) != 0); + } + + /** + * + * + *
+     * The maximum number of results to return. Applies after all other
+     * constraints. Optional.
+     * Unspecified is interpreted as no limit.
+     * Must be >= 0 if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 12; + * + * @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. Optional.
+     * Unspecified is interpreted as no limit.
+     * Must be >= 0 if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 12; + */ + public Builder setLimit(com.google.protobuf.Int32Value value) { + if (limitBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + limit_ = value; + } else { + limitBuilder_.setMessage(value); + } + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * + * + *
+     * The maximum number of results to return. Applies after all other
+     * constraints. Optional.
+     * Unspecified is interpreted as no limit.
+     * Must be >= 0 if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 12; + */ + public Builder setLimit(com.google.protobuf.Int32Value.Builder builderForValue) { + if (limitBuilder_ == null) { + limit_ = builderForValue.build(); + } else { + limitBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000100; + onChanged(); + return this; + } + + /** + * + * + *
+     * The maximum number of results to return. Applies after all other
+     * constraints. Optional.
+     * Unspecified is interpreted as no limit.
+     * Must be >= 0 if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 12; + */ + public Builder mergeLimit(com.google.protobuf.Int32Value value) { + if (limitBuilder_ == null) { + if (((bitField0_ & 0x00000100) != 0) + && limit_ != null + && limit_ != com.google.protobuf.Int32Value.getDefaultInstance()) { + getLimitBuilder().mergeFrom(value); + } else { + limit_ = value; + } + } else { + limitBuilder_.mergeFrom(value); + } + if (limit_ != null) { + bitField0_ |= 0x00000100; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The maximum number of results to return. Applies after all other
+     * constraints. Optional.
+     * Unspecified is interpreted as no limit.
+     * Must be >= 0 if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 12; + */ + public Builder clearLimit() { + bitField0_ = (bitField0_ & ~0x00000100); + limit_ = null; + if (limitBuilder_ != null) { + limitBuilder_.dispose(); + limitBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The maximum number of results to return. Applies after all other
+     * constraints. Optional.
+     * Unspecified is interpreted as no limit.
+     * Must be >= 0 if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 12; + */ + public com.google.protobuf.Int32Value.Builder getLimitBuilder() { + bitField0_ |= 0x00000100; + onChanged(); + return getLimitFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The maximum number of results to return. Applies after all other
+     * constraints. Optional.
+     * Unspecified is interpreted as no limit.
+     * Must be >= 0 if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 12; + */ + 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. Optional.
+     * Unspecified is interpreted as no limit.
+     * Must be >= 0 if specified.
+     * 
+ * + * .google.protobuf.Int32Value limit = 12; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder> + getLimitFieldBuilder() { + if (limitBuilder_ == null) { + limitBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Int32Value, + com.google.protobuf.Int32Value.Builder, + com.google.protobuf.Int32ValueOrBuilder>( + getLimit(), getParentForChildren(), isClean()); + limit_ = null; + } + return limitBuilder_; + } + + private com.google.datastore.v1.FindNearest findNearest_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.FindNearest, + com.google.datastore.v1.FindNearest.Builder, + com.google.datastore.v1.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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the findNearest field is set. + */ + public boolean hasFindNearest() { + return ((bitField0_ & 0x00000200) != 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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + public com.google.datastore.v1.FindNearest getFindNearest() { + if (findNearestBuilder_ == null) { + return findNearest_ == null + ? com.google.datastore.v1.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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setFindNearest(com.google.datastore.v1.FindNearest value) { + if (findNearestBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + findNearest_ = value; + } else { + findNearestBuilder_.setMessage(value); + } + bitField0_ |= 0x00000200; + 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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setFindNearest(com.google.datastore.v1.FindNearest.Builder builderForValue) { + if (findNearestBuilder_ == null) { + findNearest_ = builderForValue.build(); + } else { + findNearestBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000200; + 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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeFindNearest(com.google.datastore.v1.FindNearest value) { + if (findNearestBuilder_ == null) { + if (((bitField0_ & 0x00000200) != 0) + && findNearest_ != null + && findNearest_ != com.google.datastore.v1.FindNearest.getDefaultInstance()) { + getFindNearestBuilder().mergeFrom(value); + } else { + findNearest_ = value; + } + } else { + findNearestBuilder_.mergeFrom(value); + } + if (findNearest_ != null) { + bitField0_ |= 0x00000200; + 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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearFindNearest() { + bitField0_ = (bitField0_ & ~0x00000200); + 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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.FindNearest.Builder getFindNearestBuilder() { + bitField0_ |= 0x00000200; + onChanged(); + return getFindNearestFieldBuilder().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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.FindNearestOrBuilder getFindNearestOrBuilder() { + if (findNearestBuilder_ != null) { + return findNearestBuilder_.getMessageOrBuilder(); + } else { + return findNearest_ == null + ? com.google.datastore.v1.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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.FindNearest, + com.google.datastore.v1.FindNearest.Builder, + com.google.datastore.v1.FindNearestOrBuilder> + getFindNearestFieldBuilder() { + if (findNearestBuilder_ == null) { + findNearestBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.FindNearest, + com.google.datastore.v1.FindNearest.Builder, + com.google.datastore.v1.FindNearestOrBuilder>( + getFindNearest(), getParentForChildren(), isClean()); + findNearest_ = null; + } + return findNearestBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.Query) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.Query) + private static final com.google.datastore.v1.Query DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.Query(); + } + + public static com.google.datastore.v1.Query getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public Query 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.datastore.v1.Query getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryOrBuilder.java new file mode 100644 index 000000000000..226e261ed721 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryOrBuilder.java @@ -0,0 +1,472 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface QueryOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.Query) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The projection to return. Defaults to returning all properties.
+   * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + java.util.List getProjectionList(); + + /** + * + * + *
+   * The projection to return. Defaults to returning all properties.
+   * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + com.google.datastore.v1.Projection getProjection(int index); + + /** + * + * + *
+   * The projection to return. Defaults to returning all properties.
+   * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + int getProjectionCount(); + + /** + * + * + *
+   * The projection to return. Defaults to returning all properties.
+   * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + java.util.List + getProjectionOrBuilderList(); + + /** + * + * + *
+   * The projection to return. Defaults to returning all properties.
+   * 
+ * + * repeated .google.datastore.v1.Projection projection = 2; + */ + com.google.datastore.v1.ProjectionOrBuilder getProjectionOrBuilder(int index); + + /** + * + * + *
+   * The kinds to query (if empty, returns entities of all kinds).
+   * Currently at most 1 kind may be specified.
+   * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + java.util.List getKindList(); + + /** + * + * + *
+   * The kinds to query (if empty, returns entities of all kinds).
+   * Currently at most 1 kind may be specified.
+   * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + com.google.datastore.v1.KindExpression getKind(int index); + + /** + * + * + *
+   * The kinds to query (if empty, returns entities of all kinds).
+   * Currently at most 1 kind may be specified.
+   * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + int getKindCount(); + + /** + * + * + *
+   * The kinds to query (if empty, returns entities of all kinds).
+   * Currently at most 1 kind may be specified.
+   * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + java.util.List getKindOrBuilderList(); + + /** + * + * + *
+   * The kinds to query (if empty, returns entities of all kinds).
+   * Currently at most 1 kind may be specified.
+   * 
+ * + * repeated .google.datastore.v1.KindExpression kind = 3; + */ + com.google.datastore.v1.KindExpressionOrBuilder getKindOrBuilder(int index); + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.datastore.v1.Filter filter = 4; + * + * @return Whether the filter field is set. + */ + boolean hasFilter(); + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.datastore.v1.Filter filter = 4; + * + * @return The filter. + */ + com.google.datastore.v1.Filter getFilter(); + + /** + * + * + *
+   * The filter to apply.
+   * 
+ * + * .google.datastore.v1.Filter filter = 4; + */ + com.google.datastore.v1.FilterOrBuilder getFilterOrBuilder(); + + /** + * + * + *
+   * The order to apply to the query results (if empty, order is unspecified).
+   * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + java.util.List getOrderList(); + + /** + * + * + *
+   * The order to apply to the query results (if empty, order is unspecified).
+   * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + com.google.datastore.v1.PropertyOrder getOrder(int index); + + /** + * + * + *
+   * The order to apply to the query results (if empty, order is unspecified).
+   * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + int getOrderCount(); + + /** + * + * + *
+   * The order to apply to the query results (if empty, order is unspecified).
+   * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + java.util.List getOrderOrBuilderList(); + + /** + * + * + *
+   * The order to apply to the query results (if empty, order is unspecified).
+   * 
+ * + * repeated .google.datastore.v1.PropertyOrder order = 5; + */ + com.google.datastore.v1.PropertyOrderOrBuilder getOrderOrBuilder(int index); + + /** + * + * + *
+   * The properties to make distinct. The query results will contain the first
+   * result for each distinct combination of values for the given properties
+   * (if empty, all results are returned).
+   *
+   * Requires:
+   *
+   * * If `order` is specified, the set of distinct on properties must appear
+   * before the non-distinct on properties in `order`.
+   * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + java.util.List getDistinctOnList(); + + /** + * + * + *
+   * The properties to make distinct. The query results will contain the first
+   * result for each distinct combination of values for the given properties
+   * (if empty, all results are returned).
+   *
+   * Requires:
+   *
+   * * If `order` is specified, the set of distinct on properties must appear
+   * before the non-distinct on properties in `order`.
+   * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + com.google.datastore.v1.PropertyReference getDistinctOn(int index); + + /** + * + * + *
+   * The properties to make distinct. The query results will contain the first
+   * result for each distinct combination of values for the given properties
+   * (if empty, all results are returned).
+   *
+   * Requires:
+   *
+   * * If `order` is specified, the set of distinct on properties must appear
+   * before the non-distinct on properties in `order`.
+   * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + int getDistinctOnCount(); + + /** + * + * + *
+   * The properties to make distinct. The query results will contain the first
+   * result for each distinct combination of values for the given properties
+   * (if empty, all results are returned).
+   *
+   * Requires:
+   *
+   * * If `order` is specified, the set of distinct on properties must appear
+   * before the non-distinct on properties in `order`.
+   * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + java.util.List + getDistinctOnOrBuilderList(); + + /** + * + * + *
+   * The properties to make distinct. The query results will contain the first
+   * result for each distinct combination of values for the given properties
+   * (if empty, all results are returned).
+   *
+   * Requires:
+   *
+   * * If `order` is specified, the set of distinct on properties must appear
+   * before the non-distinct on properties in `order`.
+   * 
+ * + * repeated .google.datastore.v1.PropertyReference distinct_on = 6; + */ + com.google.datastore.v1.PropertyReferenceOrBuilder getDistinctOnOrBuilder(int index); + + /** + * + * + *
+   * A starting point for the query results. Query cursors are
+   * returned in query result batches and
+   * [can only be used to continue the same
+   * query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
+   * 
+ * + * bytes start_cursor = 7; + * + * @return The startCursor. + */ + com.google.protobuf.ByteString getStartCursor(); + + /** + * + * + *
+   * An ending point for the query results. Query cursors are
+   * returned in query result batches and
+   * [can only be used to limit the same
+   * query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets).
+   * 
+ * + * bytes end_cursor = 8; + * + * @return The endCursor. + */ + com.google.protobuf.ByteString getEndCursor(); + + /** + * + * + *
+   * The number of results to skip. Applies before limit, but after all other
+   * constraints. Optional. Must be >= 0 if specified.
+   * 
+ * + * int32 offset = 10; + * + * @return The offset. + */ + int getOffset(); + + /** + * + * + *
+   * The maximum number of results to return. Applies after all other
+   * constraints. Optional.
+   * Unspecified is interpreted as no limit.
+   * Must be >= 0 if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 12; + * + * @return Whether the limit field is set. + */ + boolean hasLimit(); + + /** + * + * + *
+   * The maximum number of results to return. Applies after all other
+   * constraints. Optional.
+   * Unspecified is interpreted as no limit.
+   * Must be >= 0 if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 12; + * + * @return The limit. + */ + com.google.protobuf.Int32Value getLimit(); + + /** + * + * + *
+   * The maximum number of results to return. Applies after all other
+   * constraints. Optional.
+   * Unspecified is interpreted as no limit.
+   * Must be >= 0 if specified.
+   * 
+ * + * .google.protobuf.Int32Value limit = 12; + */ + 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.datastore.v1.FindNearest find_nearest = 13 [(.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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The findNearest. + */ + com.google.datastore.v1.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.datastore.v1.FindNearest find_nearest = 13 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.datastore.v1.FindNearestOrBuilder getFindNearestOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProfileProto.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProfileProto.java new file mode 100644 index 000000000000..2fa5ac143dfe --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProfileProto.java @@ -0,0 +1,128 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query_profile.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public final class QueryProfileProto { + private 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_datastore_v1_ExplainOptions_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_ExplainOptions_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_ExplainMetrics_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_ExplainMetrics_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_PlanSummary_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_PlanSummary_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_ExecutionStats_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_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/datastore/v1/query_profile.prot" + + "o\022\023google.datastore.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.datastore.v1.PlanSummary\022<\n\017exec" + + "ution_stats\030\002 \001(\0132#.google.datastore.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\302\001\n\027com.google.datastore.v1B\021Que" + + "ryProfileProtoP\001Z;cloud.google.com/go/da" + + "tastore/apiv1/datastorepb;datastorepb\252\002\031" + + "Google.Cloud.Datastore.V1\312\002\031Google\\Cloud" + + "\\Datastore\\V1\352\002\034Google::Cloud::Datastore" + + "::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_datastore_v1_ExplainOptions_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_datastore_v1_ExplainOptions_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_ExplainOptions_descriptor, + new java.lang.String[] { + "Analyze", + }); + internal_static_google_datastore_v1_ExplainMetrics_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_datastore_v1_ExplainMetrics_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_ExplainMetrics_descriptor, + new java.lang.String[] { + "PlanSummary", "ExecutionStats", + }); + internal_static_google_datastore_v1_PlanSummary_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_datastore_v1_PlanSummary_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_PlanSummary_descriptor, + new java.lang.String[] { + "IndexesUsed", + }); + internal_static_google_datastore_v1_ExecutionStats_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_datastore_v1_ExecutionStats_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_ExecutionStats_descriptor, + new java.lang.String[] { + "ResultsReturned", "ExecutionDuration", "ReadOperations", "DebugStats", + }); + 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); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.protobuf.DurationProto.getDescriptor(); + com.google.protobuf.StructProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProto.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProto.java new file mode 100644 index 000000000000..67392d6cb840 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryProto.java @@ -0,0 +1,458 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public final class QueryProto { + private 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_datastore_v1_EntityResult_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_EntityResult_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_Query_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_Query_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_AggregationQuery_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_AggregationQuery_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_AggregationQuery_Aggregation_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_AggregationQuery_Aggregation_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Count_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Count_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Sum_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Sum_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Avg_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Avg_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_KindExpression_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_KindExpression_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_PropertyReference_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_PropertyReference_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_Projection_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_Projection_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_PropertyOrder_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_PropertyOrder_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_Filter_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_Filter_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_CompositeFilter_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_CompositeFilter_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_PropertyFilter_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_PropertyFilter_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_FindNearest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_FindNearest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_GqlQuery_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_GqlQuery_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_GqlQuery_NamedBindingsEntry_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_GqlQuery_NamedBindingsEntry_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_GqlQueryParameter_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_GqlQueryParameter_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_datastore_v1_QueryResultBatch_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_datastore_v1_QueryResultBatch_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/datastore/v1/query.proto\022\023googl" + + "e.datastore.v1\032\037google/api/field_behavior.proto\032" + + " google/datastore/v1/entity.prot" + + "o\032\037google/protobuf/timestamp.proto\032\036google/protobuf/wrappers.proto\"\221\002\n" + + "\014EntityResult\022+\n" + + "\006entity\030\001 \001(\0132\033.google.datastore.v1.Entity\022\017\n" + + "\007version\030\004 \001(\003\022/\n" + + "\013create_time\030\006 \001(\0132\032.google.protobuf.Timestamp\022/\n" + + "\013update_time\030\005 \001(\0132\032.google.protobuf.Timestamp\022\016\n" + + "\006cursor\030\003 \001(\014\"Q\n\n" + + "ResultType\022\033\n" + + "\027RESULT_TYPE_UNSPECIFIED\020\000\022\010\n" + + "\004FULL\020\001\022\016\n\n" + + "PROJECTION\020\002\022\014\n" + + "\010KEY_ONLY\020\003\"\257\003\n" + + "\005Query\0223\n\n" + + "projection\030\002 \003(\0132\037.google.datastore.v1.Projection\0221\n" + + "\004kind\030\003 \003(\0132#.google.datastore.v1.KindExpression\022+\n" + + "\006filter\030\004 \001(\0132\033.google.datastore.v1.Filter\0221\n" + + "\005order\030\005 \003(\0132\".google.datastore.v1.PropertyOrder\022;\n" + + "\013distinct_on\030\006 \003(\0132&.google.datastore.v1.PropertyReference\022\024\n" + + "\014start_cursor\030\007 \001(\014\022\022\n\n" + + "end_cursor\030\010 \001(\014\022\016\n" + + "\006offset\030\n" + + " \001(\005\022*\n" + + "\005limit\030\014 \001(\0132\033.google.protobuf.Int32Value\022;\n" + + "\014find_nearest\030\r" + + " \001(\0132 .google.datastore.v1.FindNearestB\003\340A\001\"\344\004\n" + + "\020AggregationQuery\0222\n" + + "\014nested_query\030\001 \001(\0132\032.google.datastore.v1.QueryH\000\022L\n" + + "\014aggregations\030\003 \003(\01321.google" + + ".datastore.v1.AggregationQuery.AggregationB\003\340A\001\032\277\003\n" + + "\013Aggregation\022H\n" + + "\005count\030\001 \001(\01327" + + ".google.datastore.v1.AggregationQuery.Aggregation.CountH\000\022D\n" + + "\003sum\030\002 \001(\01325.google." + + "datastore.v1.AggregationQuery.Aggregation.SumH\000\022D\n" + + "\003avg\030\003" + + " \001(\01325.google.datastore.v1.AggregationQuery.Aggregation.AvgH\000\022\022\n" + + "\005alias\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\032?\n" + + "\003Sum\0228\n" + + "\010property\030\001 \001(\0132&.google.datastore.v1.PropertyReference\032?\n" + + "\003Avg\0228\n" + + "\010property\030\001 \001(\0132&.google.datastore.v1.PropertyReferenceB\n\n" + + "\010operatorB\014\n\n" + + "query_type\"\036\n" + + "\016KindExpression\022\014\n" + + "\004name\030\001 \001(\t\"!\n" + + "\021PropertyReference\022\014\n" + + "\004name\030\002 \001(\t\"F\n\n" + + "Projection\0228\n" + + "\010property\030\001 \001(\0132&.google.datastore.v1.PropertyReference\"\321\001\n\r" + + "PropertyOrder\0228\n" + + "\010property\030\001 \001(\0132&.google.datastore.v1.PropertyReference\022?\n" + + "\tdirection\030\002 \001(\0162,.google.datastore.v1.PropertyOrder.Direction\"E\n" + + "\tDirection\022\031\n" + + "\025DIRECTION_UNSPECIFIED\020\000\022\r\n" + + "\tASCENDING\020\001\022\016\n\n" + + "DESCENDING\020\002\"\231\001\n" + + "\006Filter\022@\n" + + "\020composite_filter\030\001" + + " \001(\0132$.google.datastore.v1.CompositeFilterH\000\022>\n" + + "\017property_filter\030\002 \001(\0132#.google.datastore.v1.PropertyFilterH\000B\r\n" + + "\013filter_type\"\261\001\n" + + "\017CompositeFilter\0229\n" + + "\002op\030\001 \001(\0162-.google.datastore.v1.CompositeFilter.Operator\022,\n" + + "\007filters\030\002 \003(\0132\033.google.datastore.v1.Filter\"5\n" + + "\010Operator\022\030\n" + + "\024OPERATOR_UNSPECIFIED\020\000\022\007\n" + + "\003AND\020\001\022\006\n" + + "\002OR\020\002\"\352\002\n" + + "\016PropertyFilter\0228\n" + + "\010property\030\001 \001(\0132&.google.datastore.v1.PropertyReference\0228\n" + + "\002op\030\002 \001(\0162,.google.datastore.v1.PropertyFilter.Operator\022)\n" + + "\005value\030\003 \001(\0132\032.google.datastore.v1.Value\"\270\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" + + "\014GREATER_THAN\020\003\022\031\n" + + "\025GREATER_THAN_OR_EQUAL\020\004\022\t\n" + + "\005EQUAL\020\005\022\006\n" + + "\002IN\020\006\022\r" + + "\n" + + "\tNOT_EQUAL\020\t\022\020\n" + + "\014HAS_ANCESTOR\020\013\022\n\n" + + "\006NOT_IN\020\r" + + "\"\323\003\n" + + "\013FindNearest\022D\n" + + "\017vector_property\030\001" + + " \001(\0132&.google.datastore.v1.PropertyReferenceB\003\340A\002\0225\n" + + "\014query_vector\030\002 \001(\0132\032.google.datastore.v1.ValueB\003\340A\002\022O\n" + + "\020distance_measure\030\003" + + " \001(\01620.google.datastore.v1.FindNearest.DistanceMeasureB\003\340A\002\022/\n" + + "\005limit\030\004 \001(\0132\033.google.protobuf.Int32ValueB\003\340A\002\022%\n" + + "\030distance_result_property\030\005 \001(\tB\003\340A\001\022=\n" + + "\022distance_threshold\030\006" + + " \001(\0132\034.google.protobuf.DoubleValueB\003\340A\001\"_\n" + + "\017DistanceMeasure\022 \n" + + "\034DISTANCE_MEASURE_UNSPECIFIED\020\000\022\r\n" + + "\tEUCLIDEAN\020\001\022\n\n" + + "\006COSINE\020\002\022\017\n" + + "\013DOT_PRODUCT\020\003\"\245\002\n" + + "\010GqlQuery\022\024\n" + + "\014query_string\030\001 \001(\t\022\026\n" + + "\016allow_literals\030\002 \001(\010\022H\n" + + "\016named_bindings\030\005 \003(\01320.g" + + "oogle.datastore.v1.GqlQuery.NamedBindingsEntry\022C\n" + + "\023positional_bindings\030\004" + + " \003(\0132&.google.datastore.v1.GqlQueryParameter\032\\\n" + + "\022NamedBindingsEntry\022\013\n" + + "\003key\030\001 \001(\t\0225\n" + + "\005value\030\002 \001(\0132&.google.datastore.v1.GqlQueryParameter:\0028\001\"d\n" + + "\021GqlQueryParameter\022+\n" + + "\005value\030\002 \001(\0132\032.google.datastore.v1.ValueH\000\022\020\n" + + "\006cursor\030\003 \001(\014H\000B\020\n" + + "\016parameter_type\"\215\004\n" + + "\020QueryResultBatch\022\027\n" + + "\017skipped_results\030\006 \001(\005\022\026\n" + + "\016skipped_cursor\030\003 \001(\014\022H\n" + + "\022entity_result_type\030\001" + + " \001(\0162,.google.datastore.v1.EntityResult.ResultType\0229\n" + + "\016entity_results\030\002 \003(\0132!.google.datastore.v1.EntityResult\022\022\n\n" + + "end_cursor\030\004 \001(\014\022K\n" + + "\014more_results\030\005 \001(\01625.g" + + "oogle.datastore.v1.QueryResultBatch.MoreResultsType\022\030\n" + + "\020snapshot_version\030\007 \001(\003\022-\n" + + "\tread_time\030\010 \001(\0132\032.google.protobuf.Timestamp\"\230\001\n" + + "\017MoreResultsType\022!\n" + + "\035MORE_RESULTS_TYPE_UNSPECIFIED\020\000\022\020\n" + + "\014NOT_FINISHED\020\001\022\034\n" + + "\030MORE_RESULTS_AFTER_LIMIT\020\002\022\035\n" + + "\031MORE_RESULTS_AFTER_CURSOR\020\004\022\023\n" + + "\017NO_MORE_RESULTS\020\003B\273\001\n" + + "\027com.google.datastore.v1B\n" + + "QueryProtoP\001Z;cloud.google.com/go/datastore/apiv1/d" + + "atastorepb;datastorepb\252\002\031Google.Cloud.Da" + + "tastore.V1\312\002\031Google\\Cloud\\Datastore\\V1\352\002" + + "\034Google::Cloud::Datastore::V1b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.datastore.v1.EntityProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + com.google.protobuf.WrappersProto.getDescriptor(), + }); + internal_static_google_datastore_v1_EntityResult_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_datastore_v1_EntityResult_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_EntityResult_descriptor, + new java.lang.String[] { + "Entity", "Version", "CreateTime", "UpdateTime", "Cursor", + }); + internal_static_google_datastore_v1_Query_descriptor = getDescriptor().getMessageTypes().get(1); + internal_static_google_datastore_v1_Query_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_Query_descriptor, + new java.lang.String[] { + "Projection", + "Kind", + "Filter", + "Order", + "DistinctOn", + "StartCursor", + "EndCursor", + "Offset", + "Limit", + "FindNearest", + }); + internal_static_google_datastore_v1_AggregationQuery_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_datastore_v1_AggregationQuery_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_AggregationQuery_descriptor, + new java.lang.String[] { + "NestedQuery", "Aggregations", "QueryType", + }); + internal_static_google_datastore_v1_AggregationQuery_Aggregation_descriptor = + internal_static_google_datastore_v1_AggregationQuery_descriptor.getNestedTypes().get(0); + internal_static_google_datastore_v1_AggregationQuery_Aggregation_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_AggregationQuery_Aggregation_descriptor, + new java.lang.String[] { + "Count", "Sum", "Avg", "Alias", "Operator", + }); + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Count_descriptor = + internal_static_google_datastore_v1_AggregationQuery_Aggregation_descriptor + .getNestedTypes() + .get(0); + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Count_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Count_descriptor, + new java.lang.String[] { + "UpTo", + }); + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Sum_descriptor = + internal_static_google_datastore_v1_AggregationQuery_Aggregation_descriptor + .getNestedTypes() + .get(1); + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Sum_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Sum_descriptor, + new java.lang.String[] { + "Property", + }); + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Avg_descriptor = + internal_static_google_datastore_v1_AggregationQuery_Aggregation_descriptor + .getNestedTypes() + .get(2); + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Avg_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_AggregationQuery_Aggregation_Avg_descriptor, + new java.lang.String[] { + "Property", + }); + internal_static_google_datastore_v1_KindExpression_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_datastore_v1_KindExpression_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_KindExpression_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_datastore_v1_PropertyReference_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_datastore_v1_PropertyReference_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_PropertyReference_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_datastore_v1_Projection_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_datastore_v1_Projection_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_Projection_descriptor, + new java.lang.String[] { + "Property", + }); + internal_static_google_datastore_v1_PropertyOrder_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_google_datastore_v1_PropertyOrder_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_PropertyOrder_descriptor, + new java.lang.String[] { + "Property", "Direction", + }); + internal_static_google_datastore_v1_Filter_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_google_datastore_v1_Filter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_Filter_descriptor, + new java.lang.String[] { + "CompositeFilter", "PropertyFilter", "FilterType", + }); + internal_static_google_datastore_v1_CompositeFilter_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_google_datastore_v1_CompositeFilter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_CompositeFilter_descriptor, + new java.lang.String[] { + "Op", "Filters", + }); + internal_static_google_datastore_v1_PropertyFilter_descriptor = + getDescriptor().getMessageTypes().get(9); + internal_static_google_datastore_v1_PropertyFilter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_PropertyFilter_descriptor, + new java.lang.String[] { + "Property", "Op", "Value", + }); + internal_static_google_datastore_v1_FindNearest_descriptor = + getDescriptor().getMessageTypes().get(10); + internal_static_google_datastore_v1_FindNearest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_FindNearest_descriptor, + new java.lang.String[] { + "VectorProperty", + "QueryVector", + "DistanceMeasure", + "Limit", + "DistanceResultProperty", + "DistanceThreshold", + }); + internal_static_google_datastore_v1_GqlQuery_descriptor = + getDescriptor().getMessageTypes().get(11); + internal_static_google_datastore_v1_GqlQuery_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_GqlQuery_descriptor, + new java.lang.String[] { + "QueryString", "AllowLiterals", "NamedBindings", "PositionalBindings", + }); + internal_static_google_datastore_v1_GqlQuery_NamedBindingsEntry_descriptor = + internal_static_google_datastore_v1_GqlQuery_descriptor.getNestedTypes().get(0); + internal_static_google_datastore_v1_GqlQuery_NamedBindingsEntry_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_GqlQuery_NamedBindingsEntry_descriptor, + new java.lang.String[] { + "Key", "Value", + }); + internal_static_google_datastore_v1_GqlQueryParameter_descriptor = + getDescriptor().getMessageTypes().get(12); + internal_static_google_datastore_v1_GqlQueryParameter_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_GqlQueryParameter_descriptor, + new java.lang.String[] { + "Value", "Cursor", "ParameterType", + }); + internal_static_google_datastore_v1_QueryResultBatch_descriptor = + getDescriptor().getMessageTypes().get(13); + internal_static_google_datastore_v1_QueryResultBatch_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_datastore_v1_QueryResultBatch_descriptor, + new java.lang.String[] { + "SkippedResults", + "SkippedCursor", + "EntityResultType", + "EntityResults", + "EndCursor", + "MoreResults", + "SnapshotVersion", + "ReadTime", + }); + 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); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.datastore.v1.EntityProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.protobuf.WrappersProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatch.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatch.java new file mode 100644 index 000000000000..b188c5c04500 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatch.java @@ -0,0 +1,2312 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A batch of results produced by a query.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.QueryResultBatch} + */ +public final class QueryResultBatch extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.QueryResultBatch) + QueryResultBatchOrBuilder { + private static final long serialVersionUID = 0L; + + // Use QueryResultBatch.newBuilder() to construct. + private QueryResultBatch(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private QueryResultBatch() { + skippedCursor_ = com.google.protobuf.ByteString.EMPTY; + entityResultType_ = 0; + entityResults_ = java.util.Collections.emptyList(); + endCursor_ = com.google.protobuf.ByteString.EMPTY; + moreResults_ = 0; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new QueryResultBatch(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_QueryResultBatch_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_QueryResultBatch_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.QueryResultBatch.class, + com.google.datastore.v1.QueryResultBatch.Builder.class); + } + + /** + * + * + *
+   * The possible values for the `more_results` field.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.QueryResultBatch.MoreResultsType} + */ + public enum MoreResultsType implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. This value is never used.
+     * 
+ * + * MORE_RESULTS_TYPE_UNSPECIFIED = 0; + */ + MORE_RESULTS_TYPE_UNSPECIFIED(0), + /** + * + * + *
+     * There may be additional batches to fetch from this query.
+     * 
+ * + * NOT_FINISHED = 1; + */ + NOT_FINISHED(1), + /** + * + * + *
+     * The query is finished, but there may be more results after the limit.
+     * 
+ * + * MORE_RESULTS_AFTER_LIMIT = 2; + */ + MORE_RESULTS_AFTER_LIMIT(2), + /** + * + * + *
+     * The query is finished, but there may be more results after the end
+     * cursor.
+     * 
+ * + * MORE_RESULTS_AFTER_CURSOR = 4; + */ + MORE_RESULTS_AFTER_CURSOR(4), + /** + * + * + *
+     * The query is finished, and there are no more results.
+     * 
+ * + * NO_MORE_RESULTS = 3; + */ + NO_MORE_RESULTS(3), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified. This value is never used.
+     * 
+ * + * MORE_RESULTS_TYPE_UNSPECIFIED = 0; + */ + public static final int MORE_RESULTS_TYPE_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * There may be additional batches to fetch from this query.
+     * 
+ * + * NOT_FINISHED = 1; + */ + public static final int NOT_FINISHED_VALUE = 1; + + /** + * + * + *
+     * The query is finished, but there may be more results after the limit.
+     * 
+ * + * MORE_RESULTS_AFTER_LIMIT = 2; + */ + public static final int MORE_RESULTS_AFTER_LIMIT_VALUE = 2; + + /** + * + * + *
+     * The query is finished, but there may be more results after the end
+     * cursor.
+     * 
+ * + * MORE_RESULTS_AFTER_CURSOR = 4; + */ + public static final int MORE_RESULTS_AFTER_CURSOR_VALUE = 4; + + /** + * + * + *
+     * The query is finished, and there are no more results.
+     * 
+ * + * NO_MORE_RESULTS = 3; + */ + public static final int NO_MORE_RESULTS_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 MoreResultsType 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 MoreResultsType forNumber(int value) { + switch (value) { + case 0: + return MORE_RESULTS_TYPE_UNSPECIFIED; + case 1: + return NOT_FINISHED; + case 2: + return MORE_RESULTS_AFTER_LIMIT; + case 4: + return MORE_RESULTS_AFTER_CURSOR; + case 3: + return NO_MORE_RESULTS; + 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 MoreResultsType findValueByNumber(int number) { + return MoreResultsType.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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.QueryResultBatch.getDescriptor().getEnumTypes().get(0); + } + + private static final MoreResultsType[] VALUES = values(); + + public static MoreResultsType 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 MoreResultsType(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.v1.QueryResultBatch.MoreResultsType) + } + + private int bitField0_; + public static final int SKIPPED_RESULTS_FIELD_NUMBER = 6; + private int skippedResults_ = 0; + + /** + * + * + *
+   * The number of results skipped, typically because of an offset.
+   * 
+ * + * int32 skipped_results = 6; + * + * @return The skippedResults. + */ + @java.lang.Override + public int getSkippedResults() { + return skippedResults_; + } + + public static final int SKIPPED_CURSOR_FIELD_NUMBER = 3; + private com.google.protobuf.ByteString skippedCursor_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * A cursor that points to the position after the last skipped result.
+   * Will be set when `skipped_results` != 0.
+   * 
+ * + * bytes skipped_cursor = 3; + * + * @return The skippedCursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSkippedCursor() { + return skippedCursor_; + } + + public static final int ENTITY_RESULT_TYPE_FIELD_NUMBER = 1; + private int entityResultType_ = 0; + + /** + * + * + *
+   * The result type for every entity in `entity_results`.
+   * 
+ * + * .google.datastore.v1.EntityResult.ResultType entity_result_type = 1; + * + * @return The enum numeric value on the wire for entityResultType. + */ + @java.lang.Override + public int getEntityResultTypeValue() { + return entityResultType_; + } + + /** + * + * + *
+   * The result type for every entity in `entity_results`.
+   * 
+ * + * .google.datastore.v1.EntityResult.ResultType entity_result_type = 1; + * + * @return The entityResultType. + */ + @java.lang.Override + public com.google.datastore.v1.EntityResult.ResultType getEntityResultType() { + com.google.datastore.v1.EntityResult.ResultType result = + com.google.datastore.v1.EntityResult.ResultType.forNumber(entityResultType_); + return result == null ? com.google.datastore.v1.EntityResult.ResultType.UNRECOGNIZED : result; + } + + public static final int ENTITY_RESULTS_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private java.util.List entityResults_; + + /** + * + * + *
+   * The results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + @java.lang.Override + public java.util.List getEntityResultsList() { + return entityResults_; + } + + /** + * + * + *
+   * The results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + @java.lang.Override + public java.util.List + getEntityResultsOrBuilderList() { + return entityResults_; + } + + /** + * + * + *
+   * The results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + @java.lang.Override + public int getEntityResultsCount() { + return entityResults_.size(); + } + + /** + * + * + *
+   * The results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + @java.lang.Override + public com.google.datastore.v1.EntityResult getEntityResults(int index) { + return entityResults_.get(index); + } + + /** + * + * + *
+   * The results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + @java.lang.Override + public com.google.datastore.v1.EntityResultOrBuilder getEntityResultsOrBuilder(int index) { + return entityResults_.get(index); + } + + public static final int END_CURSOR_FIELD_NUMBER = 4; + private com.google.protobuf.ByteString endCursor_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * A cursor that points to the position after the last result in the batch.
+   * 
+ * + * bytes end_cursor = 4; + * + * @return The endCursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getEndCursor() { + return endCursor_; + } + + public static final int MORE_RESULTS_FIELD_NUMBER = 5; + private int moreResults_ = 0; + + /** + * + * + *
+   * The state of the query after the current batch.
+   * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5; + * + * @return The enum numeric value on the wire for moreResults. + */ + @java.lang.Override + public int getMoreResultsValue() { + return moreResults_; + } + + /** + * + * + *
+   * The state of the query after the current batch.
+   * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5; + * + * @return The moreResults. + */ + @java.lang.Override + public com.google.datastore.v1.QueryResultBatch.MoreResultsType getMoreResults() { + com.google.datastore.v1.QueryResultBatch.MoreResultsType result = + com.google.datastore.v1.QueryResultBatch.MoreResultsType.forNumber(moreResults_); + return result == null + ? com.google.datastore.v1.QueryResultBatch.MoreResultsType.UNRECOGNIZED + : result; + } + + public static final int SNAPSHOT_VERSION_FIELD_NUMBER = 7; + private long snapshotVersion_ = 0L; + + /** + * + * + *
+   * The version number of the snapshot this batch was returned from.
+   * This applies to the range of results from the query's `start_cursor` (or
+   * the beginning of the query if no cursor was given) to this batch's
+   * `end_cursor` (not the query's `end_cursor`).
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater snapshot version number. Each batch's snapshot version
+   * is valid for all preceding batches.
+   * The value will be zero for eventually consistent queries.
+   * 
+ * + * int64 snapshot_version = 7; + * + * @return The snapshotVersion. + */ + @java.lang.Override + public long getSnapshotVersion() { + return snapshotVersion_; + } + + public static final int READ_TIME_FIELD_NUMBER = 8; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   * This applies to the range of results from the query's `start_cursor` (or
+   * the beginning of the query if no cursor was given) to this batch's
+   * `end_cursor` (not the query's `end_cursor`).
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * This value will not be set for eventually consistent queries in Cloud
+   * Datastore.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 8; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   * This applies to the range of results from the query's `start_cursor` (or
+   * the beginning of the query if no cursor was given) to this batch's
+   * `end_cursor` (not the query's `end_cursor`).
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * This value will not be set for eventually consistent queries in Cloud
+   * Datastore.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 8; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   * This applies to the range of results from the query's `start_cursor` (or
+   * the beginning of the query if no cursor was given) to this batch's
+   * `end_cursor` (not the query's `end_cursor`).
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * This value will not be set for eventually consistent queries in Cloud
+   * Datastore.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 8; + */ + @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 (entityResultType_ + != com.google.datastore.v1.EntityResult.ResultType.RESULT_TYPE_UNSPECIFIED.getNumber()) { + output.writeEnum(1, entityResultType_); + } + for (int i = 0; i < entityResults_.size(); i++) { + output.writeMessage(2, entityResults_.get(i)); + } + if (!skippedCursor_.isEmpty()) { + output.writeBytes(3, skippedCursor_); + } + if (!endCursor_.isEmpty()) { + output.writeBytes(4, endCursor_); + } + if (moreResults_ + != com.google.datastore.v1.QueryResultBatch.MoreResultsType.MORE_RESULTS_TYPE_UNSPECIFIED + .getNumber()) { + output.writeEnum(5, moreResults_); + } + if (skippedResults_ != 0) { + output.writeInt32(6, skippedResults_); + } + if (snapshotVersion_ != 0L) { + output.writeInt64(7, snapshotVersion_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(8, getReadTime()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (entityResultType_ + != com.google.datastore.v1.EntityResult.ResultType.RESULT_TYPE_UNSPECIFIED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, entityResultType_); + } + for (int i = 0; i < entityResults_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, entityResults_.get(i)); + } + if (!skippedCursor_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(3, skippedCursor_); + } + if (!endCursor_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(4, endCursor_); + } + if (moreResults_ + != com.google.datastore.v1.QueryResultBatch.MoreResultsType.MORE_RESULTS_TYPE_UNSPECIFIED + .getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(5, moreResults_); + } + if (skippedResults_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(6, skippedResults_); + } + if (snapshotVersion_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(7, snapshotVersion_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(8, 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.datastore.v1.QueryResultBatch)) { + return super.equals(obj); + } + com.google.datastore.v1.QueryResultBatch other = (com.google.datastore.v1.QueryResultBatch) obj; + + if (getSkippedResults() != other.getSkippedResults()) return false; + if (!getSkippedCursor().equals(other.getSkippedCursor())) return false; + if (entityResultType_ != other.entityResultType_) return false; + if (!getEntityResultsList().equals(other.getEntityResultsList())) return false; + if (!getEndCursor().equals(other.getEndCursor())) return false; + if (moreResults_ != other.moreResults_) return false; + if (getSnapshotVersion() != other.getSnapshotVersion()) 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) + SKIPPED_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getSkippedResults(); + hash = (37 * hash) + SKIPPED_CURSOR_FIELD_NUMBER; + hash = (53 * hash) + getSkippedCursor().hashCode(); + hash = (37 * hash) + ENTITY_RESULT_TYPE_FIELD_NUMBER; + hash = (53 * hash) + entityResultType_; + if (getEntityResultsCount() > 0) { + hash = (37 * hash) + ENTITY_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + getEntityResultsList().hashCode(); + } + hash = (37 * hash) + END_CURSOR_FIELD_NUMBER; + hash = (53 * hash) + getEndCursor().hashCode(); + hash = (37 * hash) + MORE_RESULTS_FIELD_NUMBER; + hash = (53 * hash) + moreResults_; + hash = (37 * hash) + SNAPSHOT_VERSION_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getSnapshotVersion()); + 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.datastore.v1.QueryResultBatch parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.QueryResultBatch parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.QueryResultBatch parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.QueryResultBatch 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.datastore.v1.QueryResultBatch parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.QueryResultBatch parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.QueryResultBatch parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.QueryResultBatch parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.QueryResultBatch parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.QueryResultBatch parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.QueryResultBatch parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.QueryResultBatch parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.QueryResultBatch 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A batch of results produced by a query.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.QueryResultBatch} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.QueryResultBatch) + com.google.datastore.v1.QueryResultBatchOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_QueryResultBatch_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_QueryResultBatch_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.QueryResultBatch.class, + com.google.datastore.v1.QueryResultBatch.Builder.class); + } + + // Construct using com.google.datastore.v1.QueryResultBatch.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getEntityResultsFieldBuilder(); + getReadTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + skippedResults_ = 0; + skippedCursor_ = com.google.protobuf.ByteString.EMPTY; + entityResultType_ = 0; + if (entityResultsBuilder_ == null) { + entityResults_ = java.util.Collections.emptyList(); + } else { + entityResults_ = null; + entityResultsBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000008); + endCursor_ = com.google.protobuf.ByteString.EMPTY; + moreResults_ = 0; + snapshotVersion_ = 0L; + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.QueryProto + .internal_static_google_datastore_v1_QueryResultBatch_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.QueryResultBatch getDefaultInstanceForType() { + return com.google.datastore.v1.QueryResultBatch.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.QueryResultBatch build() { + com.google.datastore.v1.QueryResultBatch result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.QueryResultBatch buildPartial() { + com.google.datastore.v1.QueryResultBatch result = + new com.google.datastore.v1.QueryResultBatch(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.QueryResultBatch result) { + if (entityResultsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0)) { + entityResults_ = java.util.Collections.unmodifiableList(entityResults_); + bitField0_ = (bitField0_ & ~0x00000008); + } + result.entityResults_ = entityResults_; + } else { + result.entityResults_ = entityResultsBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.QueryResultBatch result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.skippedResults_ = skippedResults_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.skippedCursor_ = skippedCursor_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.entityResultType_ = entityResultType_; + } + if (((from_bitField0_ & 0x00000010) != 0)) { + result.endCursor_ = endCursor_; + } + if (((from_bitField0_ & 0x00000020) != 0)) { + result.moreResults_ = moreResults_; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.snapshotVersion_ = snapshotVersion_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000080) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.QueryResultBatch) { + return mergeFrom((com.google.datastore.v1.QueryResultBatch) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.QueryResultBatch other) { + if (other == com.google.datastore.v1.QueryResultBatch.getDefaultInstance()) return this; + if (other.getSkippedResults() != 0) { + setSkippedResults(other.getSkippedResults()); + } + if (other.getSkippedCursor() != com.google.protobuf.ByteString.EMPTY) { + setSkippedCursor(other.getSkippedCursor()); + } + if (other.entityResultType_ != 0) { + setEntityResultTypeValue(other.getEntityResultTypeValue()); + } + if (entityResultsBuilder_ == null) { + if (!other.entityResults_.isEmpty()) { + if (entityResults_.isEmpty()) { + entityResults_ = other.entityResults_; + bitField0_ = (bitField0_ & ~0x00000008); + } else { + ensureEntityResultsIsMutable(); + entityResults_.addAll(other.entityResults_); + } + onChanged(); + } + } else { + if (!other.entityResults_.isEmpty()) { + if (entityResultsBuilder_.isEmpty()) { + entityResultsBuilder_.dispose(); + entityResultsBuilder_ = null; + entityResults_ = other.entityResults_; + bitField0_ = (bitField0_ & ~0x00000008); + entityResultsBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getEntityResultsFieldBuilder() + : null; + } else { + entityResultsBuilder_.addAllMessages(other.entityResults_); + } + } + } + if (other.getEndCursor() != com.google.protobuf.ByteString.EMPTY) { + setEndCursor(other.getEndCursor()); + } + if (other.moreResults_ != 0) { + setMoreResultsValue(other.getMoreResultsValue()); + } + if (other.getSnapshotVersion() != 0L) { + setSnapshotVersion(other.getSnapshotVersion()); + } + 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: + { + entityResultType_ = input.readEnum(); + bitField0_ |= 0x00000004; + break; + } // case 8 + case 18: + { + com.google.datastore.v1.EntityResult m = + input.readMessage( + com.google.datastore.v1.EntityResult.parser(), extensionRegistry); + if (entityResultsBuilder_ == null) { + ensureEntityResultsIsMutable(); + entityResults_.add(m); + } else { + entityResultsBuilder_.addMessage(m); + } + break; + } // case 18 + case 26: + { + skippedCursor_ = input.readBytes(); + bitField0_ |= 0x00000002; + break; + } // case 26 + case 34: + { + endCursor_ = input.readBytes(); + bitField0_ |= 0x00000010; + break; + } // case 34 + case 40: + { + moreResults_ = input.readEnum(); + bitField0_ |= 0x00000020; + break; + } // case 40 + case 48: + { + skippedResults_ = input.readInt32(); + bitField0_ |= 0x00000001; + break; + } // case 48 + case 56: + { + snapshotVersion_ = input.readInt64(); + bitField0_ |= 0x00000040; + break; + } // case 56 + case 66: + { + input.readMessage(getReadTimeFieldBuilder().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 int skippedResults_; + + /** + * + * + *
+     * The number of results skipped, typically because of an offset.
+     * 
+ * + * int32 skipped_results = 6; + * + * @return The skippedResults. + */ + @java.lang.Override + public int getSkippedResults() { + return skippedResults_; + } + + /** + * + * + *
+     * The number of results skipped, typically because of an offset.
+     * 
+ * + * int32 skipped_results = 6; + * + * @param value The skippedResults to set. + * @return This builder for chaining. + */ + public Builder setSkippedResults(int value) { + + skippedResults_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * The number of results skipped, typically because of an offset.
+     * 
+ * + * int32 skipped_results = 6; + * + * @return This builder for chaining. + */ + public Builder clearSkippedResults() { + bitField0_ = (bitField0_ & ~0x00000001); + skippedResults_ = 0; + onChanged(); + return this; + } + + private com.google.protobuf.ByteString skippedCursor_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * A cursor that points to the position after the last skipped result.
+     * Will be set when `skipped_results` != 0.
+     * 
+ * + * bytes skipped_cursor = 3; + * + * @return The skippedCursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getSkippedCursor() { + return skippedCursor_; + } + + /** + * + * + *
+     * A cursor that points to the position after the last skipped result.
+     * Will be set when `skipped_results` != 0.
+     * 
+ * + * bytes skipped_cursor = 3; + * + * @param value The skippedCursor to set. + * @return This builder for chaining. + */ + public Builder setSkippedCursor(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + skippedCursor_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * A cursor that points to the position after the last skipped result.
+     * Will be set when `skipped_results` != 0.
+     * 
+ * + * bytes skipped_cursor = 3; + * + * @return This builder for chaining. + */ + public Builder clearSkippedCursor() { + bitField0_ = (bitField0_ & ~0x00000002); + skippedCursor_ = getDefaultInstance().getSkippedCursor(); + onChanged(); + return this; + } + + private int entityResultType_ = 0; + + /** + * + * + *
+     * The result type for every entity in `entity_results`.
+     * 
+ * + * .google.datastore.v1.EntityResult.ResultType entity_result_type = 1; + * + * @return The enum numeric value on the wire for entityResultType. + */ + @java.lang.Override + public int getEntityResultTypeValue() { + return entityResultType_; + } + + /** + * + * + *
+     * The result type for every entity in `entity_results`.
+     * 
+ * + * .google.datastore.v1.EntityResult.ResultType entity_result_type = 1; + * + * @param value The enum numeric value on the wire for entityResultType to set. + * @return This builder for chaining. + */ + public Builder setEntityResultTypeValue(int value) { + entityResultType_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The result type for every entity in `entity_results`.
+     * 
+ * + * .google.datastore.v1.EntityResult.ResultType entity_result_type = 1; + * + * @return The entityResultType. + */ + @java.lang.Override + public com.google.datastore.v1.EntityResult.ResultType getEntityResultType() { + com.google.datastore.v1.EntityResult.ResultType result = + com.google.datastore.v1.EntityResult.ResultType.forNumber(entityResultType_); + return result == null ? com.google.datastore.v1.EntityResult.ResultType.UNRECOGNIZED : result; + } + + /** + * + * + *
+     * The result type for every entity in `entity_results`.
+     * 
+ * + * .google.datastore.v1.EntityResult.ResultType entity_result_type = 1; + * + * @param value The entityResultType to set. + * @return This builder for chaining. + */ + public Builder setEntityResultType(com.google.datastore.v1.EntityResult.ResultType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000004; + entityResultType_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The result type for every entity in `entity_results`.
+     * 
+ * + * .google.datastore.v1.EntityResult.ResultType entity_result_type = 1; + * + * @return This builder for chaining. + */ + public Builder clearEntityResultType() { + bitField0_ = (bitField0_ & ~0x00000004); + entityResultType_ = 0; + onChanged(); + return this; + } + + private java.util.List entityResults_ = + java.util.Collections.emptyList(); + + private void ensureEntityResultsIsMutable() { + if (!((bitField0_ & 0x00000008) != 0)) { + entityResults_ = + new java.util.ArrayList(entityResults_); + bitField0_ |= 0x00000008; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.EntityResult, + com.google.datastore.v1.EntityResult.Builder, + com.google.datastore.v1.EntityResultOrBuilder> + entityResultsBuilder_; + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public java.util.List getEntityResultsList() { + if (entityResultsBuilder_ == null) { + return java.util.Collections.unmodifiableList(entityResults_); + } else { + return entityResultsBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public int getEntityResultsCount() { + if (entityResultsBuilder_ == null) { + return entityResults_.size(); + } else { + return entityResultsBuilder_.getCount(); + } + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public com.google.datastore.v1.EntityResult getEntityResults(int index) { + if (entityResultsBuilder_ == null) { + return entityResults_.get(index); + } else { + return entityResultsBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public Builder setEntityResults(int index, com.google.datastore.v1.EntityResult value) { + if (entityResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEntityResultsIsMutable(); + entityResults_.set(index, value); + onChanged(); + } else { + entityResultsBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public Builder setEntityResults( + int index, com.google.datastore.v1.EntityResult.Builder builderForValue) { + if (entityResultsBuilder_ == null) { + ensureEntityResultsIsMutable(); + entityResults_.set(index, builderForValue.build()); + onChanged(); + } else { + entityResultsBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public Builder addEntityResults(com.google.datastore.v1.EntityResult value) { + if (entityResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEntityResultsIsMutable(); + entityResults_.add(value); + onChanged(); + } else { + entityResultsBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public Builder addEntityResults(int index, com.google.datastore.v1.EntityResult value) { + if (entityResultsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureEntityResultsIsMutable(); + entityResults_.add(index, value); + onChanged(); + } else { + entityResultsBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public Builder addEntityResults(com.google.datastore.v1.EntityResult.Builder builderForValue) { + if (entityResultsBuilder_ == null) { + ensureEntityResultsIsMutable(); + entityResults_.add(builderForValue.build()); + onChanged(); + } else { + entityResultsBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public Builder addEntityResults( + int index, com.google.datastore.v1.EntityResult.Builder builderForValue) { + if (entityResultsBuilder_ == null) { + ensureEntityResultsIsMutable(); + entityResults_.add(index, builderForValue.build()); + onChanged(); + } else { + entityResultsBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public Builder addAllEntityResults( + java.lang.Iterable values) { + if (entityResultsBuilder_ == null) { + ensureEntityResultsIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, entityResults_); + onChanged(); + } else { + entityResultsBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public Builder clearEntityResults() { + if (entityResultsBuilder_ == null) { + entityResults_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000008); + onChanged(); + } else { + entityResultsBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public Builder removeEntityResults(int index) { + if (entityResultsBuilder_ == null) { + ensureEntityResultsIsMutable(); + entityResults_.remove(index); + onChanged(); + } else { + entityResultsBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public com.google.datastore.v1.EntityResult.Builder getEntityResultsBuilder(int index) { + return getEntityResultsFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public com.google.datastore.v1.EntityResultOrBuilder getEntityResultsOrBuilder(int index) { + if (entityResultsBuilder_ == null) { + return entityResults_.get(index); + } else { + return entityResultsBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public java.util.List + getEntityResultsOrBuilderList() { + if (entityResultsBuilder_ != null) { + return entityResultsBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(entityResults_); + } + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public com.google.datastore.v1.EntityResult.Builder addEntityResultsBuilder() { + return getEntityResultsFieldBuilder() + .addBuilder(com.google.datastore.v1.EntityResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public com.google.datastore.v1.EntityResult.Builder addEntityResultsBuilder(int index) { + return getEntityResultsFieldBuilder() + .addBuilder(index, com.google.datastore.v1.EntityResult.getDefaultInstance()); + } + + /** + * + * + *
+     * The results for this batch.
+     * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + public java.util.List + getEntityResultsBuilderList() { + return getEntityResultsFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.EntityResult, + com.google.datastore.v1.EntityResult.Builder, + com.google.datastore.v1.EntityResultOrBuilder> + getEntityResultsFieldBuilder() { + if (entityResultsBuilder_ == null) { + entityResultsBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.EntityResult, + com.google.datastore.v1.EntityResult.Builder, + com.google.datastore.v1.EntityResultOrBuilder>( + entityResults_, + ((bitField0_ & 0x00000008) != 0), + getParentForChildren(), + isClean()); + entityResults_ = null; + } + return entityResultsBuilder_; + } + + private com.google.protobuf.ByteString endCursor_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * A cursor that points to the position after the last result in the batch.
+     * 
+ * + * bytes end_cursor = 4; + * + * @return The endCursor. + */ + @java.lang.Override + public com.google.protobuf.ByteString getEndCursor() { + return endCursor_; + } + + /** + * + * + *
+     * A cursor that points to the position after the last result in the batch.
+     * 
+ * + * bytes end_cursor = 4; + * + * @param value The endCursor to set. + * @return This builder for chaining. + */ + public Builder setEndCursor(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + endCursor_ = value; + bitField0_ |= 0x00000010; + onChanged(); + return this; + } + + /** + * + * + *
+     * A cursor that points to the position after the last result in the batch.
+     * 
+ * + * bytes end_cursor = 4; + * + * @return This builder for chaining. + */ + public Builder clearEndCursor() { + bitField0_ = (bitField0_ & ~0x00000010); + endCursor_ = getDefaultInstance().getEndCursor(); + onChanged(); + return this; + } + + private int moreResults_ = 0; + + /** + * + * + *
+     * The state of the query after the current batch.
+     * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5; + * + * @return The enum numeric value on the wire for moreResults. + */ + @java.lang.Override + public int getMoreResultsValue() { + return moreResults_; + } + + /** + * + * + *
+     * The state of the query after the current batch.
+     * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5; + * + * @param value The enum numeric value on the wire for moreResults to set. + * @return This builder for chaining. + */ + public Builder setMoreResultsValue(int value) { + moreResults_ = value; + bitField0_ |= 0x00000020; + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the query after the current batch.
+     * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5; + * + * @return The moreResults. + */ + @java.lang.Override + public com.google.datastore.v1.QueryResultBatch.MoreResultsType getMoreResults() { + com.google.datastore.v1.QueryResultBatch.MoreResultsType result = + com.google.datastore.v1.QueryResultBatch.MoreResultsType.forNumber(moreResults_); + return result == null + ? com.google.datastore.v1.QueryResultBatch.MoreResultsType.UNRECOGNIZED + : result; + } + + /** + * + * + *
+     * The state of the query after the current batch.
+     * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5; + * + * @param value The moreResults to set. + * @return This builder for chaining. + */ + public Builder setMoreResults(com.google.datastore.v1.QueryResultBatch.MoreResultsType value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000020; + moreResults_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The state of the query after the current batch.
+     * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5; + * + * @return This builder for chaining. + */ + public Builder clearMoreResults() { + bitField0_ = (bitField0_ & ~0x00000020); + moreResults_ = 0; + onChanged(); + return this; + } + + private long snapshotVersion_; + + /** + * + * + *
+     * The version number of the snapshot this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater snapshot version number. Each batch's snapshot version
+     * is valid for all preceding batches.
+     * The value will be zero for eventually consistent queries.
+     * 
+ * + * int64 snapshot_version = 7; + * + * @return The snapshotVersion. + */ + @java.lang.Override + public long getSnapshotVersion() { + return snapshotVersion_; + } + + /** + * + * + *
+     * The version number of the snapshot this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater snapshot version number. Each batch's snapshot version
+     * is valid for all preceding batches.
+     * The value will be zero for eventually consistent queries.
+     * 
+ * + * int64 snapshot_version = 7; + * + * @param value The snapshotVersion to set. + * @return This builder for chaining. + */ + public Builder setSnapshotVersion(long value) { + + snapshotVersion_ = value; + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The version number of the snapshot this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater snapshot version number. Each batch's snapshot version
+     * is valid for all preceding batches.
+     * The value will be zero for eventually consistent queries.
+     * 
+ * + * int64 snapshot_version = 7; + * + * @return This builder for chaining. + */ + public Builder clearSnapshotVersion() { + bitField0_ = (bitField0_ & ~0x00000040); + snapshotVersion_ = 0L; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * This value will not be set for eventually consistent queries in Cloud
+     * Datastore.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 8; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000080) != 0); + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * This value will not be set for eventually consistent queries in Cloud
+     * Datastore.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 8; + * + * @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(); + } + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * This value will not be set for eventually consistent queries in Cloud
+     * Datastore.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 8; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readTime_ = value; + } else { + readTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * This value will not be set for eventually consistent queries in Cloud
+     * Datastore.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 8; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + readTime_ = builderForValue.build(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * This value will not be set for eventually consistent queries in Cloud
+     * Datastore.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 8; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (((bitField0_ & 0x00000080) != 0) + && readTime_ != null + && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getReadTimeBuilder().mergeFrom(value); + } else { + readTime_ = value; + } + } else { + readTimeBuilder_.mergeFrom(value); + } + if (readTime_ != null) { + bitField0_ |= 0x00000080; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * This value will not be set for eventually consistent queries in Cloud
+     * Datastore.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 8; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000080); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * This value will not be set for eventually consistent queries in Cloud
+     * Datastore.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 8; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000080; + onChanged(); + return getReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * This value will not be set for eventually consistent queries in Cloud
+     * Datastore.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 8; + */ + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (readTimeBuilder_ != null) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + } + + /** + * + * + *
+     * Read timestamp this batch was returned from.
+     * This applies to the range of results from the query's `start_cursor` (or
+     * the beginning of the query if no cursor was given) to this batch's
+     * `end_cursor` (not the query's `end_cursor`).
+     *
+     * In a single transaction, subsequent query result batches for the same query
+     * can have a greater timestamp. Each batch's read timestamp
+     * is valid for all preceding batches.
+     * This value will not be set for eventually consistent queries in Cloud
+     * Datastore.
+     * 
+ * + * .google.protobuf.Timestamp read_time = 8; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.QueryResultBatch) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.QueryResultBatch) + private static final com.google.datastore.v1.QueryResultBatch DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.QueryResultBatch(); + } + + public static com.google.datastore.v1.QueryResultBatch getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public QueryResultBatch 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.datastore.v1.QueryResultBatch getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatchOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatchOrBuilder.java new file mode 100644 index 000000000000..c6981a114300 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/QueryResultBatchOrBuilder.java @@ -0,0 +1,259 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/query.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface QueryResultBatchOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.QueryResultBatch) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The number of results skipped, typically because of an offset.
+   * 
+ * + * int32 skipped_results = 6; + * + * @return The skippedResults. + */ + int getSkippedResults(); + + /** + * + * + *
+   * A cursor that points to the position after the last skipped result.
+   * Will be set when `skipped_results` != 0.
+   * 
+ * + * bytes skipped_cursor = 3; + * + * @return The skippedCursor. + */ + com.google.protobuf.ByteString getSkippedCursor(); + + /** + * + * + *
+   * The result type for every entity in `entity_results`.
+   * 
+ * + * .google.datastore.v1.EntityResult.ResultType entity_result_type = 1; + * + * @return The enum numeric value on the wire for entityResultType. + */ + int getEntityResultTypeValue(); + + /** + * + * + *
+   * The result type for every entity in `entity_results`.
+   * 
+ * + * .google.datastore.v1.EntityResult.ResultType entity_result_type = 1; + * + * @return The entityResultType. + */ + com.google.datastore.v1.EntityResult.ResultType getEntityResultType(); + + /** + * + * + *
+   * The results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + java.util.List getEntityResultsList(); + + /** + * + * + *
+   * The results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + com.google.datastore.v1.EntityResult getEntityResults(int index); + + /** + * + * + *
+   * The results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + int getEntityResultsCount(); + + /** + * + * + *
+   * The results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + java.util.List + getEntityResultsOrBuilderList(); + + /** + * + * + *
+   * The results for this batch.
+   * 
+ * + * repeated .google.datastore.v1.EntityResult entity_results = 2; + */ + com.google.datastore.v1.EntityResultOrBuilder getEntityResultsOrBuilder(int index); + + /** + * + * + *
+   * A cursor that points to the position after the last result in the batch.
+   * 
+ * + * bytes end_cursor = 4; + * + * @return The endCursor. + */ + com.google.protobuf.ByteString getEndCursor(); + + /** + * + * + *
+   * The state of the query after the current batch.
+   * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5; + * + * @return The enum numeric value on the wire for moreResults. + */ + int getMoreResultsValue(); + + /** + * + * + *
+   * The state of the query after the current batch.
+   * 
+ * + * .google.datastore.v1.QueryResultBatch.MoreResultsType more_results = 5; + * + * @return The moreResults. + */ + com.google.datastore.v1.QueryResultBatch.MoreResultsType getMoreResults(); + + /** + * + * + *
+   * The version number of the snapshot this batch was returned from.
+   * This applies to the range of results from the query's `start_cursor` (or
+   * the beginning of the query if no cursor was given) to this batch's
+   * `end_cursor` (not the query's `end_cursor`).
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater snapshot version number. Each batch's snapshot version
+   * is valid for all preceding batches.
+   * The value will be zero for eventually consistent queries.
+   * 
+ * + * int64 snapshot_version = 7; + * + * @return The snapshotVersion. + */ + long getSnapshotVersion(); + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   * This applies to the range of results from the query's `start_cursor` (or
+   * the beginning of the query if no cursor was given) to this batch's
+   * `end_cursor` (not the query's `end_cursor`).
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * This value will not be set for eventually consistent queries in Cloud
+   * Datastore.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 8; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   * This applies to the range of results from the query's `start_cursor` (or
+   * the beginning of the query if no cursor was given) to this batch's
+   * `end_cursor` (not the query's `end_cursor`).
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * This value will not be set for eventually consistent queries in Cloud
+   * Datastore.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 8; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+   * Read timestamp this batch was returned from.
+   * This applies to the range of results from the query's `start_cursor` (or
+   * the beginning of the query if no cursor was given) to this batch's
+   * `end_cursor` (not the query's `end_cursor`).
+   *
+   * In a single transaction, subsequent query result batches for the same query
+   * can have a greater timestamp. Each batch's read timestamp
+   * is valid for all preceding batches.
+   * This value will not be set for eventually consistent queries in Cloud
+   * Datastore.
+   * 
+ * + * .google.protobuf.Timestamp read_time = 8; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptions.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptions.java new file mode 100644 index 000000000000..78a93952b61c --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptions.java @@ -0,0 +1,1789 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The options shared by read requests.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.ReadOptions} + */ +public final class ReadOptions extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.ReadOptions) + ReadOptionsOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ReadOptions.newBuilder() to construct. + private ReadOptions(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ReadOptions() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ReadOptions(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReadOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReadOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ReadOptions.class, + com.google.datastore.v1.ReadOptions.Builder.class); + } + + /** + * + * + *
+   * The possible values for read consistencies.
+   * 
+ * + * Protobuf enum {@code google.datastore.v1.ReadOptions.ReadConsistency} + */ + public enum ReadConsistency implements com.google.protobuf.ProtocolMessageEnum { + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * READ_CONSISTENCY_UNSPECIFIED = 0; + */ + READ_CONSISTENCY_UNSPECIFIED(0), + /** + * + * + *
+     * Strong consistency.
+     * 
+ * + * STRONG = 1; + */ + STRONG(1), + /** + * + * + *
+     * Eventual consistency.
+     * 
+ * + * EVENTUAL = 2; + */ + EVENTUAL(2), + UNRECOGNIZED(-1), + ; + + /** + * + * + *
+     * Unspecified. This value must not be used.
+     * 
+ * + * READ_CONSISTENCY_UNSPECIFIED = 0; + */ + public static final int READ_CONSISTENCY_UNSPECIFIED_VALUE = 0; + + /** + * + * + *
+     * Strong consistency.
+     * 
+ * + * STRONG = 1; + */ + public static final int STRONG_VALUE = 1; + + /** + * + * + *
+     * Eventual consistency.
+     * 
+ * + * EVENTUAL = 2; + */ + public static final int EVENTUAL_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 ReadConsistency 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 ReadConsistency forNumber(int value) { + switch (value) { + case 0: + return READ_CONSISTENCY_UNSPECIFIED; + case 1: + return STRONG; + case 2: + return EVENTUAL; + 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 ReadConsistency findValueByNumber(int number) { + return ReadConsistency.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 final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { + return com.google.datastore.v1.ReadOptions.getDescriptor().getEnumTypes().get(0); + } + + private static final ReadConsistency[] VALUES = values(); + + public static ReadConsistency 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 ReadConsistency(int value) { + this.value = value; + } + + // @@protoc_insertion_point(enum_scope:google.datastore.v1.ReadOptions.ReadConsistency) + } + + private int consistencyTypeCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object consistencyType_; + + public enum ConsistencyTypeCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + READ_CONSISTENCY(1), + TRANSACTION(2), + NEW_TRANSACTION(3), + READ_TIME(4), + CONSISTENCYTYPE_NOT_SET(0); + private final int value; + + private ConsistencyTypeCase(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 ConsistencyTypeCase valueOf(int value) { + return forNumber(value); + } + + public static ConsistencyTypeCase forNumber(int value) { + switch (value) { + case 1: + return READ_CONSISTENCY; + case 2: + return TRANSACTION; + case 3: + return NEW_TRANSACTION; + case 4: + return READ_TIME; + case 0: + return CONSISTENCYTYPE_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ConsistencyTypeCase getConsistencyTypeCase() { + return ConsistencyTypeCase.forNumber(consistencyTypeCase_); + } + + public static final int READ_CONSISTENCY_FIELD_NUMBER = 1; + + /** + * + * + *
+   * The non-transactional read consistency to use.
+   * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @return Whether the readConsistency field is set. + */ + public boolean hasReadConsistency() { + return consistencyTypeCase_ == 1; + } + + /** + * + * + *
+   * The non-transactional read consistency to use.
+   * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @return The enum numeric value on the wire for readConsistency. + */ + public int getReadConsistencyValue() { + if (consistencyTypeCase_ == 1) { + return (java.lang.Integer) consistencyType_; + } + return 0; + } + + /** + * + * + *
+   * The non-transactional read consistency to use.
+   * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @return The readConsistency. + */ + public com.google.datastore.v1.ReadOptions.ReadConsistency getReadConsistency() { + if (consistencyTypeCase_ == 1) { + com.google.datastore.v1.ReadOptions.ReadConsistency result = + com.google.datastore.v1.ReadOptions.ReadConsistency.forNumber( + (java.lang.Integer) consistencyType_); + return result == null + ? com.google.datastore.v1.ReadOptions.ReadConsistency.UNRECOGNIZED + : result; + } + return com.google.datastore.v1.ReadOptions.ReadConsistency.READ_CONSISTENCY_UNSPECIFIED; + } + + public static final int TRANSACTION_FIELD_NUMBER = 2; + + /** + * + * + *
+   * The identifier of the transaction in which to read. A
+   * transaction identifier is returned by a call to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * bytes transaction = 2; + * + * @return Whether the transaction field is set. + */ + @java.lang.Override + public boolean hasTransaction() { + return consistencyTypeCase_ == 2; + } + + /** + * + * + *
+   * The identifier of the transaction in which to read. A
+   * transaction identifier is returned by a call to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * bytes transaction = 2; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + if (consistencyTypeCase_ == 2) { + return (com.google.protobuf.ByteString) consistencyType_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + public static final int NEW_TRANSACTION_FIELD_NUMBER = 3; + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   *
+   * The new transaction identifier will be returned in the corresponding
+   * response as either
+   * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+   * or
+   * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+   * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencyTypeCase_ == 3; + } + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   *
+   * The new transaction identifier will be returned in the corresponding
+   * response as either
+   * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+   * or
+   * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+   * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions getNewTransaction() { + if (consistencyTypeCase_ == 3) { + return (com.google.datastore.v1.TransactionOptions) consistencyType_; + } + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   *
+   * The new transaction identifier will be returned in the corresponding
+   * response as either
+   * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+   * or
+   * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+   * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if (consistencyTypeCase_ == 3) { + return (com.google.datastore.v1.TransactionOptions) consistencyType_; + } + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + + public static final int READ_TIME_FIELD_NUMBER = 4; + + /** + * + * + *
+   * Reads entities as they were at the given time. This value is only
+   * supported for Cloud Firestore in Datastore mode.
+   *
+   * 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 consistencyTypeCase_ == 4; + } + + /** + * + * + *
+   * Reads entities as they were at the given time. This value is only
+   * supported for Cloud Firestore in Datastore mode.
+   *
+   * 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 (consistencyTypeCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencyType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + + /** + * + * + *
+   * Reads entities as they were at the given time. This value is only
+   * supported for Cloud Firestore in Datastore mode.
+   *
+   * 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 (consistencyTypeCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencyType_; + } + 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 (consistencyTypeCase_ == 1) { + output.writeEnum(1, ((java.lang.Integer) consistencyType_)); + } + if (consistencyTypeCase_ == 2) { + output.writeBytes(2, (com.google.protobuf.ByteString) consistencyType_); + } + if (consistencyTypeCase_ == 3) { + output.writeMessage(3, (com.google.datastore.v1.TransactionOptions) consistencyType_); + } + if (consistencyTypeCase_ == 4) { + output.writeMessage(4, (com.google.protobuf.Timestamp) consistencyType_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (consistencyTypeCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeEnumSize( + 1, ((java.lang.Integer) consistencyType_)); + } + if (consistencyTypeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 2, (com.google.protobuf.ByteString) consistencyType_); + } + if (consistencyTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.datastore.v1.TransactionOptions) consistencyType_); + } + if (consistencyTypeCase_ == 4) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 4, (com.google.protobuf.Timestamp) consistencyType_); + } + 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.datastore.v1.ReadOptions)) { + return super.equals(obj); + } + com.google.datastore.v1.ReadOptions other = (com.google.datastore.v1.ReadOptions) obj; + + if (!getConsistencyTypeCase().equals(other.getConsistencyTypeCase())) return false; + switch (consistencyTypeCase_) { + case 1: + if (getReadConsistencyValue() != other.getReadConsistencyValue()) return false; + break; + case 2: + if (!getTransaction().equals(other.getTransaction())) return false; + break; + case 3: + if (!getNewTransaction().equals(other.getNewTransaction())) return false; + break; + 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(); + switch (consistencyTypeCase_) { + case 1: + hash = (37 * hash) + READ_CONSISTENCY_FIELD_NUMBER; + hash = (53 * hash) + getReadConsistencyValue(); + break; + case 2: + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().hashCode(); + break; + case 3: + hash = (37 * hash) + NEW_TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getNewTransaction().hashCode(); + break; + 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.datastore.v1.ReadOptions parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ReadOptions parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.ReadOptions parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ReadOptions 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.datastore.v1.ReadOptions parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ReadOptions parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.ReadOptions parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ReadOptions parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ReadOptions parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ReadOptions parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ReadOptions parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ReadOptions parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.ReadOptions 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The options shared by read requests.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.ReadOptions} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.ReadOptions) + com.google.datastore.v1.ReadOptionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReadOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReadOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ReadOptions.class, + com.google.datastore.v1.ReadOptions.Builder.class); + } + + // Construct using com.google.datastore.v1.ReadOptions.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (newTransactionBuilder_ != null) { + newTransactionBuilder_.clear(); + } + if (readTimeBuilder_ != null) { + readTimeBuilder_.clear(); + } + consistencyTypeCase_ = 0; + consistencyType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReadOptions_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.ReadOptions getDefaultInstanceForType() { + return com.google.datastore.v1.ReadOptions.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.ReadOptions build() { + com.google.datastore.v1.ReadOptions result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.ReadOptions buildPartial() { + com.google.datastore.v1.ReadOptions result = new com.google.datastore.v1.ReadOptions(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.ReadOptions result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.datastore.v1.ReadOptions result) { + result.consistencyTypeCase_ = consistencyTypeCase_; + result.consistencyType_ = this.consistencyType_; + if (consistencyTypeCase_ == 3 && newTransactionBuilder_ != null) { + result.consistencyType_ = newTransactionBuilder_.build(); + } + if (consistencyTypeCase_ == 4 && readTimeBuilder_ != null) { + result.consistencyType_ = readTimeBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.ReadOptions) { + return mergeFrom((com.google.datastore.v1.ReadOptions) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.ReadOptions other) { + if (other == com.google.datastore.v1.ReadOptions.getDefaultInstance()) return this; + switch (other.getConsistencyTypeCase()) { + case READ_CONSISTENCY: + { + setReadConsistencyValue(other.getReadConsistencyValue()); + break; + } + case TRANSACTION: + { + setTransaction(other.getTransaction()); + break; + } + case NEW_TRANSACTION: + { + mergeNewTransaction(other.getNewTransaction()); + break; + } + case READ_TIME: + { + mergeReadTime(other.getReadTime()); + break; + } + case CONSISTENCYTYPE_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: + { + int rawValue = input.readEnum(); + consistencyTypeCase_ = 1; + consistencyType_ = rawValue; + break; + } // case 8 + case 18: + { + consistencyType_ = input.readBytes(); + consistencyTypeCase_ = 2; + break; + } // case 18 + case 26: + { + input.readMessage(getNewTransactionFieldBuilder().getBuilder(), extensionRegistry); + consistencyTypeCase_ = 3; + break; + } // case 26 + case 34: + { + input.readMessage(getReadTimeFieldBuilder().getBuilder(), extensionRegistry); + consistencyTypeCase_ = 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 consistencyTypeCase_ = 0; + private java.lang.Object consistencyType_; + + public ConsistencyTypeCase getConsistencyTypeCase() { + return ConsistencyTypeCase.forNumber(consistencyTypeCase_); + } + + public Builder clearConsistencyType() { + consistencyTypeCase_ = 0; + consistencyType_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + /** + * + * + *
+     * The non-transactional read consistency to use.
+     * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @return Whether the readConsistency field is set. + */ + @java.lang.Override + public boolean hasReadConsistency() { + return consistencyTypeCase_ == 1; + } + + /** + * + * + *
+     * The non-transactional read consistency to use.
+     * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @return The enum numeric value on the wire for readConsistency. + */ + @java.lang.Override + public int getReadConsistencyValue() { + if (consistencyTypeCase_ == 1) { + return ((java.lang.Integer) consistencyType_).intValue(); + } + return 0; + } + + /** + * + * + *
+     * The non-transactional read consistency to use.
+     * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @param value The enum numeric value on the wire for readConsistency to set. + * @return This builder for chaining. + */ + public Builder setReadConsistencyValue(int value) { + consistencyTypeCase_ = 1; + consistencyType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * The non-transactional read consistency to use.
+     * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @return The readConsistency. + */ + @java.lang.Override + public com.google.datastore.v1.ReadOptions.ReadConsistency getReadConsistency() { + if (consistencyTypeCase_ == 1) { + com.google.datastore.v1.ReadOptions.ReadConsistency result = + com.google.datastore.v1.ReadOptions.ReadConsistency.forNumber( + (java.lang.Integer) consistencyType_); + return result == null + ? com.google.datastore.v1.ReadOptions.ReadConsistency.UNRECOGNIZED + : result; + } + return com.google.datastore.v1.ReadOptions.ReadConsistency.READ_CONSISTENCY_UNSPECIFIED; + } + + /** + * + * + *
+     * The non-transactional read consistency to use.
+     * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @param value The readConsistency to set. + * @return This builder for chaining. + */ + public Builder setReadConsistency(com.google.datastore.v1.ReadOptions.ReadConsistency value) { + if (value == null) { + throw new NullPointerException(); + } + consistencyTypeCase_ = 1; + consistencyType_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * + * + *
+     * The non-transactional read consistency to use.
+     * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @return This builder for chaining. + */ + public Builder clearReadConsistency() { + if (consistencyTypeCase_ == 1) { + consistencyTypeCase_ = 0; + consistencyType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The identifier of the transaction in which to read. A
+     * transaction identifier is returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * bytes transaction = 2; + * + * @return Whether the transaction field is set. + */ + public boolean hasTransaction() { + return consistencyTypeCase_ == 2; + } + + /** + * + * + *
+     * The identifier of the transaction in which to read. A
+     * transaction identifier is returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * bytes transaction = 2; + * + * @return The transaction. + */ + public com.google.protobuf.ByteString getTransaction() { + if (consistencyTypeCase_ == 2) { + return (com.google.protobuf.ByteString) consistencyType_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * The identifier of the transaction in which to read. A
+     * transaction identifier is returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * 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(); + } + consistencyTypeCase_ = 2; + consistencyType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * The identifier of the transaction in which to read. A
+     * transaction identifier is returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * bytes transaction = 2; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + if (consistencyTypeCase_ == 2) { + consistencyTypeCase_ = 0; + consistencyType_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions, + com.google.datastore.v1.TransactionOptions.Builder, + com.google.datastore.v1.TransactionOptionsOrBuilder> + newTransactionBuilder_; + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     *
+     * The new transaction identifier will be returned in the corresponding
+     * response as either
+     * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+     * or
+     * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+     * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + * + * @return Whether the newTransaction field is set. + */ + @java.lang.Override + public boolean hasNewTransaction() { + return consistencyTypeCase_ == 3; + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     *
+     * The new transaction identifier will be returned in the corresponding
+     * response as either
+     * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+     * or
+     * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+     * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + * + * @return The newTransaction. + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions getNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencyTypeCase_ == 3) { + return (com.google.datastore.v1.TransactionOptions) consistencyType_; + } + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } else { + if (consistencyTypeCase_ == 3) { + return newTransactionBuilder_.getMessage(); + } + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     *
+     * The new transaction identifier will be returned in the corresponding
+     * response as either
+     * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+     * or
+     * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+     * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + */ + public Builder setNewTransaction(com.google.datastore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + consistencyType_ = value; + onChanged(); + } else { + newTransactionBuilder_.setMessage(value); + } + consistencyTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     *
+     * The new transaction identifier will be returned in the corresponding
+     * response as either
+     * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+     * or
+     * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+     * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + */ + public Builder setNewTransaction( + com.google.datastore.v1.TransactionOptions.Builder builderForValue) { + if (newTransactionBuilder_ == null) { + consistencyType_ = builderForValue.build(); + onChanged(); + } else { + newTransactionBuilder_.setMessage(builderForValue.build()); + } + consistencyTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     *
+     * The new transaction identifier will be returned in the corresponding
+     * response as either
+     * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+     * or
+     * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+     * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + */ + public Builder mergeNewTransaction(com.google.datastore.v1.TransactionOptions value) { + if (newTransactionBuilder_ == null) { + if (consistencyTypeCase_ == 3 + && consistencyType_ + != com.google.datastore.v1.TransactionOptions.getDefaultInstance()) { + consistencyType_ = + com.google.datastore.v1.TransactionOptions.newBuilder( + (com.google.datastore.v1.TransactionOptions) consistencyType_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencyType_ = value; + } + onChanged(); + } else { + if (consistencyTypeCase_ == 3) { + newTransactionBuilder_.mergeFrom(value); + } else { + newTransactionBuilder_.setMessage(value); + } + } + consistencyTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     *
+     * The new transaction identifier will be returned in the corresponding
+     * response as either
+     * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+     * or
+     * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+     * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + */ + public Builder clearNewTransaction() { + if (newTransactionBuilder_ == null) { + if (consistencyTypeCase_ == 3) { + consistencyTypeCase_ = 0; + consistencyType_ = null; + onChanged(); + } + } else { + if (consistencyTypeCase_ == 3) { + consistencyTypeCase_ = 0; + consistencyType_ = null; + } + newTransactionBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     *
+     * The new transaction identifier will be returned in the corresponding
+     * response as either
+     * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+     * or
+     * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+     * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + */ + public com.google.datastore.v1.TransactionOptions.Builder getNewTransactionBuilder() { + return getNewTransactionFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     *
+     * The new transaction identifier will be returned in the corresponding
+     * response as either
+     * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+     * or
+     * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+     * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder() { + if ((consistencyTypeCase_ == 3) && (newTransactionBuilder_ != null)) { + return newTransactionBuilder_.getMessageOrBuilder(); + } else { + if (consistencyTypeCase_ == 3) { + return (com.google.datastore.v1.TransactionOptions) consistencyType_; + } + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Options for beginning a new transaction for this request.
+     *
+     * The new transaction identifier will be returned in the corresponding
+     * response as either
+     * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+     * or
+     * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+     * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions, + com.google.datastore.v1.TransactionOptions.Builder, + com.google.datastore.v1.TransactionOptionsOrBuilder> + getNewTransactionFieldBuilder() { + if (newTransactionBuilder_ == null) { + if (!(consistencyTypeCase_ == 3)) { + consistencyType_ = com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + newTransactionBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions, + com.google.datastore.v1.TransactionOptions.Builder, + com.google.datastore.v1.TransactionOptionsOrBuilder>( + (com.google.datastore.v1.TransactionOptions) consistencyType_, + getParentForChildren(), + isClean()); + consistencyType_ = null; + } + consistencyTypeCase_ = 3; + onChanged(); + return newTransactionBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+     * Reads entities as they were at the given time. This value is only
+     * supported for Cloud Firestore in Datastore mode.
+     *
+     * 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 consistencyTypeCase_ == 4; + } + + /** + * + * + *
+     * Reads entities as they were at the given time. This value is only
+     * supported for Cloud Firestore in Datastore mode.
+     *
+     * 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 (consistencyTypeCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencyType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } else { + if (consistencyTypeCase_ == 4) { + return readTimeBuilder_.getMessage(); + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads entities as they were at the given time. This value is only
+     * supported for Cloud Firestore in Datastore mode.
+     *
+     * 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(); + } + consistencyType_ = value; + onChanged(); + } else { + readTimeBuilder_.setMessage(value); + } + consistencyTypeCase_ = 4; + return this; + } + + /** + * + * + *
+     * Reads entities as they were at the given time. This value is only
+     * supported for Cloud Firestore in Datastore mode.
+     *
+     * 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) { + consistencyType_ = builderForValue.build(); + onChanged(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + consistencyTypeCase_ = 4; + return this; + } + + /** + * + * + *
+     * Reads entities as they were at the given time. This value is only
+     * supported for Cloud Firestore in Datastore mode.
+     *
+     * 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 (consistencyTypeCase_ == 4 + && consistencyType_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + consistencyType_ = + com.google.protobuf.Timestamp.newBuilder( + (com.google.protobuf.Timestamp) consistencyType_) + .mergeFrom(value) + .buildPartial(); + } else { + consistencyType_ = value; + } + onChanged(); + } else { + if (consistencyTypeCase_ == 4) { + readTimeBuilder_.mergeFrom(value); + } else { + readTimeBuilder_.setMessage(value); + } + } + consistencyTypeCase_ = 4; + return this; + } + + /** + * + * + *
+     * Reads entities as they were at the given time. This value is only
+     * supported for Cloud Firestore in Datastore mode.
+     *
+     * 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 (consistencyTypeCase_ == 4) { + consistencyTypeCase_ = 0; + consistencyType_ = null; + onChanged(); + } + } else { + if (consistencyTypeCase_ == 4) { + consistencyTypeCase_ = 0; + consistencyType_ = null; + } + readTimeBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Reads entities as they were at the given time. This value is only
+     * supported for Cloud Firestore in Datastore mode.
+     *
+     * 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 getReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Reads entities as they were at the given time. This value is only
+     * supported for Cloud Firestore in Datastore mode.
+     *
+     * 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 ((consistencyTypeCase_ == 4) && (readTimeBuilder_ != null)) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + if (consistencyTypeCase_ == 4) { + return (com.google.protobuf.Timestamp) consistencyType_; + } + return com.google.protobuf.Timestamp.getDefaultInstance(); + } + } + + /** + * + * + *
+     * Reads entities as they were at the given time. This value is only
+     * supported for Cloud Firestore in Datastore mode.
+     *
+     * 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.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + if (!(consistencyTypeCase_ == 4)) { + consistencyType_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + (com.google.protobuf.Timestamp) consistencyType_, + getParentForChildren(), + isClean()); + consistencyType_ = null; + } + consistencyTypeCase_ = 4; + onChanged(); + return readTimeBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.ReadOptions) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.ReadOptions) + private static final com.google.datastore.v1.ReadOptions DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.ReadOptions(); + } + + public static com.google.datastore.v1.ReadOptions getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ReadOptions 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.datastore.v1.ReadOptions getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptionsOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptionsOrBuilder.java new file mode 100644 index 000000000000..f2de0cd09537 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReadOptionsOrBuilder.java @@ -0,0 +1,204 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface ReadOptionsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.ReadOptions) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The non-transactional read consistency to use.
+   * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @return Whether the readConsistency field is set. + */ + boolean hasReadConsistency(); + + /** + * + * + *
+   * The non-transactional read consistency to use.
+   * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @return The enum numeric value on the wire for readConsistency. + */ + int getReadConsistencyValue(); + + /** + * + * + *
+   * The non-transactional read consistency to use.
+   * 
+ * + * .google.datastore.v1.ReadOptions.ReadConsistency read_consistency = 1; + * + * @return The readConsistency. + */ + com.google.datastore.v1.ReadOptions.ReadConsistency getReadConsistency(); + + /** + * + * + *
+   * The identifier of the transaction in which to read. A
+   * transaction identifier is returned by a call to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * bytes transaction = 2; + * + * @return Whether the transaction field is set. + */ + boolean hasTransaction(); + + /** + * + * + *
+   * The identifier of the transaction in which to read. A
+   * transaction identifier is returned by a call to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * bytes transaction = 2; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   *
+   * The new transaction identifier will be returned in the corresponding
+   * response as either
+   * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+   * or
+   * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+   * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + * + * @return Whether the newTransaction field is set. + */ + boolean hasNewTransaction(); + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   *
+   * The new transaction identifier will be returned in the corresponding
+   * response as either
+   * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+   * or
+   * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+   * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + * + * @return The newTransaction. + */ + com.google.datastore.v1.TransactionOptions getNewTransaction(); + + /** + * + * + *
+   * Options for beginning a new transaction for this request.
+   *
+   * The new transaction identifier will be returned in the corresponding
+   * response as either
+   * [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction]
+   * or
+   * [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction].
+   * 
+ * + * .google.datastore.v1.TransactionOptions new_transaction = 3; + */ + com.google.datastore.v1.TransactionOptionsOrBuilder getNewTransactionOrBuilder(); + + /** + * + * + *
+   * Reads entities as they were at the given time. This value is only
+   * supported for Cloud Firestore in Datastore mode.
+   *
+   * 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 entities as they were at the given time. This value is only
+   * supported for Cloud Firestore in Datastore mode.
+   *
+   * 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 entities as they were at the given time. This value is only
+   * supported for Cloud Firestore in Datastore mode.
+   *
+   * 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.datastore.v1.ReadOptions.ConsistencyTypeCase getConsistencyTypeCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequest.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequest.java new file mode 100644 index 000000000000..f4962f595be9 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequest.java @@ -0,0 +1,1396 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The request for
+ * [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.ReserveIdsRequest} + */ +public final class ReserveIdsRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.ReserveIdsRequest) + ReserveIdsRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ReserveIdsRequest.newBuilder() to construct. + private ReserveIdsRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ReserveIdsRequest() { + projectId_ = ""; + databaseId_ = ""; + keys_ = java.util.Collections.emptyList(); + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ReserveIdsRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReserveIdsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReserveIdsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ReserveIdsRequest.class, + com.google.datastore.v1.ReserveIdsRequest.Builder.class); + } + + public static final int PROJECT_ID_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 9; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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 KEYS_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List keys_; + + /** + * + * + *
+   * Required. A list of keys with complete key paths whose numeric IDs should
+   * not be auto-allocated.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public java.util.List getKeysList() { + return keys_; + } + + /** + * + * + *
+   * Required. A list of keys with complete key paths whose numeric IDs should
+   * not be auto-allocated.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public java.util.List getKeysOrBuilderList() { + return keys_; + } + + /** + * + * + *
+   * Required. A list of keys with complete key paths whose numeric IDs should
+   * not be auto-allocated.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public int getKeysCount() { + return keys_.size(); + } + + /** + * + * + *
+   * Required. A list of keys with complete key paths whose numeric IDs should
+   * not be auto-allocated.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.v1.Key getKeys(int index) { + return keys_.get(index); + } + + /** + * + * + *
+   * Required. A list of keys with complete key paths whose numeric IDs should
+   * not be auto-allocated.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index) { + return keys_.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 < keys_.size(); i++) { + output.writeMessage(1, keys_.get(i)); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, databaseId_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + for (int i = 0; i < keys_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, keys_.get(i)); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, 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.datastore.v1.ReserveIdsRequest)) { + return super.equals(obj); + } + com.google.datastore.v1.ReserveIdsRequest other = + (com.google.datastore.v1.ReserveIdsRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (!getKeysList().equals(other.getKeysList())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + if (getKeysCount() > 0) { + hash = (37 * hash) + KEYS_FIELD_NUMBER; + hash = (53 * hash) + getKeysList().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.ReserveIdsRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ReserveIdsRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.ReserveIdsRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ReserveIdsRequest 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.datastore.v1.ReserveIdsRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ReserveIdsRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.ReserveIdsRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ReserveIdsRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ReserveIdsRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ReserveIdsRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ReserveIdsRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ReserveIdsRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.ReserveIdsRequest 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.ReserveIdsRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.ReserveIdsRequest) + com.google.datastore.v1.ReserveIdsRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReserveIdsRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReserveIdsRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ReserveIdsRequest.class, + com.google.datastore.v1.ReserveIdsRequest.Builder.class); + } + + // Construct using com.google.datastore.v1.ReserveIdsRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + databaseId_ = ""; + if (keysBuilder_ == null) { + keys_ = java.util.Collections.emptyList(); + } else { + keys_ = null; + keysBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000004); + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReserveIdsRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.ReserveIdsRequest getDefaultInstanceForType() { + return com.google.datastore.v1.ReserveIdsRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.ReserveIdsRequest build() { + com.google.datastore.v1.ReserveIdsRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.ReserveIdsRequest buildPartial() { + com.google.datastore.v1.ReserveIdsRequest result = + new com.google.datastore.v1.ReserveIdsRequest(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields(com.google.datastore.v1.ReserveIdsRequest result) { + if (keysBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0)) { + keys_ = java.util.Collections.unmodifiableList(keys_); + bitField0_ = (bitField0_ & ~0x00000004); + } + result.keys_ = keys_; + } else { + result.keys_ = keysBuilder_.build(); + } + } + + private void buildPartial0(com.google.datastore.v1.ReserveIdsRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.ReserveIdsRequest) { + return mergeFrom((com.google.datastore.v1.ReserveIdsRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.ReserveIdsRequest other) { + if (other == com.google.datastore.v1.ReserveIdsRequest.getDefaultInstance()) return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (keysBuilder_ == null) { + if (!other.keys_.isEmpty()) { + if (keys_.isEmpty()) { + keys_ = other.keys_; + bitField0_ = (bitField0_ & ~0x00000004); + } else { + ensureKeysIsMutable(); + keys_.addAll(other.keys_); + } + onChanged(); + } + } else { + if (!other.keys_.isEmpty()) { + if (keysBuilder_.isEmpty()) { + keysBuilder_.dispose(); + keysBuilder_ = null; + keys_ = other.keys_; + bitField0_ = (bitField0_ & ~0x00000004); + keysBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getKeysFieldBuilder() + : null; + } else { + keysBuilder_.addAllMessages(other.keys_); + } + } + } + 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.datastore.v1.Key m = + input.readMessage(com.google.datastore.v1.Key.parser(), extensionRegistry); + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(m); + } else { + keysBuilder_.addMessage(m); + } + break; + } // case 10 + case 66: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 66 + case 74: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + 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 java.lang.Object projectId_ = ""; + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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.util.List keys_ = java.util.Collections.emptyList(); + + private void ensureKeysIsMutable() { + if (!((bitField0_ & 0x00000004) != 0)) { + keys_ = new java.util.ArrayList(keys_); + bitField0_ |= 0x00000004; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + keysBuilder_; + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getKeysList() { + if (keysBuilder_ == null) { + return java.util.Collections.unmodifiableList(keys_); + } else { + return keysBuilder_.getMessageList(); + } + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public int getKeysCount() { + if (keysBuilder_ == null) { + return keys_.size(); + } else { + return keysBuilder_.getCount(); + } + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key getKeys(int index) { + if (keysBuilder_ == null) { + return keys_.get(index); + } else { + return keysBuilder_.getMessage(index); + } + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setKeys(int index, com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.set(index, value); + onChanged(); + } else { + keysBuilder_.setMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setKeys(int index, com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.set(index, builderForValue.build()); + onChanged(); + } else { + keysBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.add(value); + onChanged(); + } else { + keysBuilder_.addMessage(value); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(int index, com.google.datastore.v1.Key value) { + if (keysBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureKeysIsMutable(); + keys_.add(index, value); + onChanged(); + } else { + keysBuilder_.addMessage(index, value); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(builderForValue.build()); + onChanged(); + } else { + keysBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addKeys(int index, com.google.datastore.v1.Key.Builder builderForValue) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.add(index, builderForValue.build()); + onChanged(); + } else { + keysBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder addAllKeys(java.lang.Iterable values) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, keys_); + onChanged(); + } else { + keysBuilder_.addAllMessages(values); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearKeys() { + if (keysBuilder_ == null) { + keys_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + } else { + keysBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder removeKeys(int index) { + if (keysBuilder_ == null) { + ensureKeysIsMutable(); + keys_.remove(index); + onChanged(); + } else { + keysBuilder_.remove(index); + } + return this; + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key.Builder getKeysBuilder(int index) { + return getKeysFieldBuilder().getBuilder(index); + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index) { + if (keysBuilder_ == null) { + return keys_.get(index); + } else { + return keysBuilder_.getMessageOrBuilder(index); + } + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getKeysOrBuilderList() { + if (keysBuilder_ != null) { + return keysBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(keys_); + } + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key.Builder addKeysBuilder() { + return getKeysFieldBuilder().addBuilder(com.google.datastore.v1.Key.getDefaultInstance()); + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.datastore.v1.Key.Builder addKeysBuilder(int index) { + return getKeysFieldBuilder() + .addBuilder(index, com.google.datastore.v1.Key.getDefaultInstance()); + } + + /** + * + * + *
+     * Required. A list of keys with complete key paths whose numeric IDs should
+     * not be auto-allocated.
+     * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public java.util.List getKeysBuilderList() { + return getKeysFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + getKeysFieldBuilder() { + if (keysBuilder_ == null) { + keysBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder>( + keys_, ((bitField0_ & 0x00000004) != 0), getParentForChildren(), isClean()); + keys_ = null; + } + return keysBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.ReserveIdsRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.ReserveIdsRequest) + private static final com.google.datastore.v1.ReserveIdsRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.ReserveIdsRequest(); + } + + public static com.google.datastore.v1.ReserveIdsRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ReserveIdsRequest 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.datastore.v1.ReserveIdsRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequestOrBuilder.java new file mode 100644 index 000000000000..3568efbd8e1a --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsRequestOrBuilder.java @@ -0,0 +1,149 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface ReserveIdsRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.ReserveIdsRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * Required. A list of keys with complete key paths whose numeric IDs should
+   * not be auto-allocated.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + java.util.List getKeysList(); + + /** + * + * + *
+   * Required. A list of keys with complete key paths whose numeric IDs should
+   * not be auto-allocated.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.v1.Key getKeys(int index); + + /** + * + * + *
+   * Required. A list of keys with complete key paths whose numeric IDs should
+   * not be auto-allocated.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + int getKeysCount(); + + /** + * + * + *
+   * Required. A list of keys with complete key paths whose numeric IDs should
+   * not be auto-allocated.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + java.util.List getKeysOrBuilderList(); + + /** + * + * + *
+   * Required. A list of keys with complete key paths whose numeric IDs should
+   * not be auto-allocated.
+   * 
+ * + * repeated .google.datastore.v1.Key keys = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.datastore.v1.KeyOrBuilder getKeysOrBuilder(int index); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponse.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponse.java new file mode 100644 index 000000000000..9a915ffe949d --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponse.java @@ -0,0 +1,435 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The response for
+ * [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.ReserveIdsResponse} + */ +public final class ReserveIdsResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.ReserveIdsResponse) + ReserveIdsResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ReserveIdsResponse.newBuilder() to construct. + private ReserveIdsResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ReserveIdsResponse() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ReserveIdsResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReserveIdsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReserveIdsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ReserveIdsResponse.class, + com.google.datastore.v1.ReserveIdsResponse.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.datastore.v1.ReserveIdsResponse)) { + return super.equals(obj); + } + com.google.datastore.v1.ReserveIdsResponse other = + (com.google.datastore.v1.ReserveIdsResponse) 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.datastore.v1.ReserveIdsResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ReserveIdsResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.ReserveIdsResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ReserveIdsResponse 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.datastore.v1.ReserveIdsResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.ReserveIdsResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.ReserveIdsResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ReserveIdsResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ReserveIdsResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ReserveIdsResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.ReserveIdsResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.ReserveIdsResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.ReserveIdsResponse 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.ReserveIdsResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.ReserveIdsResponse) + com.google.datastore.v1.ReserveIdsResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReserveIdsResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReserveIdsResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.ReserveIdsResponse.class, + com.google.datastore.v1.ReserveIdsResponse.Builder.class); + } + + // Construct using com.google.datastore.v1.ReserveIdsResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_ReserveIdsResponse_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.ReserveIdsResponse getDefaultInstanceForType() { + return com.google.datastore.v1.ReserveIdsResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.ReserveIdsResponse build() { + com.google.datastore.v1.ReserveIdsResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.ReserveIdsResponse buildPartial() { + com.google.datastore.v1.ReserveIdsResponse result = + new com.google.datastore.v1.ReserveIdsResponse(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.ReserveIdsResponse) { + return mergeFrom((com.google.datastore.v1.ReserveIdsResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.ReserveIdsResponse other) { + if (other == com.google.datastore.v1.ReserveIdsResponse.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; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.ReserveIdsResponse) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.ReserveIdsResponse) + private static final com.google.datastore.v1.ReserveIdsResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.ReserveIdsResponse(); + } + + public static com.google.datastore.v1.ReserveIdsResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ReserveIdsResponse 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.datastore.v1.ReserveIdsResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponseOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponseOrBuilder.java new file mode 100644 index 000000000000..ff223f82cd99 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ReserveIdsResponseOrBuilder.java @@ -0,0 +1,25 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface ReserveIdsResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.ReserveIdsResponse) + com.google.protobuf.MessageOrBuilder {} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequest.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequest.java new file mode 100644 index 000000000000..a7ec66800898 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequest.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! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The request for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.RollbackRequest} + */ +public final class RollbackRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.RollbackRequest) + RollbackRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use RollbackRequest.newBuilder() to construct. + private RollbackRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private RollbackRequest() { + projectId_ = ""; + databaseId_ = ""; + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new RollbackRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RollbackRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RollbackRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RollbackRequest.class, + com.google.datastore.v1.RollbackRequest.Builder.class); + } + + public static final int PROJECT_ID_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 9; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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 TRANSACTION_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * Required. The transaction identifier, returned by a call to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * bytes transaction = 1 [(.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 (!transaction_.isEmpty()) { + output.writeBytes(1, transaction_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, databaseId_); + } + 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_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, 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.datastore.v1.RollbackRequest)) { + return super.equals(obj); + } + com.google.datastore.v1.RollbackRequest other = (com.google.datastore.v1.RollbackRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().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.datastore.v1.RollbackRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.RollbackRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.RollbackRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.RollbackRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.RollbackRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RollbackRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RollbackRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RollbackRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RollbackRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RollbackRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.RollbackRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.RollbackRequest) + com.google.datastore.v1.RollbackRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RollbackRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RollbackRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RollbackRequest.class, + com.google.datastore.v1.RollbackRequest.Builder.class); + } + + // Construct using com.google.datastore.v1.RollbackRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + databaseId_ = ""; + transaction_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RollbackRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.RollbackRequest getDefaultInstanceForType() { + return com.google.datastore.v1.RollbackRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.RollbackRequest build() { + com.google.datastore.v1.RollbackRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.RollbackRequest buildPartial() { + com.google.datastore.v1.RollbackRequest result = + new com.google.datastore.v1.RollbackRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.RollbackRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.transaction_ = transaction_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.RollbackRequest) { + return mergeFrom((com.google.datastore.v1.RollbackRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.RollbackRequest other) { + if (other == com.google.datastore.v1.RollbackRequest.getDefaultInstance()) return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.getTransaction() != com.google.protobuf.ByteString.EMPTY) { + 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_ |= 0x00000004; + break; + } // case 10 + case 66: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 66 + case 74: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + 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 java.lang.Object projectId_ = ""; + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * Required. The transaction identifier, returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * bytes transaction = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * Required. The transaction identifier, returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * bytes transaction = 1 [(.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_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The transaction identifier, returned by a call to
+     * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+     * 
+ * + * bytes transaction = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000004); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.RollbackRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.RollbackRequest) + private static final com.google.datastore.v1.RollbackRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.RollbackRequest(); + } + + public static com.google.datastore.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.datastore.v1.RollbackRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequestOrBuilder.java new file mode 100644 index 000000000000..343feed3f722 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackRequestOrBuilder.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! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface RollbackRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.RollbackRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * Required. The transaction identifier, returned by a call to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
+   * 
+ * + * bytes transaction = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponse.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponse.java new file mode 100644 index 000000000000..6bcf2e82e533 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponse.java @@ -0,0 +1,436 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The response for
+ * [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. (an empty
+ * message).
+ * 
+ * + * Protobuf type {@code google.datastore.v1.RollbackResponse} + */ +public final class RollbackResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.RollbackResponse) + RollbackResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use RollbackResponse.newBuilder() to construct. + private RollbackResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private RollbackResponse() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new RollbackResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RollbackResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RollbackResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RollbackResponse.class, + com.google.datastore.v1.RollbackResponse.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.datastore.v1.RollbackResponse)) { + return super.equals(obj); + } + com.google.datastore.v1.RollbackResponse other = (com.google.datastore.v1.RollbackResponse) 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.datastore.v1.RollbackResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.RollbackResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.RollbackResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.RollbackResponse 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.datastore.v1.RollbackResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.RollbackResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.RollbackResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RollbackResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RollbackResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RollbackResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RollbackResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RollbackResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.v1.RollbackResponse 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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. (an empty
+   * message).
+   * 
+ * + * Protobuf type {@code google.datastore.v1.RollbackResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.RollbackResponse) + com.google.datastore.v1.RollbackResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RollbackResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RollbackResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RollbackResponse.class, + com.google.datastore.v1.RollbackResponse.Builder.class); + } + + // Construct using com.google.datastore.v1.RollbackResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.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.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RollbackResponse_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.RollbackResponse getDefaultInstanceForType() { + return com.google.datastore.v1.RollbackResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.RollbackResponse build() { + com.google.datastore.v1.RollbackResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.RollbackResponse buildPartial() { + com.google.datastore.v1.RollbackResponse result = + new com.google.datastore.v1.RollbackResponse(this); + onBuilt(); + return result; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.RollbackResponse) { + return mergeFrom((com.google.datastore.v1.RollbackResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.RollbackResponse other) { + if (other == com.google.datastore.v1.RollbackResponse.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; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.RollbackResponse) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.RollbackResponse) + private static final com.google.datastore.v1.RollbackResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.RollbackResponse(); + } + + public static com.google.datastore.v1.RollbackResponse getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public RollbackResponse 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.datastore.v1.RollbackResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponseOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponseOrBuilder.java new file mode 100644 index 000000000000..9809ceb070a0 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RollbackResponseOrBuilder.java @@ -0,0 +1,25 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface RollbackResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.RollbackResponse) + com.google.protobuf.MessageOrBuilder {} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequest.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequest.java new file mode 100644 index 000000000000..dbabd22b8301 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequest.java @@ -0,0 +1,2466 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The request for
+ * [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.RunAggregationQueryRequest} + */ +public final class RunAggregationQueryRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.RunAggregationQueryRequest) + RunAggregationQueryRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use RunAggregationQueryRequest.newBuilder() to construct. + private RunAggregationQueryRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private RunAggregationQueryRequest() { + projectId_ = ""; + databaseId_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new RunAggregationQueryRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunAggregationQueryRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunAggregationQueryRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RunAggregationQueryRequest.class, + com.google.datastore.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 { + AGGREGATION_QUERY(3), + GQL_QUERY(7), + 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 3: + return AGGREGATION_QUERY; + case 7: + return GQL_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 PROJECT_ID_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 9; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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 PARTITION_ID_FIELD_NUMBER = 2; + private com.google.datastore.v1.PartitionId partitionId_; + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return Whether the partitionId field is set. + */ + @java.lang.Override + public boolean hasPartitionId() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return The partitionId. + */ + @java.lang.Override + public com.google.datastore.v1.PartitionId getPartitionId() { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + @java.lang.Override + public com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder() { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } + + public static final int READ_OPTIONS_FIELD_NUMBER = 1; + private com.google.datastore.v1.ReadOptions readOptions_; + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return Whether the readOptions field is set. + */ + @java.lang.Override + public boolean hasReadOptions() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return The readOptions. + */ + @java.lang.Override + public com.google.datastore.v1.ReadOptions getReadOptions() { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + @java.lang.Override + public com.google.datastore.v1.ReadOptionsOrBuilder getReadOptionsOrBuilder() { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } + + public static final int AGGREGATION_QUERY_FIELD_NUMBER = 3; + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + * + * @return Whether the aggregationQuery field is set. + */ + @java.lang.Override + public boolean hasAggregationQuery() { + return queryTypeCase_ == 3; + } + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + * + * @return The aggregationQuery. + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery getAggregationQuery() { + if (queryTypeCase_ == 3) { + return (com.google.datastore.v1.AggregationQuery) queryType_; + } + return com.google.datastore.v1.AggregationQuery.getDefaultInstance(); + } + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQueryOrBuilder getAggregationQueryOrBuilder() { + if (queryTypeCase_ == 3) { + return (com.google.datastore.v1.AggregationQuery) queryType_; + } + return com.google.datastore.v1.AggregationQuery.getDefaultInstance(); + } + + public static final int GQL_QUERY_FIELD_NUMBER = 7; + + /** + * + * + *
+   * The GQL query to run. This query must be an aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return Whether the gqlQuery field is set. + */ + @java.lang.Override + public boolean hasGqlQuery() { + return queryTypeCase_ == 7; + } + + /** + * + * + *
+   * The GQL query to run. This query must be an aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return The gqlQuery. + */ + @java.lang.Override + public com.google.datastore.v1.GqlQuery getGqlQuery() { + if (queryTypeCase_ == 7) { + return (com.google.datastore.v1.GqlQuery) queryType_; + } + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + + /** + * + * + *
+   * The GQL query to run. This query must be an aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + @java.lang.Override + public com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder() { + if (queryTypeCase_ == 7) { + return (com.google.datastore.v1.GqlQuery) queryType_; + } + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + + public static final int EXPLAIN_OPTIONS_FIELD_NUMBER = 11; + private com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the explainOptions field is set. + */ + @java.lang.Override + public boolean hasExplainOptions() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + @java.lang.Override + public com.google.datastore.v1.ExplainOptions getExplainOptions() { + return explainOptions_ == null + ? com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.datastore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder() { + return explainOptions_ == null + ? com.google.datastore.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 (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(1, getReadOptions()); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getPartitionId()); + } + if (queryTypeCase_ == 3) { + output.writeMessage(3, (com.google.datastore.v1.AggregationQuery) queryType_); + } + if (queryTypeCase_ == 7) { + output.writeMessage(7, (com.google.datastore.v1.GqlQuery) queryType_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, databaseId_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(11, getExplainOptions()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getReadOptions()); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getPartitionId()); + } + if (queryTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.datastore.v1.AggregationQuery) queryType_); + } + if (queryTypeCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.datastore.v1.GqlQuery) queryType_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, databaseId_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(11, 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.datastore.v1.RunAggregationQueryRequest)) { + return super.equals(obj); + } + com.google.datastore.v1.RunAggregationQueryRequest other = + (com.google.datastore.v1.RunAggregationQueryRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (hasPartitionId() != other.hasPartitionId()) return false; + if (hasPartitionId()) { + if (!getPartitionId().equals(other.getPartitionId())) return false; + } + if (hasReadOptions() != other.hasReadOptions()) return false; + if (hasReadOptions()) { + if (!getReadOptions().equals(other.getReadOptions())) 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 3: + if (!getAggregationQuery().equals(other.getAggregationQuery())) return false; + break; + case 7: + if (!getGqlQuery().equals(other.getGqlQuery())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + if (hasPartitionId()) { + hash = (37 * hash) + PARTITION_ID_FIELD_NUMBER; + hash = (53 * hash) + getPartitionId().hashCode(); + } + if (hasReadOptions()) { + hash = (37 * hash) + READ_OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + getReadOptions().hashCode(); + } + if (hasExplainOptions()) { + hash = (37 * hash) + EXPLAIN_OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + getExplainOptions().hashCode(); + } + switch (queryTypeCase_) { + case 3: + hash = (37 * hash) + AGGREGATION_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getAggregationQuery().hashCode(); + break; + case 7: + hash = (37 * hash) + GQL_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getGqlQuery().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.RunAggregationQueryRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.RunAggregationQueryRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.RunAggregationQueryRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.RunAggregationQueryRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.RunAggregationQueryRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunAggregationQueryRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RunAggregationQueryRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunAggregationQueryRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RunAggregationQueryRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunAggregationQueryRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for
+   * [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.RunAggregationQueryRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.RunAggregationQueryRequest) + com.google.datastore.v1.RunAggregationQueryRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunAggregationQueryRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunAggregationQueryRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RunAggregationQueryRequest.class, + com.google.datastore.v1.RunAggregationQueryRequest.Builder.class); + } + + // Construct using com.google.datastore.v1.RunAggregationQueryRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPartitionIdFieldBuilder(); + getReadOptionsFieldBuilder(); + getExplainOptionsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + databaseId_ = ""; + partitionId_ = null; + if (partitionIdBuilder_ != null) { + partitionIdBuilder_.dispose(); + partitionIdBuilder_ = null; + } + readOptions_ = null; + if (readOptionsBuilder_ != null) { + readOptionsBuilder_.dispose(); + readOptionsBuilder_ = null; + } + if (aggregationQueryBuilder_ != null) { + aggregationQueryBuilder_.clear(); + } + if (gqlQueryBuilder_ != null) { + gqlQueryBuilder_.clear(); + } + explainOptions_ = null; + if (explainOptionsBuilder_ != null) { + explainOptionsBuilder_.dispose(); + explainOptionsBuilder_ = null; + } + queryTypeCase_ = 0; + queryType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunAggregationQueryRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.RunAggregationQueryRequest getDefaultInstanceForType() { + return com.google.datastore.v1.RunAggregationQueryRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.RunAggregationQueryRequest build() { + com.google.datastore.v1.RunAggregationQueryRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.RunAggregationQueryRequest buildPartial() { + com.google.datastore.v1.RunAggregationQueryRequest result = + new com.google.datastore.v1.RunAggregationQueryRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.RunAggregationQueryRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.partitionId_ = + partitionIdBuilder_ == null ? partitionId_ : partitionIdBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.readOptions_ = + readOptionsBuilder_ == null ? readOptions_ : readOptionsBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.explainOptions_ = + explainOptionsBuilder_ == null ? explainOptions_ : explainOptionsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.datastore.v1.RunAggregationQueryRequest result) { + result.queryTypeCase_ = queryTypeCase_; + result.queryType_ = this.queryType_; + if (queryTypeCase_ == 3 && aggregationQueryBuilder_ != null) { + result.queryType_ = aggregationQueryBuilder_.build(); + } + if (queryTypeCase_ == 7 && gqlQueryBuilder_ != null) { + result.queryType_ = gqlQueryBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.RunAggregationQueryRequest) { + return mergeFrom((com.google.datastore.v1.RunAggregationQueryRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.RunAggregationQueryRequest other) { + if (other == com.google.datastore.v1.RunAggregationQueryRequest.getDefaultInstance()) + return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.hasPartitionId()) { + mergePartitionId(other.getPartitionId()); + } + if (other.hasReadOptions()) { + mergeReadOptions(other.getReadOptions()); + } + if (other.hasExplainOptions()) { + mergeExplainOptions(other.getExplainOptions()); + } + switch (other.getQueryTypeCase()) { + case AGGREGATION_QUERY: + { + mergeAggregationQuery(other.getAggregationQuery()); + break; + } + case GQL_QUERY: + { + mergeGqlQuery(other.getGqlQuery()); + 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(getReadOptionsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 10 + case 18: + { + input.readMessage(getPartitionIdFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 18 + case 26: + { + input.readMessage( + getAggregationQueryFieldBuilder().getBuilder(), extensionRegistry); + queryTypeCase_ = 3; + break; + } // case 26 + case 58: + { + input.readMessage(getGqlQueryFieldBuilder().getBuilder(), extensionRegistry); + queryTypeCase_ = 7; + break; + } // case 58 + case 66: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 66 + case 74: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 74 + case 90: + { + input.readMessage(getExplainOptionsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000040; + 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 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 projectId_ = ""; + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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.datastore.v1.PartitionId partitionId_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PartitionId, + com.google.datastore.v1.PartitionId.Builder, + com.google.datastore.v1.PartitionIdOrBuilder> + partitionIdBuilder_; + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return Whether the partitionId field is set. + */ + public boolean hasPartitionId() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return The partitionId. + */ + public com.google.datastore.v1.PartitionId getPartitionId() { + if (partitionIdBuilder_ == null) { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } else { + return partitionIdBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public Builder setPartitionId(com.google.datastore.v1.PartitionId value) { + if (partitionIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + partitionId_ = value; + } else { + partitionIdBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public Builder setPartitionId(com.google.datastore.v1.PartitionId.Builder builderForValue) { + if (partitionIdBuilder_ == null) { + partitionId_ = builderForValue.build(); + } else { + partitionIdBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public Builder mergePartitionId(com.google.datastore.v1.PartitionId value) { + if (partitionIdBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && partitionId_ != null + && partitionId_ != com.google.datastore.v1.PartitionId.getDefaultInstance()) { + getPartitionIdBuilder().mergeFrom(value); + } else { + partitionId_ = value; + } + } else { + partitionIdBuilder_.mergeFrom(value); + } + if (partitionId_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public Builder clearPartitionId() { + bitField0_ = (bitField0_ & ~0x00000004); + partitionId_ = null; + if (partitionIdBuilder_ != null) { + partitionIdBuilder_.dispose(); + partitionIdBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public com.google.datastore.v1.PartitionId.Builder getPartitionIdBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getPartitionIdFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder() { + if (partitionIdBuilder_ != null) { + return partitionIdBuilder_.getMessageOrBuilder(); + } else { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PartitionId, + com.google.datastore.v1.PartitionId.Builder, + com.google.datastore.v1.PartitionIdOrBuilder> + getPartitionIdFieldBuilder() { + if (partitionIdBuilder_ == null) { + partitionIdBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PartitionId, + com.google.datastore.v1.PartitionId.Builder, + com.google.datastore.v1.PartitionIdOrBuilder>( + getPartitionId(), getParentForChildren(), isClean()); + partitionId_ = null; + } + return partitionIdBuilder_; + } + + private com.google.datastore.v1.ReadOptions readOptions_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ReadOptions, + com.google.datastore.v1.ReadOptions.Builder, + com.google.datastore.v1.ReadOptionsOrBuilder> + readOptionsBuilder_; + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return Whether the readOptions field is set. + */ + public boolean hasReadOptions() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return The readOptions. + */ + public com.google.datastore.v1.ReadOptions getReadOptions() { + if (readOptionsBuilder_ == null) { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } else { + return readOptionsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder setReadOptions(com.google.datastore.v1.ReadOptions value) { + if (readOptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readOptions_ = value; + } else { + readOptionsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder setReadOptions(com.google.datastore.v1.ReadOptions.Builder builderForValue) { + if (readOptionsBuilder_ == null) { + readOptions_ = builderForValue.build(); + } else { + readOptionsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder mergeReadOptions(com.google.datastore.v1.ReadOptions value) { + if (readOptionsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && readOptions_ != null + && readOptions_ != com.google.datastore.v1.ReadOptions.getDefaultInstance()) { + getReadOptionsBuilder().mergeFrom(value); + } else { + readOptions_ = value; + } + } else { + readOptionsBuilder_.mergeFrom(value); + } + if (readOptions_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder clearReadOptions() { + bitField0_ = (bitField0_ & ~0x00000008); + readOptions_ = null; + if (readOptionsBuilder_ != null) { + readOptionsBuilder_.dispose(); + readOptionsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public com.google.datastore.v1.ReadOptions.Builder getReadOptionsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getReadOptionsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public com.google.datastore.v1.ReadOptionsOrBuilder getReadOptionsOrBuilder() { + if (readOptionsBuilder_ != null) { + return readOptionsBuilder_.getMessageOrBuilder(); + } else { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ReadOptions, + com.google.datastore.v1.ReadOptions.Builder, + com.google.datastore.v1.ReadOptionsOrBuilder> + getReadOptionsFieldBuilder() { + if (readOptionsBuilder_ == null) { + readOptionsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ReadOptions, + com.google.datastore.v1.ReadOptions.Builder, + com.google.datastore.v1.ReadOptionsOrBuilder>( + getReadOptions(), getParentForChildren(), isClean()); + readOptions_ = null; + } + return readOptionsBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery, + com.google.datastore.v1.AggregationQuery.Builder, + com.google.datastore.v1.AggregationQueryOrBuilder> + aggregationQueryBuilder_; + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + * + * @return Whether the aggregationQuery field is set. + */ + @java.lang.Override + public boolean hasAggregationQuery() { + return queryTypeCase_ == 3; + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + * + * @return The aggregationQuery. + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery getAggregationQuery() { + if (aggregationQueryBuilder_ == null) { + if (queryTypeCase_ == 3) { + return (com.google.datastore.v1.AggregationQuery) queryType_; + } + return com.google.datastore.v1.AggregationQuery.getDefaultInstance(); + } else { + if (queryTypeCase_ == 3) { + return aggregationQueryBuilder_.getMessage(); + } + return com.google.datastore.v1.AggregationQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + */ + public Builder setAggregationQuery(com.google.datastore.v1.AggregationQuery value) { + if (aggregationQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + aggregationQueryBuilder_.setMessage(value); + } + queryTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + */ + public Builder setAggregationQuery( + com.google.datastore.v1.AggregationQuery.Builder builderForValue) { + if (aggregationQueryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + aggregationQueryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + */ + public Builder mergeAggregationQuery(com.google.datastore.v1.AggregationQuery value) { + if (aggregationQueryBuilder_ == null) { + if (queryTypeCase_ == 3 + && queryType_ != com.google.datastore.v1.AggregationQuery.getDefaultInstance()) { + queryType_ = + com.google.datastore.v1.AggregationQuery.newBuilder( + (com.google.datastore.v1.AggregationQuery) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 3) { + aggregationQueryBuilder_.mergeFrom(value); + } else { + aggregationQueryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + */ + public Builder clearAggregationQuery() { + if (aggregationQueryBuilder_ == null) { + if (queryTypeCase_ == 3) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 3) { + queryTypeCase_ = 0; + queryType_ = null; + } + aggregationQueryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + */ + public com.google.datastore.v1.AggregationQuery.Builder getAggregationQueryBuilder() { + return getAggregationQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQueryOrBuilder getAggregationQueryOrBuilder() { + if ((queryTypeCase_ == 3) && (aggregationQueryBuilder_ != null)) { + return aggregationQueryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 3) { + return (com.google.datastore.v1.AggregationQuery) queryType_; + } + return com.google.datastore.v1.AggregationQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery, + com.google.datastore.v1.AggregationQuery.Builder, + com.google.datastore.v1.AggregationQueryOrBuilder> + getAggregationQueryFieldBuilder() { + if (aggregationQueryBuilder_ == null) { + if (!(queryTypeCase_ == 3)) { + queryType_ = com.google.datastore.v1.AggregationQuery.getDefaultInstance(); + } + aggregationQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery, + com.google.datastore.v1.AggregationQuery.Builder, + com.google.datastore.v1.AggregationQueryOrBuilder>( + (com.google.datastore.v1.AggregationQuery) queryType_, + getParentForChildren(), + isClean()); + queryType_ = null; + } + queryTypeCase_ = 3; + onChanged(); + return aggregationQueryBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.GqlQuery, + com.google.datastore.v1.GqlQuery.Builder, + com.google.datastore.v1.GqlQueryOrBuilder> + gqlQueryBuilder_; + + /** + * + * + *
+     * The GQL query to run. This query must be an aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return Whether the gqlQuery field is set. + */ + @java.lang.Override + public boolean hasGqlQuery() { + return queryTypeCase_ == 7; + } + + /** + * + * + *
+     * The GQL query to run. This query must be an aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return The gqlQuery. + */ + @java.lang.Override + public com.google.datastore.v1.GqlQuery getGqlQuery() { + if (gqlQueryBuilder_ == null) { + if (queryTypeCase_ == 7) { + return (com.google.datastore.v1.GqlQuery) queryType_; + } + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } else { + if (queryTypeCase_ == 7) { + return gqlQueryBuilder_.getMessage(); + } + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The GQL query to run. This query must be an aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + public Builder setGqlQuery(com.google.datastore.v1.GqlQuery value) { + if (gqlQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + gqlQueryBuilder_.setMessage(value); + } + queryTypeCase_ = 7; + return this; + } + + /** + * + * + *
+     * The GQL query to run. This query must be an aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + public Builder setGqlQuery(com.google.datastore.v1.GqlQuery.Builder builderForValue) { + if (gqlQueryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + gqlQueryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 7; + return this; + } + + /** + * + * + *
+     * The GQL query to run. This query must be an aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + public Builder mergeGqlQuery(com.google.datastore.v1.GqlQuery value) { + if (gqlQueryBuilder_ == null) { + if (queryTypeCase_ == 7 + && queryType_ != com.google.datastore.v1.GqlQuery.getDefaultInstance()) { + queryType_ = + com.google.datastore.v1.GqlQuery.newBuilder( + (com.google.datastore.v1.GqlQuery) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 7) { + gqlQueryBuilder_.mergeFrom(value); + } else { + gqlQueryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 7; + return this; + } + + /** + * + * + *
+     * The GQL query to run. This query must be an aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + public Builder clearGqlQuery() { + if (gqlQueryBuilder_ == null) { + if (queryTypeCase_ == 7) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 7) { + queryTypeCase_ = 0; + queryType_ = null; + } + gqlQueryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The GQL query to run. This query must be an aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + public com.google.datastore.v1.GqlQuery.Builder getGqlQueryBuilder() { + return getGqlQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The GQL query to run. This query must be an aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + @java.lang.Override + public com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder() { + if ((queryTypeCase_ == 7) && (gqlQueryBuilder_ != null)) { + return gqlQueryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 7) { + return (com.google.datastore.v1.GqlQuery) queryType_; + } + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The GQL query to run. This query must be an aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.GqlQuery, + com.google.datastore.v1.GqlQuery.Builder, + com.google.datastore.v1.GqlQueryOrBuilder> + getGqlQueryFieldBuilder() { + if (gqlQueryBuilder_ == null) { + if (!(queryTypeCase_ == 7)) { + queryType_ = com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + gqlQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.GqlQuery, + com.google.datastore.v1.GqlQuery.Builder, + com.google.datastore.v1.GqlQueryOrBuilder>( + (com.google.datastore.v1.GqlQuery) queryType_, getParentForChildren(), isClean()); + queryType_ = null; + } + queryTypeCase_ = 7; + onChanged(); + return gqlQueryBuilder_; + } + + private com.google.datastore.v1.ExplainOptions explainOptions_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainOptions, + com.google.datastore.v1.ExplainOptions.Builder, + com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the explainOptions field is set. + */ + public boolean hasExplainOptions() { + return ((bitField0_ & 0x00000040) != 0); + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + public com.google.datastore.v1.ExplainOptions getExplainOptions() { + if (explainOptionsBuilder_ == null) { + return explainOptions_ == null + ? com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setExplainOptions(com.google.datastore.v1.ExplainOptions value) { + if (explainOptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + explainOptions_ = value; + } else { + explainOptionsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000040; + 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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setExplainOptions( + com.google.datastore.v1.ExplainOptions.Builder builderForValue) { + if (explainOptionsBuilder_ == null) { + explainOptions_ = builderForValue.build(); + } else { + explainOptionsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000040; + 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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeExplainOptions(com.google.datastore.v1.ExplainOptions value) { + if (explainOptionsBuilder_ == null) { + if (((bitField0_ & 0x00000040) != 0) + && explainOptions_ != null + && explainOptions_ != com.google.datastore.v1.ExplainOptions.getDefaultInstance()) { + getExplainOptionsBuilder().mergeFrom(value); + } else { + explainOptions_ = value; + } + } else { + explainOptionsBuilder_.mergeFrom(value); + } + if (explainOptions_ != null) { + bitField0_ |= 0x00000040; + 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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearExplainOptions() { + bitField0_ = (bitField0_ & ~0x00000040); + 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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.ExplainOptions.Builder getExplainOptionsBuilder() { + bitField0_ |= 0x00000040; + onChanged(); + return getExplainOptionsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder() { + if (explainOptionsBuilder_ != null) { + return explainOptionsBuilder_.getMessageOrBuilder(); + } else { + return explainOptions_ == null + ? com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainOptions, + com.google.datastore.v1.ExplainOptions.Builder, + com.google.datastore.v1.ExplainOptionsOrBuilder> + getExplainOptionsFieldBuilder() { + if (explainOptionsBuilder_ == null) { + explainOptionsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainOptions, + com.google.datastore.v1.ExplainOptions.Builder, + com.google.datastore.v1.ExplainOptionsOrBuilder>( + getExplainOptions(), getParentForChildren(), isClean()); + explainOptions_ = null; + } + return explainOptionsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.RunAggregationQueryRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.RunAggregationQueryRequest) + private static final com.google.datastore.v1.RunAggregationQueryRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.RunAggregationQueryRequest(); + } + + public static com.google.datastore.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.datastore.v1.RunAggregationQueryRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequestOrBuilder.java new file mode 100644 index 000000000000..9994dc734c12 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryRequestOrBuilder.java @@ -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 + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface RunAggregationQueryRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.RunAggregationQueryRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return Whether the partitionId field is set. + */ + boolean hasPartitionId(); + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return The partitionId. + */ + com.google.datastore.v1.PartitionId getPartitionId(); + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder(); + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return Whether the readOptions field is set. + */ + boolean hasReadOptions(); + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return The readOptions. + */ + com.google.datastore.v1.ReadOptions getReadOptions(); + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + com.google.datastore.v1.ReadOptionsOrBuilder getReadOptionsOrBuilder(); + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + * + * @return Whether the aggregationQuery field is set. + */ + boolean hasAggregationQuery(); + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + * + * @return The aggregationQuery. + */ + com.google.datastore.v1.AggregationQuery getAggregationQuery(); + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.AggregationQuery aggregation_query = 3; + */ + com.google.datastore.v1.AggregationQueryOrBuilder getAggregationQueryOrBuilder(); + + /** + * + * + *
+   * The GQL query to run. This query must be an aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return Whether the gqlQuery field is set. + */ + boolean hasGqlQuery(); + + /** + * + * + *
+   * The GQL query to run. This query must be an aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return The gqlQuery. + */ + com.google.datastore.v1.GqlQuery getGqlQuery(); + + /** + * + * + *
+   * The GQL query to run. This query must be an aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder(); + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.datastore.v1.ExplainOptions explain_options = 11 [(.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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 11 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.datastore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder(); + + com.google.datastore.v1.RunAggregationQueryRequest.QueryTypeCase getQueryTypeCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponse.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponse.java new file mode 100644 index 000000000000..f0bfa2cc4717 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponse.java @@ -0,0 +1,1445 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The response for
+ * [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.RunAggregationQueryResponse} + */ +public final class RunAggregationQueryResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.RunAggregationQueryResponse) + RunAggregationQueryResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use RunAggregationQueryResponse.newBuilder() to construct. + private RunAggregationQueryResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private RunAggregationQueryResponse() { + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new RunAggregationQueryResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunAggregationQueryResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunAggregationQueryResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RunAggregationQueryResponse.class, + com.google.datastore.v1.RunAggregationQueryResponse.Builder.class); + } + + private int bitField0_; + public static final int BATCH_FIELD_NUMBER = 1; + private com.google.datastore.v1.AggregationResultBatch batch_; + + /** + * + * + *
+   * A batch of aggregation results. Always present.
+   * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + * + * @return Whether the batch field is set. + */ + @java.lang.Override + public boolean hasBatch() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * A batch of aggregation results. Always present.
+   * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + * + * @return The batch. + */ + @java.lang.Override + public com.google.datastore.v1.AggregationResultBatch getBatch() { + return batch_ == null + ? com.google.datastore.v1.AggregationResultBatch.getDefaultInstance() + : batch_; + } + + /** + * + * + *
+   * A batch of aggregation results. Always present.
+   * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationResultBatchOrBuilder getBatchOrBuilder() { + return batch_ == null + ? com.google.datastore.v1.AggregationResultBatch.getDefaultInstance() + : batch_; + } + + public static final int QUERY_FIELD_NUMBER = 2; + private com.google.datastore.v1.AggregationQuery query_; + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + * + * @return Whether the query field is set. + */ + @java.lang.Override + public boolean hasQuery() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + * + * @return The query. + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQuery getQuery() { + return query_ == null ? com.google.datastore.v1.AggregationQuery.getDefaultInstance() : query_; + } + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + */ + @java.lang.Override + public com.google.datastore.v1.AggregationQueryOrBuilder getQueryOrBuilder() { + return query_ == null ? com.google.datastore.v1.AggregationQuery.getDefaultInstance() : query_; + } + + public static final int TRANSACTION_FIELD_NUMBER = 5; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * The identifier of the transaction that was started as part of this
+   * RunAggregationQuery request.
+   *
+   * Set only when
+   * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+   * was set in
+   * [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options].
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + public static final int EXPLAIN_METRICS_FIELD_NUMBER = 9; + private com.google.datastore.v1.ExplainMetrics explainMetrics_; + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @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.datastore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @return The explainMetrics. + */ + @java.lang.Override + public com.google.datastore.v1.ExplainMetrics getExplainMetrics() { + return explainMetrics_ == null + ? com.google.datastore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + @java.lang.Override + public com.google.datastore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() { + return explainMetrics_ == null + ? com.google.datastore.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, getBatch()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getQuery()); + } + if (!transaction_.isEmpty()) { + output.writeBytes(5, transaction_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(9, 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, getBatch()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getQuery()); + } + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(5, transaction_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, 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.datastore.v1.RunAggregationQueryResponse)) { + return super.equals(obj); + } + com.google.datastore.v1.RunAggregationQueryResponse other = + (com.google.datastore.v1.RunAggregationQueryResponse) obj; + + if (hasBatch() != other.hasBatch()) return false; + if (hasBatch()) { + if (!getBatch().equals(other.getBatch())) return false; + } + if (hasQuery() != other.hasQuery()) return false; + if (hasQuery()) { + if (!getQuery().equals(other.getQuery())) return false; + } + if (!getTransaction().equals(other.getTransaction())) 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 (hasBatch()) { + hash = (37 * hash) + BATCH_FIELD_NUMBER; + hash = (53 * hash) + getBatch().hashCode(); + } + if (hasQuery()) { + hash = (37 * hash) + QUERY_FIELD_NUMBER; + hash = (53 * hash) + getQuery().hashCode(); + } + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().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.datastore.v1.RunAggregationQueryResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.RunAggregationQueryResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.RunAggregationQueryResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.RunAggregationQueryResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.RunAggregationQueryResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunAggregationQueryResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RunAggregationQueryResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunAggregationQueryResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RunAggregationQueryResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunAggregationQueryResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.RunAggregationQueryResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.RunAggregationQueryResponse) + com.google.datastore.v1.RunAggregationQueryResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunAggregationQueryResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunAggregationQueryResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RunAggregationQueryResponse.class, + com.google.datastore.v1.RunAggregationQueryResponse.Builder.class); + } + + // Construct using com.google.datastore.v1.RunAggregationQueryResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getBatchFieldBuilder(); + getQueryFieldBuilder(); + getExplainMetricsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + batch_ = null; + if (batchBuilder_ != null) { + batchBuilder_.dispose(); + batchBuilder_ = null; + } + query_ = null; + if (queryBuilder_ != null) { + queryBuilder_.dispose(); + queryBuilder_ = null; + } + transaction_ = com.google.protobuf.ByteString.EMPTY; + explainMetrics_ = null; + if (explainMetricsBuilder_ != null) { + explainMetricsBuilder_.dispose(); + explainMetricsBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunAggregationQueryResponse_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.RunAggregationQueryResponse getDefaultInstanceForType() { + return com.google.datastore.v1.RunAggregationQueryResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.RunAggregationQueryResponse build() { + com.google.datastore.v1.RunAggregationQueryResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.RunAggregationQueryResponse buildPartial() { + com.google.datastore.v1.RunAggregationQueryResponse result = + new com.google.datastore.v1.RunAggregationQueryResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.RunAggregationQueryResponse result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.batch_ = batchBuilder_ == null ? batch_ : batchBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.query_ = queryBuilder_ == null ? query_ : queryBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.transaction_ = transaction_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.explainMetrics_ = + explainMetricsBuilder_ == null ? explainMetrics_ : explainMetricsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.RunAggregationQueryResponse) { + return mergeFrom((com.google.datastore.v1.RunAggregationQueryResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.RunAggregationQueryResponse other) { + if (other == com.google.datastore.v1.RunAggregationQueryResponse.getDefaultInstance()) + return this; + if (other.hasBatch()) { + mergeBatch(other.getBatch()); + } + if (other.hasQuery()) { + mergeQuery(other.getQuery()); + } + if (other.getTransaction() != com.google.protobuf.ByteString.EMPTY) { + setTransaction(other.getTransaction()); + } + 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(getBatchFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getQueryFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 42: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000004; + break; + } // case 42 + case 74: + { + input.readMessage(getExplainMetricsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + 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.datastore.v1.AggregationResultBatch batch_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationResultBatch, + com.google.datastore.v1.AggregationResultBatch.Builder, + com.google.datastore.v1.AggregationResultBatchOrBuilder> + batchBuilder_; + + /** + * + * + *
+     * A batch of aggregation results. Always present.
+     * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + * + * @return Whether the batch field is set. + */ + public boolean hasBatch() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * A batch of aggregation results. Always present.
+     * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + * + * @return The batch. + */ + public com.google.datastore.v1.AggregationResultBatch getBatch() { + if (batchBuilder_ == null) { + return batch_ == null + ? com.google.datastore.v1.AggregationResultBatch.getDefaultInstance() + : batch_; + } else { + return batchBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * A batch of aggregation results. Always present.
+     * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + */ + public Builder setBatch(com.google.datastore.v1.AggregationResultBatch value) { + if (batchBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + batch_ = value; + } else { + batchBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * A batch of aggregation results. Always present.
+     * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + */ + public Builder setBatch( + com.google.datastore.v1.AggregationResultBatch.Builder builderForValue) { + if (batchBuilder_ == null) { + batch_ = builderForValue.build(); + } else { + batchBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * A batch of aggregation results. Always present.
+     * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + */ + public Builder mergeBatch(com.google.datastore.v1.AggregationResultBatch value) { + if (batchBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && batch_ != null + && batch_ != com.google.datastore.v1.AggregationResultBatch.getDefaultInstance()) { + getBatchBuilder().mergeFrom(value); + } else { + batch_ = value; + } + } else { + batchBuilder_.mergeFrom(value); + } + if (batch_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A batch of aggregation results. Always present.
+     * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + */ + public Builder clearBatch() { + bitField0_ = (bitField0_ & ~0x00000001); + batch_ = null; + if (batchBuilder_ != null) { + batchBuilder_.dispose(); + batchBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * A batch of aggregation results. Always present.
+     * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + */ + public com.google.datastore.v1.AggregationResultBatch.Builder getBatchBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getBatchFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A batch of aggregation results. Always present.
+     * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + */ + public com.google.datastore.v1.AggregationResultBatchOrBuilder getBatchOrBuilder() { + if (batchBuilder_ != null) { + return batchBuilder_.getMessageOrBuilder(); + } else { + return batch_ == null + ? com.google.datastore.v1.AggregationResultBatch.getDefaultInstance() + : batch_; + } + } + + /** + * + * + *
+     * A batch of aggregation results. Always present.
+     * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationResultBatch, + com.google.datastore.v1.AggregationResultBatch.Builder, + com.google.datastore.v1.AggregationResultBatchOrBuilder> + getBatchFieldBuilder() { + if (batchBuilder_ == null) { + batchBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationResultBatch, + com.google.datastore.v1.AggregationResultBatch.Builder, + com.google.datastore.v1.AggregationResultBatchOrBuilder>( + getBatch(), getParentForChildren(), isClean()); + batch_ = null; + } + return batchBuilder_; + } + + private com.google.datastore.v1.AggregationQuery query_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery, + com.google.datastore.v1.AggregationQuery.Builder, + com.google.datastore.v1.AggregationQueryOrBuilder> + queryBuilder_; + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + * + * @return Whether the query field is set. + */ + public boolean hasQuery() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + * + * @return The query. + */ + public com.google.datastore.v1.AggregationQuery getQuery() { + if (queryBuilder_ == null) { + return query_ == null + ? com.google.datastore.v1.AggregationQuery.getDefaultInstance() + : query_; + } else { + return queryBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + */ + public Builder setQuery(com.google.datastore.v1.AggregationQuery value) { + if (queryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + query_ = value; + } else { + queryBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + */ + public Builder setQuery(com.google.datastore.v1.AggregationQuery.Builder builderForValue) { + if (queryBuilder_ == null) { + query_ = builderForValue.build(); + } else { + queryBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + */ + public Builder mergeQuery(com.google.datastore.v1.AggregationQuery value) { + if (queryBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && query_ != null + && query_ != com.google.datastore.v1.AggregationQuery.getDefaultInstance()) { + getQueryBuilder().mergeFrom(value); + } else { + query_ = value; + } + } else { + queryBuilder_.mergeFrom(value); + } + if (query_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + */ + public Builder clearQuery() { + bitField0_ = (bitField0_ & ~0x00000002); + query_ = null; + if (queryBuilder_ != null) { + queryBuilder_.dispose(); + queryBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + */ + public com.google.datastore.v1.AggregationQuery.Builder getQueryBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + */ + public com.google.datastore.v1.AggregationQueryOrBuilder getQueryOrBuilder() { + if (queryBuilder_ != null) { + return queryBuilder_.getMessageOrBuilder(); + } else { + return query_ == null + ? com.google.datastore.v1.AggregationQuery.getDefaultInstance() + : query_; + } + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery, + com.google.datastore.v1.AggregationQuery.Builder, + com.google.datastore.v1.AggregationQueryOrBuilder> + getQueryFieldBuilder() { + if (queryBuilder_ == null) { + queryBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.AggregationQuery, + com.google.datastore.v1.AggregationQuery.Builder, + com.google.datastore.v1.AggregationQueryOrBuilder>( + getQuery(), getParentForChildren(), isClean()); + query_ = null; + } + return queryBuilder_; + } + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * The identifier of the transaction that was started as part of this
+     * RunAggregationQuery request.
+     *
+     * Set only when
+     * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+     * was set in
+     * [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options].
+     * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * The identifier of the transaction that was started as part of this
+     * RunAggregationQuery request.
+     *
+     * Set only when
+     * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+     * was set in
+     * [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options].
+     * 
+ * + * 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(); + } + transaction_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The identifier of the transaction that was started as part of this
+     * RunAggregationQuery request.
+     *
+     * Set only when
+     * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+     * was set in
+     * [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options].
+     * 
+ * + * bytes transaction = 5; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000004); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + private com.google.datastore.v1.ExplainMetrics explainMetrics_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainMetrics, + com.google.datastore.v1.ExplainMetrics.Builder, + com.google.datastore.v1.ExplainMetricsOrBuilder> + explainMetricsBuilder_; + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @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.datastore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @return The explainMetrics. + */ + public com.google.datastore.v1.ExplainMetrics getExplainMetrics() { + if (explainMetricsBuilder_ == null) { + return explainMetrics_ == null + ? com.google.datastore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } else { + return explainMetricsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + public Builder setExplainMetrics(com.google.datastore.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.datastore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + public Builder setExplainMetrics( + com.google.datastore.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.datastore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + public Builder mergeExplainMetrics(com.google.datastore.v1.ExplainMetrics value) { + if (explainMetricsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && explainMetrics_ != null + && explainMetrics_ != com.google.datastore.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.datastore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + 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.datastore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + public com.google.datastore.v1.ExplainMetrics.Builder getExplainMetricsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getExplainMetricsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + public com.google.datastore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() { + if (explainMetricsBuilder_ != null) { + return explainMetricsBuilder_.getMessageOrBuilder(); + } else { + return explainMetrics_ == null + ? com.google.datastore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainMetrics, + com.google.datastore.v1.ExplainMetrics.Builder, + com.google.datastore.v1.ExplainMetricsOrBuilder> + getExplainMetricsFieldBuilder() { + if (explainMetricsBuilder_ == null) { + explainMetricsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainMetrics, + com.google.datastore.v1.ExplainMetrics.Builder, + com.google.datastore.v1.ExplainMetricsOrBuilder>( + getExplainMetrics(), getParentForChildren(), isClean()); + explainMetrics_ = null; + } + return explainMetricsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.RunAggregationQueryResponse) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.RunAggregationQueryResponse) + private static final com.google.datastore.v1.RunAggregationQueryResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.RunAggregationQueryResponse(); + } + + public static com.google.datastore.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.datastore.v1.RunAggregationQueryResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponseOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponseOrBuilder.java new file mode 100644 index 000000000000..877b9f58d3d1 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunAggregationQueryResponseOrBuilder.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! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface RunAggregationQueryResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.RunAggregationQueryResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A batch of aggregation results. Always present.
+   * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + * + * @return Whether the batch field is set. + */ + boolean hasBatch(); + + /** + * + * + *
+   * A batch of aggregation results. Always present.
+   * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + * + * @return The batch. + */ + com.google.datastore.v1.AggregationResultBatch getBatch(); + + /** + * + * + *
+   * A batch of aggregation results. Always present.
+   * 
+ * + * .google.datastore.v1.AggregationResultBatch batch = 1; + */ + com.google.datastore.v1.AggregationResultBatchOrBuilder getBatchOrBuilder(); + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + * + * @return Whether the query field is set. + */ + boolean hasQuery(); + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + * + * @return The query. + */ + com.google.datastore.v1.AggregationQuery getQuery(); + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.AggregationQuery query = 2; + */ + com.google.datastore.v1.AggregationQueryOrBuilder getQueryOrBuilder(); + + /** + * + * + *
+   * The identifier of the transaction that was started as part of this
+   * RunAggregationQuery request.
+   *
+   * Set only when
+   * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+   * was set in
+   * [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options].
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @return Whether the explainMetrics field is set. + */ + boolean hasExplainMetrics(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @return The explainMetrics. + */ + com.google.datastore.v1.ExplainMetrics getExplainMetrics(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + com.google.datastore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequest.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequest.java new file mode 100644 index 000000000000..df93c2817823 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequest.java @@ -0,0 +1,2786 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The request for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.RunQueryRequest} + */ +public final class RunQueryRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.RunQueryRequest) + RunQueryRequestOrBuilder { + private static final long serialVersionUID = 0L; + + // Use RunQueryRequest.newBuilder() to construct. + private RunQueryRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private RunQueryRequest() { + projectId_ = ""; + databaseId_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new RunQueryRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunQueryRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunQueryRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RunQueryRequest.class, + com.google.datastore.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 { + QUERY(3), + GQL_QUERY(7), + 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 3: + return QUERY; + case 7: + return GQL_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 PROJECT_ID_FIELD_NUMBER = 8; + + @SuppressWarnings("serial") + private volatile java.lang.Object projectId_ = ""; + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + @java.lang.Override + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + 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(); + projectId_ = s; + return s; + } + } + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int DATABASE_ID_FIELD_NUMBER = 9; + + @SuppressWarnings("serial") + private volatile java.lang.Object databaseId_ = ""; + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @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 PARTITION_ID_FIELD_NUMBER = 2; + private com.google.datastore.v1.PartitionId partitionId_; + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return Whether the partitionId field is set. + */ + @java.lang.Override + public boolean hasPartitionId() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return The partitionId. + */ + @java.lang.Override + public com.google.datastore.v1.PartitionId getPartitionId() { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + @java.lang.Override + public com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder() { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } + + public static final int READ_OPTIONS_FIELD_NUMBER = 1; + private com.google.datastore.v1.ReadOptions readOptions_; + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return Whether the readOptions field is set. + */ + @java.lang.Override + public boolean hasReadOptions() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return The readOptions. + */ + @java.lang.Override + public com.google.datastore.v1.ReadOptions getReadOptions() { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + @java.lang.Override + public com.google.datastore.v1.ReadOptionsOrBuilder getReadOptionsOrBuilder() { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } + + public static final int QUERY_FIELD_NUMBER = 3; + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.Query query = 3; + * + * @return Whether the query field is set. + */ + @java.lang.Override + public boolean hasQuery() { + return queryTypeCase_ == 3; + } + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.Query query = 3; + * + * @return The query. + */ + @java.lang.Override + public com.google.datastore.v1.Query getQuery() { + if (queryTypeCase_ == 3) { + return (com.google.datastore.v1.Query) queryType_; + } + return com.google.datastore.v1.Query.getDefaultInstance(); + } + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.Query query = 3; + */ + @java.lang.Override + public com.google.datastore.v1.QueryOrBuilder getQueryOrBuilder() { + if (queryTypeCase_ == 3) { + return (com.google.datastore.v1.Query) queryType_; + } + return com.google.datastore.v1.Query.getDefaultInstance(); + } + + public static final int GQL_QUERY_FIELD_NUMBER = 7; + + /** + * + * + *
+   * The GQL query to run. This query must be a non-aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return Whether the gqlQuery field is set. + */ + @java.lang.Override + public boolean hasGqlQuery() { + return queryTypeCase_ == 7; + } + + /** + * + * + *
+   * The GQL query to run. This query must be a non-aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return The gqlQuery. + */ + @java.lang.Override + public com.google.datastore.v1.GqlQuery getGqlQuery() { + if (queryTypeCase_ == 7) { + return (com.google.datastore.v1.GqlQuery) queryType_; + } + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + + /** + * + * + *
+   * The GQL query to run. This query must be a non-aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + @java.lang.Override + public com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder() { + if (queryTypeCase_ == 7) { + return (com.google.datastore.v1.GqlQuery) queryType_; + } + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + + public static final int PROPERTY_MASK_FIELD_NUMBER = 10; + private com.google.datastore.v1.PropertyMask propertyMask_; + + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return Whether the propertyMask field is set. + */ + @java.lang.Override + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return The propertyMask. + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMask getPropertyMask() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + @java.lang.Override + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + + public static final int EXPLAIN_OPTIONS_FIELD_NUMBER = 12; + private com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the explainOptions field is set. + */ + @java.lang.Override + public boolean hasExplainOptions() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + @java.lang.Override + public com.google.datastore.v1.ExplainOptions getExplainOptions() { + return explainOptions_ == null + ? com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.datastore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder() { + return explainOptions_ == null + ? com.google.datastore.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 (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(1, getReadOptions()); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(2, getPartitionId()); + } + if (queryTypeCase_ == 3) { + output.writeMessage(3, (com.google.datastore.v1.Query) queryType_); + } + if (queryTypeCase_ == 7) { + output.writeMessage(7, (com.google.datastore.v1.GqlQuery) queryType_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 9, databaseId_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(10, getPropertyMask()); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(12, getExplainOptions()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getReadOptions()); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getPartitionId()); + } + if (queryTypeCase_ == 3) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 3, (com.google.datastore.v1.Query) queryType_); + } + if (queryTypeCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.datastore.v1.GqlQuery) queryType_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(projectId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(8, projectId_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(databaseId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(9, databaseId_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(10, getPropertyMask()); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(12, 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.datastore.v1.RunQueryRequest)) { + return super.equals(obj); + } + com.google.datastore.v1.RunQueryRequest other = (com.google.datastore.v1.RunQueryRequest) obj; + + if (!getProjectId().equals(other.getProjectId())) return false; + if (!getDatabaseId().equals(other.getDatabaseId())) return false; + if (hasPartitionId() != other.hasPartitionId()) return false; + if (hasPartitionId()) { + if (!getPartitionId().equals(other.getPartitionId())) return false; + } + if (hasReadOptions() != other.hasReadOptions()) return false; + if (hasReadOptions()) { + if (!getReadOptions().equals(other.getReadOptions())) return false; + } + if (hasPropertyMask() != other.hasPropertyMask()) return false; + if (hasPropertyMask()) { + if (!getPropertyMask().equals(other.getPropertyMask())) 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 3: + if (!getQuery().equals(other.getQuery())) return false; + break; + case 7: + if (!getGqlQuery().equals(other.getGqlQuery())) 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) + PROJECT_ID_FIELD_NUMBER; + hash = (53 * hash) + getProjectId().hashCode(); + hash = (37 * hash) + DATABASE_ID_FIELD_NUMBER; + hash = (53 * hash) + getDatabaseId().hashCode(); + if (hasPartitionId()) { + hash = (37 * hash) + PARTITION_ID_FIELD_NUMBER; + hash = (53 * hash) + getPartitionId().hashCode(); + } + if (hasReadOptions()) { + hash = (37 * hash) + READ_OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + getReadOptions().hashCode(); + } + if (hasPropertyMask()) { + hash = (37 * hash) + PROPERTY_MASK_FIELD_NUMBER; + hash = (53 * hash) + getPropertyMask().hashCode(); + } + if (hasExplainOptions()) { + hash = (37 * hash) + EXPLAIN_OPTIONS_FIELD_NUMBER; + hash = (53 * hash) + getExplainOptions().hashCode(); + } + switch (queryTypeCase_) { + case 3: + hash = (37 * hash) + QUERY_FIELD_NUMBER; + hash = (53 * hash) + getQuery().hashCode(); + break; + case 7: + hash = (37 * hash) + GQL_QUERY_FIELD_NUMBER; + hash = (53 * hash) + getGqlQuery().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.RunQueryRequest parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.RunQueryRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.RunQueryRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.RunQueryRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.RunQueryRequest parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunQueryRequest parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RunQueryRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunQueryRequest parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RunQueryRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunQueryRequest parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The request for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.RunQueryRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.RunQueryRequest) + com.google.datastore.v1.RunQueryRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunQueryRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunQueryRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RunQueryRequest.class, + com.google.datastore.v1.RunQueryRequest.Builder.class); + } + + // Construct using com.google.datastore.v1.RunQueryRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getPartitionIdFieldBuilder(); + getReadOptionsFieldBuilder(); + getPropertyMaskFieldBuilder(); + getExplainOptionsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + projectId_ = ""; + databaseId_ = ""; + partitionId_ = null; + if (partitionIdBuilder_ != null) { + partitionIdBuilder_.dispose(); + partitionIdBuilder_ = null; + } + readOptions_ = null; + if (readOptionsBuilder_ != null) { + readOptionsBuilder_.dispose(); + readOptionsBuilder_ = null; + } + if (queryBuilder_ != null) { + queryBuilder_.clear(); + } + if (gqlQueryBuilder_ != null) { + gqlQueryBuilder_.clear(); + } + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } + explainOptions_ = null; + if (explainOptionsBuilder_ != null) { + explainOptionsBuilder_.dispose(); + explainOptionsBuilder_ = null; + } + queryTypeCase_ = 0; + queryType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunQueryRequest_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.RunQueryRequest getDefaultInstanceForType() { + return com.google.datastore.v1.RunQueryRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.RunQueryRequest build() { + com.google.datastore.v1.RunQueryRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.RunQueryRequest buildPartial() { + com.google.datastore.v1.RunQueryRequest result = + new com.google.datastore.v1.RunQueryRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.RunQueryRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.projectId_ = projectId_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.databaseId_ = databaseId_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.partitionId_ = + partitionIdBuilder_ == null ? partitionId_ : partitionIdBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.readOptions_ = + readOptionsBuilder_ == null ? readOptions_ : readOptionsBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.propertyMask_ = + propertyMaskBuilder_ == null ? propertyMask_ : propertyMaskBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000080) != 0)) { + result.explainOptions_ = + explainOptionsBuilder_ == null ? explainOptions_ : explainOptionsBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.datastore.v1.RunQueryRequest result) { + result.queryTypeCase_ = queryTypeCase_; + result.queryType_ = this.queryType_; + if (queryTypeCase_ == 3 && queryBuilder_ != null) { + result.queryType_ = queryBuilder_.build(); + } + if (queryTypeCase_ == 7 && gqlQueryBuilder_ != null) { + result.queryType_ = gqlQueryBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.RunQueryRequest) { + return mergeFrom((com.google.datastore.v1.RunQueryRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.RunQueryRequest other) { + if (other == com.google.datastore.v1.RunQueryRequest.getDefaultInstance()) return this; + if (!other.getProjectId().isEmpty()) { + projectId_ = other.projectId_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getDatabaseId().isEmpty()) { + databaseId_ = other.databaseId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.hasPartitionId()) { + mergePartitionId(other.getPartitionId()); + } + if (other.hasReadOptions()) { + mergeReadOptions(other.getReadOptions()); + } + if (other.hasPropertyMask()) { + mergePropertyMask(other.getPropertyMask()); + } + if (other.hasExplainOptions()) { + mergeExplainOptions(other.getExplainOptions()); + } + switch (other.getQueryTypeCase()) { + case QUERY: + { + mergeQuery(other.getQuery()); + break; + } + case GQL_QUERY: + { + mergeGqlQuery(other.getGqlQuery()); + 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(getReadOptionsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 10 + case 18: + { + input.readMessage(getPartitionIdFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 18 + case 26: + { + input.readMessage(getQueryFieldBuilder().getBuilder(), extensionRegistry); + queryTypeCase_ = 3; + break; + } // case 26 + case 58: + { + input.readMessage(getGqlQueryFieldBuilder().getBuilder(), extensionRegistry); + queryTypeCase_ = 7; + break; + } // case 58 + case 66: + { + projectId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 66 + case 74: + { + databaseId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 74 + case 82: + { + input.readMessage(getPropertyMaskFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000040; + break; + } // case 82 + case 98: + { + input.readMessage(getExplainOptionsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000080; + 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 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 projectId_ = ""; + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + public java.lang.String getProjectId() { + java.lang.Object ref = projectId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + projectId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + public com.google.protobuf.ByteString getProjectIdBytes() { + java.lang.Object ref = projectId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + projectId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearProjectId() { + projectId_ = getDefaultInstance().getProjectId(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + + /** + * + * + *
+     * Required. The ID of the project against which to make the request.
+     * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for projectId to set. + * @return This builder for chaining. + */ + public Builder setProjectIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + projectId_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object databaseId_ = ""; + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @return This builder for chaining. + */ + public Builder clearDatabaseId() { + databaseId_ = getDefaultInstance().getDatabaseId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * + * + *
+     * The ID of the database against which to make the request.
+     *
+     * '(default)' is not allowed; please use empty string '' to refer the default
+     * database.
+     * 
+ * + * string database_id = 9; + * + * @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.datastore.v1.PartitionId partitionId_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PartitionId, + com.google.datastore.v1.PartitionId.Builder, + com.google.datastore.v1.PartitionIdOrBuilder> + partitionIdBuilder_; + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return Whether the partitionId field is set. + */ + public boolean hasPartitionId() { + return ((bitField0_ & 0x00000004) != 0); + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return The partitionId. + */ + public com.google.datastore.v1.PartitionId getPartitionId() { + if (partitionIdBuilder_ == null) { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } else { + return partitionIdBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public Builder setPartitionId(com.google.datastore.v1.PartitionId value) { + if (partitionIdBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + partitionId_ = value; + } else { + partitionIdBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public Builder setPartitionId(com.google.datastore.v1.PartitionId.Builder builderForValue) { + if (partitionIdBuilder_ == null) { + partitionId_ = builderForValue.build(); + } else { + partitionIdBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public Builder mergePartitionId(com.google.datastore.v1.PartitionId value) { + if (partitionIdBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && partitionId_ != null + && partitionId_ != com.google.datastore.v1.PartitionId.getDefaultInstance()) { + getPartitionIdBuilder().mergeFrom(value); + } else { + partitionId_ = value; + } + } else { + partitionIdBuilder_.mergeFrom(value); + } + if (partitionId_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public Builder clearPartitionId() { + bitField0_ = (bitField0_ & ~0x00000004); + partitionId_ = null; + if (partitionIdBuilder_ != null) { + partitionIdBuilder_.dispose(); + partitionIdBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public com.google.datastore.v1.PartitionId.Builder getPartitionIdBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getPartitionIdFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + public com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder() { + if (partitionIdBuilder_ != null) { + return partitionIdBuilder_.getMessageOrBuilder(); + } else { + return partitionId_ == null + ? com.google.datastore.v1.PartitionId.getDefaultInstance() + : partitionId_; + } + } + + /** + * + * + *
+     * Entities are partitioned into subsets, identified by a partition ID.
+     * Queries are scoped to a single partition.
+     * This partition ID is normalized with the standard default context
+     * partition ID.
+     * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PartitionId, + com.google.datastore.v1.PartitionId.Builder, + com.google.datastore.v1.PartitionIdOrBuilder> + getPartitionIdFieldBuilder() { + if (partitionIdBuilder_ == null) { + partitionIdBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PartitionId, + com.google.datastore.v1.PartitionId.Builder, + com.google.datastore.v1.PartitionIdOrBuilder>( + getPartitionId(), getParentForChildren(), isClean()); + partitionId_ = null; + } + return partitionIdBuilder_; + } + + private com.google.datastore.v1.ReadOptions readOptions_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ReadOptions, + com.google.datastore.v1.ReadOptions.Builder, + com.google.datastore.v1.ReadOptionsOrBuilder> + readOptionsBuilder_; + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return Whether the readOptions field is set. + */ + public boolean hasReadOptions() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return The readOptions. + */ + public com.google.datastore.v1.ReadOptions getReadOptions() { + if (readOptionsBuilder_ == null) { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } else { + return readOptionsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder setReadOptions(com.google.datastore.v1.ReadOptions value) { + if (readOptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readOptions_ = value; + } else { + readOptionsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder setReadOptions(com.google.datastore.v1.ReadOptions.Builder builderForValue) { + if (readOptionsBuilder_ == null) { + readOptions_ = builderForValue.build(); + } else { + readOptionsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder mergeReadOptions(com.google.datastore.v1.ReadOptions value) { + if (readOptionsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && readOptions_ != null + && readOptions_ != com.google.datastore.v1.ReadOptions.getDefaultInstance()) { + getReadOptionsBuilder().mergeFrom(value); + } else { + readOptions_ = value; + } + } else { + readOptionsBuilder_.mergeFrom(value); + } + if (readOptions_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public Builder clearReadOptions() { + bitField0_ = (bitField0_ & ~0x00000008); + readOptions_ = null; + if (readOptionsBuilder_ != null) { + readOptionsBuilder_.dispose(); + readOptionsBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public com.google.datastore.v1.ReadOptions.Builder getReadOptionsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getReadOptionsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + public com.google.datastore.v1.ReadOptionsOrBuilder getReadOptionsOrBuilder() { + if (readOptionsBuilder_ != null) { + return readOptionsBuilder_.getMessageOrBuilder(); + } else { + return readOptions_ == null + ? com.google.datastore.v1.ReadOptions.getDefaultInstance() + : readOptions_; + } + } + + /** + * + * + *
+     * The options for this query.
+     * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ReadOptions, + com.google.datastore.v1.ReadOptions.Builder, + com.google.datastore.v1.ReadOptionsOrBuilder> + getReadOptionsFieldBuilder() { + if (readOptionsBuilder_ == null) { + readOptionsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ReadOptions, + com.google.datastore.v1.ReadOptions.Builder, + com.google.datastore.v1.ReadOptionsOrBuilder>( + getReadOptions(), getParentForChildren(), isClean()); + readOptions_ = null; + } + return readOptionsBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Query, + com.google.datastore.v1.Query.Builder, + com.google.datastore.v1.QueryOrBuilder> + queryBuilder_; + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.Query query = 3; + * + * @return Whether the query field is set. + */ + @java.lang.Override + public boolean hasQuery() { + return queryTypeCase_ == 3; + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.Query query = 3; + * + * @return The query. + */ + @java.lang.Override + public com.google.datastore.v1.Query getQuery() { + if (queryBuilder_ == null) { + if (queryTypeCase_ == 3) { + return (com.google.datastore.v1.Query) queryType_; + } + return com.google.datastore.v1.Query.getDefaultInstance(); + } else { + if (queryTypeCase_ == 3) { + return queryBuilder_.getMessage(); + } + return com.google.datastore.v1.Query.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.Query query = 3; + */ + public Builder setQuery(com.google.datastore.v1.Query value) { + if (queryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + queryBuilder_.setMessage(value); + } + queryTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.Query query = 3; + */ + public Builder setQuery(com.google.datastore.v1.Query.Builder builderForValue) { + if (queryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + queryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.Query query = 3; + */ + public Builder mergeQuery(com.google.datastore.v1.Query value) { + if (queryBuilder_ == null) { + if (queryTypeCase_ == 3 + && queryType_ != com.google.datastore.v1.Query.getDefaultInstance()) { + queryType_ = + com.google.datastore.v1.Query.newBuilder((com.google.datastore.v1.Query) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 3) { + queryBuilder_.mergeFrom(value); + } else { + queryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 3; + return this; + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.Query query = 3; + */ + public Builder clearQuery() { + if (queryBuilder_ == null) { + if (queryTypeCase_ == 3) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 3) { + queryTypeCase_ = 0; + queryType_ = null; + } + queryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.Query query = 3; + */ + public com.google.datastore.v1.Query.Builder getQueryBuilder() { + return getQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.Query query = 3; + */ + @java.lang.Override + public com.google.datastore.v1.QueryOrBuilder getQueryOrBuilder() { + if ((queryTypeCase_ == 3) && (queryBuilder_ != null)) { + return queryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 3) { + return (com.google.datastore.v1.Query) queryType_; + } + return com.google.datastore.v1.Query.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The query to run.
+     * 
+ * + * .google.datastore.v1.Query query = 3; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Query, + com.google.datastore.v1.Query.Builder, + com.google.datastore.v1.QueryOrBuilder> + getQueryFieldBuilder() { + if (queryBuilder_ == null) { + if (!(queryTypeCase_ == 3)) { + queryType_ = com.google.datastore.v1.Query.getDefaultInstance(); + } + queryBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Query, + com.google.datastore.v1.Query.Builder, + com.google.datastore.v1.QueryOrBuilder>( + (com.google.datastore.v1.Query) queryType_, getParentForChildren(), isClean()); + queryType_ = null; + } + queryTypeCase_ = 3; + onChanged(); + return queryBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.GqlQuery, + com.google.datastore.v1.GqlQuery.Builder, + com.google.datastore.v1.GqlQueryOrBuilder> + gqlQueryBuilder_; + + /** + * + * + *
+     * The GQL query to run. This query must be a non-aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return Whether the gqlQuery field is set. + */ + @java.lang.Override + public boolean hasGqlQuery() { + return queryTypeCase_ == 7; + } + + /** + * + * + *
+     * The GQL query to run. This query must be a non-aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return The gqlQuery. + */ + @java.lang.Override + public com.google.datastore.v1.GqlQuery getGqlQuery() { + if (gqlQueryBuilder_ == null) { + if (queryTypeCase_ == 7) { + return (com.google.datastore.v1.GqlQuery) queryType_; + } + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } else { + if (queryTypeCase_ == 7) { + return gqlQueryBuilder_.getMessage(); + } + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The GQL query to run. This query must be a non-aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + public Builder setGqlQuery(com.google.datastore.v1.GqlQuery value) { + if (gqlQueryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + queryType_ = value; + onChanged(); + } else { + gqlQueryBuilder_.setMessage(value); + } + queryTypeCase_ = 7; + return this; + } + + /** + * + * + *
+     * The GQL query to run. This query must be a non-aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + public Builder setGqlQuery(com.google.datastore.v1.GqlQuery.Builder builderForValue) { + if (gqlQueryBuilder_ == null) { + queryType_ = builderForValue.build(); + onChanged(); + } else { + gqlQueryBuilder_.setMessage(builderForValue.build()); + } + queryTypeCase_ = 7; + return this; + } + + /** + * + * + *
+     * The GQL query to run. This query must be a non-aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + public Builder mergeGqlQuery(com.google.datastore.v1.GqlQuery value) { + if (gqlQueryBuilder_ == null) { + if (queryTypeCase_ == 7 + && queryType_ != com.google.datastore.v1.GqlQuery.getDefaultInstance()) { + queryType_ = + com.google.datastore.v1.GqlQuery.newBuilder( + (com.google.datastore.v1.GqlQuery) queryType_) + .mergeFrom(value) + .buildPartial(); + } else { + queryType_ = value; + } + onChanged(); + } else { + if (queryTypeCase_ == 7) { + gqlQueryBuilder_.mergeFrom(value); + } else { + gqlQueryBuilder_.setMessage(value); + } + } + queryTypeCase_ = 7; + return this; + } + + /** + * + * + *
+     * The GQL query to run. This query must be a non-aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + public Builder clearGqlQuery() { + if (gqlQueryBuilder_ == null) { + if (queryTypeCase_ == 7) { + queryTypeCase_ = 0; + queryType_ = null; + onChanged(); + } + } else { + if (queryTypeCase_ == 7) { + queryTypeCase_ = 0; + queryType_ = null; + } + gqlQueryBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The GQL query to run. This query must be a non-aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + public com.google.datastore.v1.GqlQuery.Builder getGqlQueryBuilder() { + return getGqlQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The GQL query to run. This query must be a non-aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + @java.lang.Override + public com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder() { + if ((queryTypeCase_ == 7) && (gqlQueryBuilder_ != null)) { + return gqlQueryBuilder_.getMessageOrBuilder(); + } else { + if (queryTypeCase_ == 7) { + return (com.google.datastore.v1.GqlQuery) queryType_; + } + return com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The GQL query to run. This query must be a non-aggregation query.
+     * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.GqlQuery, + com.google.datastore.v1.GqlQuery.Builder, + com.google.datastore.v1.GqlQueryOrBuilder> + getGqlQueryFieldBuilder() { + if (gqlQueryBuilder_ == null) { + if (!(queryTypeCase_ == 7)) { + queryType_ = com.google.datastore.v1.GqlQuery.getDefaultInstance(); + } + gqlQueryBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.GqlQuery, + com.google.datastore.v1.GqlQuery.Builder, + com.google.datastore.v1.GqlQueryOrBuilder>( + (com.google.datastore.v1.GqlQuery) queryType_, getParentForChildren(), isClean()); + queryType_ = null; + } + queryTypeCase_ = 7; + onChanged(); + return gqlQueryBuilder_; + } + + private com.google.datastore.v1.PropertyMask propertyMask_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + propertyMaskBuilder_; + + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return Whether the propertyMask field is set. + */ + public boolean hasPropertyMask() { + return ((bitField0_ & 0x00000040) != 0); + } + + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return The propertyMask. + */ + public com.google.datastore.v1.PropertyMask getPropertyMask() { + if (propertyMaskBuilder_ == null) { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } else { + return propertyMaskBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + propertyMask_ = value; + } else { + propertyMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public Builder setPropertyMask(com.google.datastore.v1.PropertyMask.Builder builderForValue) { + if (propertyMaskBuilder_ == null) { + propertyMask_ = builderForValue.build(); + } else { + propertyMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public Builder mergePropertyMask(com.google.datastore.v1.PropertyMask value) { + if (propertyMaskBuilder_ == null) { + if (((bitField0_ & 0x00000040) != 0) + && propertyMask_ != null + && propertyMask_ != com.google.datastore.v1.PropertyMask.getDefaultInstance()) { + getPropertyMaskBuilder().mergeFrom(value); + } else { + propertyMask_ = value; + } + } else { + propertyMaskBuilder_.mergeFrom(value); + } + if (propertyMask_ != null) { + bitField0_ |= 0x00000040; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public Builder clearPropertyMask() { + bitField0_ = (bitField0_ & ~0x00000040); + propertyMask_ = null; + if (propertyMaskBuilder_ != null) { + propertyMaskBuilder_.dispose(); + propertyMaskBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public com.google.datastore.v1.PropertyMask.Builder getPropertyMaskBuilder() { + bitField0_ |= 0x00000040; + onChanged(); + return getPropertyMaskFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + public com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder() { + if (propertyMaskBuilder_ != null) { + return propertyMaskBuilder_.getMessageOrBuilder(); + } else { + return propertyMask_ == null + ? com.google.datastore.v1.PropertyMask.getDefaultInstance() + : propertyMask_; + } + } + + /** + * + * + *
+     * The properties to return.
+     * This field must not be set for a projection query.
+     *
+     * See
+     * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+     * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder> + getPropertyMaskFieldBuilder() { + if (propertyMaskBuilder_ == null) { + propertyMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.PropertyMask, + com.google.datastore.v1.PropertyMask.Builder, + com.google.datastore.v1.PropertyMaskOrBuilder>( + getPropertyMask(), getParentForChildren(), isClean()); + propertyMask_ = null; + } + return propertyMaskBuilder_; + } + + private com.google.datastore.v1.ExplainOptions explainOptions_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainOptions, + com.google.datastore.v1.ExplainOptions.Builder, + com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the explainOptions field is set. + */ + public boolean hasExplainOptions() { + return ((bitField0_ & 0x00000080) != 0); + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + public com.google.datastore.v1.ExplainOptions getExplainOptions() { + if (explainOptionsBuilder_ == null) { + return explainOptions_ == null + ? com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setExplainOptions(com.google.datastore.v1.ExplainOptions value) { + if (explainOptionsBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + explainOptions_ = value; + } else { + explainOptionsBuilder_.setMessage(value); + } + bitField0_ |= 0x00000080; + 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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setExplainOptions( + com.google.datastore.v1.ExplainOptions.Builder builderForValue) { + if (explainOptionsBuilder_ == null) { + explainOptions_ = builderForValue.build(); + } else { + explainOptionsBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000080; + 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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeExplainOptions(com.google.datastore.v1.ExplainOptions value) { + if (explainOptionsBuilder_ == null) { + if (((bitField0_ & 0x00000080) != 0) + && explainOptions_ != null + && explainOptions_ != com.google.datastore.v1.ExplainOptions.getDefaultInstance()) { + getExplainOptionsBuilder().mergeFrom(value); + } else { + explainOptions_ = value; + } + } else { + explainOptionsBuilder_.mergeFrom(value); + } + if (explainOptions_ != null) { + bitField0_ |= 0x00000080; + 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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearExplainOptions() { + bitField0_ = (bitField0_ & ~0x00000080); + 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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.ExplainOptions.Builder getExplainOptionsBuilder() { + bitField0_ |= 0x00000080; + onChanged(); + return getExplainOptionsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Optional. Explain options for the query. If set, additional query
+     * statistics will be returned. If not, only query results will be returned.
+     * 
+ * + * + * .google.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.datastore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder() { + if (explainOptionsBuilder_ != null) { + return explainOptionsBuilder_.getMessageOrBuilder(); + } else { + return explainOptions_ == null + ? com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainOptions, + com.google.datastore.v1.ExplainOptions.Builder, + com.google.datastore.v1.ExplainOptionsOrBuilder> + getExplainOptionsFieldBuilder() { + if (explainOptionsBuilder_ == null) { + explainOptionsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainOptions, + com.google.datastore.v1.ExplainOptions.Builder, + com.google.datastore.v1.ExplainOptionsOrBuilder>( + getExplainOptions(), getParentForChildren(), isClean()); + explainOptions_ = null; + } + return explainOptionsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.RunQueryRequest) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.RunQueryRequest) + private static final com.google.datastore.v1.RunQueryRequest DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.RunQueryRequest(); + } + + public static com.google.datastore.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.datastore.v1.RunQueryRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequestOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequestOrBuilder.java new file mode 100644 index 000000000000..e76e33170636 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryRequestOrBuilder.java @@ -0,0 +1,338 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface RunQueryRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.RunQueryRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The projectId. + */ + java.lang.String getProjectId(); + + /** + * + * + *
+   * Required. The ID of the project against which to make the request.
+   * 
+ * + * string project_id = 8 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for projectId. + */ + com.google.protobuf.ByteString getProjectIdBytes(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The databaseId. + */ + java.lang.String getDatabaseId(); + + /** + * + * + *
+   * The ID of the database against which to make the request.
+   *
+   * '(default)' is not allowed; please use empty string '' to refer the default
+   * database.
+   * 
+ * + * string database_id = 9; + * + * @return The bytes for databaseId. + */ + com.google.protobuf.ByteString getDatabaseIdBytes(); + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return Whether the partitionId field is set. + */ + boolean hasPartitionId(); + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + * + * @return The partitionId. + */ + com.google.datastore.v1.PartitionId getPartitionId(); + + /** + * + * + *
+   * Entities are partitioned into subsets, identified by a partition ID.
+   * Queries are scoped to a single partition.
+   * This partition ID is normalized with the standard default context
+   * partition ID.
+   * 
+ * + * .google.datastore.v1.PartitionId partition_id = 2; + */ + com.google.datastore.v1.PartitionIdOrBuilder getPartitionIdOrBuilder(); + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return Whether the readOptions field is set. + */ + boolean hasReadOptions(); + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + * + * @return The readOptions. + */ + com.google.datastore.v1.ReadOptions getReadOptions(); + + /** + * + * + *
+   * The options for this query.
+   * 
+ * + * .google.datastore.v1.ReadOptions read_options = 1; + */ + com.google.datastore.v1.ReadOptionsOrBuilder getReadOptionsOrBuilder(); + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.Query query = 3; + * + * @return Whether the query field is set. + */ + boolean hasQuery(); + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.Query query = 3; + * + * @return The query. + */ + com.google.datastore.v1.Query getQuery(); + + /** + * + * + *
+   * The query to run.
+   * 
+ * + * .google.datastore.v1.Query query = 3; + */ + com.google.datastore.v1.QueryOrBuilder getQueryOrBuilder(); + + /** + * + * + *
+   * The GQL query to run. This query must be a non-aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return Whether the gqlQuery field is set. + */ + boolean hasGqlQuery(); + + /** + * + * + *
+   * The GQL query to run. This query must be a non-aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + * + * @return The gqlQuery. + */ + com.google.datastore.v1.GqlQuery getGqlQuery(); + + /** + * + * + *
+   * The GQL query to run. This query must be a non-aggregation query.
+   * 
+ * + * .google.datastore.v1.GqlQuery gql_query = 7; + */ + com.google.datastore.v1.GqlQueryOrBuilder getGqlQueryOrBuilder(); + + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return Whether the propertyMask field is set. + */ + boolean hasPropertyMask(); + + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + * + * @return The propertyMask. + */ + com.google.datastore.v1.PropertyMask getPropertyMask(); + + /** + * + * + *
+   * The properties to return.
+   * This field must not be set for a projection query.
+   *
+   * See
+   * [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask].
+   * 
+ * + * .google.datastore.v1.PropertyMask property_mask = 10; + */ + com.google.datastore.v1.PropertyMaskOrBuilder getPropertyMaskOrBuilder(); + + /** + * + * + *
+   * Optional. Explain options for the query. If set, additional query
+   * statistics will be returned. If not, only query results will be returned.
+   * 
+ * + * + * .google.datastore.v1.ExplainOptions explain_options = 12 [(.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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The explainOptions. + */ + com.google.datastore.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.datastore.v1.ExplainOptions explain_options = 12 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.datastore.v1.ExplainOptionsOrBuilder getExplainOptionsOrBuilder(); + + com.google.datastore.v1.RunQueryRequest.QueryTypeCase getQueryTypeCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponse.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponse.java new file mode 100644 index 000000000000..967b0ab56d33 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponse.java @@ -0,0 +1,1434 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * The response for
+ * [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
+ * 
+ * + * Protobuf type {@code google.datastore.v1.RunQueryResponse} + */ +public final class RunQueryResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.RunQueryResponse) + RunQueryResponseOrBuilder { + private static final long serialVersionUID = 0L; + + // Use RunQueryResponse.newBuilder() to construct. + private RunQueryResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private RunQueryResponse() { + transaction_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new RunQueryResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunQueryResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunQueryResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RunQueryResponse.class, + com.google.datastore.v1.RunQueryResponse.Builder.class); + } + + private int bitField0_; + public static final int BATCH_FIELD_NUMBER = 1; + private com.google.datastore.v1.QueryResultBatch batch_; + + /** + * + * + *
+   * A batch of query results (always present).
+   * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + * + * @return Whether the batch field is set. + */ + @java.lang.Override + public boolean hasBatch() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+   * A batch of query results (always present).
+   * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + * + * @return The batch. + */ + @java.lang.Override + public com.google.datastore.v1.QueryResultBatch getBatch() { + return batch_ == null ? com.google.datastore.v1.QueryResultBatch.getDefaultInstance() : batch_; + } + + /** + * + * + *
+   * A batch of query results (always present).
+   * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + */ + @java.lang.Override + public com.google.datastore.v1.QueryResultBatchOrBuilder getBatchOrBuilder() { + return batch_ == null ? com.google.datastore.v1.QueryResultBatch.getDefaultInstance() : batch_; + } + + public static final int QUERY_FIELD_NUMBER = 2; + private com.google.datastore.v1.Query query_; + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.Query query = 2; + * + * @return Whether the query field is set. + */ + @java.lang.Override + public boolean hasQuery() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.Query query = 2; + * + * @return The query. + */ + @java.lang.Override + public com.google.datastore.v1.Query getQuery() { + return query_ == null ? com.google.datastore.v1.Query.getDefaultInstance() : query_; + } + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.Query query = 2; + */ + @java.lang.Override + public com.google.datastore.v1.QueryOrBuilder getQueryOrBuilder() { + return query_ == null ? com.google.datastore.v1.Query.getDefaultInstance() : query_; + } + + public static final int TRANSACTION_FIELD_NUMBER = 5; + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+   * The identifier of the transaction that was started as part of this
+   * RunQuery request.
+   *
+   * Set only when
+   * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+   * was set in
+   * [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options].
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + public static final int EXPLAIN_METRICS_FIELD_NUMBER = 9; + private com.google.datastore.v1.ExplainMetrics explainMetrics_; + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @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.datastore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @return The explainMetrics. + */ + @java.lang.Override + public com.google.datastore.v1.ExplainMetrics getExplainMetrics() { + return explainMetrics_ == null + ? com.google.datastore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + @java.lang.Override + public com.google.datastore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() { + return explainMetrics_ == null + ? com.google.datastore.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, getBatch()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getQuery()); + } + if (!transaction_.isEmpty()) { + output.writeBytes(5, transaction_); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(9, 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, getBatch()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getQuery()); + } + if (!transaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(5, transaction_); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, 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.datastore.v1.RunQueryResponse)) { + return super.equals(obj); + } + com.google.datastore.v1.RunQueryResponse other = (com.google.datastore.v1.RunQueryResponse) obj; + + if (hasBatch() != other.hasBatch()) return false; + if (hasBatch()) { + if (!getBatch().equals(other.getBatch())) return false; + } + if (hasQuery() != other.hasQuery()) return false; + if (hasQuery()) { + if (!getQuery().equals(other.getQuery())) return false; + } + if (!getTransaction().equals(other.getTransaction())) 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 (hasBatch()) { + hash = (37 * hash) + BATCH_FIELD_NUMBER; + hash = (53 * hash) + getBatch().hashCode(); + } + if (hasQuery()) { + hash = (37 * hash) + QUERY_FIELD_NUMBER; + hash = (53 * hash) + getQuery().hashCode(); + } + hash = (37 * hash) + TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getTransaction().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.datastore.v1.RunQueryResponse parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.RunQueryResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.RunQueryResponse parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.RunQueryResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.RunQueryResponse parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunQueryResponse parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RunQueryResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunQueryResponse parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.RunQueryResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.RunQueryResponse parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * The response for
+   * [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery].
+   * 
+ * + * Protobuf type {@code google.datastore.v1.RunQueryResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.RunQueryResponse) + com.google.datastore.v1.RunQueryResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunQueryResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunQueryResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.RunQueryResponse.class, + com.google.datastore.v1.RunQueryResponse.Builder.class); + } + + // Construct using com.google.datastore.v1.RunQueryResponse.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getBatchFieldBuilder(); + getQueryFieldBuilder(); + getExplainMetricsFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + batch_ = null; + if (batchBuilder_ != null) { + batchBuilder_.dispose(); + batchBuilder_ = null; + } + query_ = null; + if (queryBuilder_ != null) { + queryBuilder_.dispose(); + queryBuilder_ = null; + } + transaction_ = com.google.protobuf.ByteString.EMPTY; + explainMetrics_ = null; + if (explainMetricsBuilder_ != null) { + explainMetricsBuilder_.dispose(); + explainMetricsBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_RunQueryResponse_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.RunQueryResponse getDefaultInstanceForType() { + return com.google.datastore.v1.RunQueryResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.RunQueryResponse build() { + com.google.datastore.v1.RunQueryResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.RunQueryResponse buildPartial() { + com.google.datastore.v1.RunQueryResponse result = + new com.google.datastore.v1.RunQueryResponse(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.RunQueryResponse result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.batch_ = batchBuilder_ == null ? batch_ : batchBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.query_ = queryBuilder_ == null ? query_ : queryBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.transaction_ = transaction_; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.explainMetrics_ = + explainMetricsBuilder_ == null ? explainMetrics_ : explainMetricsBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.RunQueryResponse) { + return mergeFrom((com.google.datastore.v1.RunQueryResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.RunQueryResponse other) { + if (other == com.google.datastore.v1.RunQueryResponse.getDefaultInstance()) return this; + if (other.hasBatch()) { + mergeBatch(other.getBatch()); + } + if (other.hasQuery()) { + mergeQuery(other.getQuery()); + } + if (other.getTransaction() != com.google.protobuf.ByteString.EMPTY) { + setTransaction(other.getTransaction()); + } + 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(getBatchFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getQueryFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 42: + { + transaction_ = input.readBytes(); + bitField0_ |= 0x00000004; + break; + } // case 42 + case 74: + { + input.readMessage(getExplainMetricsFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + 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.datastore.v1.QueryResultBatch batch_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.QueryResultBatch, + com.google.datastore.v1.QueryResultBatch.Builder, + com.google.datastore.v1.QueryResultBatchOrBuilder> + batchBuilder_; + + /** + * + * + *
+     * A batch of query results (always present).
+     * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + * + * @return Whether the batch field is set. + */ + public boolean hasBatch() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * A batch of query results (always present).
+     * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + * + * @return The batch. + */ + public com.google.datastore.v1.QueryResultBatch getBatch() { + if (batchBuilder_ == null) { + return batch_ == null + ? com.google.datastore.v1.QueryResultBatch.getDefaultInstance() + : batch_; + } else { + return batchBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * A batch of query results (always present).
+     * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + */ + public Builder setBatch(com.google.datastore.v1.QueryResultBatch value) { + if (batchBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + batch_ = value; + } else { + batchBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * A batch of query results (always present).
+     * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + */ + public Builder setBatch(com.google.datastore.v1.QueryResultBatch.Builder builderForValue) { + if (batchBuilder_ == null) { + batch_ = builderForValue.build(); + } else { + batchBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+     * A batch of query results (always present).
+     * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + */ + public Builder mergeBatch(com.google.datastore.v1.QueryResultBatch value) { + if (batchBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && batch_ != null + && batch_ != com.google.datastore.v1.QueryResultBatch.getDefaultInstance()) { + getBatchBuilder().mergeFrom(value); + } else { + batch_ = value; + } + } else { + batchBuilder_.mergeFrom(value); + } + if (batch_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A batch of query results (always present).
+     * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + */ + public Builder clearBatch() { + bitField0_ = (bitField0_ & ~0x00000001); + batch_ = null; + if (batchBuilder_ != null) { + batchBuilder_.dispose(); + batchBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * A batch of query results (always present).
+     * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + */ + public com.google.datastore.v1.QueryResultBatch.Builder getBatchBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getBatchFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A batch of query results (always present).
+     * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + */ + public com.google.datastore.v1.QueryResultBatchOrBuilder getBatchOrBuilder() { + if (batchBuilder_ != null) { + return batchBuilder_.getMessageOrBuilder(); + } else { + return batch_ == null + ? com.google.datastore.v1.QueryResultBatch.getDefaultInstance() + : batch_; + } + } + + /** + * + * + *
+     * A batch of query results (always present).
+     * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.QueryResultBatch, + com.google.datastore.v1.QueryResultBatch.Builder, + com.google.datastore.v1.QueryResultBatchOrBuilder> + getBatchFieldBuilder() { + if (batchBuilder_ == null) { + batchBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.QueryResultBatch, + com.google.datastore.v1.QueryResultBatch.Builder, + com.google.datastore.v1.QueryResultBatchOrBuilder>( + getBatch(), getParentForChildren(), isClean()); + batch_ = null; + } + return batchBuilder_; + } + + private com.google.datastore.v1.Query query_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Query, + com.google.datastore.v1.Query.Builder, + com.google.datastore.v1.QueryOrBuilder> + queryBuilder_; + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.Query query = 2; + * + * @return Whether the query field is set. + */ + public boolean hasQuery() { + return ((bitField0_ & 0x00000002) != 0); + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.Query query = 2; + * + * @return The query. + */ + public com.google.datastore.v1.Query getQuery() { + if (queryBuilder_ == null) { + return query_ == null ? com.google.datastore.v1.Query.getDefaultInstance() : query_; + } else { + return queryBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.Query query = 2; + */ + public Builder setQuery(com.google.datastore.v1.Query value) { + if (queryBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + query_ = value; + } else { + queryBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.Query query = 2; + */ + public Builder setQuery(com.google.datastore.v1.Query.Builder builderForValue) { + if (queryBuilder_ == null) { + query_ = builderForValue.build(); + } else { + queryBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.Query query = 2; + */ + public Builder mergeQuery(com.google.datastore.v1.Query value) { + if (queryBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && query_ != null + && query_ != com.google.datastore.v1.Query.getDefaultInstance()) { + getQueryBuilder().mergeFrom(value); + } else { + query_ = value; + } + } else { + queryBuilder_.mergeFrom(value); + } + if (query_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.Query query = 2; + */ + public Builder clearQuery() { + bitField0_ = (bitField0_ & ~0x00000002); + query_ = null; + if (queryBuilder_ != null) { + queryBuilder_.dispose(); + queryBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.Query query = 2; + */ + public com.google.datastore.v1.Query.Builder getQueryBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getQueryFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.Query query = 2; + */ + public com.google.datastore.v1.QueryOrBuilder getQueryOrBuilder() { + if (queryBuilder_ != null) { + return queryBuilder_.getMessageOrBuilder(); + } else { + return query_ == null ? com.google.datastore.v1.Query.getDefaultInstance() : query_; + } + } + + /** + * + * + *
+     * The parsed form of the `GqlQuery` from the request, if it was set.
+     * 
+ * + * .google.datastore.v1.Query query = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Query, + com.google.datastore.v1.Query.Builder, + com.google.datastore.v1.QueryOrBuilder> + getQueryFieldBuilder() { + if (queryBuilder_ == null) { + queryBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Query, + com.google.datastore.v1.Query.Builder, + com.google.datastore.v1.QueryOrBuilder>( + getQuery(), getParentForChildren(), isClean()); + query_ = null; + } + return queryBuilder_; + } + + private com.google.protobuf.ByteString transaction_ = com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * The identifier of the transaction that was started as part of this
+     * RunQuery request.
+     *
+     * Set only when
+     * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+     * was set in
+     * [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options].
+     * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTransaction() { + return transaction_; + } + + /** + * + * + *
+     * The identifier of the transaction that was started as part of this
+     * RunQuery request.
+     *
+     * Set only when
+     * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+     * was set in
+     * [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options].
+     * 
+ * + * 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(); + } + transaction_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + + /** + * + * + *
+     * The identifier of the transaction that was started as part of this
+     * RunQuery request.
+     *
+     * Set only when
+     * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+     * was set in
+     * [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options].
+     * 
+ * + * bytes transaction = 5; + * + * @return This builder for chaining. + */ + public Builder clearTransaction() { + bitField0_ = (bitField0_ & ~0x00000004); + transaction_ = getDefaultInstance().getTransaction(); + onChanged(); + return this; + } + + private com.google.datastore.v1.ExplainMetrics explainMetrics_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainMetrics, + com.google.datastore.v1.ExplainMetrics.Builder, + com.google.datastore.v1.ExplainMetricsOrBuilder> + explainMetricsBuilder_; + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @return Whether the explainMetrics field is set. + */ + public boolean hasExplainMetrics() { + return ((bitField0_ & 0x00000008) != 0); + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @return The explainMetrics. + */ + public com.google.datastore.v1.ExplainMetrics getExplainMetrics() { + if (explainMetricsBuilder_ == null) { + return explainMetrics_ == null + ? com.google.datastore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } else { + return explainMetricsBuilder_.getMessage(); + } + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + public Builder setExplainMetrics(com.google.datastore.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
+     * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + public Builder setExplainMetrics( + com.google.datastore.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
+     * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + public Builder mergeExplainMetrics(com.google.datastore.v1.ExplainMetrics value) { + if (explainMetricsBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && explainMetrics_ != null + && explainMetrics_ != com.google.datastore.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
+     * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + 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
+     * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + public com.google.datastore.v1.ExplainMetrics.Builder getExplainMetricsBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getExplainMetricsFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + public com.google.datastore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder() { + if (explainMetricsBuilder_ != null) { + return explainMetricsBuilder_.getMessageOrBuilder(); + } else { + return explainMetrics_ == null + ? com.google.datastore.v1.ExplainMetrics.getDefaultInstance() + : explainMetrics_; + } + } + + /** + * + * + *
+     * Query explain metrics. This is only present when the
+     * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+     * is provided, and it is sent only once with the last response in the stream.
+     * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainMetrics, + com.google.datastore.v1.ExplainMetrics.Builder, + com.google.datastore.v1.ExplainMetricsOrBuilder> + getExplainMetricsFieldBuilder() { + if (explainMetricsBuilder_ == null) { + explainMetricsBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ExplainMetrics, + com.google.datastore.v1.ExplainMetrics.Builder, + com.google.datastore.v1.ExplainMetricsOrBuilder>( + getExplainMetrics(), getParentForChildren(), isClean()); + explainMetrics_ = null; + } + return explainMetricsBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.RunQueryResponse) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.RunQueryResponse) + private static final com.google.datastore.v1.RunQueryResponse DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.RunQueryResponse(); + } + + public static com.google.datastore.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.datastore.v1.RunQueryResponse getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponseOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponseOrBuilder.java new file mode 100644 index 000000000000..6cbe1650a296 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/RunQueryResponseOrBuilder.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! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface RunQueryResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.RunQueryResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * A batch of query results (always present).
+   * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + * + * @return Whether the batch field is set. + */ + boolean hasBatch(); + + /** + * + * + *
+   * A batch of query results (always present).
+   * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + * + * @return The batch. + */ + com.google.datastore.v1.QueryResultBatch getBatch(); + + /** + * + * + *
+   * A batch of query results (always present).
+   * 
+ * + * .google.datastore.v1.QueryResultBatch batch = 1; + */ + com.google.datastore.v1.QueryResultBatchOrBuilder getBatchOrBuilder(); + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.Query query = 2; + * + * @return Whether the query field is set. + */ + boolean hasQuery(); + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.Query query = 2; + * + * @return The query. + */ + com.google.datastore.v1.Query getQuery(); + + /** + * + * + *
+   * The parsed form of the `GqlQuery` from the request, if it was set.
+   * 
+ * + * .google.datastore.v1.Query query = 2; + */ + com.google.datastore.v1.QueryOrBuilder getQueryOrBuilder(); + + /** + * + * + *
+   * The identifier of the transaction that was started as part of this
+   * RunQuery request.
+   *
+   * Set only when
+   * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+   * was set in
+   * [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options].
+   * 
+ * + * bytes transaction = 5; + * + * @return The transaction. + */ + com.google.protobuf.ByteString getTransaction(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @return Whether the explainMetrics field is set. + */ + boolean hasExplainMetrics(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + * + * @return The explainMetrics. + */ + com.google.datastore.v1.ExplainMetrics getExplainMetrics(); + + /** + * + * + *
+   * Query explain metrics. This is only present when the
+   * [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options]
+   * is provided, and it is sent only once with the last response in the stream.
+   * 
+ * + * .google.datastore.v1.ExplainMetrics explain_metrics = 9; + */ + com.google.datastore.v1.ExplainMetricsOrBuilder getExplainMetricsOrBuilder(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptions.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptions.java new file mode 100644 index 000000000000..7b14b00e0b30 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptions.java @@ -0,0 +1,2520 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * Options for beginning a new transaction.
+ *
+ * Transactions can be created explicitly with calls to
+ * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]
+ * or implicitly by setting
+ * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+ * in read requests.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.TransactionOptions} + */ +public final class TransactionOptions extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.TransactionOptions) + TransactionOptionsOrBuilder { + private static final long serialVersionUID = 0L; + + // Use TransactionOptions.newBuilder() to construct. + private TransactionOptions(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private TransactionOptions() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new TransactionOptions(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.TransactionOptions.class, + com.google.datastore.v1.TransactionOptions.Builder.class); + } + + public interface ReadWriteOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.TransactionOptions.ReadWrite) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * The transaction identifier of the transaction being retried.
+     * 
+ * + * bytes previous_transaction = 1; + * + * @return The previousTransaction. + */ + com.google.protobuf.ByteString getPreviousTransaction(); + } + + /** + * + * + *
+   * Options specific to read / write transactions.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.TransactionOptions.ReadWrite} + */ + public static final class ReadWrite extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.TransactionOptions.ReadWrite) + ReadWriteOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ReadWrite.newBuilder() to construct. + private ReadWrite(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ReadWrite() { + previousTransaction_ = com.google.protobuf.ByteString.EMPTY; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ReadWrite(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_ReadWrite_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_ReadWrite_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.TransactionOptions.ReadWrite.class, + com.google.datastore.v1.TransactionOptions.ReadWrite.Builder.class); + } + + public static final int PREVIOUS_TRANSACTION_FIELD_NUMBER = 1; + private com.google.protobuf.ByteString previousTransaction_ = + com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+     * The transaction identifier of the transaction being retried.
+     * 
+ * + * bytes previous_transaction = 1; + * + * @return The previousTransaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPreviousTransaction() { + return previousTransaction_; + } + + 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 (!previousTransaction_.isEmpty()) { + output.writeBytes(1, previousTransaction_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!previousTransaction_.isEmpty()) { + size += com.google.protobuf.CodedOutputStream.computeBytesSize(1, previousTransaction_); + } + 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.datastore.v1.TransactionOptions.ReadWrite)) { + return super.equals(obj); + } + com.google.datastore.v1.TransactionOptions.ReadWrite other = + (com.google.datastore.v1.TransactionOptions.ReadWrite) obj; + + if (!getPreviousTransaction().equals(other.getPreviousTransaction())) 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) + PREVIOUS_TRANSACTION_FIELD_NUMBER; + hash = (53 * hash) + getPreviousTransaction().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.TransactionOptions.ReadWrite parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.TransactionOptions.ReadWrite parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.TransactionOptions.ReadWrite parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.TransactionOptions.ReadWrite parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.TransactionOptions.ReadWrite parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.TransactionOptions.ReadWrite parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.TransactionOptions.ReadWrite parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.TransactionOptions.ReadWrite parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.TransactionOptions.ReadWrite parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Options specific to read / write transactions.
+     * 
+ * + * Protobuf type {@code google.datastore.v1.TransactionOptions.ReadWrite} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.TransactionOptions.ReadWrite) + com.google.datastore.v1.TransactionOptions.ReadWriteOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_ReadWrite_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_ReadWrite_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.TransactionOptions.ReadWrite.class, + com.google.datastore.v1.TransactionOptions.ReadWrite.Builder.class); + } + + // Construct using com.google.datastore.v1.TransactionOptions.ReadWrite.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + previousTransaction_ = com.google.protobuf.ByteString.EMPTY; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_ReadWrite_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadWrite getDefaultInstanceForType() { + return com.google.datastore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadWrite build() { + com.google.datastore.v1.TransactionOptions.ReadWrite result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadWrite buildPartial() { + com.google.datastore.v1.TransactionOptions.ReadWrite result = + new com.google.datastore.v1.TransactionOptions.ReadWrite(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.TransactionOptions.ReadWrite result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.previousTransaction_ = previousTransaction_; + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.TransactionOptions.ReadWrite) { + return mergeFrom((com.google.datastore.v1.TransactionOptions.ReadWrite) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.TransactionOptions.ReadWrite other) { + if (other == com.google.datastore.v1.TransactionOptions.ReadWrite.getDefaultInstance()) + return this; + if (other.getPreviousTransaction() != com.google.protobuf.ByteString.EMPTY) { + setPreviousTransaction(other.getPreviousTransaction()); + } + 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: + { + previousTransaction_ = 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 previousTransaction_ = + com.google.protobuf.ByteString.EMPTY; + + /** + * + * + *
+       * The transaction identifier of the transaction being retried.
+       * 
+ * + * bytes previous_transaction = 1; + * + * @return The previousTransaction. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPreviousTransaction() { + return previousTransaction_; + } + + /** + * + * + *
+       * The transaction identifier of the transaction being retried.
+       * 
+ * + * bytes previous_transaction = 1; + * + * @param value The previousTransaction to set. + * @return This builder for chaining. + */ + public Builder setPreviousTransaction(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + previousTransaction_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * The transaction identifier of the transaction being retried.
+       * 
+ * + * bytes previous_transaction = 1; + * + * @return This builder for chaining. + */ + public Builder clearPreviousTransaction() { + bitField0_ = (bitField0_ & ~0x00000001); + previousTransaction_ = getDefaultInstance().getPreviousTransaction(); + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.TransactionOptions.ReadWrite) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.TransactionOptions.ReadWrite) + private static final com.google.datastore.v1.TransactionOptions.ReadWrite DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.TransactionOptions.ReadWrite(); + } + + public static com.google.datastore.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.datastore.v1.TransactionOptions.ReadWrite getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + + public interface ReadOnlyOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.TransactionOptions.ReadOnly) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+     * Reads entities 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 = 1; + * + * @return Whether the readTime field is set. + */ + boolean hasReadTime(); + + /** + * + * + *
+     * Reads entities 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 = 1; + * + * @return The readTime. + */ + com.google.protobuf.Timestamp getReadTime(); + + /** + * + * + *
+     * Reads entities 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 = 1; + */ + com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder(); + } + + /** + * + * + *
+   * Options specific to read-only transactions.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.TransactionOptions.ReadOnly} + */ + public static final class ReadOnly extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.TransactionOptions.ReadOnly) + ReadOnlyOrBuilder { + private static final long serialVersionUID = 0L; + + // Use ReadOnly.newBuilder() to construct. + private ReadOnly(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ReadOnly() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ReadOnly(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_ReadOnly_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_ReadOnly_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.TransactionOptions.ReadOnly.class, + com.google.datastore.v1.TransactionOptions.ReadOnly.Builder.class); + } + + private int bitField0_; + public static final int READ_TIME_FIELD_NUMBER = 1; + private com.google.protobuf.Timestamp readTime_; + + /** + * + * + *
+     * Reads entities 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 = 1; + * + * @return Whether the readTime field is set. + */ + @java.lang.Override + public boolean hasReadTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+     * Reads entities 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 = 1; + * + * @return The readTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getReadTime() { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + + /** + * + * + *
+     * Reads entities 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 = 1; + */ + @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 (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getReadTime()); + } + 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, 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.datastore.v1.TransactionOptions.ReadOnly)) { + return super.equals(obj); + } + com.google.datastore.v1.TransactionOptions.ReadOnly other = + (com.google.datastore.v1.TransactionOptions.ReadOnly) obj; + + 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(); + 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.datastore.v1.TransactionOptions.ReadOnly parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.TransactionOptions.ReadOnly parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.TransactionOptions.ReadOnly parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.TransactionOptions.ReadOnly parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.TransactionOptions.ReadOnly parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.TransactionOptions.ReadOnly parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.TransactionOptions.ReadOnly parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.TransactionOptions.ReadOnly parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.TransactionOptions.ReadOnly parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+     * Options specific to read-only transactions.
+     * 
+ * + * Protobuf type {@code google.datastore.v1.TransactionOptions.ReadOnly} + */ + public static final class Builder + extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.TransactionOptions.ReadOnly) + com.google.datastore.v1.TransactionOptions.ReadOnlyOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_ReadOnly_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_ReadOnly_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.TransactionOptions.ReadOnly.class, + com.google.datastore.v1.TransactionOptions.ReadOnly.Builder.class); + } + + // Construct using com.google.datastore.v1.TransactionOptions.ReadOnly.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getReadTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_ReadOnly_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadOnly getDefaultInstanceForType() { + return com.google.datastore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadOnly build() { + com.google.datastore.v1.TransactionOptions.ReadOnly result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadOnly buildPartial() { + com.google.datastore.v1.TransactionOptions.ReadOnly result = + new com.google.datastore.v1.TransactionOptions.ReadOnly(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.TransactionOptions.ReadOnly result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.readTime_ = readTimeBuilder_ == null ? readTime_ : readTimeBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, + int index, + java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.TransactionOptions.ReadOnly) { + return mergeFrom((com.google.datastore.v1.TransactionOptions.ReadOnly) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.TransactionOptions.ReadOnly other) { + if (other == com.google.datastore.v1.TransactionOptions.ReadOnly.getDefaultInstance()) + return this; + 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: + { + input.readMessage(getReadTimeFieldBuilder().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.Timestamp readTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + readTimeBuilder_; + + /** + * + * + *
+       * Reads entities 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 = 1; + * + * @return Whether the readTime field is set. + */ + public boolean hasReadTime() { + return ((bitField0_ & 0x00000001) != 0); + } + + /** + * + * + *
+       * Reads entities 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 = 1; + * + * @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(); + } + } + + /** + * + * + *
+       * Reads entities 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 = 1; + */ + public Builder setReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + readTime_ = value; + } else { + readTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Reads entities 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 = 1; + */ + public Builder setReadTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (readTimeBuilder_ == null) { + readTime_ = builderForValue.build(); + } else { + readTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * + * + *
+       * Reads entities 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 = 1; + */ + public Builder mergeReadTime(com.google.protobuf.Timestamp value) { + if (readTimeBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && readTime_ != null + && readTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getReadTimeBuilder().mergeFrom(value); + } else { + readTime_ = value; + } + } else { + readTimeBuilder_.mergeFrom(value); + } + if (readTime_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + + /** + * + * + *
+       * Reads entities 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 = 1; + */ + public Builder clearReadTime() { + bitField0_ = (bitField0_ & ~0x00000001); + readTime_ = null; + if (readTimeBuilder_ != null) { + readTimeBuilder_.dispose(); + readTimeBuilder_ = null; + } + onChanged(); + return this; + } + + /** + * + * + *
+       * Reads entities 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 = 1; + */ + public com.google.protobuf.Timestamp.Builder getReadTimeBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getReadTimeFieldBuilder().getBuilder(); + } + + /** + * + * + *
+       * Reads entities 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 = 1; + */ + public com.google.protobuf.TimestampOrBuilder getReadTimeOrBuilder() { + if (readTimeBuilder_ != null) { + return readTimeBuilder_.getMessageOrBuilder(); + } else { + return readTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : readTime_; + } + } + + /** + * + * + *
+       * Reads entities 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 = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getReadTimeFieldBuilder() { + if (readTimeBuilder_ == null) { + readTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getReadTime(), getParentForChildren(), isClean()); + readTime_ = null; + } + return readTimeBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.TransactionOptions.ReadOnly) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.TransactionOptions.ReadOnly) + private static final com.google.datastore.v1.TransactionOptions.ReadOnly DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.TransactionOptions.ReadOnly(); + } + + public static com.google.datastore.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.datastore.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_WRITE(1), + READ_ONLY(2), + 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 1: + return READ_WRITE; + case 2: + return READ_ONLY; + 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_WRITE_FIELD_NUMBER = 1; + + /** + * + * + *
+   * The transaction should allow both reads and writes.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return Whether the readWrite field is set. + */ + @java.lang.Override + public boolean hasReadWrite() { + return modeCase_ == 1; + } + + /** + * + * + *
+   * The transaction should allow both reads and writes.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return The readWrite. + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadWrite getReadWrite() { + if (modeCase_ == 1) { + return (com.google.datastore.v1.TransactionOptions.ReadWrite) mode_; + } + return com.google.datastore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + + /** + * + * + *
+   * The transaction should allow both reads and writes.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadWriteOrBuilder getReadWriteOrBuilder() { + if (modeCase_ == 1) { + return (com.google.datastore.v1.TransactionOptions.ReadWrite) mode_; + } + return com.google.datastore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + + public static final int READ_ONLY_FIELD_NUMBER = 2; + + /** + * + * + *
+   * The transaction should only allow reads.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return Whether the readOnly field is set. + */ + @java.lang.Override + public boolean hasReadOnly() { + return modeCase_ == 2; + } + + /** + * + * + *
+   * The transaction should only allow reads.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return The readOnly. + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadOnly getReadOnly() { + if (modeCase_ == 2) { + return (com.google.datastore.v1.TransactionOptions.ReadOnly) mode_; + } + return com.google.datastore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + + /** + * + * + *
+   * The transaction should only allow reads.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadOnlyOrBuilder getReadOnlyOrBuilder() { + if (modeCase_ == 2) { + return (com.google.datastore.v1.TransactionOptions.ReadOnly) mode_; + } + return com.google.datastore.v1.TransactionOptions.ReadOnly.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_ == 1) { + output.writeMessage(1, (com.google.datastore.v1.TransactionOptions.ReadWrite) mode_); + } + if (modeCase_ == 2) { + output.writeMessage(2, (com.google.datastore.v1.TransactionOptions.ReadOnly) mode_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (modeCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, (com.google.datastore.v1.TransactionOptions.ReadWrite) mode_); + } + if (modeCase_ == 2) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 2, (com.google.datastore.v1.TransactionOptions.ReadOnly) 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.datastore.v1.TransactionOptions)) { + return super.equals(obj); + } + com.google.datastore.v1.TransactionOptions other = + (com.google.datastore.v1.TransactionOptions) obj; + + if (!getModeCase().equals(other.getModeCase())) return false; + switch (modeCase_) { + case 1: + if (!getReadWrite().equals(other.getReadWrite())) return false; + break; + case 2: + if (!getReadOnly().equals(other.getReadOnly())) 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 1: + hash = (37 * hash) + READ_WRITE_FIELD_NUMBER; + hash = (53 * hash) + getReadWrite().hashCode(); + break; + case 2: + hash = (37 * hash) + READ_ONLY_FIELD_NUMBER; + hash = (53 * hash) + getReadOnly().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.TransactionOptions parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.TransactionOptions parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.TransactionOptions parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.TransactionOptions parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.TransactionOptions parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.TransactionOptions parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.TransactionOptions parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.TransactionOptions parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.TransactionOptions parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.TransactionOptions parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * Options for beginning a new transaction.
+   *
+   * Transactions can be created explicitly with calls to
+   * [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]
+   * or implicitly by setting
+   * [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction]
+   * in read requests.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.TransactionOptions} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.TransactionOptions) + com.google.datastore.v1.TransactionOptionsOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.TransactionOptions.class, + com.google.datastore.v1.TransactionOptions.Builder.class); + } + + // Construct using com.google.datastore.v1.TransactionOptions.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (readWriteBuilder_ != null) { + readWriteBuilder_.clear(); + } + if (readOnlyBuilder_ != null) { + readOnlyBuilder_.clear(); + } + modeCase_ = 0; + mode_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.DatastoreProto + .internal_static_google_datastore_v1_TransactionOptions_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.TransactionOptions getDefaultInstanceForType() { + return com.google.datastore.v1.TransactionOptions.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.TransactionOptions build() { + com.google.datastore.v1.TransactionOptions result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.TransactionOptions buildPartial() { + com.google.datastore.v1.TransactionOptions result = + new com.google.datastore.v1.TransactionOptions(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.TransactionOptions result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs(com.google.datastore.v1.TransactionOptions result) { + result.modeCase_ = modeCase_; + result.mode_ = this.mode_; + if (modeCase_ == 1 && readWriteBuilder_ != null) { + result.mode_ = readWriteBuilder_.build(); + } + if (modeCase_ == 2 && readOnlyBuilder_ != null) { + result.mode_ = readOnlyBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.TransactionOptions) { + return mergeFrom((com.google.datastore.v1.TransactionOptions) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.TransactionOptions other) { + if (other == com.google.datastore.v1.TransactionOptions.getDefaultInstance()) return this; + switch (other.getModeCase()) { + case READ_WRITE: + { + mergeReadWrite(other.getReadWrite()); + break; + } + case READ_ONLY: + { + mergeReadOnly(other.getReadOnly()); + 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 10: + { + input.readMessage(getReadWriteFieldBuilder().getBuilder(), extensionRegistry); + modeCase_ = 1; + break; + } // case 10 + case 18: + { + input.readMessage(getReadOnlyFieldBuilder().getBuilder(), extensionRegistry); + modeCase_ = 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 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.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions.ReadWrite, + com.google.datastore.v1.TransactionOptions.ReadWrite.Builder, + com.google.datastore.v1.TransactionOptions.ReadWriteOrBuilder> + readWriteBuilder_; + + /** + * + * + *
+     * The transaction should allow both reads and writes.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return Whether the readWrite field is set. + */ + @java.lang.Override + public boolean hasReadWrite() { + return modeCase_ == 1; + } + + /** + * + * + *
+     * The transaction should allow both reads and writes.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return The readWrite. + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadWrite getReadWrite() { + if (readWriteBuilder_ == null) { + if (modeCase_ == 1) { + return (com.google.datastore.v1.TransactionOptions.ReadWrite) mode_; + } + return com.google.datastore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } else { + if (modeCase_ == 1) { + return readWriteBuilder_.getMessage(); + } + return com.google.datastore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The transaction should allow both reads and writes.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + */ + public Builder setReadWrite(com.google.datastore.v1.TransactionOptions.ReadWrite value) { + if (readWriteBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + mode_ = value; + onChanged(); + } else { + readWriteBuilder_.setMessage(value); + } + modeCase_ = 1; + return this; + } + + /** + * + * + *
+     * The transaction should allow both reads and writes.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + */ + public Builder setReadWrite( + com.google.datastore.v1.TransactionOptions.ReadWrite.Builder builderForValue) { + if (readWriteBuilder_ == null) { + mode_ = builderForValue.build(); + onChanged(); + } else { + readWriteBuilder_.setMessage(builderForValue.build()); + } + modeCase_ = 1; + return this; + } + + /** + * + * + *
+     * The transaction should allow both reads and writes.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + */ + public Builder mergeReadWrite(com.google.datastore.v1.TransactionOptions.ReadWrite value) { + if (readWriteBuilder_ == null) { + if (modeCase_ == 1 + && mode_ != com.google.datastore.v1.TransactionOptions.ReadWrite.getDefaultInstance()) { + mode_ = + com.google.datastore.v1.TransactionOptions.ReadWrite.newBuilder( + (com.google.datastore.v1.TransactionOptions.ReadWrite) mode_) + .mergeFrom(value) + .buildPartial(); + } else { + mode_ = value; + } + onChanged(); + } else { + if (modeCase_ == 1) { + readWriteBuilder_.mergeFrom(value); + } else { + readWriteBuilder_.setMessage(value); + } + } + modeCase_ = 1; + return this; + } + + /** + * + * + *
+     * The transaction should allow both reads and writes.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + */ + public Builder clearReadWrite() { + if (readWriteBuilder_ == null) { + if (modeCase_ == 1) { + modeCase_ = 0; + mode_ = null; + onChanged(); + } + } else { + if (modeCase_ == 1) { + modeCase_ = 0; + mode_ = null; + } + readWriteBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * The transaction should allow both reads and writes.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + */ + public com.google.datastore.v1.TransactionOptions.ReadWrite.Builder getReadWriteBuilder() { + return getReadWriteFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The transaction should allow both reads and writes.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadWriteOrBuilder getReadWriteOrBuilder() { + if ((modeCase_ == 1) && (readWriteBuilder_ != null)) { + return readWriteBuilder_.getMessageOrBuilder(); + } else { + if (modeCase_ == 1) { + return (com.google.datastore.v1.TransactionOptions.ReadWrite) mode_; + } + return com.google.datastore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The transaction should allow both reads and writes.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions.ReadWrite, + com.google.datastore.v1.TransactionOptions.ReadWrite.Builder, + com.google.datastore.v1.TransactionOptions.ReadWriteOrBuilder> + getReadWriteFieldBuilder() { + if (readWriteBuilder_ == null) { + if (!(modeCase_ == 1)) { + mode_ = com.google.datastore.v1.TransactionOptions.ReadWrite.getDefaultInstance(); + } + readWriteBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions.ReadWrite, + com.google.datastore.v1.TransactionOptions.ReadWrite.Builder, + com.google.datastore.v1.TransactionOptions.ReadWriteOrBuilder>( + (com.google.datastore.v1.TransactionOptions.ReadWrite) mode_, + getParentForChildren(), + isClean()); + mode_ = null; + } + modeCase_ = 1; + onChanged(); + return readWriteBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions.ReadOnly, + com.google.datastore.v1.TransactionOptions.ReadOnly.Builder, + com.google.datastore.v1.TransactionOptions.ReadOnlyOrBuilder> + readOnlyBuilder_; + + /** + * + * + *
+     * The transaction should only allow reads.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return Whether the readOnly field is set. + */ + @java.lang.Override + public boolean hasReadOnly() { + return modeCase_ == 2; + } + + /** + * + * + *
+     * The transaction should only allow reads.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return The readOnly. + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadOnly getReadOnly() { + if (readOnlyBuilder_ == null) { + if (modeCase_ == 2) { + return (com.google.datastore.v1.TransactionOptions.ReadOnly) mode_; + } + return com.google.datastore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } else { + if (modeCase_ == 2) { + return readOnlyBuilder_.getMessage(); + } + return com.google.datastore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The transaction should only allow reads.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + public Builder setReadOnly(com.google.datastore.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 should only allow reads.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + public Builder setReadOnly( + com.google.datastore.v1.TransactionOptions.ReadOnly.Builder builderForValue) { + if (readOnlyBuilder_ == null) { + mode_ = builderForValue.build(); + onChanged(); + } else { + readOnlyBuilder_.setMessage(builderForValue.build()); + } + modeCase_ = 2; + return this; + } + + /** + * + * + *
+     * The transaction should only allow reads.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + public Builder mergeReadOnly(com.google.datastore.v1.TransactionOptions.ReadOnly value) { + if (readOnlyBuilder_ == null) { + if (modeCase_ == 2 + && mode_ != com.google.datastore.v1.TransactionOptions.ReadOnly.getDefaultInstance()) { + mode_ = + com.google.datastore.v1.TransactionOptions.ReadOnly.newBuilder( + (com.google.datastore.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 should only allow reads.
+     * 
+ * + * .google.datastore.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 should only allow reads.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + public com.google.datastore.v1.TransactionOptions.ReadOnly.Builder getReadOnlyBuilder() { + return getReadOnlyFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * The transaction should only allow reads.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + @java.lang.Override + public com.google.datastore.v1.TransactionOptions.ReadOnlyOrBuilder getReadOnlyOrBuilder() { + if ((modeCase_ == 2) && (readOnlyBuilder_ != null)) { + return readOnlyBuilder_.getMessageOrBuilder(); + } else { + if (modeCase_ == 2) { + return (com.google.datastore.v1.TransactionOptions.ReadOnly) mode_; + } + return com.google.datastore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + } + + /** + * + * + *
+     * The transaction should only allow reads.
+     * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions.ReadOnly, + com.google.datastore.v1.TransactionOptions.ReadOnly.Builder, + com.google.datastore.v1.TransactionOptions.ReadOnlyOrBuilder> + getReadOnlyFieldBuilder() { + if (readOnlyBuilder_ == null) { + if (!(modeCase_ == 2)) { + mode_ = com.google.datastore.v1.TransactionOptions.ReadOnly.getDefaultInstance(); + } + readOnlyBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.TransactionOptions.ReadOnly, + com.google.datastore.v1.TransactionOptions.ReadOnly.Builder, + com.google.datastore.v1.TransactionOptions.ReadOnlyOrBuilder>( + (com.google.datastore.v1.TransactionOptions.ReadOnly) mode_, + getParentForChildren(), + isClean()); + mode_ = null; + } + modeCase_ = 2; + onChanged(); + return readOnlyBuilder_; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.TransactionOptions) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.TransactionOptions) + private static final com.google.datastore.v1.TransactionOptions DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.TransactionOptions(); + } + + public static com.google.datastore.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.datastore.v1.TransactionOptions getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptionsOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptionsOrBuilder.java new file mode 100644 index 000000000000..61a7fe682d95 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/TransactionOptionsOrBuilder.java @@ -0,0 +1,102 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/datastore.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface TransactionOptionsOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.v1.TransactionOptions) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The transaction should allow both reads and writes.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return Whether the readWrite field is set. + */ + boolean hasReadWrite(); + + /** + * + * + *
+   * The transaction should allow both reads and writes.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + * + * @return The readWrite. + */ + com.google.datastore.v1.TransactionOptions.ReadWrite getReadWrite(); + + /** + * + * + *
+   * The transaction should allow both reads and writes.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadWrite read_write = 1; + */ + com.google.datastore.v1.TransactionOptions.ReadWriteOrBuilder getReadWriteOrBuilder(); + + /** + * + * + *
+   * The transaction should only allow reads.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return Whether the readOnly field is set. + */ + boolean hasReadOnly(); + + /** + * + * + *
+   * The transaction should only allow reads.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + * + * @return The readOnly. + */ + com.google.datastore.v1.TransactionOptions.ReadOnly getReadOnly(); + + /** + * + * + *
+   * The transaction should only allow reads.
+   * 
+ * + * .google.datastore.v1.TransactionOptions.ReadOnly read_only = 2; + */ + com.google.datastore.v1.TransactionOptions.ReadOnlyOrBuilder getReadOnlyOrBuilder(); + + com.google.datastore.v1.TransactionOptions.ModeCase getModeCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Value.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Value.java new file mode 100644 index 000000000000..4e7a02a242af --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/Value.java @@ -0,0 +1,3378 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +/** + * + * + *
+ * A message that can hold any of the supported value types and associated
+ * metadata.
+ * 
+ * + * Protobuf type {@code google.datastore.v1.Value} + */ +public final class Value extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.datastore.v1.Value) + ValueOrBuilder { + private static final long serialVersionUID = 0L; + + // Use Value.newBuilder() to construct. + private Value(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private Value() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new Value(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto.internal_static_google_datastore_v1_Value_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Value_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Value.class, com.google.datastore.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), + KEY_VALUE(5), + STRING_VALUE(17), + BLOB_VALUE(18), + GEO_POINT_VALUE(8), + ENTITY_VALUE(6), + ARRAY_VALUE(9), + 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 5: + return KEY_VALUE; + case 17: + return STRING_VALUE; + case 18: + return BLOB_VALUE; + case 8: + return GEO_POINT_VALUE; + case 6: + return ENTITY_VALUE; + case 9: + return ARRAY_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.
+   * When stored in the Datastore, precise only to microseconds;
+   * 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.
+   * When stored in the Datastore, precise only to microseconds;
+   * 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.
+   * When stored in the Datastore, precise only to microseconds;
+   * 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 KEY_VALUE_FIELD_NUMBER = 5; + + /** + * + * + *
+   * A key value.
+   * 
+ * + * .google.datastore.v1.Key key_value = 5; + * + * @return Whether the keyValue field is set. + */ + @java.lang.Override + public boolean hasKeyValue() { + return valueTypeCase_ == 5; + } + + /** + * + * + *
+   * A key value.
+   * 
+ * + * .google.datastore.v1.Key key_value = 5; + * + * @return The keyValue. + */ + @java.lang.Override + public com.google.datastore.v1.Key getKeyValue() { + if (valueTypeCase_ == 5) { + return (com.google.datastore.v1.Key) valueType_; + } + return com.google.datastore.v1.Key.getDefaultInstance(); + } + + /** + * + * + *
+   * A key value.
+   * 
+ * + * .google.datastore.v1.Key key_value = 5; + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getKeyValueOrBuilder() { + if (valueTypeCase_ == 5) { + return (com.google.datastore.v1.Key) valueType_; + } + return com.google.datastore.v1.Key.getDefaultInstance(); + } + + public static final int STRING_VALUE_FIELD_NUMBER = 17; + + /** + * + * + *
+   * A UTF-8 encoded string value.
+   * When `exclude_from_indexes` is false (it is indexed) , may have at most
+   * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+   * 
+ * + * string string_value = 17; + * + * @return Whether the stringValue field is set. + */ + public boolean hasStringValue() { + return valueTypeCase_ == 17; + } + + /** + * + * + *
+   * A UTF-8 encoded string value.
+   * When `exclude_from_indexes` is false (it is indexed) , may have at most
+   * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+   * 
+ * + * 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 UTF-8 encoded string value.
+   * When `exclude_from_indexes` is false (it is indexed) , may have at most
+   * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+   * 
+ * + * 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 BLOB_VALUE_FIELD_NUMBER = 18; + + /** + * + * + *
+   * A blob value.
+   * May have at most 1,000,000 bytes.
+   * When `exclude_from_indexes` is false, may have at most 1500 bytes.
+   * In JSON requests, must be base64-encoded.
+   * 
+ * + * bytes blob_value = 18; + * + * @return Whether the blobValue field is set. + */ + @java.lang.Override + public boolean hasBlobValue() { + return valueTypeCase_ == 18; + } + + /** + * + * + *
+   * A blob value.
+   * May have at most 1,000,000 bytes.
+   * When `exclude_from_indexes` is false, may have at most 1500 bytes.
+   * In JSON requests, must be base64-encoded.
+   * 
+ * + * bytes blob_value = 18; + * + * @return The blobValue. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBlobValue() { + if (valueTypeCase_ == 18) { + return (com.google.protobuf.ByteString) valueType_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + 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 ENTITY_VALUE_FIELD_NUMBER = 6; + + /** + * + * + *
+   * An entity value.
+   *
+   * - May have no key.
+   * - May have a key with an incomplete key path.
+   * - May have a reserved/read-only key.
+   * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + * + * @return Whether the entityValue field is set. + */ + @java.lang.Override + public boolean hasEntityValue() { + return valueTypeCase_ == 6; + } + + /** + * + * + *
+   * An entity value.
+   *
+   * - May have no key.
+   * - May have a key with an incomplete key path.
+   * - May have a reserved/read-only key.
+   * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + * + * @return The entityValue. + */ + @java.lang.Override + public com.google.datastore.v1.Entity getEntityValue() { + if (valueTypeCase_ == 6) { + return (com.google.datastore.v1.Entity) valueType_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + + /** + * + * + *
+   * An entity value.
+   *
+   * - May have no key.
+   * - May have a key with an incomplete key path.
+   * - May have a reserved/read-only key.
+   * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + */ + @java.lang.Override + public com.google.datastore.v1.EntityOrBuilder getEntityValueOrBuilder() { + if (valueTypeCase_ == 6) { + return (com.google.datastore.v1.Entity) valueType_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + + public static final int ARRAY_VALUE_FIELD_NUMBER = 9; + + /** + * + * + *
+   * An array value.
+   * Cannot contain another array value.
+   * A `Value` instance that sets field `array_value` must not set fields
+   * `meaning` or `exclude_from_indexes`.
+   * 
+ * + * .google.datastore.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 contain another array value.
+   * A `Value` instance that sets field `array_value` must not set fields
+   * `meaning` or `exclude_from_indexes`.
+   * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + * + * @return The arrayValue. + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValue getArrayValue() { + if (valueTypeCase_ == 9) { + return (com.google.datastore.v1.ArrayValue) valueType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + + /** + * + * + *
+   * An array value.
+   * Cannot contain another array value.
+   * A `Value` instance that sets field `array_value` must not set fields
+   * `meaning` or `exclude_from_indexes`.
+   * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValueOrBuilder getArrayValueOrBuilder() { + if (valueTypeCase_ == 9) { + return (com.google.datastore.v1.ArrayValue) valueType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + + public static final int MEANING_FIELD_NUMBER = 14; + private int meaning_ = 0; + + /** + * + * + *
+   * The `meaning` field should only be populated for backwards compatibility.
+   * 
+ * + * int32 meaning = 14; + * + * @return The meaning. + */ + @java.lang.Override + public int getMeaning() { + return meaning_; + } + + public static final int EXCLUDE_FROM_INDEXES_FIELD_NUMBER = 19; + private boolean excludeFromIndexes_ = false; + + /** + * + * + *
+   * If the value should be excluded from all indexes including those defined
+   * explicitly.
+   * 
+ * + * bool exclude_from_indexes = 19; + * + * @return The excludeFromIndexes. + */ + @java.lang.Override + public boolean getExcludeFromIndexes() { + return excludeFromIndexes_; + } + + 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) { + output.writeMessage(5, (com.google.datastore.v1.Key) valueType_); + } + if (valueTypeCase_ == 6) { + output.writeMessage(6, (com.google.datastore.v1.Entity) valueType_); + } + if (valueTypeCase_ == 8) { + output.writeMessage(8, (com.google.type.LatLng) valueType_); + } + if (valueTypeCase_ == 9) { + output.writeMessage(9, (com.google.datastore.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 (meaning_ != 0) { + output.writeInt32(14, meaning_); + } + if (valueTypeCase_ == 17) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 17, valueType_); + } + if (valueTypeCase_ == 18) { + output.writeBytes(18, (com.google.protobuf.ByteString) valueType_); + } + if (excludeFromIndexes_ != false) { + output.writeBool(19, excludeFromIndexes_); + } + 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.CodedOutputStream.computeMessageSize( + 5, (com.google.datastore.v1.Key) valueType_); + } + if (valueTypeCase_ == 6) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 6, (com.google.datastore.v1.Entity) 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.datastore.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 (meaning_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(14, meaning_); + } + if (valueTypeCase_ == 17) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(17, valueType_); + } + if (valueTypeCase_ == 18) { + size += + com.google.protobuf.CodedOutputStream.computeBytesSize( + 18, (com.google.protobuf.ByteString) valueType_); + } + if (excludeFromIndexes_ != false) { + size += com.google.protobuf.CodedOutputStream.computeBoolSize(19, excludeFromIndexes_); + } + 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.datastore.v1.Value)) { + return super.equals(obj); + } + com.google.datastore.v1.Value other = (com.google.datastore.v1.Value) obj; + + if (getMeaning() != other.getMeaning()) return false; + if (getExcludeFromIndexes() != other.getExcludeFromIndexes()) return false; + 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 5: + if (!getKeyValue().equals(other.getKeyValue())) return false; + break; + case 17: + if (!getStringValue().equals(other.getStringValue())) return false; + break; + case 18: + if (!getBlobValue().equals(other.getBlobValue())) return false; + break; + case 8: + if (!getGeoPointValue().equals(other.getGeoPointValue())) return false; + break; + case 6: + if (!getEntityValue().equals(other.getEntityValue())) return false; + break; + case 9: + if (!getArrayValue().equals(other.getArrayValue())) 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) + MEANING_FIELD_NUMBER; + hash = (53 * hash) + getMeaning(); + hash = (37 * hash) + EXCLUDE_FROM_INDEXES_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashBoolean(getExcludeFromIndexes()); + 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 5: + hash = (37 * hash) + KEY_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getKeyValue().hashCode(); + break; + case 17: + hash = (37 * hash) + STRING_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getStringValue().hashCode(); + break; + case 18: + hash = (37 * hash) + BLOB_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getBlobValue().hashCode(); + break; + case 8: + hash = (37 * hash) + GEO_POINT_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getGeoPointValue().hashCode(); + break; + case 6: + hash = (37 * hash) + ENTITY_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getEntityValue().hashCode(); + break; + case 9: + hash = (37 * hash) + ARRAY_VALUE_FIELD_NUMBER; + hash = (53 * hash) + getArrayValue().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.datastore.v1.Value parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.Value parseFrom(com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.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.datastore.v1.Value parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.datastore.v1.Value parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.datastore.v1.Value parseFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Value parseFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Value parseDelimitedFrom(java.io.InputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Value parseDelimitedFrom( + java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException( + PARSER, input, extensionRegistry); + } + + public static com.google.datastore.v1.Value parseFrom(com.google.protobuf.CodedInputStream input) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.datastore.v1.Value parseFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.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.datastore.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.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * + * + *
+   * A message that can hold any of the supported value types and associated
+   * metadata.
+   * 
+ * + * Protobuf type {@code google.datastore.v1.Value} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.datastore.v1.Value) + com.google.datastore.v1.ValueOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Value_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Value_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.datastore.v1.Value.class, com.google.datastore.v1.Value.Builder.class); + } + + // Construct using com.google.datastore.v1.Value.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (timestampValueBuilder_ != null) { + timestampValueBuilder_.clear(); + } + if (keyValueBuilder_ != null) { + keyValueBuilder_.clear(); + } + if (geoPointValueBuilder_ != null) { + geoPointValueBuilder_.clear(); + } + if (entityValueBuilder_ != null) { + entityValueBuilder_.clear(); + } + if (arrayValueBuilder_ != null) { + arrayValueBuilder_.clear(); + } + meaning_ = 0; + excludeFromIndexes_ = false; + valueTypeCase_ = 0; + valueType_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.datastore.v1.EntityProto + .internal_static_google_datastore_v1_Value_descriptor; + } + + @java.lang.Override + public com.google.datastore.v1.Value getDefaultInstanceForType() { + return com.google.datastore.v1.Value.getDefaultInstance(); + } + + @java.lang.Override + public com.google.datastore.v1.Value build() { + com.google.datastore.v1.Value result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.datastore.v1.Value buildPartial() { + com.google.datastore.v1.Value result = new com.google.datastore.v1.Value(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.datastore.v1.Value result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000800) != 0)) { + result.meaning_ = meaning_; + } + if (((from_bitField0_ & 0x00001000) != 0)) { + result.excludeFromIndexes_ = excludeFromIndexes_; + } + } + + private void buildPartialOneofs(com.google.datastore.v1.Value result) { + result.valueTypeCase_ = valueTypeCase_; + result.valueType_ = this.valueType_; + if (valueTypeCase_ == 10 && timestampValueBuilder_ != null) { + result.valueType_ = timestampValueBuilder_.build(); + } + if (valueTypeCase_ == 5 && keyValueBuilder_ != null) { + result.valueType_ = keyValueBuilder_.build(); + } + if (valueTypeCase_ == 8 && geoPointValueBuilder_ != null) { + result.valueType_ = geoPointValueBuilder_.build(); + } + if (valueTypeCase_ == 6 && entityValueBuilder_ != null) { + result.valueType_ = entityValueBuilder_.build(); + } + if (valueTypeCase_ == 9 && arrayValueBuilder_ != null) { + result.valueType_ = arrayValueBuilder_.build(); + } + } + + @java.lang.Override + public Builder clone() { + return super.clone(); + } + + @java.lang.Override + public Builder setField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.setField(field, value); + } + + @java.lang.Override + public Builder clearField(com.google.protobuf.Descriptors.FieldDescriptor field) { + return super.clearField(field); + } + + @java.lang.Override + public Builder clearOneof(com.google.protobuf.Descriptors.OneofDescriptor oneof) { + return super.clearOneof(oneof); + } + + @java.lang.Override + public Builder setRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, int index, java.lang.Object value) { + return super.setRepeatedField(field, index, value); + } + + @java.lang.Override + public Builder addRepeatedField( + com.google.protobuf.Descriptors.FieldDescriptor field, java.lang.Object value) { + return super.addRepeatedField(field, value); + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof com.google.datastore.v1.Value) { + return mergeFrom((com.google.datastore.v1.Value) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.datastore.v1.Value other) { + if (other == com.google.datastore.v1.Value.getDefaultInstance()) return this; + if (other.getMeaning() != 0) { + setMeaning(other.getMeaning()); + } + if (other.getExcludeFromIndexes() != false) { + setExcludeFromIndexes(other.getExcludeFromIndexes()); + } + 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 KEY_VALUE: + { + mergeKeyValue(other.getKeyValue()); + break; + } + case STRING_VALUE: + { + valueTypeCase_ = 17; + valueType_ = other.valueType_; + onChanged(); + break; + } + case BLOB_VALUE: + { + setBlobValue(other.getBlobValue()); + break; + } + case GEO_POINT_VALUE: + { + mergeGeoPointValue(other.getGeoPointValue()); + break; + } + case ENTITY_VALUE: + { + mergeEntityValue(other.getEntityValue()); + break; + } + case ARRAY_VALUE: + { + mergeArrayValue(other.getArrayValue()); + 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: + { + input.readMessage(getKeyValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 5; + break; + } // case 42 + case 50: + { + input.readMessage(getEntityValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 6; + break; + } // case 50 + case 66: + { + input.readMessage(getGeoPointValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 8; + break; + } // case 66 + case 74: + { + input.readMessage(getArrayValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 9; + break; + } // case 74 + case 82: + { + input.readMessage(getTimestampValueFieldBuilder().getBuilder(), extensionRegistry); + valueTypeCase_ = 10; + break; + } // case 82 + case 88: + { + int rawValue = input.readEnum(); + valueTypeCase_ = 11; + valueType_ = rawValue; + break; + } // case 88 + case 112: + { + meaning_ = input.readInt32(); + bitField0_ |= 0x00000800; + break; + } // case 112 + 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 152: + { + excludeFromIndexes_ = input.readBool(); + bitField0_ |= 0x00001000; + break; + } // case 152 + 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.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + timestampValueBuilder_; + + /** + * + * + *
+     * A timestamp value.
+     * When stored in the Datastore, precise only to microseconds;
+     * 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.
+     * When stored in the Datastore, precise only to microseconds;
+     * 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.
+     * When stored in the Datastore, precise only to microseconds;
+     * 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.
+     * When stored in the Datastore, precise only to microseconds;
+     * 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.
+     * When stored in the Datastore, precise only to microseconds;
+     * 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.
+     * When stored in the Datastore, precise only to microseconds;
+     * 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.
+     * When stored in the Datastore, precise only to microseconds;
+     * any additional precision is rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + public com.google.protobuf.Timestamp.Builder getTimestampValueBuilder() { + return getTimestampValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A timestamp value.
+     * When stored in the Datastore, precise only to microseconds;
+     * 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.
+     * When stored in the Datastore, precise only to microseconds;
+     * any additional precision is rounded down.
+     * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getTimestampValueFieldBuilder() { + if (timestampValueBuilder_ == null) { + if (!(valueTypeCase_ == 10)) { + valueType_ = com.google.protobuf.Timestamp.getDefaultInstance(); + } + timestampValueBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + 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_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + keyValueBuilder_; + + /** + * + * + *
+     * A key value.
+     * 
+ * + * .google.datastore.v1.Key key_value = 5; + * + * @return Whether the keyValue field is set. + */ + @java.lang.Override + public boolean hasKeyValue() { + return valueTypeCase_ == 5; + } + + /** + * + * + *
+     * A key value.
+     * 
+ * + * .google.datastore.v1.Key key_value = 5; + * + * @return The keyValue. + */ + @java.lang.Override + public com.google.datastore.v1.Key getKeyValue() { + if (keyValueBuilder_ == null) { + if (valueTypeCase_ == 5) { + return (com.google.datastore.v1.Key) valueType_; + } + return com.google.datastore.v1.Key.getDefaultInstance(); + } else { + if (valueTypeCase_ == 5) { + return keyValueBuilder_.getMessage(); + } + return com.google.datastore.v1.Key.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A key value.
+     * 
+ * + * .google.datastore.v1.Key key_value = 5; + */ + public Builder setKeyValue(com.google.datastore.v1.Key value) { + if (keyValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + keyValueBuilder_.setMessage(value); + } + valueTypeCase_ = 5; + return this; + } + + /** + * + * + *
+     * A key value.
+     * 
+ * + * .google.datastore.v1.Key key_value = 5; + */ + public Builder setKeyValue(com.google.datastore.v1.Key.Builder builderForValue) { + if (keyValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + keyValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 5; + return this; + } + + /** + * + * + *
+     * A key value.
+     * 
+ * + * .google.datastore.v1.Key key_value = 5; + */ + public Builder mergeKeyValue(com.google.datastore.v1.Key value) { + if (keyValueBuilder_ == null) { + if (valueTypeCase_ == 5 && valueType_ != com.google.datastore.v1.Key.getDefaultInstance()) { + valueType_ = + com.google.datastore.v1.Key.newBuilder((com.google.datastore.v1.Key) valueType_) + .mergeFrom(value) + .buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + if (valueTypeCase_ == 5) { + keyValueBuilder_.mergeFrom(value); + } else { + keyValueBuilder_.setMessage(value); + } + } + valueTypeCase_ = 5; + return this; + } + + /** + * + * + *
+     * A key value.
+     * 
+ * + * .google.datastore.v1.Key key_value = 5; + */ + public Builder clearKeyValue() { + if (keyValueBuilder_ == null) { + if (valueTypeCase_ == 5) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + } else { + if (valueTypeCase_ == 5) { + valueTypeCase_ = 0; + valueType_ = null; + } + keyValueBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * A key value.
+     * 
+ * + * .google.datastore.v1.Key key_value = 5; + */ + public com.google.datastore.v1.Key.Builder getKeyValueBuilder() { + return getKeyValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * A key value.
+     * 
+ * + * .google.datastore.v1.Key key_value = 5; + */ + @java.lang.Override + public com.google.datastore.v1.KeyOrBuilder getKeyValueOrBuilder() { + if ((valueTypeCase_ == 5) && (keyValueBuilder_ != null)) { + return keyValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 5) { + return (com.google.datastore.v1.Key) valueType_; + } + return com.google.datastore.v1.Key.getDefaultInstance(); + } + } + + /** + * + * + *
+     * A key value.
+     * 
+ * + * .google.datastore.v1.Key key_value = 5; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder> + getKeyValueFieldBuilder() { + if (keyValueBuilder_ == null) { + if (!(valueTypeCase_ == 5)) { + valueType_ = com.google.datastore.v1.Key.getDefaultInstance(); + } + keyValueBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Key, + com.google.datastore.v1.Key.Builder, + com.google.datastore.v1.KeyOrBuilder>( + (com.google.datastore.v1.Key) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 5; + onChanged(); + return keyValueBuilder_; + } + + /** + * + * + *
+     * A UTF-8 encoded string value.
+     * When `exclude_from_indexes` is false (it is indexed) , may have at most
+     * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+     * 
+ * + * string string_value = 17; + * + * @return Whether the stringValue field is set. + */ + @java.lang.Override + public boolean hasStringValue() { + return valueTypeCase_ == 17; + } + + /** + * + * + *
+     * A UTF-8 encoded string value.
+     * When `exclude_from_indexes` is false (it is indexed) , may have at most
+     * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+     * 
+ * + * 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 UTF-8 encoded string value.
+     * When `exclude_from_indexes` is false (it is indexed) , may have at most
+     * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+     * 
+ * + * 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 UTF-8 encoded string value.
+     * When `exclude_from_indexes` is false (it is indexed) , may have at most
+     * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+     * 
+ * + * 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 UTF-8 encoded string value.
+     * When `exclude_from_indexes` is false (it is indexed) , may have at most
+     * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+     * 
+ * + * string string_value = 17; + * + * @return This builder for chaining. + */ + public Builder clearStringValue() { + if (valueTypeCase_ == 17) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + + /** + * + * + *
+     * A UTF-8 encoded string value.
+     * When `exclude_from_indexes` is false (it is indexed) , may have at most
+     * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+     * 
+ * + * 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 blob value.
+     * May have at most 1,000,000 bytes.
+     * When `exclude_from_indexes` is false, may have at most 1500 bytes.
+     * In JSON requests, must be base64-encoded.
+     * 
+ * + * bytes blob_value = 18; + * + * @return Whether the blobValue field is set. + */ + public boolean hasBlobValue() { + return valueTypeCase_ == 18; + } + + /** + * + * + *
+     * A blob value.
+     * May have at most 1,000,000 bytes.
+     * When `exclude_from_indexes` is false, may have at most 1500 bytes.
+     * In JSON requests, must be base64-encoded.
+     * 
+ * + * bytes blob_value = 18; + * + * @return The blobValue. + */ + public com.google.protobuf.ByteString getBlobValue() { + if (valueTypeCase_ == 18) { + return (com.google.protobuf.ByteString) valueType_; + } + return com.google.protobuf.ByteString.EMPTY; + } + + /** + * + * + *
+     * A blob value.
+     * May have at most 1,000,000 bytes.
+     * When `exclude_from_indexes` is false, may have at most 1500 bytes.
+     * In JSON requests, must be base64-encoded.
+     * 
+ * + * bytes blob_value = 18; + * + * @param value The blobValue to set. + * @return This builder for chaining. + */ + public Builder setBlobValue(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + valueTypeCase_ = 18; + valueType_ = value; + onChanged(); + return this; + } + + /** + * + * + *
+     * A blob value.
+     * May have at most 1,000,000 bytes.
+     * When `exclude_from_indexes` is false, may have at most 1500 bytes.
+     * In JSON requests, must be base64-encoded.
+     * 
+ * + * bytes blob_value = 18; + * + * @return This builder for chaining. + */ + public Builder clearBlobValue() { + if (valueTypeCase_ == 18) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + return this; + } + + private com.google.protobuf.SingleFieldBuilderV3< + 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 getGeoPointValueFieldBuilder().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.SingleFieldBuilderV3< + com.google.type.LatLng, com.google.type.LatLng.Builder, com.google.type.LatLngOrBuilder> + getGeoPointValueFieldBuilder() { + if (geoPointValueBuilder_ == null) { + if (!(valueTypeCase_ == 8)) { + valueType_ = com.google.type.LatLng.getDefaultInstance(); + } + geoPointValueBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + 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.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder> + entityValueBuilder_; + + /** + * + * + *
+     * An entity value.
+     *
+     * - May have no key.
+     * - May have a key with an incomplete key path.
+     * - May have a reserved/read-only key.
+     * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + * + * @return Whether the entityValue field is set. + */ + @java.lang.Override + public boolean hasEntityValue() { + return valueTypeCase_ == 6; + } + + /** + * + * + *
+     * An entity value.
+     *
+     * - May have no key.
+     * - May have a key with an incomplete key path.
+     * - May have a reserved/read-only key.
+     * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + * + * @return The entityValue. + */ + @java.lang.Override + public com.google.datastore.v1.Entity getEntityValue() { + if (entityValueBuilder_ == null) { + if (valueTypeCase_ == 6) { + return (com.google.datastore.v1.Entity) valueType_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } else { + if (valueTypeCase_ == 6) { + return entityValueBuilder_.getMessage(); + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + } + + /** + * + * + *
+     * An entity value.
+     *
+     * - May have no key.
+     * - May have a key with an incomplete key path.
+     * - May have a reserved/read-only key.
+     * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + */ + public Builder setEntityValue(com.google.datastore.v1.Entity value) { + if (entityValueBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + valueType_ = value; + onChanged(); + } else { + entityValueBuilder_.setMessage(value); + } + valueTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * An entity value.
+     *
+     * - May have no key.
+     * - May have a key with an incomplete key path.
+     * - May have a reserved/read-only key.
+     * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + */ + public Builder setEntityValue(com.google.datastore.v1.Entity.Builder builderForValue) { + if (entityValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + entityValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * An entity value.
+     *
+     * - May have no key.
+     * - May have a key with an incomplete key path.
+     * - May have a reserved/read-only key.
+     * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + */ + public Builder mergeEntityValue(com.google.datastore.v1.Entity value) { + if (entityValueBuilder_ == null) { + if (valueTypeCase_ == 6 + && valueType_ != com.google.datastore.v1.Entity.getDefaultInstance()) { + valueType_ = + com.google.datastore.v1.Entity.newBuilder((com.google.datastore.v1.Entity) valueType_) + .mergeFrom(value) + .buildPartial(); + } else { + valueType_ = value; + } + onChanged(); + } else { + if (valueTypeCase_ == 6) { + entityValueBuilder_.mergeFrom(value); + } else { + entityValueBuilder_.setMessage(value); + } + } + valueTypeCase_ = 6; + return this; + } + + /** + * + * + *
+     * An entity value.
+     *
+     * - May have no key.
+     * - May have a key with an incomplete key path.
+     * - May have a reserved/read-only key.
+     * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + */ + public Builder clearEntityValue() { + if (entityValueBuilder_ == null) { + if (valueTypeCase_ == 6) { + valueTypeCase_ = 0; + valueType_ = null; + onChanged(); + } + } else { + if (valueTypeCase_ == 6) { + valueTypeCase_ = 0; + valueType_ = null; + } + entityValueBuilder_.clear(); + } + return this; + } + + /** + * + * + *
+     * An entity value.
+     *
+     * - May have no key.
+     * - May have a key with an incomplete key path.
+     * - May have a reserved/read-only key.
+     * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + */ + public com.google.datastore.v1.Entity.Builder getEntityValueBuilder() { + return getEntityValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An entity value.
+     *
+     * - May have no key.
+     * - May have a key with an incomplete key path.
+     * - May have a reserved/read-only key.
+     * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + */ + @java.lang.Override + public com.google.datastore.v1.EntityOrBuilder getEntityValueOrBuilder() { + if ((valueTypeCase_ == 6) && (entityValueBuilder_ != null)) { + return entityValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 6) { + return (com.google.datastore.v1.Entity) valueType_; + } + return com.google.datastore.v1.Entity.getDefaultInstance(); + } + } + + /** + * + * + *
+     * An entity value.
+     *
+     * - May have no key.
+     * - May have a key with an incomplete key path.
+     * - May have a reserved/read-only key.
+     * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder> + getEntityValueFieldBuilder() { + if (entityValueBuilder_ == null) { + if (!(valueTypeCase_ == 6)) { + valueType_ = com.google.datastore.v1.Entity.getDefaultInstance(); + } + entityValueBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.Entity, + com.google.datastore.v1.Entity.Builder, + com.google.datastore.v1.EntityOrBuilder>( + (com.google.datastore.v1.Entity) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 6; + onChanged(); + return entityValueBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder> + arrayValueBuilder_; + + /** + * + * + *
+     * An array value.
+     * Cannot contain another array value.
+     * A `Value` instance that sets field `array_value` must not set fields
+     * `meaning` or `exclude_from_indexes`.
+     * 
+ * + * .google.datastore.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 contain another array value.
+     * A `Value` instance that sets field `array_value` must not set fields
+     * `meaning` or `exclude_from_indexes`.
+     * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + * + * @return The arrayValue. + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValue getArrayValue() { + if (arrayValueBuilder_ == null) { + if (valueTypeCase_ == 9) { + return (com.google.datastore.v1.ArrayValue) valueType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } else { + if (valueTypeCase_ == 9) { + return arrayValueBuilder_.getMessage(); + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+     * An array value.
+     * Cannot contain another array value.
+     * A `Value` instance that sets field `array_value` must not set fields
+     * `meaning` or `exclude_from_indexes`.
+     * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + */ + public Builder setArrayValue(com.google.datastore.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 contain another array value.
+     * A `Value` instance that sets field `array_value` must not set fields
+     * `meaning` or `exclude_from_indexes`.
+     * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + */ + public Builder setArrayValue(com.google.datastore.v1.ArrayValue.Builder builderForValue) { + if (arrayValueBuilder_ == null) { + valueType_ = builderForValue.build(); + onChanged(); + } else { + arrayValueBuilder_.setMessage(builderForValue.build()); + } + valueTypeCase_ = 9; + return this; + } + + /** + * + * + *
+     * An array value.
+     * Cannot contain another array value.
+     * A `Value` instance that sets field `array_value` must not set fields
+     * `meaning` or `exclude_from_indexes`.
+     * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + */ + public Builder mergeArrayValue(com.google.datastore.v1.ArrayValue value) { + if (arrayValueBuilder_ == null) { + if (valueTypeCase_ == 9 + && valueType_ != com.google.datastore.v1.ArrayValue.getDefaultInstance()) { + valueType_ = + com.google.datastore.v1.ArrayValue.newBuilder( + (com.google.datastore.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 contain another array value.
+     * A `Value` instance that sets field `array_value` must not set fields
+     * `meaning` or `exclude_from_indexes`.
+     * 
+ * + * .google.datastore.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 contain another array value.
+     * A `Value` instance that sets field `array_value` must not set fields
+     * `meaning` or `exclude_from_indexes`.
+     * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + */ + public com.google.datastore.v1.ArrayValue.Builder getArrayValueBuilder() { + return getArrayValueFieldBuilder().getBuilder(); + } + + /** + * + * + *
+     * An array value.
+     * Cannot contain another array value.
+     * A `Value` instance that sets field `array_value` must not set fields
+     * `meaning` or `exclude_from_indexes`.
+     * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + */ + @java.lang.Override + public com.google.datastore.v1.ArrayValueOrBuilder getArrayValueOrBuilder() { + if ((valueTypeCase_ == 9) && (arrayValueBuilder_ != null)) { + return arrayValueBuilder_.getMessageOrBuilder(); + } else { + if (valueTypeCase_ == 9) { + return (com.google.datastore.v1.ArrayValue) valueType_; + } + return com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + } + + /** + * + * + *
+     * An array value.
+     * Cannot contain another array value.
+     * A `Value` instance that sets field `array_value` must not set fields
+     * `meaning` or `exclude_from_indexes`.
+     * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder> + getArrayValueFieldBuilder() { + if (arrayValueBuilder_ == null) { + if (!(valueTypeCase_ == 9)) { + valueType_ = com.google.datastore.v1.ArrayValue.getDefaultInstance(); + } + arrayValueBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.datastore.v1.ArrayValue, + com.google.datastore.v1.ArrayValue.Builder, + com.google.datastore.v1.ArrayValueOrBuilder>( + (com.google.datastore.v1.ArrayValue) valueType_, getParentForChildren(), isClean()); + valueType_ = null; + } + valueTypeCase_ = 9; + onChanged(); + return arrayValueBuilder_; + } + + private int meaning_; + + /** + * + * + *
+     * The `meaning` field should only be populated for backwards compatibility.
+     * 
+ * + * int32 meaning = 14; + * + * @return The meaning. + */ + @java.lang.Override + public int getMeaning() { + return meaning_; + } + + /** + * + * + *
+     * The `meaning` field should only be populated for backwards compatibility.
+     * 
+ * + * int32 meaning = 14; + * + * @param value The meaning to set. + * @return This builder for chaining. + */ + public Builder setMeaning(int value) { + + meaning_ = value; + bitField0_ |= 0x00000800; + onChanged(); + return this; + } + + /** + * + * + *
+     * The `meaning` field should only be populated for backwards compatibility.
+     * 
+ * + * int32 meaning = 14; + * + * @return This builder for chaining. + */ + public Builder clearMeaning() { + bitField0_ = (bitField0_ & ~0x00000800); + meaning_ = 0; + onChanged(); + return this; + } + + private boolean excludeFromIndexes_; + + /** + * + * + *
+     * If the value should be excluded from all indexes including those defined
+     * explicitly.
+     * 
+ * + * bool exclude_from_indexes = 19; + * + * @return The excludeFromIndexes. + */ + @java.lang.Override + public boolean getExcludeFromIndexes() { + return excludeFromIndexes_; + } + + /** + * + * + *
+     * If the value should be excluded from all indexes including those defined
+     * explicitly.
+     * 
+ * + * bool exclude_from_indexes = 19; + * + * @param value The excludeFromIndexes to set. + * @return This builder for chaining. + */ + public Builder setExcludeFromIndexes(boolean value) { + + excludeFromIndexes_ = value; + bitField0_ |= 0x00001000; + onChanged(); + return this; + } + + /** + * + * + *
+     * If the value should be excluded from all indexes including those defined
+     * explicitly.
+     * 
+ * + * bool exclude_from_indexes = 19; + * + * @return This builder for chaining. + */ + public Builder clearExcludeFromIndexes() { + bitField0_ = (bitField0_ & ~0x00001000); + excludeFromIndexes_ = false; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields( + final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + + // @@protoc_insertion_point(builder_scope:google.datastore.v1.Value) + } + + // @@protoc_insertion_point(class_scope:google.datastore.v1.Value) + private static final com.google.datastore.v1.Value DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.datastore.v1.Value(); + } + + public static com.google.datastore.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.datastore.v1.Value getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ValueOrBuilder.java b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ValueOrBuilder.java new file mode 100644 index 000000000000..87693966d6fb --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/java/com/google/datastore/v1/ValueOrBuilder.java @@ -0,0 +1,461 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/datastore/v1/entity.proto + +// Protobuf Java Version: 3.25.8 +package com.google.datastore.v1; + +public interface ValueOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.datastore.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.
+   * When stored in the Datastore, precise only to microseconds;
+   * any additional precision is rounded down.
+   * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + * + * @return Whether the timestampValue field is set. + */ + boolean hasTimestampValue(); + + /** + * + * + *
+   * A timestamp value.
+   * When stored in the Datastore, precise only to microseconds;
+   * any additional precision is rounded down.
+   * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + * + * @return The timestampValue. + */ + com.google.protobuf.Timestamp getTimestampValue(); + + /** + * + * + *
+   * A timestamp value.
+   * When stored in the Datastore, precise only to microseconds;
+   * any additional precision is rounded down.
+   * 
+ * + * .google.protobuf.Timestamp timestamp_value = 10; + */ + com.google.protobuf.TimestampOrBuilder getTimestampValueOrBuilder(); + + /** + * + * + *
+   * A key value.
+   * 
+ * + * .google.datastore.v1.Key key_value = 5; + * + * @return Whether the keyValue field is set. + */ + boolean hasKeyValue(); + + /** + * + * + *
+   * A key value.
+   * 
+ * + * .google.datastore.v1.Key key_value = 5; + * + * @return The keyValue. + */ + com.google.datastore.v1.Key getKeyValue(); + + /** + * + * + *
+   * A key value.
+   * 
+ * + * .google.datastore.v1.Key key_value = 5; + */ + com.google.datastore.v1.KeyOrBuilder getKeyValueOrBuilder(); + + /** + * + * + *
+   * A UTF-8 encoded string value.
+   * When `exclude_from_indexes` is false (it is indexed) , may have at most
+   * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+   * 
+ * + * string string_value = 17; + * + * @return Whether the stringValue field is set. + */ + boolean hasStringValue(); + + /** + * + * + *
+   * A UTF-8 encoded string value.
+   * When `exclude_from_indexes` is false (it is indexed) , may have at most
+   * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+   * 
+ * + * string string_value = 17; + * + * @return The stringValue. + */ + java.lang.String getStringValue(); + + /** + * + * + *
+   * A UTF-8 encoded string value.
+   * When `exclude_from_indexes` is false (it is indexed) , may have at most
+   * 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes.
+   * 
+ * + * string string_value = 17; + * + * @return The bytes for stringValue. + */ + com.google.protobuf.ByteString getStringValueBytes(); + + /** + * + * + *
+   * A blob value.
+   * May have at most 1,000,000 bytes.
+   * When `exclude_from_indexes` is false, may have at most 1500 bytes.
+   * In JSON requests, must be base64-encoded.
+   * 
+ * + * bytes blob_value = 18; + * + * @return Whether the blobValue field is set. + */ + boolean hasBlobValue(); + + /** + * + * + *
+   * A blob value.
+   * May have at most 1,000,000 bytes.
+   * When `exclude_from_indexes` is false, may have at most 1500 bytes.
+   * In JSON requests, must be base64-encoded.
+   * 
+ * + * bytes blob_value = 18; + * + * @return The blobValue. + */ + com.google.protobuf.ByteString getBlobValue(); + + /** + * + * + *
+   * 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 entity value.
+   *
+   * - May have no key.
+   * - May have a key with an incomplete key path.
+   * - May have a reserved/read-only key.
+   * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + * + * @return Whether the entityValue field is set. + */ + boolean hasEntityValue(); + + /** + * + * + *
+   * An entity value.
+   *
+   * - May have no key.
+   * - May have a key with an incomplete key path.
+   * - May have a reserved/read-only key.
+   * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + * + * @return The entityValue. + */ + com.google.datastore.v1.Entity getEntityValue(); + + /** + * + * + *
+   * An entity value.
+   *
+   * - May have no key.
+   * - May have a key with an incomplete key path.
+   * - May have a reserved/read-only key.
+   * 
+ * + * .google.datastore.v1.Entity entity_value = 6; + */ + com.google.datastore.v1.EntityOrBuilder getEntityValueOrBuilder(); + + /** + * + * + *
+   * An array value.
+   * Cannot contain another array value.
+   * A `Value` instance that sets field `array_value` must not set fields
+   * `meaning` or `exclude_from_indexes`.
+   * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + * + * @return Whether the arrayValue field is set. + */ + boolean hasArrayValue(); + + /** + * + * + *
+   * An array value.
+   * Cannot contain another array value.
+   * A `Value` instance that sets field `array_value` must not set fields
+   * `meaning` or `exclude_from_indexes`.
+   * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + * + * @return The arrayValue. + */ + com.google.datastore.v1.ArrayValue getArrayValue(); + + /** + * + * + *
+   * An array value.
+   * Cannot contain another array value.
+   * A `Value` instance that sets field `array_value` must not set fields
+   * `meaning` or `exclude_from_indexes`.
+   * 
+ * + * .google.datastore.v1.ArrayValue array_value = 9; + */ + com.google.datastore.v1.ArrayValueOrBuilder getArrayValueOrBuilder(); + + /** + * + * + *
+   * The `meaning` field should only be populated for backwards compatibility.
+   * 
+ * + * int32 meaning = 14; + * + * @return The meaning. + */ + int getMeaning(); + + /** + * + * + *
+   * If the value should be excluded from all indexes including those defined
+   * explicitly.
+   * 
+ * + * bool exclude_from_indexes = 19; + * + * @return The excludeFromIndexes. + */ + boolean getExcludeFromIndexes(); + + com.google.datastore.v1.Value.ValueTypeCase getValueTypeCase(); +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/aggregation_result.proto b/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/aggregation_result.proto new file mode 100644 index 000000000000..cd51f660c419 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/aggregation_result.proto @@ -0,0 +1,62 @@ +// 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. + +syntax = "proto3"; + +package google.datastore.v1; + +import "google/datastore/v1/entity.proto"; +import "google/datastore/v1/query.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; +option java_multiple_files = true; +option java_outer_classname = "AggregationResultProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// The result of a single bucket from a Datastore aggregation query. +// +// The keys of `aggregate_properties` are the same for all results in an +// aggregation query, unlike entity queries which can have different fields +// present for each result. +message AggregationResult { + // The result of the aggregation functions, ex: `COUNT(*) AS total_entities`. + // + // The key is the + // [alias][google.datastore.v1.AggregationQuery.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_properties = 2; +} + +// A batch of aggregation results produced by an aggregation query. +message AggregationResultBatch { + // The aggregation results for this batch. + repeated AggregationResult aggregation_results = 1; + + // The state of the query after the current batch. + // Only COUNT(*) aggregations are supported in the initial launch. Therefore, + // expected result type is limited to `NO_MORE_RESULTS`. + QueryResultBatch.MoreResultsType more_results = 2; + + // Read timestamp this batch was returned from. + // + // In a single transaction, subsequent query result batches for the same query + // can have a greater timestamp. Each batch's read timestamp + // is valid for all preceding batches. + google.protobuf.Timestamp read_time = 3; +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/datastore.proto b/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/datastore.proto new file mode 100644 index 000000000000..c0a281b18797 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/datastore.proto @@ -0,0 +1,810 @@ +// 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. + +syntax = "proto3"; + +package google.datastore.v1; + +import "google/api/annotations.proto"; +import "google/api/client.proto"; +import "google/api/field_behavior.proto"; +import "google/api/routing.proto"; +import "google/datastore/v1/aggregation_result.proto"; +import "google/datastore/v1/entity.proto"; +import "google/datastore/v1/query.proto"; +import "google/datastore/v1/query_profile.proto"; +import "google/protobuf/timestamp.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; +option java_multiple_files = true; +option java_outer_classname = "DatastoreProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// Each RPC normalizes the partition IDs of the keys in its input entities, +// and always returns entities with keys with normalized partition IDs. +// This applies to all keys and entities, including those in values, except keys +// with both an empty path and an empty or unset partition ID. Normalization of +// input keys sets the project ID (if not already set) to the project ID from +// the request. +// +service Datastore { + option (google.api.default_host) = "datastore.googleapis.com"; + option (google.api.oauth_scopes) = + "https://www.googleapis.com/auth/cloud-platform," + "https://www.googleapis.com/auth/datastore"; + + // Looks up entities by key. + rpc Lookup(LookupRequest) returns (LookupResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:lookup" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = "project_id,read_options,keys"; + } + + // Queries for entities. + rpc RunQuery(RunQueryRequest) returns (RunQueryResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:runQuery" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + } + + // Runs an aggregation query. + rpc RunAggregationQuery(RunAggregationQueryRequest) + returns (RunAggregationQueryResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:runAggregationQuery" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + } + + // Begins a new transaction. + rpc BeginTransaction(BeginTransactionRequest) + returns (BeginTransactionResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:beginTransaction" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = "project_id"; + } + + // Commits a transaction, optionally creating, deleting or modifying some + // entities. + rpc Commit(CommitRequest) returns (CommitResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:commit" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = + "project_id,mode,transaction,mutations"; + option (google.api.method_signature) = "project_id,mode,mutations"; + } + + // Rolls back a transaction. + rpc Rollback(RollbackRequest) returns (RollbackResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:rollback" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = "project_id,transaction"; + } + + // Allocates IDs for the given keys, which is useful for referencing an entity + // before it is inserted. + rpc AllocateIds(AllocateIdsRequest) returns (AllocateIdsResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:allocateIds" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = "project_id,keys"; + } + + // Prevents the supplied keys' IDs from being auto-allocated by Cloud + // Datastore. + rpc ReserveIds(ReserveIdsRequest) returns (ReserveIdsResponse) { + option (google.api.http) = { + post: "/v1/projects/{project_id}:reserveIds" + body: "*" + }; + option (google.api.routing) = { + routing_parameters { field: "project_id" } + routing_parameters { field: "database_id" } + }; + option (google.api.method_signature) = "project_id,keys"; + } +} + +// The request for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup]. +message LookupRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // The options for this lookup request. + ReadOptions read_options = 1; + + // Required. Keys of entities to look up. + repeated Key keys = 3 [(google.api.field_behavior) = REQUIRED]; + + // The properties to return. Defaults to returning all properties. + // + // If this field is set and an entity has a property not referenced in the + // mask, it will be absent from [LookupResponse.found.entity.properties][]. + // + // The entity's key is always returned. + PropertyMask property_mask = 5; +} + +// The response for [Datastore.Lookup][google.datastore.v1.Datastore.Lookup]. +message LookupResponse { + // Entities found as `ResultType.FULL` entities. The order of results in this + // field is undefined and has no relation to the order of the keys in the + // input. + repeated EntityResult found = 1; + + // Entities not found as `ResultType.KEY_ONLY` entities. The order of results + // in this field is undefined and has no relation to the order of the keys + // in the input. + repeated EntityResult missing = 2; + + // A list of keys that were not looked up due to resource constraints. The + // order of results in this field is undefined and has no relation to the + // order of the keys in the input. + repeated Key deferred = 3; + + // The identifier of the transaction that was started as part of this Lookup + // request. + // + // Set only when + // [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] + // was set in + // [LookupRequest.read_options][google.datastore.v1.LookupRequest.read_options]. + bytes transaction = 5; + + // The time at which these entities were read or found missing. + google.protobuf.Timestamp read_time = 7; +} + +// The request for [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. +message RunQueryRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Entities are partitioned into subsets, identified by a partition ID. + // Queries are scoped to a single partition. + // This partition ID is normalized with the standard default context + // partition ID. + PartitionId partition_id = 2; + + // The options for this query. + ReadOptions read_options = 1; + + // The type of query. + oneof query_type { + // The query to run. + Query query = 3; + + // The GQL query to run. This query must be a non-aggregation query. + GqlQuery gql_query = 7; + } + + // The properties to return. + // This field must not be set for a projection query. + // + // See + // [LookupRequest.property_mask][google.datastore.v1.LookupRequest.property_mask]. + PropertyMask property_mask = 10; + + // 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 = 12 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for +// [Datastore.RunQuery][google.datastore.v1.Datastore.RunQuery]. +message RunQueryResponse { + // A batch of query results (always present). + QueryResultBatch batch = 1; + + // The parsed form of the `GqlQuery` from the request, if it was set. + Query query = 2; + + // The identifier of the transaction that was started as part of this + // RunQuery request. + // + // Set only when + // [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] + // was set in + // [RunQueryRequest.read_options][google.datastore.v1.RunQueryRequest.read_options]. + bytes transaction = 5; + + // Query explain metrics. This is only present when the + // [RunQueryRequest.explain_options][google.datastore.v1.RunQueryRequest.explain_options] + // is provided, and it is sent only once with the last response in the stream. + ExplainMetrics explain_metrics = 9; +} + +// The request for +// [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery]. +message RunAggregationQueryRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Entities are partitioned into subsets, identified by a partition ID. + // Queries are scoped to a single partition. + // This partition ID is normalized with the standard default context + // partition ID. + PartitionId partition_id = 2; + + // The options for this query. + ReadOptions read_options = 1; + + // The type of query. + oneof query_type { + // The query to run. + AggregationQuery aggregation_query = 3; + + // The GQL query to run. This query must be an aggregation query. + GqlQuery gql_query = 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 = 11 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for +// [Datastore.RunAggregationQuery][google.datastore.v1.Datastore.RunAggregationQuery]. +message RunAggregationQueryResponse { + // A batch of aggregation results. Always present. + AggregationResultBatch batch = 1; + + // The parsed form of the `GqlQuery` from the request, if it was set. + AggregationQuery query = 2; + + // The identifier of the transaction that was started as part of this + // RunAggregationQuery request. + // + // Set only when + // [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] + // was set in + // [RunAggregationQueryRequest.read_options][google.datastore.v1.RunAggregationQueryRequest.read_options]. + bytes transaction = 5; + + // Query explain metrics. This is only present when the + // [RunAggregationQueryRequest.explain_options][google.datastore.v1.RunAggregationQueryRequest.explain_options] + // is provided, and it is sent only once with the last response in the stream. + ExplainMetrics explain_metrics = 9; +} + +// The request for +// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. +message BeginTransactionRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Options for a new transaction. + TransactionOptions transaction_options = 10; +} + +// The response for +// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. +message BeginTransactionResponse { + // The transaction identifier (always present). + bytes transaction = 1; +} + +// The request for [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. +message RollbackRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Required. The transaction identifier, returned by a call to + // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. + bytes transaction = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The response for +// [Datastore.Rollback][google.datastore.v1.Datastore.Rollback]. (an empty +// message). +message RollbackResponse {} + +// The request for [Datastore.Commit][google.datastore.v1.Datastore.Commit]. +message CommitRequest { + // The modes available for commits. + enum Mode { + // Unspecified. This value must not be used. + MODE_UNSPECIFIED = 0; + + // Transactional: The mutations are either all applied, or none are applied. + // Learn about transactions + // [here](https://cloud.google.com/datastore/docs/concepts/transactions). + TRANSACTIONAL = 1; + + // Non-transactional: The mutations may not apply as all or none. + NON_TRANSACTIONAL = 2; + } + + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // The type of commit to perform. Defaults to `TRANSACTIONAL`. + Mode mode = 5; + + // Must be set when mode is `TRANSACTIONAL`. + oneof transaction_selector { + // The identifier of the transaction associated with the commit. A + // transaction identifier is returned by a call to + // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. + bytes transaction = 1; + + // Options for beginning a new transaction for this request. + // The transaction is committed when the request completes. If specified, + // [TransactionOptions.mode][google.datastore.v1.TransactionOptions] must be + // [TransactionOptions.ReadWrite][google.datastore.v1.TransactionOptions.ReadWrite]. + TransactionOptions single_use_transaction = 10; + } + + // The mutations to perform. + // + // When mode is `TRANSACTIONAL`, mutations affecting a single entity are + // applied in order. The following sequences of mutations affecting a single + // entity are not permitted in a single `Commit` request: + // + // - `insert` followed by `insert` + // - `update` followed by `insert` + // - `upsert` followed by `insert` + // - `delete` followed by `update` + // + // When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single + // entity. + repeated Mutation mutations = 6; +} + +// The response for [Datastore.Commit][google.datastore.v1.Datastore.Commit]. +message CommitResponse { + // The result of performing the mutations. + // The i-th mutation result corresponds to the i-th mutation in the request. + repeated MutationResult mutation_results = 3; + + // The number of index entries updated during the commit, or zero if none were + // updated. + int32 index_updates = 4; + + // The transaction commit timestamp. Not set for non-transactional commits. + google.protobuf.Timestamp commit_time = 8; +} + +// The request for +// [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. +message AllocateIdsRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Required. A list of keys with incomplete key paths for which to allocate + // IDs. No key may be reserved/read-only. + repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The response for +// [Datastore.AllocateIds][google.datastore.v1.Datastore.AllocateIds]. +message AllocateIdsResponse { + // The keys specified in the request (in the same order), each with + // its key path completed with a newly allocated ID. + repeated Key keys = 1; +} + +// The request for +// [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds]. +message ReserveIdsRequest { + // Required. The ID of the project against which to make the request. + string project_id = 8 [(google.api.field_behavior) = REQUIRED]; + + // The ID of the database against which to make the request. + // + // '(default)' is not allowed; please use empty string '' to refer the default + // database. + string database_id = 9; + + // Required. A list of keys with complete key paths whose numeric IDs should + // not be auto-allocated. + repeated Key keys = 1 [(google.api.field_behavior) = REQUIRED]; +} + +// The response for +// [Datastore.ReserveIds][google.datastore.v1.Datastore.ReserveIds]. +message ReserveIdsResponse {} + +// A mutation to apply to an entity. +message Mutation { + // The possible ways to resolve a conflict detected in a mutation. + enum ConflictResolutionStrategy { + // Unspecified. Defaults to `SERVER_VALUE`. + STRATEGY_UNSPECIFIED = 0; + + // The server entity is kept. + SERVER_VALUE = 1; + + // The whole commit request fails. + FAIL = 3; + } + + // The mutation operation. + // + // For `insert`, `update`, and `upsert`: + // - The entity's key must not be reserved/read-only. + // - No property in the entity may have a reserved name, + // not even a property in an entity in a value. + // - No value in the entity may have meaning 18, + // not even a value in an entity in another value. + oneof operation { + // The entity to insert. The entity must not already exist. + // The entity key's final path element may be incomplete. + Entity insert = 4; + + // The entity to update. The entity must already exist. + // Must have a complete key path. + Entity update = 5; + + // The entity to upsert. The entity may or may not already exist. + // The entity key's final path element may be incomplete. + Entity upsert = 6; + + // The key of the entity to delete. The entity may or may not already exist. + // Must have a complete key path and must not be reserved/read-only. + Key delete = 7; + } + + // When set, the server will detect whether or not this mutation conflicts + // with the current version of the entity on the server. Conflicting mutations + // are not applied, and are marked as such in MutationResult. + oneof conflict_detection_strategy { + // The version of the entity that this mutation is being applied + // to. If this does not match the current version on the server, the + // mutation conflicts. + int64 base_version = 8; + + // The update time of the entity that this mutation is being applied + // to. If this does not match the current update time on the server, the + // mutation conflicts. + google.protobuf.Timestamp update_time = 11; + } + + // The strategy to use when a conflict is detected. Defaults to + // `SERVER_VALUE`. + // If this is set, then `conflict_detection_strategy` must also be set. + ConflictResolutionStrategy conflict_resolution_strategy = 10; + + // The properties to write in this mutation. + // None of the properties in the mask may have a reserved name, except for + // `__key__`. + // This field is ignored for `delete`. + // + // If the entity already exists, only properties referenced in the mask are + // updated, others are left untouched. + // Properties referenced in the mask but not in the entity are deleted. + PropertyMask property_mask = 9; + + // Optional. The transforms to perform on the entity. + // + // This field can be set only when the operation is `insert`, `update`, + // or `upsert`. If present, the transforms are be applied to the entity + // regardless of the property mask, in order, after the operation. + repeated PropertyTransform property_transforms = 12 + [(google.api.field_behavior) = OPTIONAL]; +} + +// A transformation of an entity property. +message PropertyTransform { + // 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 properties (same or different entities) + // in a transaction, all the properties will get the same server timestamp. + REQUEST_TIME = 1; + } + + // Optional. The name of the property. + // + // Property paths (a list of property names separated by dots (`.`)) may be + // used to refer to properties inside entity values. For example `foo.bar` + // means the property `bar` inside the entity property `foo`. + // + // If a property name contains a dot `.` or a backlslash `\`, then that name + // must be escaped. + string property = 1 [(google.api.field_behavior) = OPTIONAL]; + + // The transformation to apply to the property. + oneof transform_type { + // Sets the property to the given server value. + ServerValue set_to_server_value = 2; + + // Adds the given value to the property's current value. + // + // This must be an integer or a double value. + // If the property is not an integer or double, or if the property does not + // yet exist, the transformation will set the property to the given value. + // If either of the given value or the current property value are doubles, + // both values will be interpreted as doubles. Double arithmetic and + // representation of double values follows IEEE 754 semantics. + // If there is positive/negative integer overflow, the property is resolved + // to the largest magnitude positive/negative integer. + Value increment = 3; + + // Sets the property to the maximum of its current value and the given + // value. + // + // This must be an integer or a double value. + // If the property is not an integer or double, or if the property does not + // yet exist, the transformation will set the property to the given value. + // If a maximum operation is applied where the property and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the property takes on the type of the larger operand. If the operands are + // equivalent (e.g. 3 and 3.0), the property 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 property to the minimum of its current value and the given + // value. + // + // This must be an integer or a double value. + // If the property is not an integer or double, or if the property does not + // yet exist, the transformation will set the property to the input value. + // If a minimum operation is applied where the property and the input value + // are of mixed types (that is - one is an integer and one is a double) + // the property takes on the type of the smaller operand. If the operands + // are equivalent (e.g. 3 and 3.0), the property 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; + + // Appends the given elements in order if they are not already present in + // the current property value. + // If the property is not an array, or if the property 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 the null value is equal to the null value. + // 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; + + // Removes all of the given elements from the array in the property. + // If the property is not an array, or if the property does not yet exist, + // it is set to the empty array. + // + // Equivalent numbers of 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 the null value is equal to the null value. + // 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 result of applying a mutation. +message MutationResult { + // The automatically allocated key. + // Set only when the mutation allocated a key. + Key key = 3; + + // The version of the entity on the server after processing the mutation. If + // the mutation doesn't change anything on the server, then the version will + // be the version of the current entity or, if no entity is present, a version + // that is strictly greater than the version of any previous entity and less + // than the version of any possible future entity. + int64 version = 4; + + // The create time of the entity. This field will not be set after a 'delete'. + google.protobuf.Timestamp create_time = 7; + + // The update time of the entity on the server after processing the mutation. + // If the mutation doesn't change anything on the server, then the timestamp + // will be the update timestamp of the current entity. This field will not be + // set after a 'delete'. + google.protobuf.Timestamp update_time = 6; + + // Whether a conflict was detected for this mutation. Always false when a + // conflict detection strategy field is not set in the mutation. + bool conflict_detected = 5; + + // The results of applying each + // [PropertyTransform][google.datastore.v1.PropertyTransform], in the same + // order of the request. + repeated Value transform_results = 8; +} + +// The set of arbitrarily nested property paths used to restrict an operation to +// only a subset of properties in an entity. +message PropertyMask { + // The paths to the properties covered by this mask. + // + // A path is a list of property names separated by dots (`.`), for example + // `foo.bar` means the property `bar` inside the entity property `foo` inside + // the entity associated with this path. + // + // If a property name contains a dot `.` or a backslash `\`, then that + // name must be escaped. + // + // A path must not be empty, and may not reference a value inside an + // [array value][google.datastore.v1.Value.array_value]. + repeated string paths = 1; +} + +// The options shared by read requests. +message ReadOptions { + // The possible values for read consistencies. + enum ReadConsistency { + // Unspecified. This value must not be used. + READ_CONSISTENCY_UNSPECIFIED = 0; + + // Strong consistency. + STRONG = 1; + + // Eventual consistency. + EVENTUAL = 2; + } + + // For Cloud Firestore in Datastore mode, if you don't specify + // read_consistency then all lookups and queries default to + // `read_consistency`=`STRONG`. Note that, in Cloud Datastore, global queries + // defaulted to `read_consistency`=`EVENTUAL`. + // + // Explicitly setting `read_consistency`=`EVENTUAL` will result in eventually + // consistent lookups and queries. + oneof consistency_type { + // The non-transactional read consistency to use. + ReadConsistency read_consistency = 1; + + // The identifier of the transaction in which to read. A + // transaction identifier is returned by a call to + // [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction]. + bytes transaction = 2; + + // Options for beginning a new transaction for this request. + // + // The new transaction identifier will be returned in the corresponding + // response as either + // [LookupResponse.transaction][google.datastore.v1.LookupResponse.transaction] + // or + // [RunQueryResponse.transaction][google.datastore.v1.RunQueryResponse.transaction]. + TransactionOptions new_transaction = 3; + + // Reads entities as they were at the given time. This value is only + // supported for Cloud Firestore in Datastore mode. + // + // 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; + } +} + +// Options for beginning a new transaction. +// +// Transactions can be created explicitly with calls to +// [Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction] +// or implicitly by setting +// [ReadOptions.new_transaction][google.datastore.v1.ReadOptions.new_transaction] +// in read requests. +message TransactionOptions { + // Options specific to read / write transactions. + message ReadWrite { + // The transaction identifier of the transaction being retried. + bytes previous_transaction = 1; + } + + // Options specific to read-only transactions. + message ReadOnly { + // Reads entities 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 = 1; + } + + // The `mode` of the transaction, indicating whether write operations are + // supported. + oneof mode { + // The transaction should allow both reads and writes. + ReadWrite read_write = 1; + + // The transaction should only allow reads. + ReadOnly read_only = 2; + } +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/entity.proto b/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/entity.proto new file mode 100644 index 000000000000..fdf0a32cb7f9 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/entity.proto @@ -0,0 +1,217 @@ +// 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. + +syntax = "proto3"; + +package google.datastore.v1; + +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; +import "google/type/latlng.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; +option java_multiple_files = true; +option java_outer_classname = "EntityProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// A partition ID identifies a grouping of entities. The grouping is always +// by project and namespace, however the namespace ID may be empty. +// +// A partition ID contains several dimensions: +// project ID and namespace ID. +// +// Partition dimensions: +// +// - May be `""`. +// - Must be valid UTF-8 bytes. +// - Must have values that match regex `[A-Za-z\d\.\-_]{1,100}` +// If the value of any dimension matches regex `__.*__`, the partition is +// reserved/read-only. +// A reserved/read-only partition ID is forbidden in certain documented +// contexts. +// +// Foreign partition IDs (in which the project ID does +// not match the context project ID ) are discouraged. +// Reads and writes of foreign partition IDs may fail if the project is not in +// an active state. +message PartitionId { + // The ID of the project to which the entities belong. + string project_id = 2; + + // If not empty, the ID of the database to which the entities + // belong. + string database_id = 3; + + // If not empty, the ID of the namespace to which the entities belong. + string namespace_id = 4; +} + +// A unique identifier for an entity. +// If a key's partition ID or any of its path kinds or names are +// reserved/read-only, the key is reserved/read-only. +// A reserved/read-only key is forbidden in certain documented contexts. +message Key { + // A (kind, ID/name) pair used to construct a key path. + // + // If either name or ID is set, the element is complete. + // If neither is set, the element is incomplete. + message PathElement { + // The kind of the entity. + // + // A kind matching regex `__.*__` is reserved/read-only. + // A kind must not contain more than 1500 bytes when UTF-8 encoded. + // Cannot be `""`. + // + // Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are + // encoded as `__bytes__` where `` is the base-64 encoding of the + // bytes. + string kind = 1; + + // The type of ID. + oneof id_type { + // The auto-allocated ID of the entity. + // + // Never equal to zero. Values less than zero are discouraged and may not + // be supported in the future. + int64 id = 2; + + // The name of the entity. + // + // A name matching regex `__.*__` is reserved/read-only. + // A name must not be more than 1500 bytes when UTF-8 encoded. + // Cannot be `""`. + // + // Must be valid UTF-8 bytes. Legacy values that are not valid UTF-8 are + // encoded as `__bytes__` where `` is the base-64 encoding of the + // bytes. + string name = 3; + } + } + + // Entities are partitioned into subsets, currently identified by a project + // ID and namespace ID. + // Queries are scoped to a single partition. + PartitionId partition_id = 1; + + // The entity path. + // An entity path consists of one or more elements composed of a kind and a + // string or numerical identifier, which identify entities. The first + // element identifies a _root entity_, the second element identifies + // a _child_ of the root entity, the third element identifies a child of the + // second entity, and so forth. The entities identified by all prefixes of + // the path are called the element's _ancestors_. + // + // An entity path is always fully complete: *all* of the entity's ancestors + // are required to be in the path along with the entity identifier itself. + // The only exception is that in some documented cases, the identifier in the + // last path element (for the entity) itself may be omitted. For example, + // the last path element of the key of `Mutation.insert` may have no + // identifier. + // + // A path can never be empty, and a path can have at most 100 elements. + repeated PathElement path = 2; +} + +// An array value. +message ArrayValue { + // Values in the array. + // The order of values in an array is preserved as long as all values have + // identical settings for 'exclude_from_indexes'. + repeated Value values = 1; +} + +// A message that can hold any of the supported value types and associated +// metadata. +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. + // When stored in the Datastore, precise only to microseconds; + // any additional precision is rounded down. + google.protobuf.Timestamp timestamp_value = 10; + + // A key value. + Key key_value = 5; + + // A UTF-8 encoded string value. + // When `exclude_from_indexes` is false (it is indexed) , may have at most + // 1500 bytes. Otherwise, may be set to at most 1,000,000 bytes. + string string_value = 17; + + // A blob value. + // May have at most 1,000,000 bytes. + // When `exclude_from_indexes` is false, may have at most 1500 bytes. + // In JSON requests, must be base64-encoded. + bytes blob_value = 18; + + // A geo point value representing a point on the surface of Earth. + google.type.LatLng geo_point_value = 8; + + // An entity value. + // + // - May have no key. + // - May have a key with an incomplete key path. + // - May have a reserved/read-only key. + Entity entity_value = 6; + + // An array value. + // Cannot contain another array value. + // A `Value` instance that sets field `array_value` must not set fields + // `meaning` or `exclude_from_indexes`. + ArrayValue array_value = 9; + } + + // The `meaning` field should only be populated for backwards compatibility. + int32 meaning = 14; + + // If the value should be excluded from all indexes including those defined + // explicitly. + bool exclude_from_indexes = 19; +} + +// A Datastore data object. +// +// Must not exceed 1 MiB - 4 bytes. +message Entity { + // The entity's key. + // + // An entity must have a key, unless otherwise documented (for example, + // an entity in `Value.entity_value` may have no key). + // An entity's kind is its key path's last element's kind, + // or null if it has no key. + Key key = 1; + + // The entity's properties. + // The map's keys are property names. + // A property name matching regex `__.*__` is reserved. + // A reserved property name is forbidden in certain documented contexts. + // The map keys, represented as UTF-8, must not exceed 1,500 bytes and cannot + // be empty. + map properties = 3; +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query.proto b/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query.proto new file mode 100644 index 000000000000..2e36f958b67d --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query.proto @@ -0,0 +1,622 @@ +// 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. + +syntax = "proto3"; + +package google.datastore.v1; + +import "google/api/field_behavior.proto"; +import "google/datastore/v1/entity.proto"; +import "google/protobuf/timestamp.proto"; +import "google/protobuf/wrappers.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; +option java_multiple_files = true; +option java_outer_classname = "QueryProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// The result of fetching an entity from Datastore. +message EntityResult { + // Specifies what data the 'entity' field contains. + // A `ResultType` is either implied (for example, in `LookupResponse.missing` + // from `datastore.proto`, it is always `KEY_ONLY`) or specified by context + // (for example, in message `QueryResultBatch`, field `entity_result_type` + // specifies a `ResultType` for all the values in field `entity_results`). + enum ResultType { + // Unspecified. This value is never used. + RESULT_TYPE_UNSPECIFIED = 0; + + // The key and properties. + FULL = 1; + + // A projected subset of properties. The entity may have no key. + PROJECTION = 2; + + // Only the key. + KEY_ONLY = 3; + } + + // The resulting entity. + Entity entity = 1; + + // The version of the entity, a strictly positive number that monotonically + // increases with changes to the entity. + // + // This field is set for + // [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results. + // + // For [missing][google.datastore.v1.LookupResponse.missing] entities in + // `LookupResponse`, this is the version of the snapshot that was used to look + // up the entity, and it is always set except for eventually consistent reads. + int64 version = 4; + + // The time at which the entity was created. + // This field is set for + // [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results. + // If this entity is missing, this field will not be set. + google.protobuf.Timestamp create_time = 6; + + // The time at which the entity was last changed. + // This field is set for + // [`FULL`][google.datastore.v1.EntityResult.ResultType.FULL] entity results. + // If this entity is missing, this field will not be set. + google.protobuf.Timestamp update_time = 5; + + // A cursor that points to the position after the result entity. + // Set only when the `EntityResult` is part of a `QueryResultBatch` message. + bytes cursor = 3; +} + +// A query for entities. +// +// The query stages are executed in the following order: +// 1. kind +// 2. filter +// 3. projection +// 4. order + start_cursor + end_cursor +// 5. offset +// 6. limit +// 7. find_nearest +message Query { + // The projection to return. Defaults to returning all properties. + repeated Projection projection = 2; + + // The kinds to query (if empty, returns entities of all kinds). + // Currently at most 1 kind may be specified. + repeated KindExpression kind = 3; + + // The filter to apply. + Filter filter = 4; + + // The order to apply to the query results (if empty, order is unspecified). + repeated PropertyOrder order = 5; + + // The properties to make distinct. The query results will contain the first + // result for each distinct combination of values for the given properties + // (if empty, all results are returned). + // + // Requires: + // + // * If `order` is specified, the set of distinct on properties must appear + // before the non-distinct on properties in `order`. + repeated PropertyReference distinct_on = 6; + + // A starting point for the query results. Query cursors are + // returned in query result batches and + // [can only be used to continue the same + // query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). + bytes start_cursor = 7; + + // An ending point for the query results. Query cursors are + // returned in query result batches and + // [can only be used to limit the same + // query](https://cloud.google.com/datastore/docs/concepts/queries#cursors_limits_and_offsets). + bytes end_cursor = 8; + + // The number of results to skip. Applies before limit, but after all other + // constraints. Optional. Must be >= 0 if specified. + int32 offset = 10; + + // The maximum number of results to return. Applies after all other + // constraints. Optional. + // Unspecified is interpreted as no limit. + // Must be >= 0 if specified. + google.protobuf.Int32Value limit = 12; + + // 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 = 13 [(google.api.field_behavior) = OPTIONAL]; +} + +// Datastore query for running an aggregation over a +// [Query][google.datastore.v1.Query]. +message AggregationQuery { + // Defines an aggregation that produces a single result. + message Aggregation { + // Count of entities that match the query. + // + // The `COUNT(*)` aggregation function operates on the entire entity + // so it does not require a field reference. + message Count { + // Optional. Optional constraint on the maximum number of entities to + // count. + // + // This provides a way to set an upper bound on the number of entities + // to scan, limiting latency, and cost. + // + // Unspecified is interpreted as no bound. + // + // If a zero value is provided, a count result of zero should always be + // expected. + // + // High-Level Example: + // + // ``` + // AGGREGATE COUNT_UP_TO(1000) OVER ( SELECT * FROM k ); + // ``` + // + // Requires: + // + // * Must be non-negative when present. + google.protobuf.Int64Value up_to = 1 + [(google.api.field_behavior) = OPTIONAL]; + } + + // Sum of the values of the requested property. + // + // * 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 property to aggregate on. + PropertyReference property = 1; + } + + // Average of the values of the requested property. + // + // * 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 property to aggregate on. + PropertyReference property = 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 property to store the result of the + // aggregation. + // + // If not provided, Datastore will pick a default name following the format + // `property_`. 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 property_1, + // COUNT_UP_TO(3) AS count_up_to_3, + // COUNT(*) AS property_2 + // OVER ( + // ... + // ); + // ``` + // + // Requires: + // + // * Must be unique across all aggregation aliases. + // * Conform to [entity property + // name][google.datastore.v1.Entity.properties] limitations. + string alias = 7 [(google.api.field_behavior) = OPTIONAL]; + } + + // The base query to aggregate over. + oneof query_type { + // Nested query for aggregation + Query nested_query = 1; + } + + // Optional. Series of aggregations to apply over the results of the + // `nested_query`. + // + // Requires: + // + // * A minimum of one and maximum of five aggregations per query. + repeated Aggregation aggregations = 3 + [(google.api.field_behavior) = OPTIONAL]; +} + +// A representation of a kind. +message KindExpression { + // The name of the kind. + string name = 1; +} + +// A reference to a property relative to the kind expressions. +message PropertyReference { + // A reference to a property. + // + // Requires: + // + // * MUST be a dot-delimited (`.`) string of segments, where each segment + // conforms to [entity property name][google.datastore.v1.Entity.properties] + // limitations. + string name = 2; +} + +// A representation of a property in a projection. +message Projection { + // The property to project. + PropertyReference property = 1; +} + +// The desired order for a specific property. +message PropertyOrder { + // The sort direction. + enum Direction { + // Unspecified. This value must not be used. + DIRECTION_UNSPECIFIED = 0; + + // Ascending. + ASCENDING = 1; + + // Descending. + DESCENDING = 2; + } + + // The property to order by. + PropertyReference property = 1; + + // The direction to order by. Defaults to `ASCENDING`. + Direction direction = 2; +} + +// A holder for any type of filter. +message Filter { + // The type of filter. + oneof filter_type { + // A composite filter. + CompositeFilter composite_filter = 1; + + // A filter on a property. + PropertyFilter property_filter = 2; + } +} + +// 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; + + // The results are required to satisfy each 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 property. +message PropertyFilter { + // A property filter operator. + enum Operator { + // Unspecified. This value must not be used. + OPERATOR_UNSPECIFIED = 0; + + // The given `property` is less than the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + LESS_THAN = 1; + + // The given `property` is less than or equal to the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + LESS_THAN_OR_EQUAL = 2; + + // The given `property` is greater than the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + GREATER_THAN = 3; + + // The given `property` is greater than or equal to the given `value`. + // + // Requires: + // + // * That `property` comes first in `order_by`. + GREATER_THAN_OR_EQUAL = 4; + + // The given `property` is equal to the given `value`. + EQUAL = 5; + + // The given `property` 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` is in the same query. + IN = 6; + + // The given `property` is not equal to the given `value`. + // + // Requires: + // + // * No other `NOT_EQUAL` or `NOT_IN` is in the same query. + // * That `property` comes first in the `order_by`. + NOT_EQUAL = 9; + + // Limit the result set to the given entity and its descendants. + // + // Requires: + // + // * That `value` is an entity key. + // * All evaluated disjunctions must have the same `HAS_ANCESTOR` filter. + HAS_ANCESTOR = 11; + + // The value of the `property` is not in the given array. + // + // Requires: + // + // * That `value` is a non-empty `ArrayValue` with at most 10 values. + // * No other `OR`, `IN`, `NOT_IN`, `NOT_EQUAL` is in the same query. + // * That `field` comes first in the `order_by`. + NOT_IN = 13; + } + + // The property to filter by. + PropertyReference property = 1; + + // The operator to filter by. + Operator op = 2; + + // The value to compare the property to. + Value value = 3; +} + +// 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 property to search upon. Only documents which + // contain vectors whose dimensionality match the query_vector can be + // returned. + PropertyReference vector_property = 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 100. + 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 [entity + // property][google.datastore.v1.Entity.properties] limitations. + string distance_result_property = 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]; +} + +// A [GQL +// query](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). +message GqlQuery { + // A string of the format described + // [here](https://cloud.google.com/datastore/docs/apis/gql/gql_reference). + string query_string = 1; + + // When false, the query string must not contain any literals and instead must + // bind all values. For example, + // `SELECT * FROM Kind WHERE a = 'string literal'` is not allowed, while + // `SELECT * FROM Kind WHERE a = @value` is. + bool allow_literals = 2; + + // For each non-reserved named binding site in the query string, there must be + // a named parameter with that name, but not necessarily the inverse. + // + // Key must match regex `[A-Za-z_$][A-Za-z_$0-9]*`, must not match regex + // `__.*__`, and must not be `""`. + map named_bindings = 5; + + // Numbered binding site @1 references the first numbered parameter, + // effectively using 1-based indexing, rather than the usual 0. + // + // For each binding site numbered i in `query_string`, there must be an i-th + // numbered parameter. The inverse must also be true. + repeated GqlQueryParameter positional_bindings = 4; +} + +// A binding parameter for a GQL query. +message GqlQueryParameter { + // The type of parameter. + oneof parameter_type { + // A value parameter. + Value value = 2; + + // A query cursor. Query cursors are returned in query + // result batches. + bytes cursor = 3; + } +} + +// A batch of results produced by a query. +message QueryResultBatch { + // The possible values for the `more_results` field. + enum MoreResultsType { + // Unspecified. This value is never used. + MORE_RESULTS_TYPE_UNSPECIFIED = 0; + + // There may be additional batches to fetch from this query. + NOT_FINISHED = 1; + + // The query is finished, but there may be more results after the limit. + MORE_RESULTS_AFTER_LIMIT = 2; + + // The query is finished, but there may be more results after the end + // cursor. + MORE_RESULTS_AFTER_CURSOR = 4; + + // The query is finished, and there are no more results. + NO_MORE_RESULTS = 3; + } + + // The number of results skipped, typically because of an offset. + int32 skipped_results = 6; + + // A cursor that points to the position after the last skipped result. + // Will be set when `skipped_results` != 0. + bytes skipped_cursor = 3; + + // The result type for every entity in `entity_results`. + EntityResult.ResultType entity_result_type = 1; + + // The results for this batch. + repeated EntityResult entity_results = 2; + + // A cursor that points to the position after the last result in the batch. + bytes end_cursor = 4; + + // The state of the query after the current batch. + MoreResultsType more_results = 5; + + // The version number of the snapshot this batch was returned from. + // This applies to the range of results from the query's `start_cursor` (or + // the beginning of the query if no cursor was given) to this batch's + // `end_cursor` (not the query's `end_cursor`). + // + // In a single transaction, subsequent query result batches for the same query + // can have a greater snapshot version number. Each batch's snapshot version + // is valid for all preceding batches. + // The value will be zero for eventually consistent queries. + int64 snapshot_version = 7; + + // Read timestamp this batch was returned from. + // This applies to the range of results from the query's `start_cursor` (or + // the beginning of the query if no cursor was given) to this batch's + // `end_cursor` (not the query's `end_cursor`). + // + // In a single transaction, subsequent query result batches for the same query + // can have a greater timestamp. Each batch's read timestamp + // is valid for all preceding batches. + // This value will not be set for eventually consistent queries in Cloud + // Datastore. + google.protobuf.Timestamp read_time = 8; +} diff --git a/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query_profile.proto b/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query_profile.proto new file mode 100644 index 000000000000..71a4eb599335 --- /dev/null +++ b/java-datastore/proto-google-cloud-datastore-v1/src/main/proto/google/datastore/v1/query_profile.proto @@ -0,0 +1,91 @@ +// 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. + +syntax = "proto3"; + +package google.datastore.v1; + +import "google/api/field_behavior.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/struct.proto"; + +option csharp_namespace = "Google.Cloud.Datastore.V1"; +option go_package = "cloud.google.com/go/datastore/apiv1/datastorepb;datastorepb"; +option java_multiple_files = true; +option java_outer_classname = "QueryProfileProto"; +option java_package = "com.google.datastore.v1"; +option php_namespace = "Google\\Cloud\\Datastore\\V1"; +option ruby_package = "Google::Cloud::Datastore::V1"; + +// Specification of the Datastore 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.datastore.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-datastore/pull-gapic-grpc.sh b/java-datastore/pull-gapic-grpc.sh new file mode 100644 index 000000000000..327d7676c7d2 --- /dev/null +++ b/java-datastore/pull-gapic-grpc.sh @@ -0,0 +1,42 @@ +# +# 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 +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +GENERATED_CODE_DIR=$(pwd)/../googleapis-gen +DATASTORE_DIR=$(pwd) + +echo $GENERATED_CODE_DIR +if [ -d "$GENERATED_CODE_DIR" ]; then + echo "Pulling latest changes in ${GENERATED_CODE_DIR}" + pushd $GENERATED_CODE_DIR || exit + git pull + popd || exit +else + echo "Cloning googleapis-gen" + git clone --depth 1 git@github.com:googleapis/googleapis-gen.git $GENERATED_CODE_DIR +fi + +#Copying the required directories +mkdir -p "$DATASTORE_DIR/grpc-google-cloud-datastore-v1" +cp -r "$GENERATED_CODE_DIR/google/datastore/v1/google-cloud-datastore-v1-java/grpc-google-cloud-datastore-v1-java/." \ +"$DATASTORE_DIR/grpc-google-cloud-datastore-v1/." +cp -r "$GENERATED_CODE_DIR/google/datastore/v1/google-cloud-datastore-v1-java/gapic-google-cloud-datastore-v1-java/." \ +"$DATASTORE_DIR/google-cloud-datastore/." + +#Cleaning up unwanted files +rm grpc-google-cloud-datastore-v1/build.gradle +rm google-cloud-datastore/build.gradle + +echo "Success" diff --git a/java-datastore/samples/README.md b/java-datastore/samples/README.md new file mode 100644 index 000000000000..4416583fd88a --- /dev/null +++ b/java-datastore/samples/README.md @@ -0,0 +1,30 @@ +# Getting Started with Datastore Samples + +## Running a sample using Cloud Shell + +The Google Cloud Shell has application default credentials from its compute instance which will allow you to run samples without having to obtain `GOOGLE_APPLICATION_CREDENTIALS`. +Go to the [Datastore Client Readme](https://github.com/googleapis/java-datastore#samples) to run each sample in the Cloud Shell. + +## Running a sample at the command line + +1. First set up the `GOOGLE_CLOUD_PROJECT` environment variable. + +2. Obtain authentication credentials. + + Create local credentials by running the following command and following the + oauth2 flow (read more about the command [here][auth_command]): + + gcloud auth application-default login + + Or manually set the `GOOGLE_APPLICATION_CREDENTIALS` environment variable + to point to a service account key JSON file path. + + Learn more at [Setting Up Authentication for Server to Server Production Applications][ADC]. + +Now you can run a sample: + +1. `cd samples/snippets` - all samples are located in the `java-datastore/samples/snippets` directory. +2. `mvn compile exec:java -Dexec.mainClass="com.google.datastore.snippets.TaskList"` - this runs the [TaskList sample](https://github.com/googleapis/java-datastore/blob/master/samples/snippets/src/main/java/com/google/datastore/snippets/TaskList.java). + +[ADC]: https://developers.google.com/identity/protocols/application-default-credentials +[auth_command]: https://cloud.google.com/sdk/gcloud/reference/beta/auth/application-default/login diff --git a/java-datastore/samples/install-without-bom/pom.xml b/java-datastore/samples/install-without-bom/pom.xml new file mode 100644 index 000000000000..29d115bec2e3 --- /dev/null +++ b/java-datastore/samples/install-without-bom/pom.xml @@ -0,0 +1,84 @@ + + + 4.0.0 + com.google.cloud + datastore-install-without-bom + jar + Google Cloud Datastore Install Without Bom + https://github.com/googleapis/java-datastore + + + + com.google.cloud.samples + shared-configuration + 1.2.0 + + + + 1.8 + 1.8 + UTF-8 + + + + + + + com.google.cloud + google-cloud-datastore + 2.31.2 + + + + + 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-datastore/samples/native-image-sample/pom.xml b/java-datastore/samples/native-image-sample/pom.xml new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/java-datastore/samples/pom.xml b/java-datastore/samples/pom.xml new file mode 100644 index 000000000000..41074b3957d7 --- /dev/null +++ b/java-datastore/samples/pom.xml @@ -0,0 +1,56 @@ + + + 4.0.0 + com.google.cloud + google-cloud-datastore-samples + 0.0.1-SNAPSHOT + pom + Google Cloud Datastore Samples Parent + https://github.com/googleapis/java-datastore + + Java idiomatic client for Google Cloud Platform services. + + + + + com.google.cloud.samples + shared-configuration + 1.2.0 + + + + 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-datastore/samples/snapshot/pom.xml b/java-datastore/samples/snapshot/pom.xml new file mode 100644 index 000000000000..54b876b0496b --- /dev/null +++ b/java-datastore/samples/snapshot/pom.xml @@ -0,0 +1,83 @@ + + + 4.0.0 + com.google.cloud + datastore-snapshot + jar + Google Cloud Datastore Snapshot Samples + https://github.com/googleapis/java-datastore + + + + com.google.cloud.samples + shared-configuration + 1.2.0 + + + + 1.8 + 1.8 + UTF-8 + + + + + + com.google.cloud + google-cloud-datastore + 2.33.2 + + + + + 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 + + + + + + + + \ No newline at end of file diff --git a/java-datastore/samples/snippets/pom.xml b/java-datastore/samples/snippets/pom.xml new file mode 100644 index 000000000000..8ed08dea5f3b --- /dev/null +++ b/java-datastore/samples/snippets/pom.xml @@ -0,0 +1,60 @@ + + + 4.0.0 + com.google.cloud + datastore-snippets + jar + Google Cloud Datastore Snippets + https://github.com/googleapis/java-datastore + + + + com.google.cloud.samples + shared-configuration + 1.2.0 + + + + 1.8 + 1.8 + UTF-8 + + + + + + + + com.google.cloud + libraries-bom + 26.62.0 + pom + import + + + + + + + com.google.cloud + google-cloud-datastore + + + + + junit + junit + 4.13.2 + test + + + com.google.truth + truth + 1.4.4 + test + + + diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/ConfigureConnectionPool.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/ConfigureConnectionPool.java new file mode 100644 index 000000000000..7809501cc997 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/ConfigureConnectionPool.java @@ -0,0 +1,61 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +// [START datastore_configure_connection_pool] + +import com.google.api.gax.grpc.ChannelPoolSettings; +import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.v1.DatastoreSettings; +import com.google.cloud.grpc.GrpcTransportOptions; + +public class ConfigureConnectionPool { + + public static void main(String... args) throws Exception { + InstantiatingGrpcChannelProvider channelProvider = + DatastoreSettings.defaultGrpcTransportProviderBuilder() + .setChannelPoolSettings( + ChannelPoolSettings.builder() + .setInitialChannelCount(10) + .setMinChannelCount(5) + .setMaxChannelCount(200) + .build()) + .build(); + + DatastoreOptions datastoreOptions = + DatastoreOptions.newBuilder() + .setProjectId("my-project") + .setChannelProvider(channelProvider) + .setTransportOptions(GrpcTransportOptions.newBuilder().build()) + .build(); + + ChannelPoolSettings channelPoolSettings = + ((InstantiatingGrpcChannelProvider) datastoreOptions.getTransportChannelProvider()) + .getChannelPoolSettings(); + + System.out.printf( + String.format( + "Connected with pool with InitialChannelCount: %d, MinChannelCount: %d," + + " MaxChannelCount: %d", + channelPoolSettings.getInitialChannelCount(), + channelPoolSettings.getMinChannelCount(), + channelPoolSettings.getMaxChannelCount())); + } +} + +// [END datastore_configure_connection_pool] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/QuickstartSample.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/QuickstartSample.java new file mode 100644 index 000000000000..0f88c1c147db --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/QuickstartSample.java @@ -0,0 +1,52 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +// [START datastore_quickstart] +// Imports the Google Cloud client library +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Key; + +public class QuickstartSample { + public static void main(String... args) throws Exception { + // Instantiates a client + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity + String kind = "Task"; + // The name/ID for the new entity + String name = "sampletask1"; + // The Cloud Datastore key for the new entity + Key taskKey = datastore.newKeyFactory().setKind(kind).newKey(name); + + // Prepares the new entity + Entity task = Entity.newBuilder(taskKey).set("description", "Buy milk").build(); + + // Saves the entity + datastore.put(task); + + System.out.printf("Saved %s: %s%n", task.getKey().getName(), task.getString("description")); + + // Retrieve entity + Entity retrieved = datastore.get(taskKey); + + System.out.printf("Retrieved %s: %s%n", taskKey.getName(), retrieved.getString("description")); + } +} +// [END datastore_quickstart] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationOnKind.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationOnKind.java new file mode 100644 index 000000000000..312c12509b8d --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationOnKind.java @@ -0,0 +1,77 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.aggregation; + +// [START datastore_avg_aggregation_query_on_kind] + +import static com.google.cloud.datastore.aggregation.Aggregation.avg; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class AvgAggregationOnKind { + + // Instantiates a client. + private static final Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + private static final String kind = "Sales"; + + // Setting up Sales in database + private static void setUpSales() { + Key sales1Key = datastore.newKeyFactory().setKind(kind).newKey("sales1"); + Key sales2Key = datastore.newKeyFactory().setKind(kind).newKey("sales2"); + Key sales3Key = datastore.newKeyFactory().setKind(kind).newKey("sales3"); + + // Save all the sales. + datastore.put( + Entity.newBuilder(sales1Key).set("amount", 89).build(), + Entity.newBuilder(sales2Key).set("amount", 95).build(), + Entity.newBuilder(sales3Key).set("amount", 55).build()); + } + + // Accessing aggregation result by the provided custom alias. + private static void usageWithCustomAlias() { + EntityQuery selectAllSales = Query.newEntityQueryBuilder().setKind(kind).build(); + // Creating an aggregation query to get the avg of all sales. + AggregationQuery avgOfSalesQuery = + Query.newAggregationQueryBuilder() + .over(selectAllSales) + // passing 'avg_sales_amount' as alias in the aggregation query. + .addAggregation(avg("amount").as("avg_sales_amount")) + .build(); + // Executing aggregation query. + AggregationResult aggregationResult = + Iterables.getOnlyElement(datastore.runAggregation(avgOfSalesQuery)); + + System.out.printf( + "Average sales is %.8f", aggregationResult.getDouble("avg_sales_amount")); // 79.66666667 + } + + public static void invoke() { + setUpSales(); + usageWithCustomAlias(); + } +} +// [END datastore_avg_aggregation_query_on_kind] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithLimit.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithLimit.java new file mode 100644 index 000000000000..fab0a87134c3 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithLimit.java @@ -0,0 +1,66 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.aggregation; + +// [START datastore_avg_aggregation_query_with_limit] + +import static com.google.cloud.datastore.aggregation.Aggregation.avg; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class AvgAggregationWithLimit { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Sales"; + + Key sales1Key = datastore.newKeyFactory().setKind(kind).newKey("sales1"); + Key sales2Key = datastore.newKeyFactory().setKind(kind).newKey("sales2"); + Key sales3Key = datastore.newKeyFactory().setKind(kind).newKey("sales3"); + + // Save all the tasks. + datastore.put( + Entity.newBuilder(sales1Key).set("amount", 89).build(), + Entity.newBuilder(sales2Key).set("amount", 95).build(), + Entity.newBuilder(sales3Key).set("amount", 55).build()); + + EntityQuery selectAllSales = Query.newEntityQueryBuilder().setKind(kind).setLimit(2).build(); + // Creating an aggregation query to get the avg of all sales amount. + AggregationQuery avgOfSalesQuery = + Query.newAggregationQueryBuilder() + .over(selectAllSales) + .addAggregation(avg("amount").as("at_least")) + .build(); + // Executing aggregation query. + AggregationResult limitQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(avgOfSalesQuery)); + + System.out.printf("Average with limit 2 is %d.", limitQueryResult.getLong("at_least")); // 72 + } +} +// [END datastore_avg_aggregation_query_with_limit] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithOrderBy.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithOrderBy.java new file mode 100644 index 000000000000..f7573df094fe --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithOrderBy.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 + * + * 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.datastore.aggregation; + +// [START datastore_avg_aggregation_query_with_order_by] + +import static com.google.cloud.datastore.StructuredQuery.OrderBy.asc; +import static com.google.cloud.datastore.aggregation.Aggregation.avg; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class AvgAggregationWithOrderBy { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Sales"; + + Key sales1Key = datastore.newKeyFactory().setKind(kind).newKey("sales1"); + Key sales2Key = datastore.newKeyFactory().setKind(kind).newKey("sales2"); + Key sales3Key = datastore.newKeyFactory().setKind(kind).newKey("sales3"); + + // Save all the sales. + datastore.put( + Entity.newBuilder(sales1Key).set("amount", 89).set("customerId", 1).build(), + // customerId not specified (orphan record). + Entity.newBuilder(sales2Key).set("amount", 95).build(), + Entity.newBuilder(sales3Key).set("amount", 55).set("customerId", 2).build()); + + // OrderBy acts as an existence filter. + EntityQuery selectAllSales = + Query.newEntityQueryBuilder().setKind(kind).addOrderBy(asc("customerId")).build(); + + // Creating an aggregation query to avg of all sales. + AggregationQuery avgOfSalesQuery = + Query.newAggregationQueryBuilder() + .over(selectAllSales) + .addAggregation(avg("amount").as("avg_of_sales")) + .build(); + // Executing aggregation query. + AggregationResult limitQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(avgOfSalesQuery)); + + System.out.printf( + "Total avg of %d with valid customerId field", + limitQueryResult.getLong("avg_of_sales")); // 72 + } +} +// [END datastore_avg_aggregation_query_with_order_by] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithPropertyFilter.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithPropertyFilter.java new file mode 100644 index 000000000000..a2addf1dfd65 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/AvgAggregationWithPropertyFilter.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 + * + * 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.datastore.aggregation; + +// [START datastore_avg_aggregation_query_with_filters] + +import static com.google.cloud.datastore.aggregation.Aggregation.avg; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.common.collect.Iterables; + +public class AvgAggregationWithPropertyFilter { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Sales"; + + Key sales1Key = datastore.newKeyFactory().setKind(kind).newKey("sales1"); + Key sales2Key = datastore.newKeyFactory().setKind(kind).newKey("sales2"); + Key sales3Key = datastore.newKeyFactory().setKind(kind).newKey("sales3"); + + // Save all the tasks. + datastore.put( + Entity.newBuilder(sales1Key).set("amount", 89).set("customerId", 1).build(), + Entity.newBuilder(sales2Key).set("amount", 95).set("customerId", 1).build(), + Entity.newBuilder(sales3Key).set("amount", 55).set("customerId", 2).build()); + + EntityQuery customer1Sales = + Query.newEntityQueryBuilder() + .setKind(kind) + .setFilter(PropertyFilter.eq("customerId", 1)) + .build(); + + // Creating an aggregation query to get the avg of all sales for customerId 1. + AggregationQuery customer1SalesAvg = + Query.newAggregationQueryBuilder() + .over(customer1Sales) + .addAggregation(avg("amount").as("total_sales")) + .build(); + + // Executing aggregation query. + AggregationResult customer1SalesAvgQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(customer1SalesAvg)); + + System.out.printf( + "Customer 1 sales avg is %d", customer1SalesAvgQueryResult.getLong("total_sales")); // 92 + } +} +// [END datastore_avg_aggregation_query_with_filters] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationInTransaction.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationInTransaction.java new file mode 100644 index 000000000000..d2b28172ba91 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationInTransaction.java @@ -0,0 +1,85 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.aggregation; + +// [START datastore_count_aggregation_query_in_transaction] + +import static com.google.cloud.datastore.aggregation.Aggregation.count; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.Datastore.TransactionCallable; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.common.collect.Iterables; + +public class CountAggregationInTransaction { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Task"; + + Key task1Key = datastore.newKeyFactory().setKind(kind).newKey("task1"); + Key task2Key = datastore.newKeyFactory().setKind(kind).newKey("task2"); + + // Save all the tasks. + datastore.put( + Entity.newBuilder(task1Key).set("owner", "john").build(), + Entity.newBuilder(task2Key).set("owner", "john").build()); + + // Using transactions to maintain consistent application state. + datastore.runInTransaction( + (TransactionCallable) + transaction -> { + // Create a query to get the count of all tasks of owner 'John'. + EntityQuery tasksOfJohn = + Query.newEntityQueryBuilder() + .setKind(kind) + .setFilter(PropertyFilter.eq("owner", "john")) + .build(); + AggregationQuery totalTasksQuery = + Query.newAggregationQueryBuilder() + .over(tasksOfJohn) + .addAggregation(count().as("tasks_count")) + .build(); + + // Executing aggregation query in the ongoing transaction. + Long tasksCount = + Iterables.getOnlyElement(transaction.runAggregation(totalTasksQuery)) + .get("tasks_count"); + + if (tasksCount < 2) { + Key newTaskKey = datastore.newKeyFactory().setKind(kind).newKey("task3"); + Entity newTask = Entity.newBuilder(newTaskKey).set("owner", "john").build(); + // Inserting a new entity in the transaction. + transaction.put(newTask); + } else { + System.out.printf("Found existing %d tasks, rolling back", tasksCount); + throw new Exception("User 'John' cannot have more than 2 tasks"); + } + return null; + }); + } +} +// [END datastore_count_aggregation_query_in_transaction] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationOnKind.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationOnKind.java new file mode 100644 index 000000000000..c73151917f9c --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationOnKind.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 + * + * 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.datastore.aggregation; + +// [START datastore_count_aggregation_query_on_kind] +import static com.google.cloud.datastore.aggregation.Aggregation.count; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class CountAggregationOnKind { + // Instantiates a client. + private static final Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + private static final String kind = "Task"; + + // Setting up Tasks in database + private static void setUpTasks() { + Key task1Key = datastore.newKeyFactory().setKind(kind).newKey("task1"); + Key task2Key = datastore.newKeyFactory().setKind(kind).newKey("task2"); + Key task3Key = datastore.newKeyFactory().setKind(kind).newKey("task3"); + + // Save all the tasks. + datastore.put( + Entity.newBuilder(task1Key).set("done", true).build(), + Entity.newBuilder(task2Key).set("done", false).build(), + Entity.newBuilder(task3Key).set("done", true).build()); + } + + // Accessing aggregation result by the generated alias. + private static void usageWithGeneratedAlias() { + EntityQuery selectAllTasks = Query.newEntityQueryBuilder().setKind(kind).build(); + // Creating an aggregation query to get the count of all tasks. + AggregationQuery allTasksCountQuery = + Query.newAggregationQueryBuilder().over(selectAllTasks).addAggregation(count()).build(); + // Executing aggregation query. + AggregationResult aggregationResult = + Iterables.getOnlyElement(datastore.runAggregation(allTasksCountQuery)); + + System.out.printf( + "Total tasks (accessible from default alias) is %d", + aggregationResult.get("property_1")); // 3 + } + + // Accessing aggregation result by the provided custom alias. + private static void usageWithCustomAlias() { + EntityQuery selectAllTasks = Query.newEntityQueryBuilder().setKind(kind).build(); + // Creating an aggregation query to get the count of all tasks. + AggregationQuery allTasksCountQuery = + Query.newAggregationQueryBuilder() + .over(selectAllTasks) + // passing 'total_count' as alias in the aggregation query. + .addAggregation(count().as("total_count")) + .build(); + // Executing aggregation query. + AggregationResult aggregationResult = + Iterables.getOnlyElement(datastore.runAggregation(allTasksCountQuery)); + + System.out.printf("Total tasks count is %d", aggregationResult.get("total_count")); // 3 + } + + public static void invoke() { + setUpTasks(); + usageWithGeneratedAlias(); + usageWithCustomAlias(); + } +} +// [END datastore_count_aggregation_query_on_kind] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithGqlQuery.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithGqlQuery.java new file mode 100644 index 000000000000..e890cee4ec89 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithGqlQuery.java @@ -0,0 +1,87 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.aggregation; + +// [START datastore_count_aggregation_query_gql] +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.GqlQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class CountAggregationWithGqlQuery { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Task"; + + Key task1Key = datastore.newKeyFactory().setKind(kind).newKey("task1"); + Key task2Key = datastore.newKeyFactory().setKind(kind).newKey("task2"); + Key task3Key = datastore.newKeyFactory().setKind(kind).newKey("task3"); + + // Save all the tasks. + datastore.put( + Entity.newBuilder(task1Key).set("done", true).build(), + Entity.newBuilder(task2Key).set("done", false).build(), + Entity.newBuilder(task3Key).set("done", true).build()); + + // Create a GQL query to get the count of all tasks. + GqlQuery selectAllTasks = + Query.newGqlQueryBuilder( + "AGGREGATE COUNT(*) AS total_count, COUNT_UP_TO(2) AS count_with_limit " + + "OVER (SELECT * FROM Task)") + .setAllowLiteral(true) + .build(); + // Create the aggregation query builder and set the query. + AggregationQuery allTasksCountQuery = + Query.newAggregationQueryBuilder().over(selectAllTasks).build(); + // Executing aggregation query. + AggregationResult allTasksCountQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(allTasksCountQuery)); + + System.out.printf( + "We have at least %d tasks", allTasksCountQueryResult.get("count_with_limit")); // 2 + System.out.printf("Total tasks count is %d", allTasksCountQueryResult.get("total_count")); // 3 + + // Create a query to get the count of all completed tasks. + GqlQuery completedTasks = + Query.newGqlQueryBuilder( + "AGGREGATE COUNT(*) AS total_completed_count " + + "OVER (SELECT * FROM Task WHERE done = true)") + .setAllowLiteral(true) + .build(); + // Create the aggregation query builder and set the query. + AggregationQuery completedTasksCountQuery = + Query.newAggregationQueryBuilder().over(completedTasks).build(); + + // Executing aggregation query. + AggregationResult completedTasksCountQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(completedTasksCountQuery)); + + System.out.printf( + "Total completed tasks count is %d", + completedTasksCountQueryResult.get("total_completed_count")); // 2 + } +} +// [END datastore_count_aggregation_query_gql] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithLimit.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithLimit.java new file mode 100644 index 000000000000..4948972769ca --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithLimit.java @@ -0,0 +1,65 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.aggregation; + +// [START datastore_count_aggregation_query_with_limit] + +import static com.google.cloud.datastore.aggregation.Aggregation.count; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class CountAggregationWithLimit { + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Task"; + + Key task1Key = datastore.newKeyFactory().setKind(kind).newKey("task1"); + Key task2Key = datastore.newKeyFactory().setKind(kind).newKey("task2"); + Key task3Key = datastore.newKeyFactory().setKind(kind).newKey("task3"); + + // Save all the tasks. + datastore.put( + Entity.newBuilder(task1Key).set("done", true).build(), + Entity.newBuilder(task2Key).set("done", false).build(), + Entity.newBuilder(task3Key).set("done", true).build()); + + EntityQuery selectAllTasks = Query.newEntityQueryBuilder().setKind(kind).setLimit(2).build(); + // Creating an aggregation query to get the count of all tasks. + AggregationQuery allTasksCountQuery = + Query.newAggregationQueryBuilder() + .over(selectAllTasks) + .addAggregation(count().as("at_least")) + .build(); + // Executing aggregation query. + AggregationResult limitQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(allTasksCountQuery)); + + System.out.printf("We have at least %d tasks", limitQueryResult.get("at_least")); // 2 + } +} +// [END datastore_count_aggregation_query_with_limit] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithOrderBy.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithOrderBy.java new file mode 100644 index 000000000000..b7710ac8ffdb --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithOrderBy.java @@ -0,0 +1,70 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.aggregation; + +// [START datastore_count_aggregation_query_with_order_by] + +import static com.google.cloud.datastore.StructuredQuery.OrderBy.asc; +import static com.google.cloud.datastore.aggregation.Aggregation.count; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class CountAggregationWithOrderBy { + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Task"; + + Key task1Key = datastore.newKeyFactory().setKind(kind).newKey("task1"); + Key task2Key = datastore.newKeyFactory().setKind(kind).newKey("task2"); + Key task3Key = datastore.newKeyFactory().setKind(kind).newKey("task3"); + + // Save all the tasks. + datastore.put( + Entity.newBuilder(task1Key).set("done", true).set("priority", 1).build(), + // Priority not specified. + Entity.newBuilder(task2Key).set("done", false).build(), + Entity.newBuilder(task3Key).set("done", true).set("priority", 2).build()); + + // OrderBy acts as an existence filter. + EntityQuery selectAllTasks = + Query.newEntityQueryBuilder().setKind(kind).addOrderBy(asc("priority")).build(); + // Creating an aggregation query to get the count of all tasks. + AggregationQuery allTasksCountQuery = + Query.newAggregationQueryBuilder() + .over(selectAllTasks) + .addAggregation(count().as("count")) + .build(); + // Executing aggregation query. + AggregationResult limitQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(allTasksCountQuery)); + + System.out.printf( + "Total %d tasks found with priority field", limitQueryResult.get("count")); // 2 + } +} +// [END datastore_count_aggregation_query_with_order_by] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithPropertyFilter.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithPropertyFilter.java new file mode 100644 index 000000000000..9f66d1dbb554 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithPropertyFilter.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 + * + * 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.datastore.aggregation; + +// [START datastore_count_aggregation_query_with_filters] + +import static com.google.cloud.datastore.aggregation.Aggregation.count; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.common.collect.Iterables; + +public class CountAggregationWithPropertyFilter { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Task"; + + Key task1Key = datastore.newKeyFactory().setKind(kind).newKey("task1"); + Key task2Key = datastore.newKeyFactory().setKind(kind).newKey("task2"); + Key task3Key = datastore.newKeyFactory().setKind(kind).newKey("task3"); + + // Save all the tasks. + datastore.put( + Entity.newBuilder(task1Key).set("done", true).build(), + Entity.newBuilder(task2Key).set("done", false).build(), + Entity.newBuilder(task3Key).set("done", true).build()); + + EntityQuery completedTasks = + Query.newEntityQueryBuilder() + .setKind(kind) + .setFilter(PropertyFilter.eq("done", true)) + .build(); + EntityQuery remainingTasks = + Query.newEntityQueryBuilder() + .setKind(kind) + .setFilter(PropertyFilter.eq("done", false)) + .build(); + // Creating an aggregation query to get the count of all completed tasks. + AggregationQuery completedTasksCountQuery = + Query.newAggregationQueryBuilder() + .over(completedTasks) + .addAggregation(count().as("total_completed_count")) + .build(); + // Creating an aggregation query to get the count of all remaining tasks. + AggregationQuery remainingTasksCountQuery = + Query.newAggregationQueryBuilder() + .over(remainingTasks) + .addAggregation(count().as("total_remaining_count")) + .build(); + + // Executing aggregation query. + AggregationResult completedTasksCountQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(completedTasksCountQuery)); + AggregationResult remainingTasksCountQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(remainingTasksCountQuery)); + + System.out.printf( + "Total completed tasks count is %d", + completedTasksCountQueryResult.get("total_completed_count")); // 2 + System.out.printf( + "Total remaining tasks count is %d", + remainingTasksCountQueryResult.get("total_remaining_count")); // 1 + } +} +// [END datastore_count_aggregation_query_with_filters] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithStaleRead.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithStaleRead.java new file mode 100644 index 000000000000..2e0bebacfb88 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/CountAggregationWithStaleRead.java @@ -0,0 +1,80 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.aggregation; + +// [START datastore_count_aggregation_query_stale_read] + +import static com.google.cloud.datastore.aggregation.Aggregation.count; + +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.ReadOption; +import com.google.common.collect.Iterables; + +public class CountAggregationWithStaleRead { + + public static void invoke() throws InterruptedException { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Task"; + + Key task1Key = datastore.newKeyFactory().setKind(kind).newKey("task1"); + Key task2Key = datastore.newKeyFactory().setKind(kind).newKey("task2"); + + // Saving only two tasks. + datastore.put( + Entity.newBuilder(task1Key).set("done", true).build(), + Entity.newBuilder(task2Key).set("done", false).build()); + Thread.sleep(1000); + final Timestamp pastTimestamp = Timestamp.now(); // we have two tasks in database at this time. + + Thread.sleep(1000); + // Saving third tasks. + Key task3Key = datastore.newKeyFactory().setKind(kind).newKey("task3"); + datastore.put(Entity.newBuilder(task3Key).set("done", false).build()); + + EntityQuery selectAllTasks = Query.newEntityQueryBuilder().setKind(kind).build(); + + // Creating an aggregation query to get the count of all tasks. + AggregationQuery allTasksCountQuery = + Query.newAggregationQueryBuilder() + .over(selectAllTasks) + .addAggregation(count().as("total_count")) + .build(); + + // Executing aggregation query. + AggregationResult tasksCountLatest = + Iterables.getOnlyElement(datastore.runAggregation(allTasksCountQuery)); + System.out.printf("Latest tasks count is %d", tasksCountLatest.get("total_count")); // 3 + + // Executing aggregation query with past timestamp. + AggregationResult tasksCountInPast = + Iterables.getOnlyElement( + datastore.runAggregation(allTasksCountQuery, ReadOption.readTime(pastTimestamp))); + System.out.printf("Stale tasks count is %d", tasksCountInPast.get("total_count")); // 2 + } +} +// [END datastore_count_aggregation_query_stale_read] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/MultipleAggregationsInGqlQuery.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/MultipleAggregationsInGqlQuery.java new file mode 100644 index 000000000000..2129d38360de --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/MultipleAggregationsInGqlQuery.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 + * + * 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.datastore.aggregation; + +// [START datastore_multiple_aggregation_in_structured_query] + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.GqlQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class MultipleAggregationsInGqlQuery { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Sales"; + + Key sales1Key = datastore.newKeyFactory().setKind(kind).newKey("sales1"); + Key sales2Key = datastore.newKeyFactory().setKind(kind).newKey("sales2"); + Key sales3Key = datastore.newKeyFactory().setKind(kind).newKey("sales3"); + + // Save all the sales. + datastore.put( + Entity.newBuilder(sales1Key).set("amount", 89).set("customerId", 1).build(), + Entity.newBuilder(sales2Key).set("amount", 95).set("customerId", 1).build(), + Entity.newBuilder(sales3Key).set("amount", 55).set("customerId", 2).build()); + + GqlQuery baseQuery = + Query.newGqlQueryBuilder( + "AGGREGATE COUNT(*) AS total_count," + + " SUM(amount) AS sales_sum," + + " AVG(amount) AS sales_avg " + + "OVER (SELECT * FROM Sales)") + .build(); + + // Creating an aggregation query with COUNT, SUM and AVG aggregations. + AggregationQuery aggregationQuery = Query.newAggregationQueryBuilder().over(baseQuery).build(); + + // Executing aggregation query. + AggregationResult aggregationResult = + Iterables.getOnlyElement(datastore.runAggregation(aggregationQuery)); + + System.out.printf("Total sales count: %d", aggregationResult.getLong("total_count")); // 3 + System.out.printf("Sum of sales: %d", aggregationResult.getLong("sales_sum")); // 239 + System.out.printf( + "Avg of sales: %.8f", aggregationResult.getDouble("sales_avg")); // 79.66666667 + } +} +// [END datastore_multiple_aggregation_in_structured_query] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/MultipleAggregationsInStructuredQuery.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/MultipleAggregationsInStructuredQuery.java new file mode 100644 index 000000000000..39c164e6fcba --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/MultipleAggregationsInStructuredQuery.java @@ -0,0 +1,75 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.aggregation; + +// [START datastore_multiple_aggregation_in_structured_query] + +import static com.google.cloud.datastore.aggregation.Aggregation.avg; +import static com.google.cloud.datastore.aggregation.Aggregation.count; +import static com.google.cloud.datastore.aggregation.Aggregation.sum; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class MultipleAggregationsInStructuredQuery { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Sales"; + + Key sales1Key = datastore.newKeyFactory().setKind(kind).newKey("sales1"); + Key sales2Key = datastore.newKeyFactory().setKind(kind).newKey("sales2"); + Key sales3Key = datastore.newKeyFactory().setKind(kind).newKey("sales3"); + + // Save all the sales. + datastore.put( + Entity.newBuilder(sales1Key).set("amount", 89).set("customerId", 1).build(), + Entity.newBuilder(sales2Key).set("amount", 95).set("customerId", 1).build(), + Entity.newBuilder(sales3Key).set("amount", 55).set("customerId", 2).build()); + + EntityQuery baseQuery = Query.newEntityQueryBuilder().setKind(kind).build(); + + // Creating an aggregation query with COUNT, SUM and AVG aggregations. + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .over(baseQuery) + .addAggregation(count().as("total_count")) + .addAggregation(sum("amount").as("sales_sum")) + .addAggregation(avg("amount").as("sales_avg")) + .build(); + + // Executing aggregation query. + AggregationResult aggregationResult = + Iterables.getOnlyElement(datastore.runAggregation(aggregationQuery)); + + System.out.printf("Total sales count: %d", aggregationResult.getLong("total_count")); // 3 + System.out.printf("Sum of sales: %d", aggregationResult.getLong("sales_sum")); // 239 + System.out.printf( + "Avg of sales: %.8f", aggregationResult.getDouble("sales_avg")); // 79.66666667 + } +} +// [END datastore_multiple_aggregation_in_structured_query] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationOnKind.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationOnKind.java new file mode 100644 index 000000000000..d5795adf6fd7 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationOnKind.java @@ -0,0 +1,76 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.aggregation; + +// [START datastore_sum_aggregation_query_on_kind] + +import static com.google.cloud.datastore.aggregation.Aggregation.sum; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class SumAggregationOnKind { + + // Instantiates a client. + private static final Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + private static final String kind = "Sales"; + + // Setting up Sales in database + private static void setUpSales() { + Key sales1Key = datastore.newKeyFactory().setKind(kind).newKey("sales1"); + Key sales2Key = datastore.newKeyFactory().setKind(kind).newKey("sales2"); + Key sales3Key = datastore.newKeyFactory().setKind(kind).newKey("sales3"); + + // Save all the sales. + datastore.put( + Entity.newBuilder(sales1Key).set("amount", 89).build(), + Entity.newBuilder(sales2Key).set("amount", 95).build(), + Entity.newBuilder(sales3Key).set("amount", 55).build()); + } + + // Accessing aggregation result by the provided custom alias. + private static void usageWithCustomAlias() { + EntityQuery selectAllSales = Query.newEntityQueryBuilder().setKind(kind).build(); + // Creating an aggregation query to get the sum of all sales. + AggregationQuery sumOfSalesQuery = + Query.newAggregationQueryBuilder() + .over(selectAllSales) + // passing 'total_sales_amount' as alias in the aggregation query. + .addAggregation(sum("amount").as("total_sales_amount")) + .build(); + // Executing aggregation query. + AggregationResult aggregationResult = + Iterables.getOnlyElement(datastore.runAggregation(sumOfSalesQuery)); + + System.out.printf("Total sales is %d", aggregationResult.getLong("total_sales_amount")); // 239 + } + + public static void invoke() { + setUpSales(); + usageWithCustomAlias(); + } +} +// [END datastore_sum_aggregation_query_on_kind] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithLimit.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithLimit.java new file mode 100644 index 000000000000..37c43f2e2c0c --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithLimit.java @@ -0,0 +1,67 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.aggregation; + +// [START datastore_sum_aggregation_query_with_limit] + +import static com.google.cloud.datastore.aggregation.Aggregation.sum; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class SumAggregationWithLimit { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Sales"; + + Key sales1Key = datastore.newKeyFactory().setKind(kind).newKey("sales1"); + Key sales2Key = datastore.newKeyFactory().setKind(kind).newKey("sales2"); + Key sales3Key = datastore.newKeyFactory().setKind(kind).newKey("sales3"); + + // Save all the tasks. + datastore.put( + Entity.newBuilder(sales1Key).set("amount", 89).build(), + Entity.newBuilder(sales2Key).set("amount", 95).build(), + Entity.newBuilder(sales3Key).set("amount", 55).build()); + + EntityQuery selectAllSales = Query.newEntityQueryBuilder().setKind(kind).setLimit(2).build(); + // Creating an aggregation query to get the sum of all sales amount. + AggregationQuery sumOfSalesQuery = + Query.newAggregationQueryBuilder() + .over(selectAllSales) + .addAggregation(sum("amount").as("at_least")) + .build(); + // Executing aggregation query. + AggregationResult limitQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(sumOfSalesQuery)); + + System.out.printf( + "We have a minimum sales sum of %d.", limitQueryResult.getLong("at_least")); // 144 + } +} +// [END datastore_sum_aggregation_query_with_limit] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithOrderBy.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithOrderBy.java new file mode 100644 index 000000000000..e07d3d2f3305 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithOrderBy.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 + * + * 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.datastore.aggregation; + +// [START datastore_sum_aggregation_query_with_order_by] + +import static com.google.cloud.datastore.StructuredQuery.OrderBy.asc; +import static com.google.cloud.datastore.aggregation.Aggregation.sum; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.common.collect.Iterables; + +public class SumAggregationWithOrderBy { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Sales"; + + Key sales1Key = datastore.newKeyFactory().setKind(kind).newKey("sales1"); + Key sales2Key = datastore.newKeyFactory().setKind(kind).newKey("sales2"); + Key sales3Key = datastore.newKeyFactory().setKind(kind).newKey("sales3"); + + // Save all the sales. + datastore.put( + Entity.newBuilder(sales1Key).set("amount", 89).set("customerId", 1).build(), + // customerId not specified (orphan record). + Entity.newBuilder(sales2Key).set("amount", 95).build(), + Entity.newBuilder(sales3Key).set("amount", 55).set("customerId", 2).build()); + + // OrderBy acts as an existence filter. + EntityQuery selectAllSales = + Query.newEntityQueryBuilder().setKind(kind).addOrderBy(asc("customerId")).build(); + + // Creating an aggregation query to sum of all sales. + AggregationQuery sumOfSalesQuery = + Query.newAggregationQueryBuilder() + .over(selectAllSales) + .addAggregation(sum("amount").as("total_sales")) + .build(); + // Executing aggregation query. + AggregationResult limitQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(sumOfSalesQuery)); + + System.out.printf( + "Total sum of %d with valid customerId field", + limitQueryResult.getLong("total_sales")); // 144 + } +} +// [END datastore_sum_aggregation_query_with_order_by] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithPropertyFilter.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithPropertyFilter.java new file mode 100644 index 000000000000..8150618c6065 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/aggregation/SumAggregationWithPropertyFilter.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 + * + * 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.datastore.aggregation; + +// [START datastore_sum_aggregation_query_with_filters] + +import static com.google.cloud.datastore.aggregation.Aggregation.sum; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.common.collect.Iterables; + +public class SumAggregationWithPropertyFilter { + + public static void invoke() { + // Instantiates a client. + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // The kind for the new entity. + String kind = "Sales"; + + Key sales1Key = datastore.newKeyFactory().setKind(kind).newKey("sales1"); + Key sales2Key = datastore.newKeyFactory().setKind(kind).newKey("sales2"); + Key sales3Key = datastore.newKeyFactory().setKind(kind).newKey("sales3"); + + // Save all the tasks. + datastore.put( + Entity.newBuilder(sales1Key).set("amount", 89).set("customerId", 1).build(), + Entity.newBuilder(sales2Key).set("amount", 95).set("customerId", 1).build(), + Entity.newBuilder(sales3Key).set("amount", 55).set("customerId", 2).build()); + + EntityQuery customer1Sales = + Query.newEntityQueryBuilder() + .setKind(kind) + .setFilter(PropertyFilter.eq("customerId", 1)) + .build(); + + // Creating an aggregation query to get the sum of all sales for customerId 1. + AggregationQuery customer1SalesSum = + Query.newAggregationQueryBuilder() + .over(customer1Sales) + .addAggregation(sum("amount").as("total_sales")) + .build(); + + // Executing aggregation query. + AggregationResult customer1SalesSumQueryResult = + Iterables.getOnlyElement(datastore.runAggregation(customer1SalesSum)); + + System.out.printf( + "Customer 1 sales sum is %d", customer1SalesSumQueryResult.getLong("total_sales")); // 184 + } +} +// [END datastore_sum_aggregation_query_with_filters] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.java new file mode 100644 index 000000000000..2ccd8e058805 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/filters/IndexingConsiderationQuery.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 + * + * 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.datastore.filters; + +// sample-metadata: +// title: Queries with indexing considerations +// description: The following query produces a result set +// that is ordered according to the index definition. + +// [START datastore_query_indexing_considerations] + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.StructuredQuery.CompositeFilter; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; + +public class IndexingConsiderationQuery { + public static void invoke() throws Exception { + + // Instantiates a client + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // Build a query with multi inequal filters and optimized index order of index properties. + Query query = + Query.newEntityQueryBuilder() + .setKind("employees") + .setFilter( + CompositeFilter.and( + PropertyFilter.gt("salary", 100000), PropertyFilter.gt("experience", 0))) + .setOrderBy(OrderBy.asc("salary"), OrderBy.asc("experience")) + .build(); + + // Get the results back from Datastore + QueryResults results = datastore.run(query); + + if (!results.hasNext()) { + throw new Exception("query yielded no results"); + } + + while (results.hasNext()) { + Entity entity = results.next(); + System.out.printf("Entity: %s%n", entity); + } + } +} +// [END datastore_query_indexing_considerations] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/filters/OrFilterQuery.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/filters/OrFilterQuery.java new file mode 100644 index 000000000000..b36db4e78a2a --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/filters/OrFilterQuery.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 + * + * 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.datastore.filters; + +// sample-metadata: +// title: Create a union between two filters +// description: Create a union between two filters (logical OR operator) + +// [START datastore_query_filter_or] +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.StructuredQuery.CompositeFilter; +import com.google.cloud.datastore.StructuredQuery.Filter; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; + +public class OrFilterQuery { + public static void invoke() throws Exception { + + // Instantiates a client + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + String propertyName = "description"; + + // Create the two filters + Filter orFilter = + CompositeFilter.or( + PropertyFilter.eq(propertyName, "Feed cats"), + PropertyFilter.eq(propertyName, "Buy milk")); + + // Build the query + Query query = Query.newEntityQueryBuilder().setKind("Task").setFilter(orFilter).build(); + + // Get the results back from Datastore + QueryResults results = datastore.run(query); + + if (!results.hasNext()) { + throw new Exception("query yielded no results"); + } + + while (results.hasNext()) { + Entity entity = results.next(); + System.out.printf("Entity: %s%n", entity); + } + } +} +// [END datastore_query_filter_or] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.java new file mode 100644 index 000000000000..8e847ed9341b --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/filters/OrderFieldsQuery.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 + * + * 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.datastore.filters; + +// sample-metadata: +// title: Queries with order fileds +// description: The following query order properties +// in the decreasing order of query constraint selectivity. + +// [START datastore_query_order_fields] + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; + +public class OrderFieldsQuery { + public static void invoke() throws Exception { + + // Instantiates a client + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // Build a query with order properties in the decreasing order of query constraint selectivity. + Query query = + Query.newEntityQueryBuilder() + .setKind("employees") + .setFilter(PropertyFilter.gt("salary", 100000)) + .setOrderBy(OrderBy.asc("salary")) + .build(); + + // Get the results back from Datastore + QueryResults results = datastore.run(query); + // Order results by `experience` + + if (!results.hasNext()) { + throw new Exception("query yielded no results"); + } + + while (results.hasNext()) { + Entity entity = results.next(); + System.out.printf("Entity: %s%n", entity); + } + } +} +// [END datastore_query_order_fields] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplain.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplain.java new file mode 100644 index 000000000000..a8fda0bcbc4f --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplain.java @@ -0,0 +1,55 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.queryprofile; + +// [START datastore_query_explain_entity] + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.models.ExplainMetrics; +import com.google.cloud.datastore.models.ExplainOptions; +import com.google.cloud.datastore.models.PlanSummary; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public class QueryProfileExplain { + public static void invoke() throws Exception { + // Instantiates a client + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // Build the query + Query query = Query.newEntityQueryBuilder().setKind("Task").build(); + + // Set the explain options to get back *only* the plan summary + QueryResults results = datastore.run(query, ExplainOptions.newBuilder().build()); + + // Get the explain metrics + Optional explainMetrics = results.getExplainMetrics(); + if (!explainMetrics.isPresent()) { + throw new Exception("No explain metrics returned"); + } + PlanSummary planSummary = explainMetrics.get().getPlanSummary(); + List> indexesUsed = planSummary.getIndexesUsed(); + System.out.println("----- Indexes Used -----"); + indexesUsed.forEach(map -> map.forEach((key, val) -> System.out.println(key + ": " + val))); + } +} +// [END datastore_query_explain_entity] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAggregation.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAggregation.java new file mode 100644 index 000000000000..3610853a5a37 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAggregation.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 + * + * 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.datastore.queryprofile; + +// [START datastore_query_explain_aggregation] + +import static com.google.cloud.datastore.aggregation.Aggregation.count; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.datastore.models.ExplainMetrics; +import com.google.cloud.datastore.models.ExplainOptions; +import com.google.cloud.datastore.models.PlanSummary; +import java.util.List; +import java.util.Map; +import java.util.Optional; + +public class QueryProfileExplainAggregation { + public static void invoke() throws Exception { + // Instantiates a client + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // Build the query + StructuredQuery query = Query.newEntityQueryBuilder().setKind("Task").build(); + + // Build the aggregation query + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder().over(query).addAggregation(count()).build(); + + // Set the explain options to get back *only* the plan summary + AggregationResults results = + datastore.runAggregation(aggregationQuery, ExplainOptions.newBuilder().build()); + + // Get the explain metrics + Optional explainMetrics = results.getExplainMetrics(); + if (!explainMetrics.isPresent()) { + throw new Exception("No explain metrics returned"); + } + PlanSummary planSummary = explainMetrics.get().getPlanSummary(); + List> indexesUsed = planSummary.getIndexesUsed(); + System.out.println("----- Indexes Used -----"); + indexesUsed.forEach(map -> map.forEach((key, val) -> System.out.println(key + ": " + val))); + } +} +// [END datastore_query_explain_aggregation] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyze.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyze.java new file mode 100644 index 000000000000..b7ce1a213f6f --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyze.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 + * + * 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.datastore.queryprofile; + +// [START datastore_query_explain_analyze_entity] +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.models.ExecutionStats; +import com.google.cloud.datastore.models.ExplainMetrics; +import com.google.cloud.datastore.models.ExplainOptions; +import com.google.cloud.datastore.models.PlanSummary; +import java.util.List; +import java.util.Map; + +public class QueryProfileExplainAnalyze { + public static void invoke() throws Exception { + // Instantiates a client + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // Build the query + Query query = Query.newEntityQueryBuilder().setKind("Task").build(); + + // Set explain options with analzye = true to get back the query stats, plan info, and query + // results + QueryResults results = + datastore.run(query, ExplainOptions.newBuilder().setAnalyze(true).build()); + + // Get the result set stats + if (!results.getExplainMetrics().isPresent()) { + throw new Exception("No explain metrics returned"); + } + ExplainMetrics explainMetrics = results.getExplainMetrics().get(); + + // Get the execution stats + if (!explainMetrics.getExecutionStats().isPresent()) { + throw new Exception("No execution stats returned"); + } + + ExecutionStats executionStats = explainMetrics.getExecutionStats().get(); + Map debugStats = executionStats.getDebugStats(); + System.out.println("----- Debug Stats -----"); + debugStats.forEach((key, val) -> System.out.println(key + ": " + val)); + System.out.println("----------"); + + long resultsReturned = executionStats.getResultsReturned(); + System.out.println("Results returned: " + resultsReturned); + + // Get the plan summary + PlanSummary planSummary = explainMetrics.getPlanSummary(); + List> indexesUsed = planSummary.getIndexesUsed(); + System.out.println("----- Indexes Used -----"); + indexesUsed.forEach(map -> map.forEach((key, val) -> System.out.println(key + ": " + val))); + + if (!results.hasNext()) { + throw new Exception("query yielded no results"); + } + + // Get the query results + System.out.println("----- Query Results -----"); + while (results.hasNext()) { + Entity entity = results.next(); + System.out.printf("Entity: %s%n", entity); + } + } +} +// [END datastore_query_explain_analyze_entity] diff --git a/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyzeAggregation.java b/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyzeAggregation.java new file mode 100644 index 000000000000..c17660953899 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/example/datastore/queryprofile/QueryProfileExplainAnalyzeAggregation.java @@ -0,0 +1,88 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.queryprofile; + +// [START datastore_query_explain_analyze_aggregation] + +import static com.google.cloud.datastore.aggregation.Aggregation.count; + +import com.google.cloud.datastore.AggregationQuery; +import com.google.cloud.datastore.AggregationResult; +import com.google.cloud.datastore.AggregationResults; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.datastore.models.ExecutionStats; +import com.google.cloud.datastore.models.ExplainMetrics; +import com.google.cloud.datastore.models.ExplainOptions; +import com.google.cloud.datastore.models.PlanSummary; +import com.google.common.collect.Iterables; +import java.util.List; +import java.util.Map; + +public class QueryProfileExplainAnalyzeAggregation { + public static void invoke() throws Exception { + // Instantiates a client + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // Build the query + StructuredQuery query = Query.newEntityQueryBuilder().setKind("Task").build(); + + // Build the aggregation query + AggregationQuery aggregationQuery = + Query.newAggregationQueryBuilder() + .over(query) + .addAggregation(count().as("countVal")) + .build(); + + // Set the explain options with analyze = true to get back the query stats, plan info, and + // aggregation results + AggregationResults results = + datastore.runAggregation( + aggregationQuery, ExplainOptions.newBuilder().setAnalyze(true).build()); + + if (!results.getExplainMetrics().isPresent()) { + throw new Exception("No explain metrics returned"); + } + ExplainMetrics explainMetrics = results.getExplainMetrics().get(); + + if (!explainMetrics.getExecutionStats().isPresent()) { + throw new Exception("No execution stats returned"); + } + ExecutionStats executionStats = explainMetrics.getExecutionStats().get(); + Map debugStats = executionStats.getDebugStats(); + System.out.println("----- Debug Stats -----"); + debugStats.forEach((key, val) -> System.out.println(key + ": " + val)); + System.out.println("----------"); + + long resultsReturned = executionStats.getResultsReturned(); + System.out.println("Results returned: " + resultsReturned); + + // Get the plan summary + PlanSummary planSummary = explainMetrics.getPlanSummary(); + List> indexesUsed = planSummary.getIndexesUsed(); + System.out.println("----- Indexes Used -----"); + indexesUsed.forEach(map -> map.forEach((key, val) -> System.out.println(key + ": " + val))); + + System.out.println("----- Aggregation Results -----"); + AggregationResult result = Iterables.getOnlyElement(results); + System.out.println("Count: " + result.getLong("countVal")); + } +} +// [END datastore_query_explain_analyze_aggregation] diff --git a/java-datastore/samples/snippets/src/main/java/com/google/datastore/snippets/TaskList.java b/java-datastore/samples/snippets/src/main/java/com/google/datastore/snippets/TaskList.java new file mode 100644 index 000000000000..1e054537bf17 --- /dev/null +++ b/java-datastore/samples/snippets/src/main/java/com/google/datastore/snippets/TaskList.java @@ -0,0 +1,246 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.snippets; + +import com.google.cloud.Timestamp; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.StringValue; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.Transaction; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * A simple Task List application demonstrating how to connect to Cloud Datastore, create, modify, + * delete, and query entities. + */ +public class TaskList { + + // [START datastore_build_service] + // Create an authorized Datastore service using Application Default Credentials. + private final Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + // Create a Key factory to construct keys associated with this project. + private final KeyFactory keyFactory = datastore.newKeyFactory().setKind("Task"); + + // [END datastore_build_service] + + // [START datastore_add_entity] + /** + * Adds a task entity to the Datastore. + * + * @param description The task description + * @return The {@link Key} of the entity + * @throws DatastoreException if the ID allocation or put fails + */ + Key addTask(String description) { + Key key = datastore.allocateId(keyFactory.newKey()); + Entity task = + Entity.newBuilder(key) + .set( + "description", + StringValue.newBuilder(description).setExcludeFromIndexes(true).build()) + .set("created", Timestamp.now()) + .set("done", false) + .build(); + datastore.put(task); + return key; + } + + // [END datastore_add_entity] + + // [START datastore_update_entity] + /** + * Marks a task entity as done. + * + * @param id The ID of the task entity as given by {@link Key#id()} + * @return true if the task was found, false if not + * @throws DatastoreException if the transaction fails + */ + boolean markDone(long id) { + Transaction transaction = datastore.newTransaction(); + try { + Entity task = transaction.get(keyFactory.newKey(id)); + if (task != null) { + transaction.put(Entity.newBuilder(task).set("done", true).build()); + } + transaction.commit(); + return task != null; + } finally { + if (transaction.isActive()) { + transaction.rollback(); + } + } + } + + // [END datastore_update_entity] + + // [START datastore_retrieve_entities] + /** + * Returns a list of all task entities in ascending order of creation time. + * + * @throws DatastoreException if the query fails + */ + Iterator listTasks() { + Query query = + Query.newEntityQueryBuilder().setKind("Task").setOrderBy(OrderBy.asc("created")).build(); + return datastore.run(query); + } + + // [END datastore_retrieve_entities] + + // [START datastore_delete_entity] + /** + * Deletes a task entity. + * + * @param id The ID of the task entity as given by {@link Key#id()} + * @throws DatastoreException if the delete fails + */ + void deleteTask(long id) { + datastore.delete(keyFactory.newKey(id)); + } + + // [END datastore_delete_entity] + + /** + * Converts a list of task entities to a list of formatted task strings. + * + * @param tasks An iterator over task entities + * @return A list of tasks strings, one per entity + */ + static List formatTasks(Iterator tasks) { + List strings = new ArrayList<>(); + while (tasks.hasNext()) { + Entity task = tasks.next(); + if (task.getBoolean("done")) { + strings.add( + String.format("%d : %s (done)", task.getKey().getId(), task.getString("description"))); + } else { + strings.add( + String.format( + "%d : %s (created %s)", + task.getKey().getId(), + task.getString("description"), + task.getTimestamp("created"))); + } + } + return strings; + } + + /** + * Handles a single command. + * + * @param commandLine A line of input provided by the user + */ + void handleCommandLine(String commandLine) { + String[] args = commandLine.split("\\s+"); + + if (args.length < 1) { + throw new IllegalArgumentException("not enough args"); + } + + String command = args[0]; + switch (command) { + case "new": + // Everything after the first whitespace token is interpreted to be the description. + args = commandLine.split("\\s+", 2); + if (args.length != 2) { + throw new IllegalArgumentException("missing description"); + } + // Set created to now() and done to false. + addTask(args[1]); + System.out.println("task added"); + break; + case "done": + assertArgsLength(args, 2); + long id = Long.parseLong(args[1]); + if (markDone(id)) { + System.out.println("task marked done"); + } else { + System.out.printf("did not find a Task entity with ID %d%n", id); + } + break; + case "list": + assertArgsLength(args, 1); + List tasks = formatTasks(listTasks()); + System.out.printf("found %d tasks:%n", tasks.size()); + System.out.println("task ID : description"); + System.out.println("---------------------"); + for (String taskString : tasks) { + System.out.println(taskString); + } + break; + case "delete": + assertArgsLength(args, 2); + deleteTask(Long.parseLong(args[1])); + System.out.println("task deleted (if it existed)"); + break; + default: + throw new IllegalArgumentException("unrecognized command: " + command); + } + } + + private void assertArgsLength(String[] args, int expectedLength) { + if (args.length != expectedLength) { + throw new IllegalArgumentException( + String.format("expected exactly %d arg(s), found %d", expectedLength, args.length)); + } + } + + /** + * Exercises the methods defined in this class. + * + *

Assumes that you are authenticated using the Google Cloud SDK (using {@code gcloud auth + * application-default login}). + */ + public static void main(String[] args) throws Exception { + TaskList taskList = new TaskList(); + System.out.println("Cloud Datastore Task List"); + System.out.println(); + printUsage(); + while (true) { + String commandLine = System.console().readLine("> "); + if (commandLine.trim().isEmpty()) { + break; + } + try { + taskList.handleCommandLine(commandLine); + } catch (IllegalArgumentException e) { + System.out.println(e.getMessage()); + printUsage(); + } + } + System.out.println("exiting"); + System.exit(0); + } + + private static void printUsage() { + System.out.println("Usage:"); + System.out.println(); + System.out.println(" new Adds a task with a description "); + System.out.println(" done Marks a task as done"); + System.out.println(" list Lists all tasks by creation time"); + System.out.println(" delete Deletes a task"); + System.out.println(); + } +} diff --git a/java-datastore/samples/snippets/src/test/java/com/example/datastore/ConfigureConnectionPoolIT.java b/java-datastore/samples/snippets/src/test/java/com/example/datastore/ConfigureConnectionPoolIT.java new file mode 100644 index 000000000000..84fe60e77eca --- /dev/null +++ b/java-datastore/samples/snippets/src/test/java/com/example/datastore/ConfigureConnectionPoolIT.java @@ -0,0 +1,39 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore; + +import com.rule.SystemsOutRule; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for ConfigureConnectionPool sample. */ +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class ConfigureConnectionPoolIT { + + @Rule public final SystemsOutRule systemsOutRule = new SystemsOutRule(); + + @Test + public void testConfigureConnectionPool() throws Exception { + ConfigureConnectionPool.main(); + systemsOutRule.assertContains( + "Connected with pool with InitialChannelCount: 10, MinChannelCount: 5, MaxChannelCount:" + + " 200"); + } +} diff --git a/java-datastore/samples/snippets/src/test/java/com/example/datastore/QuickstartSampleIT.java b/java-datastore/samples/snippets/src/test/java/com/example/datastore/QuickstartSampleIT.java new file mode 100644 index 000000000000..ba36a8e7209d --- /dev/null +++ b/java-datastore/samples/snippets/src/test/java/com/example/datastore/QuickstartSampleIT.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 + * + * 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.datastore; + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Key; +import com.rule.SystemsOutRule; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Tests for quickstart sample. */ +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class QuickstartSampleIT { + + @Rule public final SystemsOutRule systemsOutRule = new SystemsOutRule(); + + private static final void deleteTestEntity() { + Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + String kind = "Task"; + String name = "sampletask1"; + Key taskKey = datastore.newKeyFactory().setKind(kind).newKey(name); + datastore.delete(taskKey); + } + + @Before + public void setUp() { + deleteTestEntity(); + } + + @After + public void tearDown() { + System.setOut(null); + deleteTestEntity(); + } + + @Test + public void testQuickstart() throws Exception { + QuickstartSample.main(); + systemsOutRule.assertContains("Saved sampletask1: Buy milk"); + systemsOutRule.assertContains("Retrieved sampletask1: Buy milk"); + } +} diff --git a/java-datastore/samples/snippets/src/test/java/com/example/datastore/aggregation/AggregationQuerySampleTestIT.java b/java-datastore/samples/snippets/src/test/java/com/example/datastore/aggregation/AggregationQuerySampleTestIT.java new file mode 100644 index 000000000000..e31688501f3a --- /dev/null +++ b/java-datastore/samples/snippets/src/test/java/com/example/datastore/aggregation/AggregationQuerySampleTestIT.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 + * + * 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.datastore.aggregation; + +import static org.junit.Assert.assertThrows; + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyQuery; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.common.collect.ImmutableList; +import com.rule.SystemsOutRule; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +public class AggregationQuerySampleTestIT { + + private final Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + @Rule public final SystemsOutRule systemsOutRule = new SystemsOutRule(); + + @Before + public void setUp() throws Exception { + // Retrieving and deleting all the 'Task' entities. + KeyQuery allKeysQuery = Query.newKeyQueryBuilder().setKind("Task").build(); + QueryResults allKeys = datastore.run(allKeysQuery); + Key[] keysToDelete = ImmutableList.copyOf(allKeys).toArray(new Key[0]); + datastore.delete(keysToDelete); + } + + @Test + public void testAggregationQueryAndCountAggregationSample() { + CountAggregationOnKind.invoke(); + systemsOutRule.assertContains("Total tasks count is 3"); + systemsOutRule.assertContains("Total tasks (accessible from default alias) is 3"); + } + + @Test + public void testAggregationQueryAndCountAggregationWithLimitSample() { + CountAggregationWithLimit.invoke(); + systemsOutRule.assertContains("We have at least 2 tasks"); + } + + @Test + public void testAggregationQueryAndCountAggregationWithOrderBySample() { + CountAggregationWithOrderBy.invoke(); + systemsOutRule.assertContains("Total 2 tasks found with priority field"); + } + + @Test + public void testAggregationQueryAndCountAggregationWithPropertyFilterSample() { + CountAggregationWithPropertyFilter.invoke(); + systemsOutRule.assertContains("Total completed tasks count is 2"); + systemsOutRule.assertContains("Total remaining tasks count is 1"); + } + + @Test + public void testAggregationQueryAndCountAggregationSampleWithGqlQuery() { + CountAggregationWithGqlQuery.invoke(); + systemsOutRule.assertContains("We have at least 2 tasks"); + systemsOutRule.assertContains("Total tasks count is 3"); + systemsOutRule.assertContains("Total completed tasks count is 2"); + } + + @Test + public void testAggregationQueryAndCountWithStaleRead() throws InterruptedException { + CountAggregationWithStaleRead.invoke(); + systemsOutRule.assertContains("Latest tasks count is 3"); + systemsOutRule.assertContains("Stale tasks count is 2"); + } + + @Test + public void testAggregationQueryAndCountWithTransaction() throws InterruptedException { + assertThrows(Exception.class, CountAggregationInTransaction::invoke); + systemsOutRule.assertContains("Found existing 2 tasks, rolling back"); + } + + @Test + public void testSumAggregationWithKind() { + SumAggregationOnKind.invoke(); + systemsOutRule.assertContains("Total sales is 239"); + } + + @Test + public void testAvgAggregationWithKind() { + AvgAggregationOnKind.invoke(); + systemsOutRule.assertContains("Average sales is 79.66666667"); + } + + @Test + public void testSumAggregationWithPropertyFilter() { + SumAggregationWithPropertyFilter.invoke(); + systemsOutRule.assertContains("Customer 1 sales sum is 184"); + } + + @Test + public void testAvgAggregationWithPropertyFilter() { + AvgAggregationWithPropertyFilter.invoke(); + systemsOutRule.assertContains("Customer 1 sales avg is 92"); + } + + @Test + public void testSumAggregationWithLimit() { + SumAggregationWithLimit.invoke(); + systemsOutRule.assertContains("We have a minimum sales sum of 144."); + } + + @Test + public void testAvgAggregationWithLimit() { + AvgAggregationWithLimit.invoke(); + systemsOutRule.assertContains("Average with limit 2 is 72."); + } + + @Test + public void testSumAggregationWithOrderBy() { + SumAggregationWithOrderBy.invoke(); + systemsOutRule.assertContains("Total sum of 144 with valid customerId field"); + } + + @Test + public void testAvgAggregationWithOrderBy() { + AvgAggregationWithOrderBy.invoke(); + systemsOutRule.assertContains("Total avg of 72 with valid customerId field"); + } + + @Test + public void testMultipleAggregationsInStructuredQuery() { + MultipleAggregationsInStructuredQuery.invoke(); + systemsOutRule.assertContains("Total sales count: 3"); + systemsOutRule.assertContains("Sum of sales: 239"); + systemsOutRule.assertContains("Avg of sales: 79.66666667"); + } + + @Test + public void testMultipleAggregationsInGQLQuery() { + MultipleAggregationsInGqlQuery.invoke(); + systemsOutRule.assertContains("Total sales count: 3"); + systemsOutRule.assertContains("Sum of sales: 239"); + systemsOutRule.assertContains("Avg of sales: 79.66666667"); + } +} diff --git a/java-datastore/samples/snippets/src/test/java/com/example/datastore/filters/MultiIneqQuerySampleIT.java b/java-datastore/samples/snippets/src/test/java/com/example/datastore/filters/MultiIneqQuerySampleIT.java new file mode 100644 index 000000000000..2c700a115658 --- /dev/null +++ b/java-datastore/samples/snippets/src/test/java/com/example/datastore/filters/MultiIneqQuerySampleIT.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 + * + * 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.datastore.filters; + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Key; +import com.rule.SystemsOutRule; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class MultiIneqQuerySampleIT { + + private final Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + + private Key employeeKey1; + private Key employeeKey2; + private Key employeeKey3; + + @Rule public final SystemsOutRule systemsOutRule = new SystemsOutRule(); + + @Before + public void setUp() { + employeeKey1 = datastore.newKeyFactory().setKind("employees").newKey("employee1"); + Entity employee1 = + Entity.newBuilder(employeeKey1) + .set("name", "Alice") + .set("salary", 100001) + .set("experience", 10) + .build(); + + employeeKey2 = datastore.newKeyFactory().setKind("employees").newKey("employee2"); + Entity employee2 = + Entity.newBuilder(employeeKey2) + .set("name", "Bob") + .set("salary", 90000) + .set("experience", 5) + .build(); + + employeeKey3 = datastore.newKeyFactory().setKind("employees").newKey("employee3"); + Entity employee3 = + Entity.newBuilder(employeeKey3) + .set("name", "Jay") + .set("salary", 120000) + .set("experience", 15) + .build(); + + datastore.put(employee1); + datastore.put(employee2); + datastore.put(employee3); + } + + @After + public void tearDown() { + datastore.delete(employeeKey1); + datastore.delete(employeeKey2); + datastore.delete(employeeKey3); + } + + @Test + public void testIndexingConsiderationQuery() throws Exception { + // Act + IndexingConsiderationQuery.invoke(); + + // Assert + systemsOutRule.assertContains("Entity"); + } + + @Test + public void testOrderFieldsQuery() throws Exception { + // Act + OrderFieldsQuery.invoke(); + + // Assert + systemsOutRule.assertContains("Entity"); + } +} diff --git a/java-datastore/samples/snippets/src/test/java/com/example/datastore/filters/OrFilterQuerySampleIT.java b/java-datastore/samples/snippets/src/test/java/com/example/datastore/filters/OrFilterQuerySampleIT.java new file mode 100644 index 000000000000..55731878aa05 --- /dev/null +++ b/java-datastore/samples/snippets/src/test/java/com/example/datastore/filters/OrFilterQuerySampleIT.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 + * + * 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.datastore.filters; + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Key; +import com.rule.SystemsOutRule; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class OrFilterQuerySampleIT { + + private final Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + private final String fieldName = "description"; + + private Key taskKey1; + private Key taskKey2; + + @Rule public final SystemsOutRule systemsOutRule = new SystemsOutRule(); + + @Before + public void setUp() { + taskKey1 = datastore.newKeyFactory().setKind("Task").newKey("sampleTask"); + Entity task1 = Entity.newBuilder(taskKey1).set(fieldName, "Buy milk").build(); + + taskKey2 = datastore.newKeyFactory().setKind("Task").newKey("sampleTask2"); + Entity task2 = Entity.newBuilder(taskKey2).set(fieldName, "Feed cats").build(); + + datastore.put(task1); + datastore.put(task2); + } + + @After + public void tearDown() { + datastore.delete(taskKey1); + datastore.delete(taskKey2); + } + + @Test + public void testOrFilterQuery() throws Exception { + // Act + OrFilterQuery.invoke(); + + // Assert + systemsOutRule.assertContains("Entity"); + } +} diff --git a/java-datastore/samples/snippets/src/test/java/com/example/datastore/queryprofile/QueryProfileSampleIT.java b/java-datastore/samples/snippets/src/test/java/com/example/datastore/queryprofile/QueryProfileSampleIT.java new file mode 100644 index 000000000000..f0377a507623 --- /dev/null +++ b/java-datastore/samples/snippets/src/test/java/com/example/datastore/queryprofile/QueryProfileSampleIT.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 + * + * 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.datastore.queryprofile; + +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.Key; +import com.rule.SystemsOutRule; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +@RunWith(JUnit4.class) +@SuppressWarnings("checkstyle:abbreviationaswordinname") +public class QueryProfileSampleIT { + + private final Datastore datastore = DatastoreOptions.getDefaultInstance().getService(); + private final String fieldName = "description"; + + private Key taskKey1; + private Key taskKey2; + + @Rule public final SystemsOutRule systemsOutRule = new SystemsOutRule(); + + @Before + public void setUp() { + taskKey1 = datastore.newKeyFactory().setKind("Task").newKey("sampleTask"); + Entity task1 = Entity.newBuilder(taskKey1).set(fieldName, "Buy milk").build(); + + taskKey2 = datastore.newKeyFactory().setKind("Task").newKey("sampleTask2"); + Entity task2 = Entity.newBuilder(taskKey2).set(fieldName, "Feed cats").build(); + + datastore.put(task1); + datastore.put(task2); + } + + @After + public void tearDown() { + datastore.delete(taskKey1); + datastore.delete(taskKey2); + } + + @Test + public void testQueryProfileExplain() throws Exception { + // Act + QueryProfileExplain.invoke(); + + // Assert + systemsOutRule.assertContains("query_scope: Collection group"); + systemsOutRule.assertContains("properties: (__name__ ASC)"); + } + + @Test + public void testQueryProfileExplainAggregation() throws Exception { + // Act + QueryProfileExplainAggregation.invoke(); + + // Assert + systemsOutRule.assertContains("query_scope: Collection group"); + systemsOutRule.assertContains("properties: (__name__ ASC)"); + } + + @Test + public void testQueryProfileExplainAnalyze() throws Exception { + // Act + QueryProfileExplainAnalyze.invoke(); + + // Assert + systemsOutRule.assertContains("documents_scanned:"); + systemsOutRule.assertContains("index_entries_scanned:"); + systemsOutRule.assertContains("query_scope: Collection group"); + systemsOutRule.assertContains("Entity: Entity{key="); + } + + @Test + public void testQueryProfileExplainAnalyzeAggregation() throws Exception { + // Act + QueryProfileExplainAnalyzeAggregation.invoke(); + + // Assert + systemsOutRule.assertContains("index_entries_scanned:"); + systemsOutRule.assertContains("documents_scanned:"); + systemsOutRule.assertContains("query_scope: Collection group"); + systemsOutRule.assertContains("Count: 2"); + } +} diff --git a/java-datastore/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java b/java-datastore/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java new file mode 100644 index 000000000000..1efd6cfaeb55 --- /dev/null +++ b/java-datastore/samples/snippets/src/test/java/com/google/datastore/snippets/ConceptsTest.java @@ -0,0 +1,1196 @@ +/* + * Copyright 2026 Google LLC + * + * Licensed under the Apache License, Version 2.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.datastore.snippets; + +import static java.util.Calendar.DECEMBER; +import static java.util.Calendar.JANUARY; +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 com.google.cloud.Timestamp; +import com.google.cloud.datastore.Cursor; +import com.google.cloud.datastore.Datastore; +import com.google.cloud.datastore.DatastoreException; +import com.google.cloud.datastore.DatastoreOptions; +import com.google.cloud.datastore.Entity; +import com.google.cloud.datastore.EntityQuery; +import com.google.cloud.datastore.FullEntity; +import com.google.cloud.datastore.IncompleteKey; +import com.google.cloud.datastore.Key; +import com.google.cloud.datastore.KeyFactory; +import com.google.cloud.datastore.KeyQuery; +import com.google.cloud.datastore.ListValue; +import com.google.cloud.datastore.PathElement; +import com.google.cloud.datastore.ProjectionEntity; +import com.google.cloud.datastore.Query; +import com.google.cloud.datastore.QueryResults; +import com.google.cloud.datastore.ReadOption; +import com.google.cloud.datastore.StringValue; +import com.google.cloud.datastore.StructuredQuery; +import com.google.cloud.datastore.StructuredQuery.CompositeFilter; +import com.google.cloud.datastore.StructuredQuery.OrderBy; +import com.google.cloud.datastore.StructuredQuery.PropertyFilter; +import com.google.cloud.datastore.Transaction; +import com.google.cloud.datastore.testing.LocalDatastoreHelper; +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterators; +import com.google.datastore.v1.TransactionOptions; +import com.google.datastore.v1.TransactionOptions.ReadOnly; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; +import java.util.TimeZone; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.ExpectedException; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; + +/** Contains Cloud Datastore snippets demonstrating concepts for documentation. */ +@RunWith(JUnit4.class) +public class ConceptsTest { + + private static final LocalDatastoreHelper HELPER = LocalDatastoreHelper.create(1.0); + private static final FullEntity TEST_FULL_ENTITY = FullEntity.newBuilder().build(); + + private Datastore datastore; + private Datastore datastoreRealBackend; + private KeyFactory keyFactory; + private Key taskKey; + private Entity testEntity; + private Timestamp startDate; + private Timestamp endDate; + private Timestamp includedDate; + + @Rule public ExpectedException thrown = ExpectedException.none(); + + /** + * Starts the local Datastore emulator. + * + * @throws IOException if there are errors starting the local Datastore + * @throws InterruptedException if there are errors starting the local Datastore + */ + @BeforeClass + public static void beforeClass() throws IOException, InterruptedException { + HELPER.start(); + } + + /** + * Initializes Datastore and cleans out any residual values. Also initializes global variables + * used for testing. + */ + @Before + public void setUp() { + datastore = HELPER.getOptions().toBuilder().setNamespace("ghijklmnop").build().getService(); + StructuredQuery query = Query.newKeyQueryBuilder().build(); + QueryResults result = datastore.run(query); + datastore.delete(Iterators.toArray(result, Key.class)); + keyFactory = datastore.newKeyFactory().setKind("Task"); + taskKey = keyFactory.newKey("some-arbitrary-key"); + testEntity = Entity.newBuilder(taskKey, TEST_FULL_ENTITY).build(); + Calendar calendar = Calendar.getInstance(TimeZone.getTimeZone("UTC")); + calendar.set(1990, JANUARY, 1); + startDate = Timestamp.of(calendar.getTime()); + calendar.set(2000, JANUARY, 1); + endDate = Timestamp.of(calendar.getTime()); + calendar.set(1999, DECEMBER, 31); + includedDate = Timestamp.of(calendar.getTime()); + // Create a client for tests that require a real backend + datastoreRealBackend = DatastoreOptions.getDefaultInstance().getService(); + } + + @After + public void tearDown() throws Exception { + KeyQuery taskQuery = Query.newKeyQueryBuilder().setKind("Task").build(); + Key[] taskKeysToDelete = Iterators.toArray(datastoreRealBackend.run(taskQuery), Key.class); + datastoreRealBackend.delete(taskKeysToDelete); + } + + /** + * Stops the local Datastore emulator. + * + * @throws IOException if there are errors stopping the local Datastore + * @throws InterruptedException if there are errors stopping the local Datastore + */ + @AfterClass + public static void afterClass() throws IOException, InterruptedException, TimeoutException { + HELPER.stopDuration(java.time.Duration.ofMinutes(1)); + } + + private void assertValidKey(Key taskKey) { + datastore.put(Entity.newBuilder(taskKey, TEST_FULL_ENTITY).build()); + } + + @Test + public void testIncompleteKey() { + // [START datastore_incomplete_key] + KeyFactory keyFactory = datastore.newKeyFactory().setKind("Task"); + Key taskKey = datastore.allocateId(keyFactory.newKey()); + // [END datastore_incomplete_key] + assertValidKey(taskKey); + } + + @Test + public void testNamedKey() { + // [START datastore_named_key] + Key taskKey = datastore.newKeyFactory().setKind("Task").newKey("sampleTask"); + // [END datastore_named_key] + assertValidKey(taskKey); + } + + @Test + public void testKeyWithParent() { + // [START datastore_key_with_parent] + Key taskKey = + datastore + .newKeyFactory() + .addAncestors(PathElement.of("TaskList", "default")) + .setKind("Task") + .newKey("sampleTask"); + // [END datastore_key_with_parent] + assertValidKey(taskKey); + } + + @Test + public void testKeyWithMultilevelParent() { + // [START datastore_key_with_multilevel_parent] + KeyFactory keyFactory = + datastore + .newKeyFactory() + .addAncestors(PathElement.of("User", "Alice"), PathElement.of("TaskList", "default")) + .setKind("Task"); + Key taskKey = keyFactory.newKey("sampleTask"); + // [END datastore_key_with_multilevel_parent] + assertValidKey(taskKey); + } + + private void assertValidEntity(Entity original) { + datastore.put(original); + assertEquals(original, datastore.get(original.getKey())); + } + + @Test + public void testEntityWithParent() { + // [START datastore_entity_with_parent] + Key taskKey = + datastore + .newKeyFactory() + .addAncestors(PathElement.of("TaskList", "default")) + .setKind("Task") + .newKey("sampleTask"); + Entity task = + Entity.newBuilder(taskKey) + .set("category", "Personal") + .set("done", false) + .set("priority", 4) + .set("description", "Learn Cloud Datastore") + .build(); + // [END datastore_entity_with_parent] + assertValidEntity(task); + } + + @Test + public void testProperties() { + // [START datastore_properties] + Entity task = + Entity.newBuilder(taskKey) + .set("category", "Personal") + .set("created", Timestamp.now()) + .set("done", false) + .set("priority", 4) + .set("percent_complete", 10.0) + .set( + "description", + StringValue.newBuilder("Learn Cloud Datastore").setExcludeFromIndexes(true).build()) + .build(); + // [END datastore_properties] + assertValidEntity(task); + } + + @Test + public void testArrayValue() { + // [START datastore_array_value] + Entity task = + Entity.newBuilder(taskKey) + .set("tags", "fun", "programming") + .set("collaborators", ListValue.of("alice", "bob")) + .build(); + // [END datastore_array_value] + assertValidEntity(task); + } + + @Test + public void testBasicEntity() { + // [START datastore_basic_entity] + Key taskKey = datastore.newKeyFactory().setKind("Task").newKey("sampleTask"); + Entity task = + Entity.newBuilder(taskKey) + .set("category", "Personal") + .set("done", false) + .set("priority", 4) + .set("description", "Learn Cloud Datastore") + .build(); + // [END datastore_basic_entity] + assertValidEntity(task); + } + + @Test + public void testUpsert() { + // [START datastore_upsert] + Entity task = Entity.newBuilder(keyFactory.newKey("sampleTask")).build(); + datastore.put(task); + // [END datastore_upsert] + assertEquals(task, datastore.get(task.getKey())); + } + + @Test + public void testInsert() { + // [START datastore_insert] + Key taskKey = datastore.add(FullEntity.newBuilder(keyFactory.newKey()).build()).getKey(); + // [END datastore_insert] + assertEquals(FullEntity.newBuilder(taskKey).build(), datastore.get(taskKey)); + } + + @Test + public void testLookup() { + datastore.put(testEntity); + // [START datastore_lookup] + Entity task = datastore.get(taskKey); + // [END datastore_lookup] + assertEquals(testEntity, task); + } + + @Test + public void testUpdate() { + datastore.put(testEntity); + // [START datastore_update] + Entity task; + Transaction txn = datastore.newTransaction(); + try { + task = Entity.newBuilder(txn.get(taskKey)).set("priority", 5).build(); + txn.put(task); + txn.commit(); + } finally { + if (txn.isActive()) { + txn.rollback(); + } + } + // [END datastore_update] + assertEquals(task, datastore.get(taskKey)); + } + + @Test + public void testDelete() { + datastore.put(testEntity); + // [START datastore_delete] + datastore.delete(taskKey); + // [END datastore_delete] + assertNull(datastore.get(taskKey)); + } + + private List setUpBatchTests(Key taskKey1, Key taskKey2) { + Entity task1 = + Entity.newBuilder(taskKey1) + .set("category", "Personal") + .set("done", false) + .set("priority", 4) + .set("description", "Learn Cloud Datastore") + .build(); + Entity task2 = + Entity.newBuilder(taskKey2) + .set("category", "Personal") + .set("done", false) + .set("priority", 5) + .set("description", "Integrate Cloud Datastore") + .build(); + datastore.put(task1, task2); + return ImmutableList.of(task1, task2); + } + + @Test + public void testBatchUpsert() { + // [START datastore_batch_upsert] + FullEntity task1 = + FullEntity.newBuilder(keyFactory.newKey()) + .set("category", "Personal") + .set("done", false) + .set("priority", 4) + .set("description", "Learn Cloud Datastore") + .build(); + FullEntity task2 = + Entity.newBuilder(keyFactory.newKey()) + .set("category", "Personal") + .set("done", false) + .set("priority", 5) + .set("description", "Integrate Cloud Datastore") + .build(); + List tasks = datastore.add(task1, task2); + Key taskKey1 = tasks.get(0).getKey(); + Key taskKey2 = tasks.get(1).getKey(); + // [END datastore_batch_upsert] + assertEquals(Entity.newBuilder(taskKey1, task1).build(), datastore.get(taskKey1)); + assertEquals(Entity.newBuilder(taskKey2, task2).build(), datastore.get(taskKey2)); + } + + @Test + public void testBatchLookup() { + Key taskKey1 = keyFactory.newKey(1); + Key taskKey2 = keyFactory.newKey(2); + List expectedTasks = setUpBatchTests(taskKey1, taskKey2); + // [START datastore_batch_lookup] + Iterator tasks = datastore.get(taskKey1, taskKey2); + // [END datastore_batch_lookup] + assertEquals(expectedTasks.get(0), tasks.next()); + assertEquals(expectedTasks.get(1), tasks.next()); + } + + @Test + public void testBatchDelete() { + Key taskKey1 = keyFactory.newKey(1); + Key taskKey2 = keyFactory.newKey(2); + setUpBatchTests(taskKey1, taskKey2); + // [START datastore_batch_delete] + datastore.delete(taskKey1, taskKey2); + // [END datastore_batch_delete] + assertNull(datastore.get(taskKey1)); + assertNull(datastore.get(taskKey2)); + } + + private void setUpQueryTests() { + Key taskKey = + datastore + .newKeyFactory() + .setKind("Task") + .addAncestors(PathElement.of("TaskList", "default")) + .newKey("someTask"); + datastore.put( + Entity.newBuilder(taskKey) + .set("category", "Personal") + .set("done", false) + .set("completed", false) + .set("priority", 4) + .set("created", includedDate) + .set("percent_complete", 10.0) + .set( + "description", + StringValue.newBuilder("Learn Cloud Datastore").setExcludeFromIndexes(true).build()) + .set("tag", "fun", "l", "programming", "learn") + .build()); + } + + private V assertValidQuery(Query query) { + QueryResults results = datastore.run(query); + V result = results.next(); + assertFalse(results.hasNext()); + return result; + } + + private void assertInvalidQuery(Query query) { + thrown.expect(DatastoreException.class); + datastore.run(query); + } + + @Test + public void testBasicQuery() { + setUpQueryTests(); + // [START datastore_basic_query] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter( + CompositeFilter.and( + PropertyFilter.eq("done", false), PropertyFilter.ge("priority", 4))) + .setOrderBy(OrderBy.desc("priority")) + .build(); + // [END datastore_basic_query] + assertValidQuery(query); + } + + @Test + public void testRunQuery() { + setUpQueryTests(); + Query query = Query.newEntityQueryBuilder().setKind("Task").build(); + // [START datastore_run_query] + QueryResults tasks = datastore.run(query); + // [END datastore_run_query] + assertNotNull(tasks.next()); + assertFalse(tasks.hasNext()); + } + + @Test + public void testPropertyFilter() { + setUpQueryTests(); + // [START datastore_property_filter] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.eq("done", false)) + .build(); + // [END datastore_property_filter] + assertValidQuery(query); + } + + @Test + public void testCompositeFilter() { + setUpQueryTests(); + // [START datastore_composite_filter] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter( + CompositeFilter.and( + PropertyFilter.eq("done", false), PropertyFilter.eq("priority", 4))) + .build(); + // [END datastore_composite_filter] + assertValidQuery(query); + } + + @Test + public void testKeyFilter() { + setUpQueryTests(); + // [START datastore_key_filter] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.gt("__key__", keyFactory.newKey("someTask"))) + .build(); + // [END datastore_key_filter] + assertValidQuery(query); + } + + @Test + public void testAscendingSort() { + setUpQueryTests(); + // [START datastore_ascending_sort] + Query query = + Query.newEntityQueryBuilder().setKind("Task").setOrderBy(OrderBy.asc("created")).build(); + // [END datastore_ascending_sort] + assertValidQuery(query); + } + + @Test + public void testDescendingSort() { + setUpQueryTests(); + // [START datastore_descending_sort] + Query query = + Query.newEntityQueryBuilder().setKind("Task").setOrderBy(OrderBy.desc("created")).build(); + // [END datastore_descending_sort] + assertValidQuery(query); + } + + @Test + public void testMultiSort() { + setUpQueryTests(); + // [START datastore_multi_sort] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setOrderBy(OrderBy.desc("priority"), OrderBy.asc("created")) + .build(); + // [END datastore_multi_sort] + assertValidQuery(query); + } + + @Test + public void testKindlessQuery() { + Key lastSeenKey = keyFactory.newKey("a"); + setUpQueryTests(); + // [START datastore_kindless_query] + Query query = + Query.newEntityQueryBuilder().setFilter(PropertyFilter.gt("__key__", lastSeenKey)).build(); + // [END datastore_kindless_query] + assertValidQuery(query); + } + + @Test + public void testAncestorQuery() { + setUpQueryTests(); + // [START datastore_ancestor_query] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter( + PropertyFilter.hasAncestor( + datastore.newKeyFactory().setKind("TaskList").newKey("default"))) + .build(); + // [END datastore_ancestor_query] + assertValidQuery(query); + } + + @Test + public void testProjectionQuery() { + setUpQueryTests(); + // [START datastore_projection_query] + Query query = + Query.newProjectionEntityQueryBuilder() + .setKind("Task") + .setProjection("priority", "percent_complete") + .build(); + // [END datastore_projection_query] + assertValidQuery(query); + } + + @Test + public void testRunProjectionQuery() { + setUpQueryTests(); + Query query = + Query.newProjectionEntityQueryBuilder() + .setKind("Task") + .setProjection("priority", "percent_complete") + .build(); + // [START datastore_run_query_projection] + List priorities = new LinkedList<>(); + List percentCompletes = new LinkedList<>(); + QueryResults tasks = datastore.run(query); + while (tasks.hasNext()) { + ProjectionEntity task = tasks.next(); + priorities.add(task.getLong("priority")); + percentCompletes.add(task.getDouble("percent_complete")); + } + // [END datastore_run_query_projection] + assertEquals(ImmutableList.of(4L), priorities); + assertEquals(ImmutableList.of(10.0), percentCompletes); + } + + @Test + public void testKeysOnlyQuery() { + setUpQueryTests(); + // [START datastore_keys_only_query] + Query query = Query.newKeyQueryBuilder().setKind("Task").build(); + // [END datastore_keys_only_query] + assertValidQuery(query); + } + + @Test + public void testDistinctOnQuery() { + setUpQueryTests(); + // [START datastore_distinct_on_query] + Query query = + Query.newProjectionEntityQueryBuilder() + .setKind("Task") + .setProjection("category", "priority") + .setDistinctOn("category") + .setOrderBy(OrderBy.asc("category"), OrderBy.asc("priority")) + .build(); + // [END datastore_distinct_on_query] + assertValidQuery(query); + } + + @Test + public void testArrayValueInequalityRange() { + setUpQueryTests(); + // [START datastore_array_value_inequality_range] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter( + CompositeFilter.and( + PropertyFilter.gt("tag", "learn"), PropertyFilter.lt("tag", "math"))) + .build(); + // [END datastore_array_value_inequality_range] + QueryResults results = datastore.run(query); + assertFalse(results.hasNext()); + } + + @Test + public void testArrayValueEquality() { + setUpQueryTests(); + // [START datastore_array_value_equality] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter( + CompositeFilter.and( + PropertyFilter.eq("tag", "fun"), PropertyFilter.eq("tag", "programming"))) + .build(); + // [END datastore_array_value_equality] + assertValidQuery(query); + } + + @Test + public void testInequalityRange() { + setUpQueryTests(); + // [START datastore_inequality_range] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter( + CompositeFilter.and( + PropertyFilter.gt("created", startDate), PropertyFilter.lt("created", endDate))) + .build(); + // [END datastore_inequality_range] + assertValidQuery(query); + } + + @Test + public void testInequalityInvalid() { + // [START datastore_inequality_invalid] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter( + CompositeFilter.and( + PropertyFilter.gt("created", startDate), PropertyFilter.gt("priority", 3))) + .build(); + // [END datastore_inequality_invalid] + assertInvalidQuery(query); + } + + @Test + public void testEqualAndInequalityRange() { + setUpQueryTests(); + // [START datastore_equal_and_inequality_range] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter( + CompositeFilter.and( + PropertyFilter.eq("priority", 4), + PropertyFilter.gt("created", startDate), + PropertyFilter.lt("created", endDate))) + .build(); + // [END datastore_equal_and_inequality_range] + assertValidQuery(query); + } + + @Test + public void testInequalitySort() { + setUpQueryTests(); + // [START datastore_inequality_sort] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.gt("priority", 3)) + .setOrderBy(OrderBy.asc("priority"), OrderBy.asc("created")) + .build(); + // [END datastore_inequality_sort] + assertValidQuery(query); + } + + @Test + public void testInequalitySortInvalidNotSame() { + // [START datastore_inequality_sort_invalid_not_same] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.gt("priority", 3)) + .setOrderBy(OrderBy.asc("created")) + .build(); + // [END datastore_inequality_sort_invalid_not_same] + assertInvalidQuery(query); + } + + @Test + public void testInequalitySortInvalidNotFirst() { + // [START datastore_inequality_sort_invalid_not_first] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.gt("priority", 3)) + .setOrderBy(OrderBy.asc("created"), OrderBy.asc("priority")) + .build(); + // [END datastore_inequality_sort_invalid_not_first] + assertInvalidQuery(query); + } + + @Test + public void testLimit() { + setUpQueryTests(); + // [START datastore_limit] + Query query = Query.newEntityQueryBuilder().setKind("Task").setLimit(5).build(); + // [END datastore_limit] + assertValidQuery(query); + } + + @Test + public void testCursorPaging() { + setUpQueryTests(); + datastore.put(testEntity); + Cursor nextPageCursor = cursorPaging(1, null); + assertNotNull(nextPageCursor); + nextPageCursor = cursorPaging(1, nextPageCursor); + assertNotNull(nextPageCursor); + } + + private Cursor cursorPaging(int pageSize, Cursor pageCursor) { + // [START datastore_cursor_paging] + EntityQuery.Builder queryBuilder = + Query.newEntityQueryBuilder().setKind("Task").setLimit(pageSize); + if (pageCursor != null) { + queryBuilder.setStartCursor(pageCursor); + } + QueryResults tasks = datastore.run(queryBuilder.build()); + while (tasks.hasNext()) { + Entity task = tasks.next(); + // do something with the task + } + Cursor nextPageCursor = tasks.getCursorAfter(); + // [END datastore_cursor_paging] + return nextPageCursor; + } + + @Test + public void testEventualConsistentQuery() { + setUpQueryTests(); + // [START datastore_eventual_consistent_query] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter( + PropertyFilter.hasAncestor( + datastore.newKeyFactory().setKind("TaskList").newKey("default"))) + .build(); + datastore.run(query, ReadOption.eventualConsistency()); + // [END datastore_eventual_consistent_query] + assertValidQuery(query); + } + + @Test + public void testUnindexedPropertyQuery() { + setUpQueryTests(); + // [START datastore_unindexed_property_query] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.eq("description", "A task description")) + .build(); + // [END datastore_unindexed_property_query] + QueryResults results = datastore.run(query); + assertFalse(results.hasNext()); + } + + @Test + public void testExplodingProperties() { + // [START datastore_exploding_properties] + Entity task = + Entity.newBuilder(taskKey) + .set("tags", "fun", "programming", "learn") + .set("collaborators", "alice", "bob", "charlie") + .set("created", Timestamp.now()) + .build(); + // [END datastore_exploding_properties] + assertValidEntity(task); + } + + private List setUpTransferTests() { + KeyFactory keyFactory = datastore.newKeyFactory().setKind("People"); + Key from = keyFactory.newKey("from"); + Key to = keyFactory.newKey("to"); + datastore.put(Entity.newBuilder(from).set("balance", 100).build()); + datastore.put(Entity.newBuilder(to).set("balance", 0).build()); + return ImmutableList.of(from, to); + } + + private void assertSuccessfulTransfer(Key from, Key to) { + assertEquals(90, datastore.get(from).getLong("balance")); + assertEquals(10, datastore.get(to).getLong("balance")); + } + + @Test + public void testTransactionalUpdate() { + List keys = setUpTransferTests(); + transferFunds(keys.get(0), keys.get(1), 10); + assertSuccessfulTransfer(keys.get(0), keys.get(1)); + } + + // [START datastore_transactional_update] + void transferFunds(Key fromKey, Key toKey, long amount) { + Transaction txn = datastore.newTransaction(); + try { + List entities = txn.fetch(fromKey, toKey); + Entity from = entities.get(0); + Entity updatedFrom = + Entity.newBuilder(from).set("balance", from.getLong("balance") - amount).build(); + Entity to = entities.get(1); + Entity updatedTo = + Entity.newBuilder(to).set("balance", to.getLong("balance") + amount).build(); + txn.put(updatedFrom, updatedTo); + txn.commit(); + } finally { + if (txn.isActive()) { + txn.rollback(); + } + } + } + + // [END datastore_transactional_update] + + @Test + public void testTransactionalRetry() { + List keys = setUpTransferTests(); + Key fromKey = keys.get(0); + Key toKey = keys.get(1); + // [START datastore_transactional_retry] + int retries = 5; + while (true) { + try { + transferFunds(fromKey, toKey, 10); + break; + } catch (DatastoreException e) { + if (retries == 0) { + throw e; + } + --retries; + } + } + // Retry handling can also be configured and automatically applied using google-cloud-java. + // [END datastore_transactional_retry] + assertSuccessfulTransfer(keys.get(0), keys.get(1)); + } + + @Test + public void testTransactionalGetOrCreate() { + // [START datastore_transactional_get_or_create] + Entity task; + Transaction txn = datastore.newTransaction(); + try { + task = txn.get(taskKey); + if (task == null) { + task = Entity.newBuilder(taskKey).build(); + txn.put(task); + txn.commit(); + } + } finally { + if (txn.isActive()) { + txn.rollback(); + } + } + // [END datastore_transactional_get_or_create] + assertEquals(task, datastore.get(taskKey)); + } + + @Test + public void testTransactionalSingleEntityGroupReadOnly() { + setUpQueryTests(); + Key taskListKey = datastore.newKeyFactory().setKind("TaskList").newKey("default"); + Entity taskListEntity = Entity.newBuilder(taskListKey).build(); + datastore.put(taskListEntity); + // [START datastore_transactional_single_entity_group_read_only] + Entity taskList; + QueryResults tasks; + Transaction txn = + datastore.newTransaction( + TransactionOptions.newBuilder().setReadOnly(ReadOnly.newBuilder().build()).build()); + try { + taskList = txn.get(taskListKey); + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.hasAncestor(taskListKey)) + .build(); + tasks = txn.run(query); + txn.commit(); + } finally { + if (txn.isActive()) { + txn.rollback(); + } + } + // [END datastore_transactional_single_entity_group_read_only] + assertEquals(taskListEntity, taskList); + assertNotNull(tasks.next()); + assertFalse(tasks.hasNext()); + } + + @Test + public void testNamespaceRunQuery() { + setUpQueryTests(); + // [START datastore_namespace_run_query] + KeyFactory keyFactory = datastore.newKeyFactory().setKind("__namespace__"); + Key startNamespace = keyFactory.newKey("g"); + Key endNamespace = keyFactory.newKey("h"); + Query query = + Query.newKeyQueryBuilder() + .setKind("__namespace__") + .setFilter( + CompositeFilter.and( + PropertyFilter.gt("__key__", startNamespace), + PropertyFilter.lt("__key__", endNamespace))) + .build(); + List namespaces = new ArrayList<>(); + QueryResults results = datastore.run(query); + while (results.hasNext()) { + namespaces.add(results.next().getName()); + } + // [END datastore_namespace_run_query] + assertEquals(ImmutableList.of("ghijklmnop"), namespaces); + } + + @Test + public void testKindRunQuery() { + setUpQueryTests(); + // [START datastore_kind_run_query] + Query query = Query.newKeyQueryBuilder().setKind("__kind__").build(); + List kinds = new ArrayList<>(); + QueryResults results = datastore.run(query); + while (results.hasNext()) { + kinds.add(results.next().getName()); + } + // [END datastore_kind_run_query] + assertEquals(ImmutableList.of("Task"), kinds); + } + + @Test + public void testPropertyRunQuery() { + setUpQueryTests(); + // [START datastore_property_run_query] + Query query = Query.newKeyQueryBuilder().setKind("__property__").build(); + QueryResults keys = datastore.run(query); + Map> propertiesByKind = new HashMap<>(); + while (keys.hasNext()) { + Key key = keys.next(); + String kind = key.getParent().getName(); + String propertyName = key.getName(); + Collection properties = propertiesByKind.get(kind); + if (properties == null) { + properties = new HashSet<>(); + propertiesByKind.put(kind, properties); + } + properties.add(propertyName); + } + // [END datastore_property_run_query] + Map> expected = + ImmutableMap.of( + "Task", + ImmutableSet.of( + "done", + "category", + "done", + "completed", + "priority", + "created", + "percent_complete", + "tag")); + assertEquals(expected, propertiesByKind); + } + + @Test + public void testPropertyByKindRunQuery() { + setUpQueryTests(); + // [START datastore_property_by_kind_run_query] + Key key = datastore.newKeyFactory().setKind("__kind__").newKey("Task"); + Query query = + Query.newEntityQueryBuilder() + .setKind("__property__") + .setFilter(PropertyFilter.hasAncestor(key)) + .build(); + QueryResults results = datastore.run(query); + Map> representationsByProperty = new HashMap<>(); + while (results.hasNext()) { + Entity result = results.next(); + String propertyName = result.getKey().getName(); + List representations = result.getList("property_representation"); + Collection currentRepresentations = representationsByProperty.get(propertyName); + if (currentRepresentations == null) { + currentRepresentations = new HashSet<>(); + representationsByProperty.put(propertyName, currentRepresentations); + } + for (StringValue value : representations) { + currentRepresentations.add(value.get()); + } + } + // [END datastore_property_by_kind_run_query] + Map> expected = + ImmutableMap.>builder() + .put("category", Collections.singleton("STRING")) + .put("done", Collections.singleton("BOOLEAN")) + .put("completed", Collections.singleton("BOOLEAN")) + .put("priority", Collections.singleton("INT64")) + .put("created", Collections.singleton("INT64")) + .put("percent_complete", Collections.singleton("DOUBLE")) + .put("tag", Collections.singleton("STRING")) + .build(); + assertEquals(expected, representationsByProperty); + } + + @Test + public void testPropertyFilteringRunQuery() { + setUpQueryTests(); + // [START datastore_property_filtering_run_query] + Key startKey = + datastore + .newKeyFactory() + .setKind("__property__") + .addAncestors(PathElement.of("__kind__", "Task")) + .newKey("priority"); + Query query = + Query.newKeyQueryBuilder() + .setKind("__property__") + .setFilter(PropertyFilter.ge("__key__", startKey)) + .build(); + Map> propertiesByKind = new HashMap<>(); + QueryResults keys = datastore.run(query); + while (keys.hasNext()) { + Key key = keys.next(); + String kind = key.getParent().getName(); + String propertyName = key.getName(); + Collection properties = propertiesByKind.get(kind); + if (properties == null) { + properties = new HashSet(); + propertiesByKind.put(kind, properties); + } + properties.add(propertyName); + } + // [END datastore_property_filtering_run_query] + Map> expected = + ImmutableMap.of("Task", ImmutableSet.of("priority", "tag")); + assertEquals(expected, propertiesByKind); + } + + @Test + public void testEqQuerySorted() { + setUpQueryTests(); + // [START datastore_eq_query_sorted] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.eq("tag", "learn")) + .setOrderBy(OrderBy.asc("tag")) + .build(); + // [END datastore_eq_query_sorted] + assertValidQuery(query); + } + + /** Start tests using a real backend. */ + private V assertValidQueryRealBackend(Query query) { + QueryResults results = datastoreRealBackend.run(query); + V result = results.next(); + // assertFalse(results.hasNext()); + return result; + } + + private void setUpQueryTestsRealBackend() { + Key taskKey = + datastoreRealBackend + .newKeyFactory() + .setKind("Task") + .addAncestors(PathElement.of("TaskList", "default")) + .newKey("someTask"); + datastoreRealBackend.put( + Entity.newBuilder(taskKey) + .set("category", "Personal") + .set("done", false) + .set("completed", false) + .set("priority", 4) + .set("created", includedDate) + .set("percent_complete", 10.0) + .set( + "description", + StringValue.newBuilder("Learn Cloud Datastore").setExcludeFromIndexes(true).build()) + .set("tag", "fun", "l", "programming", "learn") + .build()); + } + + @Test + public void testInQuery() { + setUpQueryTestsRealBackend(); + // [START datastore_in_query] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.in("tag", ListValue.of("learn", "study"))) + .build(); + // [END datastore_in_query] + assertValidQueryRealBackend(query); + } + + @Test + public void testNotEqualsQuery() { + setUpQueryTestsRealBackend(); + // [START datastore_not_equals_query] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.neq("category", "Work")) + .build(); + // [END datastore_not_equals_query] + assertValidQueryRealBackend(query); + } + + @Test + public void testNotInQuery() { + setUpQueryTestsRealBackend(); + // [START datastore_not_in_query] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.not_in("category", ListValue.of("Work", "Chores", "School"))) + .build(); + // [END datastore_not_in_query] + assertValidQueryRealBackend(query); + } + + @Test + public void testInQuerySorted() { + setUpQueryTestsRealBackend(); + // [START datastore_in_query_sorted] + Query query = + Query.newEntityQueryBuilder() + .setKind("Task") + .setFilter(PropertyFilter.in("tag", ListValue.of("learn", "study"))) + .setOrderBy(OrderBy.asc("tag")) + .build(); + // [END datastore_in_query_sorted] + assertValidQueryRealBackend(query); + } + + @Test + public void testStaleReads() throws InterruptedException { + setUpQueryTestsRealBackend(); + // waiting for 6 seconds, so that we can query with read time of 5 seconds ago + TimeUnit.SECONDS.sleep(6); + Datastore datastoreClient = datastoreRealBackend; + // [START datastore_stale_read] + Key taskKey = + datastoreClient + .newKeyFactory() + .setKind("Task") + .addAncestors(PathElement.of("TaskList", "default")) + .newKey("someTask"); + + Timestamp fiveSecondsAgo = + Timestamp.ofTimeSecondsAndNanos(Timestamp.now().getSeconds() - 5L, 0); + // Create a readOption with read time fiveSecondsAgo + ReadOption readOption = ReadOption.readTime(fiveSecondsAgo); + // Use the readOption to Fetch entity + Entity entity = datastoreClient.get(taskKey, readOption); + + // Use the readOption to Query kind Task + Query query = Query.newEntityQueryBuilder().setKind("Task").setLimit(10).build(); + QueryResults results = datastoreClient.run(query, readOption); + Entity result = results.next(); + // [END datastore_stale_read] + assertValidQueryRealBackend(query); + } +} diff --git a/java-datastore/samples/snippets/src/test/java/com/rule/SystemsOutRule.java b/java-datastore/samples/snippets/src/test/java/com/rule/SystemsOutRule.java new file mode 100644 index 000000000000..d7f09140f636 --- /dev/null +++ b/java-datastore/samples/snippets/src/test/java/com/rule/SystemsOutRule.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 + * + * 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.rule; + +import static com.google.common.truth.Truth.assertThat; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import org.junit.rules.TestRule; +import org.junit.runner.Description; +import org.junit.runners.model.Statement; + +public class SystemsOutRule implements TestRule { + private ByteArrayOutputStream currentOut; + + @Override + public Statement apply(Statement statement, Description description) { + return new Statement() { + @Override + public void evaluate() throws Throwable { + // Setting up customized PrintStream + final PrintStream originalOut = System.out; + currentOut = new ByteArrayOutputStream(); + System.setOut(new PrintStream(currentOut)); + + // Running tests + statement.evaluate(); + + // Restoring original PrintStream + System.setOut(originalOut); + currentOut = null; + } + }; + } + + public void assertContains(String content) { + assertThat(currentOut.toString().toLowerCase()).contains(content.toLowerCase()); + } +} diff --git a/java-datastore/samples/snippets/src/test/resources/index.yaml b/java-datastore/samples/snippets/src/test/resources/index.yaml new file mode 100644 index 000000000000..5f2f0c74a646 --- /dev/null +++ b/java-datastore/samples/snippets/src/test/resources/index.yaml @@ -0,0 +1,29 @@ +# 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. + +# one time index creation is required to run AggregationQuerySampleTestIT and ConceptsTest +# see https://cloud.google.com/sdk/gcloud/reference/datastore/indexes/create for more details +indexes: +- kind: Sales + properties: + - name: customerId + - name: amount +- kind: Task + properties: + - name: tag + - name: tag +- kind: employees + properties: + - name: salary + - name: experience \ No newline at end of file diff --git a/monorepo-migration/fix_copyright_headers.py b/monorepo-migration/fix_copyright_headers.py new file mode 100644 index 000000000000..cd813851d383 --- /dev/null +++ b/monorepo-migration/fix_copyright_headers.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python3 +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.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. + +import os +import re +import sys + +def fix_copyright(path): + if os.path.isfile(path): + if path.endswith(".java"): + _fix_file(path) + elif os.path.isdir(path): + for root, _, files in os.walk(path): + for file in files: + if file.endswith(".java"): + _fix_file(os.path.join(root, file)) + +def _fix_file(file_path): + with open(file_path, 'r') as f: + content = f.read() + + # Replace "Copyright [Year] Google LLC" or "Copyright [Year] Google Inc." + # with "Copyright 2026 Google LLC" + new_content = re.sub( + r'Copyright \d{4} Google (Inc\.|LLC)', + 'Copyright 2026 Google LLC', + content + ) + + if new_content != content: + with open(file_path, 'w') as f: + f.write(new_content) + print(f"Updated copyright in {file_path}") + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: fix_copyright_headers.py ...") + sys.exit(1) + + for arg in sys.argv[1:]: + fix_copyright(arg) diff --git a/monorepo-migration/migrate.sh b/monorepo-migration/migrate.sh new file mode 100755 index 000000000000..390f8eef2d47 --- /dev/null +++ b/monorepo-migration/migrate.sh @@ -0,0 +1,380 @@ +#!/bin/bash +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.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. + + +# Exit on error +set -e + +# Function to check if a command exists +check_command() { + if ! command -v "$1" >/dev/null 2>&1; then + echo "Error: $1 is not installed or not in PATH." >&2 + exit 1 + fi +} + +# Check for necessary CLI binaries +check_command git +check_command python3 +check_command mvn + +# Configuration +MONOREPO_URL="https://github.com/googleapis/google-cloud-java" +if [ -z "$SOURCE_REPO_URL" ]; then + read -p "Enter SOURCE_REPO_URL [https://github.com/googleapis/java-logging]: " input_url + SOURCE_REPO_URL="${input_url:-https://github.com/googleapis/java-logging}" +fi +CODEOWNER="${CODEOWNER:-}" + +# Derive names from URLs to avoid duplication +SOURCE_REPO_NAME="${SOURCE_REPO_URL##*/}" +MONOREPO_NAME="${MONOREPO_URL##*/}" + +# Use a temporary working directory sibling to the current monorepo +WORKING_DIR="../../migration-work" +SOURCE_DIR="$WORKING_DIR/$SOURCE_REPO_NAME-source" +TARGET_DIR="$WORKING_DIR/$MONOREPO_NAME-target" + +# Get absolute path to the transformation script before any cd +TRANSFORM_SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +TRANSFORM_SCRIPT="$TRANSFORM_SCRIPT_DIR/transform_workflow.py" +MODERNIZE_POM_SCRIPT="$TRANSFORM_SCRIPT_DIR/modernize_pom.py" +UPDATE_ROOT_POM_SCRIPT="$TRANSFORM_SCRIPT_DIR/update_root_pom.py" +FIX_COPYRIGHT_SCRIPT="$TRANSFORM_SCRIPT_DIR/fix_copyright_headers.py" +UPDATE_GENERATION_CONFIG_SCRIPT="$TRANSFORM_SCRIPT_DIR/update_generation_config.py" +UPDATE_OWLBOT_HERMETIC_SCRIPT="$TRANSFORM_SCRIPT_DIR/update_owlbot_hermetic.py" +TRANSFORM_OWLBOT_SCRIPT="$TRANSFORM_SCRIPT_DIR/update_owlbot.py" + +# Track number of commits made by this script +COMMIT_COUNT=0 + +echo "Starting migration using git read-tree with isolated clones..." + +# 0. Create working directory +mkdir -p "$WORKING_DIR" + +MIGRATION_HEAD_BRANCH="add-migration-script" + +# 1. Clone the source repository +if [ ! -d "$SOURCE_DIR" ]; then + echo "Cloning source repo: $SOURCE_REPO_URL into $SOURCE_DIR" + git clone "$SOURCE_REPO_URL" "$SOURCE_DIR" +else + echo "Source directory $SOURCE_DIR already exists. Ensuring it is clean and up-to-date..." + cd "$SOURCE_DIR" + git fetch origin + git checkout -f "main" + git reset --hard origin/main + git clean -fd + cd - > /dev/null +fi + +# 1.5 Extract CODEOWNERS from source repository as default +if [ -z "$CODEOWNER" ]; then + echo "Attempting to find default CODEOWNER from source repository..." + CODEOWNERS_FILE="" + if [ -f "$SOURCE_DIR/.github/CODEOWNERS" ]; then + CODEOWNERS_FILE="$SOURCE_DIR/.github/CODEOWNERS" + elif [ -f "$SOURCE_DIR/CODEOWNERS" ]; then + CODEOWNERS_FILE="$SOURCE_DIR/CODEOWNERS" + fi + + DEFAULT_CODEOWNER="" + if [ -n "$CODEOWNERS_FILE" ]; then + # Extract the line(s) starting with * (global owners) + # Use grep to find the line, then sed to remove the '*' and standard team handle + EXTRACTED_OWNERS=$(grep "^\* " "$CODEOWNERS_FILE" | sed 's/^\*[[:space:]]*//' | sed 's/@googleapis\/cloud-java-team-teamsync//g' | xargs) + if [ -n "$EXTRACTED_OWNERS" ]; then + DEFAULT_CODEOWNER="$EXTRACTED_OWNERS" + echo "Found default CODEOWNER: $DEFAULT_CODEOWNER" + fi + fi + + if [ -n "$DEFAULT_CODEOWNER" ]; then + read -p "Enter CODEOWNER [$DEFAULT_CODEOWNER]: " input_owner + CODEOWNER="${input_owner:-$DEFAULT_CODEOWNER}" + else + read -p "Enter CODEOWNER (e.g., @chingor13): " CODEOWNER + fi +fi + +# 2. Clone the target monorepo (the "isolated clone") +if [ ! -d "$TARGET_DIR" ]; then + echo "Cloning target monorepo: $MONOREPO_URL into $TARGET_DIR" + git clone "$MONOREPO_URL" "$TARGET_DIR" + git checkout -f "${MIGRATION_HEAD_BRANCH}" + git reset --hard origin/${MIGRATION_HEAD_BRANCH} +else + echo "Target directory $TARGET_DIR already exists. Ensuring it is clean and up-to-date..." + cd "$TARGET_DIR" + git fetch origin + git checkout -f "${MIGRATION_HEAD_BRANCH}" + git reset --hard origin/${MIGRATION_HEAD_BRANCH} + git clean -fd + cd - > /dev/null +fi + +cd "$TARGET_DIR" + +# Ensure we are on a clean main branch in the target clone +echo "Ensuring clean state in target monorepo..." +git fetch origin +git reset --hard HEAD +git clean -fd +git checkout -f "${MIGRATION_HEAD_BRANCH}" +git reset --hard origin/${MIGRATION_HEAD_BRANCH} +git clean -fdx + +# Check if the repository is already migrated +if [ -d "$SOURCE_REPO_NAME" ]; then + echo "Error: Directory $SOURCE_REPO_NAME already exists in the monorepo." >&2 + echo "This repository seems to have already been migrated." >&2 + exit 1 +fi + + +# 2.5 Create a new feature branch for the migration +BRANCH_NAME="migrate-$SOURCE_REPO_NAME" +echo "Creating feature branch: $BRANCH_NAME" +if git rev-parse --verify "$BRANCH_NAME" >/dev/null 2>&1; then + git branch -D "$BRANCH_NAME" +fi +git checkout -b "$BRANCH_NAME" + +# 3. Add the source repo as a remote +echo "Adding remote for $SOURCE_REPO_NAME: $SOURCE_DIR" +if git remote | grep -q "^$SOURCE_REPO_NAME$"; then + git remote remove "$SOURCE_REPO_NAME" +fi +git remote add "$SOURCE_REPO_NAME" "../$SOURCE_REPO_NAME-source" + +# 4. Fetch the source repo +echo "Fetching $SOURCE_REPO_NAME..." +git fetch "$SOURCE_REPO_NAME" + +# 5. Merge the histories using 'ours' strategy to keep monorepo content +echo "Merging histories (strategy: ours)..." +git merge --allow-unrelated-histories --no-ff "$SOURCE_REPO_NAME/main" -s ours --no-commit -m "chore($SOURCE_REPO_NAME): migrate $SOURCE_REPO_NAME into monorepo" + +# 6. Read the tree from the source repo into the desired subdirectory +echo "Reading tree into prefix $SOURCE_REPO_NAME/..." +git read-tree --prefix="$SOURCE_REPO_NAME/" -u "$SOURCE_REPO_NAME/main" + +# 6.5 Remove common files from the root of the migrated library +echo "Removing common files from the root of $SOURCE_REPO_NAME/..." +rm -f "$SOURCE_REPO_NAME/.gitignore" +rm -f "$SOURCE_REPO_NAME/renovate.json" +rm -f "$SOURCE_REPO_NAME/LICENSE" +rm -f "$SOURCE_REPO_NAME/java.header" +rm -rf "$SOURCE_REPO_NAME/.kokoro" +# rm -rf "$SOURCE_REPO_NAME/.kokoro/continuous" "$SOURCE_REPO_NAME/.kokoro/nightly" "$SOURCE_REPO_NAME/.kokoro/presubmit" +rm -f "$SOURCE_REPO_NAME/codecov.yaml" +rm -f "$SOURCE_REPO_NAME/synth.metadata" +rm -f "$SOURCE_REPO_NAME/license-checks.xml" +find "$SOURCE_REPO_NAME" -maxdepth 1 -name "*.md" ! -name "CHANGELOG.md" ! -name "README.md" -delete + +# 7. Commit the migration +echo "Committing migration..." +git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): migrate $SOURCE_REPO_NAME into monorepo" +COMMIT_COUNT=$((COMMIT_COUNT + 1)) + +# 7.1 Update CODEOWNERS +if [ -n "$CODEOWNER" ]; then + echo "Updating .github/CODEOWNERS..." + mkdir -p .github + echo "/$SOURCE_REPO_NAME/ $CODEOWNER @googleapis/cloud-java-team-teamsync" >> .github/CODEOWNERS + + echo "Committing CODEOWNERS update..." + git add .github/CODEOWNERS + git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): add code owners for $SOURCE_REPO_NAME" + COMMIT_COUNT=$((COMMIT_COUNT + 1)) +fi + +# 7.2 Update root pom.xml modules +echo "Updating root pom.xml modules..." +python3 "$UPDATE_ROOT_POM_SCRIPT" "pom.xml" "$SOURCE_REPO_NAME" + +echo "Committing root pom.xml modules update..." +git add pom.xml +git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): add module to root pom.xml" +COMMIT_COUNT=$((COMMIT_COUNT + 1)) + +# 7.5 Migrate GitHub Actions workflows +echo "Checking for GitHub Actions workflows..." +if [ -d "$SOURCE_REPO_NAME/.github/workflows" ]; then + echo "Migrating workflows to root .github/workflows/..." + mkdir -p .github/workflows + + for workflow in "$SOURCE_REPO_NAME/.github/workflows/"*; do + if [ -f "$workflow" ]; then + filename=$(basename "$workflow") + + # Skip redundant workflows as requested by user + case "$filename" in + "hermetic_library_generation.yaml" | "update_generation_config.yaml" | \ + "approve-readme.yaml" | "auto-release.yaml" | "renovate_config_check.yaml" | \ + "samples.yaml" | "unmanaged_dependency_check.yaml") + echo "Skipping redundant workflow: $filename" + continue + ;; + esac + + new_filename="${SOURCE_REPO_NAME}-${filename}" + target_path=".github/workflows/$new_filename" + + echo "Migrating and adapting $filename to $target_path" + python3 "$TRANSFORM_SCRIPT" "$SOURCE_REPO_NAME" < "$workflow" > "$target_path" + fi + done + + # Cleanup empty .github directory if it exists + rm -rf "$SOURCE_REPO_NAME/.github" + + echo "Committing workflow migration..." + git add .github/workflows + git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): migrate and adapt GitHub Actions workflows" + COMMIT_COUNT=$((COMMIT_COUNT + 1)) +fi + +# 7.6 Update generation_config.yaml +echo "Updating generation_config.yaml..." +SOURCE_CONFIG="$SOURCE_REPO_NAME/generation_config.yaml" +if [ -f "$SOURCE_CONFIG" ]; then + python3 "$UPDATE_GENERATION_CONFIG_SCRIPT" "generation_config.yaml" "$SOURCE_CONFIG" + + # Remove the source generation_config.yaml as it is now merged + rm "$SOURCE_CONFIG" + + echo "Committing generation_config.yaml update..." + git add generation_config.yaml "$SOURCE_CONFIG" + git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): add library to generation_config.yaml" + COMMIT_COUNT=$((COMMIT_COUNT + 1)) +fi + +# 7.7 Consolidate versions.txt +echo "Consolidating versions.txt..." +SOURCE_VERSIONS="$SOURCE_REPO_NAME/versions.txt" +if [ -f "$SOURCE_VERSIONS" ]; then + # Append data lines only to root versions.txt (exclude comments/headers) + grep "^[a-zA-Z0-9]" "$SOURCE_VERSIONS" >> versions.txt + + # Remove the migrated subdirectory's versions.txt + rm "$SOURCE_VERSIONS" + + echo "Committing versions.txt update..." + git add versions.txt "$SOURCE_VERSIONS" + git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): consolidate versions.txt into root" + COMMIT_COUNT=$((COMMIT_COUNT + 1)) +fi + +# 7.8 Migrate .OwlBot-hermetic.yaml +echo "Migrating .OwlBot-hermetic.yaml..." +if [ -f "$SOURCE_DIR/.github/.OwlBot-hermetic.yaml" ]; then + SOURCE_OWLBOT="$SOURCE_DIR/.github/.OwlBot-hermetic.yaml" +else + SOURCE_OWLBOT="" +fi + +if [ -n "$SOURCE_OWLBOT" ]; then + TARGET_OWLBOT="$SOURCE_REPO_NAME/.OwlBot-hermetic.yaml" + python3 "$UPDATE_OWLBOT_HERMETIC_SCRIPT" "$TARGET_OWLBOT" "$SOURCE_OWLBOT" "$SOURCE_REPO_NAME" + + echo "Committing .OwlBot-hermetic.yaml migration..." + git add "$TARGET_OWLBOT" + git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): migrate .OwlBot-hermetic.yaml" + COMMIT_COUNT=$((COMMIT_COUNT + 1)) +fi + + +# 7.8b Migrate owlbot.py +echo "Migrating owlbot.py..." +if [ -f "$SOURCE_DIR/owlbot.py" ]; then + TARGET_OWLBOT="$SOURCE_REPO_NAME/owlbot.py" + + python3 "$TRANSFORM_OWLBOT_SCRIPT" "$TARGET_OWLBOT" "$SOURCE_DIR/owlbot.py" + + echo "Committing owlbot.py migration..." + git add "$TARGET_OWLBOT" + git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): migrate owlbot.py" + COMMIT_COUNT=$((COMMIT_COUNT + 1)) +fi + +# 7.9 Fix copyright headers in Java files +echo "Fixing copyright headers in Java files..." +python3 "$FIX_COPYRIGHT_SCRIPT" "$SOURCE_REPO_NAME" + +echo "Committing copyright header fixes..." +git add "$SOURCE_REPO_NAME" +git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): update copyright headers to 2026 Google LLC" +COMMIT_COUNT=$((COMMIT_COUNT + 1)) + +# 7.11 Modernize root pom.xml +echo "Modernizing root pom.xml..." +PARENT_VERSION=$(grep -m 1 ".*{x-version-update:google-cloud-java:current}" google-cloud-jar-parent/pom.xml | sed -E 's/.*(.*)<\/version>.*/\1/') +python3 "$MODERNIZE_POM_SCRIPT" "$SOURCE_REPO_NAME/pom.xml" "$PARENT_VERSION" "$SOURCE_REPO_NAME" + +echo "Committing root pom.xml modernization..." +git add "$SOURCE_REPO_NAME/pom.xml" +git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): modernize root pom.xml" +COMMIT_COUNT=$((COMMIT_COUNT + 1)) + +# 7.12 Modernize BOM pom.xml +echo "Modernizing BOM pom.xml..." +# Find potential BOM POMs (usually in a subdirectory ending with -bom) +# Use process substitution or just a loop over the output of find to avoid subshell issues with counters +while read -r bom_pom; do + echo "Modernizing BOM: $bom_pom" + # BOMs should inherit from google-cloud-pom-parent + python3 "$MODERNIZE_POM_SCRIPT" "$bom_pom" "$PARENT_VERSION" "$SOURCE_REPO_NAME" "google-cloud-pom-parent" "../../google-cloud-pom-parent/pom.xml" + + echo "Committing BOM pom.xml modernization for $bom_pom..." + git add "$bom_pom" + git commit -n --no-gpg-sign -m "chore($SOURCE_REPO_NAME): modernize BOM pom.xml" + COMMIT_COUNT=$((COMMIT_COUNT + 1)) +done < <(find "$SOURCE_REPO_NAME" -name "pom.xml" | grep "\-bom/pom.xml" | grep -v "samples") + +# 7.11 Verify compilation +echo "Verifying compilation..." +(cd "$SOURCE_REPO_NAME" && mvn compile -DskipTests -T 1C) + +# 7.13 Squash commits +if [ "${SQUASH_COMMITS:-false}" = "true" ]; then + echo "Squashing $COMMIT_COUNT commits..." + if [ "$COMMIT_COUNT" -gt 1 ]; then + # Reset soft to the first commit of the migration + # We want to keep the very first commit message, or maybe a combined one? + # The requirement is "squash all the commits it's made into a single migration commit" + # The first commit we made was "chore($SOURCE_REPO_NAME): migrate $SOURCE_REPO_NAME into monorepo" + + # We can do this by soft resetting back COMMIT_COUNT-1 commits + # This leaves the first commit as HEAD, but with changes from subsequent commits staged. + # NO. Soft reset back N commits. + # If we made 3 commits: C1, C2, C3. HEAD is C3. + # reset --soft HEAD~2 results in HEAD at C1, with changes from C2 and C3 staged. + # then commit --amend adds those staged changes to C1. + + git reset --soft "HEAD~$((COMMIT_COUNT - 1))" + git commit --amend --no-edit --no-gpg-sign + echo "Squashed everything into one commit." + fi +fi + +# 8. Cleanup +echo "Cleaning up temporary source clone..." +rm -rf "$SOURCE_DIR" + +echo "Migration complete!" +echo "The migrated codebase is available in: $TARGET_DIR" +echo "You are on the $BRANCH_NAME branch in that clone." diff --git a/monorepo-migration/modernize_pom.py b/monorepo-migration/modernize_pom.py new file mode 100644 index 000000000000..ea0c023a9b57 --- /dev/null +++ b/monorepo-migration/modernize_pom.py @@ -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 +# +# 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. + +import sys +import re + + +def modernize_pom(file_path, parent_version, source_repo_name=None, parent_artifactId='google-cloud-jar-parent', relative_path='../google-cloud-jar-parent/pom.xml'): + with open(file_path, 'r') as f: + lines = f.readlines() + + new_lines = [] + in_parent = False + in_dep_mgmt = False + in_dependencies = False + in_dependency = False + in_reporting = False + current_dependency_lines = [] + should_preserve = False + current_group_id = None + has_version = False + + for line in lines: + # URL Modernization + if any(tag in line for tag in ['', '', '']): + if 'github.com' in line and 'googleapis/' in line: + if source_repo_name: + repo_pattern = re.escape(source_repo_name) + else: + repo_pattern = r'[a-zA-Z0-9-]+' + + # Replace HTTPS URLs + line = re.sub( + r'https://github\.com/googleapis/' + repo_pattern, + 'https://github.com/googleapis/google-cloud-java', + line + ) + # Replace Git SSH URLs + line = re.sub( + r'git@github\.com:googleapis/' + repo_pattern + r'(\.git)?', + 'git@github.com:googleapis/google-cloud-java.git', + line + ) + # Handle scm:git: prefix if it has https + line = re.sub( + r'scm:git:https://github\.com/googleapis/' + repo_pattern, + 'scm:git:https://github.com/googleapis/google-cloud-java.git', + line + ) + + # Parent section modernization + if '' in line and not in_parent: + in_parent = True + indent = line[:line.find('<')] + new_lines.append(f"{indent}\n") + new_lines.append(f"{indent} com.google.cloud\n") + new_lines.append(f"{indent} {parent_artifactId}\n") + new_lines.append(f"{indent} {parent_version}\n") + new_lines.append(f"{indent} {relative_path}\n") + continue + if '' in line and in_parent: + in_parent = False + new_lines.append(line) + continue + if in_parent: + continue # skip original parent content + + # Dependency Management pruning + if '' in line: + in_dep_mgmt = True + new_lines.append(line) + continue + if '' in line: + in_dep_mgmt = False + new_lines.append(line) + continue + + if in_dep_mgmt: + if '' in line: + in_dependencies = True + new_lines.append(line) + continue + if '' in line: + in_dependencies = False + new_lines.append(line) + continue + + if in_dependencies: + if '' in line: + in_dependency = True + current_dependency_lines = [line] + should_preserve = False + current_group_id = None + current_artifact_id = None + has_version = False + continue + if '' in line: + in_dependency = False + current_dependency_lines.append(line) + + # Preservation logic: + # 1. Has x-version-update comment + # 2. Is NOT com.google group AND has a version tag + # 3. Is com.google.cloud group AND artifactId starts with google-cloud- AND has a version tag + is_external = current_group_id and not current_group_id.startswith('com.google') + is_google_cloud_lib = current_group_id == 'com.google.cloud' and current_artifact_id and current_artifact_id.startswith('google-cloud-') + + if should_preserve or (is_external and has_version) or (is_google_cloud_lib and has_version): + new_lines.extend(current_dependency_lines) + continue + + if in_dependency: + current_dependency_lines.append(line) + if '{x-version-update:' in line: + should_preserve = True + if '' in line: + match = re.search(r'(.*?)', line) + if match: + current_group_id = match.group(1).strip() + if '' in line: + match = re.search(r'(.*?)', line) + if match: + current_artifact_id = match.group(1).strip() + if '' in line: + has_version = True + continue + + # Prune comments and extra whitespace in depMgmt for a cleaner result + if not line.strip(): + new_lines.append(line) + continue + + # Reporting section removal + if '' in line: + in_reporting = True + continue + if '' in line: + in_reporting = False + continue + if in_reporting: + continue + + new_lines.append(line) + + with open(file_path, 'w') as f: + # Clean up double empty lines potentially introduced by pruning + content = "".join(new_lines) + content = re.sub(r'\n\s*\n\s*\n', '\n\n', content) + f.write(content) + +if __name__ == "__main__": + if len(sys.argv) > 2: + source_repo = sys.argv[3] if len(sys.argv) > 3 else None + parent_artifactId = sys.argv[4] if len(sys.argv) > 4 else 'google-cloud-jar-parent' + relative_path = sys.argv[5] if len(sys.argv) > 5 else '../google-cloud-jar-parent/pom.xml' + modernize_pom(sys.argv[1], sys.argv[2], source_repo, parent_artifactId, relative_path) + else: + print("Usage: python3 modernize_pom.py [source_repo_name] [parent_artifactId] [relative_path]") + sys.exit(1) + diff --git a/monorepo-migration/transform_workflow.py b/monorepo-migration/transform_workflow.py new file mode 100644 index 000000000000..fba791634ebe --- /dev/null +++ b/monorepo-migration/transform_workflow.py @@ -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 +# +# 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. + +import sys +import re + +def transform(content, lib_name): + lines = content.splitlines() + new_lines = [] + inserted_defaults = False + + filter_job = f""" filter: + runs-on: ubuntu-latest + outputs: + library: ${{{{ steps.filter.outputs.library }}}} + steps: + - uses: actions/checkout@v4 + - uses: dorny/paths-filter@v3 + id: filter + with: + filters: | + library: + - '{lib_name}/**'""" + + in_jobs = False + skip_current_job = False + current_job_is_windows = False + + for line in lines: + if line.startswith('name:') and not in_jobs: + name_match = re.match(r'^name:\s*(.*)', line) + if name_match: + orig_name = name_match.group(1).strip() + # Remove quotes if they exist + orig_name = orig_name.strip("\"'") + new_lines.append(f"name: {lib_name} {orig_name}") + continue + + if line.startswith('jobs:'): + if not inserted_defaults: + new_lines.append("env:") + new_lines.append(f" BUILD_SUBDIR: {lib_name}") + inserted_defaults = True + new_lines.append(line) + new_lines.append(filter_job) + in_jobs = True + continue + + if in_jobs and line.startswith(' ') and not line.startswith(' ') and line.strip() and not line.strip().startswith('#'): + job_match = re.match(r'^ ([\w-]+):', line) + if job_match: + job_name = job_match.group(1) + current_job_is_windows = False # Reset for new job + if job_name == 'clirr': + skip_current_job = True + continue + else: + skip_current_job = False + + if job_name != 'filter': + new_lines.append(line) + new_lines.append(" needs: filter") + new_lines.append(f" if: ${{{{ needs.filter.outputs.library == 'true' }}}}") + continue + + if not skip_current_job: + if 'runs-on:' in line and 'windows' in line: + current_job_is_windows = True + + if line.strip() == 'steps:' and current_job_is_windows: + new_lines.append(line) + new_lines.append(" - name: Support longpaths") + new_lines.append(" run: git config --system core.longpaths true") + continue + + if 'run: echo "SUREFIRE_JVM_OPT=' in line and '!java17' not in line: + line = line.replace('" >> $GITHUB_ENV', ' -P !java17" >> $GITHUB_ENV') + if 'build.bat' in line: + line = line.replace('build.bat', 'build.sh') + + new_lines.append(line) + return "\n".join(new_lines) + +if __name__ == "__main__": + if len(sys.argv) < 2: + print("Usage: python3 transform_workflow.py ") + sys.exit(1) + lib = sys.argv[1] + print(transform(sys.stdin.read(), lib)) diff --git a/monorepo-migration/update_generation_config.py b/monorepo-migration/update_generation_config.py new file mode 100644 index 000000000000..1ba7e6fc8c3e --- /dev/null +++ b/monorepo-migration/update_generation_config.py @@ -0,0 +1,107 @@ +#!/usr/bin/env python3 +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.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. + +import sys +import yaml +import re + +def get_library_id(lib): + """ + Returns a unique identifier for a library. + Prefer 'library_name', then 'api_shortname'. + """ + if 'library_name' in lib: + return f"java-{lib['library_name']}" + if 'api_shortname' in lib: + return f"java-{lib['api_shortname']}" + return "unknown" + +def merge_libraries(target_libs, source_libs): + """ + Merges source_libs into target_libs. + Libraries are matched by get_library_id. + GAPICs are merged and deduplicated by proto_path. + The final list is sorted by library_id. + """ + # Map from library_id to library dict + target_map = {get_library_id(lib): lib for lib in target_libs} + + for s_lib in source_libs: + lib_id = get_library_id(s_lib) + + # Clean up source library (remove repo fields) + s_lib_cleaned = {k: v for k, v in s_lib.items() if k not in ('repo', 'repo_short')} + + if lib_id in target_map: + t_lib = target_map[lib_id] + # Merge GAPICs + t_gapics_list = t_lib.get('GAPICs', []) + s_gapics_list = s_lib_cleaned.get('GAPICs', []) + + # Map by proto_path for deduplication + proto_map = {g['proto_path']: g for g in t_gapics_list} + for g in s_gapics_list: + proto_map[g['proto_path']] = g + + # Sort GAPICs by proto_path + sorted_protos = sorted(proto_map.keys()) + t_lib['GAPICs'] = [proto_map[p] for p in sorted_protos] + + # Update other fields from source + for k, v in s_lib_cleaned.items(): + if k != 'GAPICs': + t_lib[k] = v + else: + target_map[lib_id] = s_lib_cleaned + + # Return sorted list of libraries + sorted_ids = sorted(target_map.keys()) + return [target_map[lib_id] for lib_id in sorted_ids] + +def update_config(target_path, source_path): + with open(target_path, 'r') as f: + target_content = f.read() + + with open(source_path, 'r') as f: + source_data = yaml.safe_load(f) or {} + + # Load target data + target_data = yaml.safe_load(target_content) or {} + + target_libs = target_data.get('libraries', []) + source_libs = source_data.get('libraries', []) + + merged_libs = merge_libraries(target_libs, source_libs) + target_data['libraries'] = merged_libs + + # Write back + with open(target_path, 'w') as f: + # Check if there was a license header in the original file + header_match = re.search(r'^(#.*?\n\n)', target_content, re.DOTALL) + if header_match: + f.write(header_match.group(1)) + + # Use yaml.dump to write the data. + # sort_keys=False to preserve order of fields within libraries if possible (YAML 1.2+ usually does, but pyyaml depends) + yaml.dump(target_data, f, sort_keys=False, default_flow_style=False, indent=2) + +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: python3 update_generation_config.py ") + sys.exit(1) + + target_path = sys.argv[1] + source_path = sys.argv[2] + update_config(target_path, source_path) diff --git a/monorepo-migration/update_owlbot.py b/monorepo-migration/update_owlbot.py new file mode 100644 index 000000000000..5b02501e7625 --- /dev/null +++ b/monorepo-migration/update_owlbot.py @@ -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 +# +# 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. + +import ast +import sys +import os + +def is_call_to(node, name_parts): + """ + Checks if an AST node is a call to a specific function. + name_parts: list of strings, e.g. ['s', 'move'] for s.move() + or ['java', 'common_templates'] + """ + if not isinstance(node, ast.Call): + return False + + func = node.func + # Handle attribute access (e.g. s.move) + if isinstance(func, ast.Attribute): + if len(name_parts) == 2: + # Check object and attr + obj = func.value + if isinstance(obj, ast.Name) and obj.id == name_parts[0] and func.attr == name_parts[1]: + return True + elif len(name_parts) == 1: + if func.attr == name_parts[0]: + return True + # Handle direct name (e.g. if imported directly, though less common for these) + elif isinstance(func, ast.Name): + if len(name_parts) == 1 and func.id == name_parts[0]: + return True + + return False + +def extract_excludes_from_call(call_node): + excludes = [] + for keyword in call_node.keywords: + if keyword.arg == 'excludes': + if isinstance(keyword.value, ast.List): + for elt in keyword.value.elts: + if isinstance(elt, ast.Constant): # Python 3.8+ + excludes.append(elt.value) + elif isinstance(elt, ast.Str): # Python < 3.8 + excludes.append(elt.s) + break + return excludes + +def extract_info(source_code): + excludes = [] + loop_body_lines = [] + top_level_lines = [] + + try: + tree = ast.parse(source_code) + except SyntaxError: + return excludes, top_level_lines, loop_body_lines + + for node in tree.body: + # Some nodes are wrapped in Expr, e.g. s.remove_staging_dirs() + inner_node = node + if isinstance(node, ast.Expr): + inner_node = node.value + + # Ignore standard imports (we will inject them) + if isinstance(node, (ast.Import, ast.ImportFrom)): + # We assume we only care about synthtool/java imports which we regenerate. + # If there are other imports, we should probably preserve them. + # Heuristic: if it mentions 'synthtool', ignore it. + if isinstance(node, ast.Import): + if any('synthtool' in alias.name for alias in node.names): + continue + if isinstance(node, ast.ImportFrom): + if node.module and 'synthtool' in node.module: + continue + # Preserve other imports + if sys.version_info >= (3, 9): + top_level_lines.append(ast.unparse(node)) + continue + + # Check for java.common_templates (top level) + if is_call_to(inner_node, ['java', 'common_templates']) or is_call_to(inner_node, ['common', 'java_library']): + excludes.extend(extract_excludes_from_call(inner_node)) + continue + + # Check for s.remove_staging_dirs() + if is_call_to(inner_node, ['s', 'remove_staging_dirs']): + continue + + # Check for the main loop: for library in s.get_staging_dirs(): + if isinstance(node, ast.For): + is_staging_loop = False + if isinstance(node.iter, ast.Call): + # Check for s.get_staging_dirs() + if is_call_to(node.iter, ['s', 'get_staging_dirs']): + is_staging_loop = True + + if is_staging_loop: + # Extract body + for child in node.body: + child_inner = child + if isinstance(child, ast.Expr): + child_inner = child.value + + # Check for nested common_templates (rare but possible) + if is_call_to(child_inner, ['java', 'common_templates']) or is_call_to(child_inner, ['common', 'java_library']): + excludes.extend(extract_excludes_from_call(child_inner)) + continue + + if sys.version_info >= (3, 9): + loop_body_lines.append(ast.unparse(child)) + continue + # else fall through to preserve other loops + + # Preserve everything else (constants, functions, other logic) + if sys.version_info >= (3, 9): + top_level_lines.append(ast.unparse(node)) + + return excludes, top_level_lines, loop_body_lines + +def generate_target_content(excludes, top_level_lines, loop_body_lines): + standard_excludes = [ + ".github/*", + ".kokoro/*", + "samples/*", + "CODE_OF_CONDUCT.md", + "CONTRIBUTING.md", + "LICENSE", + "SECURITY.md", + "java.header", + "license-checks.xml", + "renovate.json", + ".gitignore", + ] + excludes_str = ",\n ".join([f'"{e}"' for e in standard_excludes]) + + # Reconstruct content + lines = [] + lines.append("# Copyright 2026 Google LLC") + lines.append("#") + lines.append("# Licensed under the Apache License, Version 2.0 (the \"License\");") + lines.append("# you may not use this file except in compliance with the License.") + lines.append("# You may obtain a copy of the License at") + lines.append("#") + lines.append("# https://www.apache.org/licenses/LICENSE-2.0") + lines.append("#") + lines.append("# Unless required by applicable law or agreed to in writing, software") + lines.append("# distributed under the License is distributed on an \"AS IS\" BASIS,") + lines.append("# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.") + lines.append("# See the License for the specific language governing permissions and") + lines.append("# limitations under the License.") + lines.append("") + lines.append("import synthtool as s") + lines.append("from synthtool.languages import java") + lines.append("") + + if top_level_lines: + lines.extend(top_level_lines) + lines.append("") + + lines.append("for library in s.get_staging_dirs():") + lines.append(" # put any special-case replacements here") + for l in loop_body_lines: + # Indent loop body + for sl in l.split('\n'): + lines.append(" " + sl) + + lines.append("s.remove_staging_dirs()") + lines.append(f"java.common_templates(monorepo=True, excludes=[") + lines.append(f" {excludes_str}") + lines.append("])") + + return "\n".join(lines) + "\n" + +def main(): + if len(sys.argv) < 3: + print("Usage: update_owlbot.py [template_file]") + sys.exit(1) + + target_file = sys.argv[1] + source_file = sys.argv[2] + template_file = sys.argv[3] if len(sys.argv) > 3 else None + + if not os.path.exists(source_file): + print(f"Source file {source_file} not found.") + sys.exit(1) + + with open(source_file, 'r') as f: + source_code = f.read() + + excludes, top_level_lines, loop_body_lines = extract_info(source_code) + target_content = generate_target_content(excludes, top_level_lines, loop_body_lines) + + if os.path.dirname(target_file): + os.makedirs(os.path.dirname(target_file), exist_ok=True) + with open(target_file, 'w') as f: + f.write(target_content) + + print(f"Generated {target_file}") + +if __name__ == "__main__": + main() diff --git a/monorepo-migration/update_owlbot_hermetic.py b/monorepo-migration/update_owlbot_hermetic.py new file mode 100644 index 000000000000..7f9f803822f5 --- /dev/null +++ b/monorepo-migration/update_owlbot_hermetic.py @@ -0,0 +1,77 @@ +#!/usr/bin/env python3 +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.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. + +import sys +import yaml +import re + +def update_config(target_path, source_path, prefix): + """ + Reads source_path, prepends prefix to paths in deep-remove-regex and deep-preserve-regex, + and writes to target_path. + """ + with open(source_path, 'r') as f: + source_content = f.read() + + # Load source data + source_data = yaml.safe_load(source_content) or {} + + # Define fields to update + fields_to_update = ['deep-remove-regex', 'deep-preserve-regex'] + + for field in fields_to_update: + if field in source_data: + updated_list = [] + for item in source_data[field]: + # If item is a string, prepend prefix + # Regex might need handling if it starts with ^ + # But usually these are just paths. + # Assuming simple concatenation for now as per requirement. + # "When referencing paths in the deep-remove-regex and deep-preserve-regex, the new directory name should be prefixed" + + # If the regex starts with ^, insert the prefix after it. + if item.startswith('^'): + updated_list.append(f"^{prefix}/{item[1:]}") + else: + updated_list.append(f"/{prefix}{item}") + source_data[field] = updated_list + + if 'deep-copy-regex' in source_data: + for item in source_data['deep-copy-regex']: + if 'dest' in item and item['dest'].startswith('/owl-bot-staging/'): + item['dest'] = item['dest'].replace('/owl-bot-staging/', f'/owl-bot-staging/{prefix}/', 1) + + # Write to target_path + with open(target_path, 'w') as f: + # Check if there was a license header in the original file + # Match a block of lines starting with # at the beginning of the file + header_match = re.search(r'^((?:#[^\n]*\n)+)', source_content) + if header_match: + f.write(header_match.group(1)) + f.write("\n") # Add a newline after the header + + # Use yaml.dump to write the data. + yaml.dump(source_data, f, sort_keys=False, default_flow_style=False, indent=2) + +if __name__ == "__main__": + if len(sys.argv) != 4: + print("Usage: python3 update_owlbot_hermetic.py ") + sys.exit(1) + + target_path = sys.argv[1] + source_path = sys.argv[2] + prefix = sys.argv[3] + + update_config(target_path, source_path, prefix) diff --git a/monorepo-migration/update_root_pom.py b/monorepo-migration/update_root_pom.py new file mode 100644 index 000000000000..fec12930dee3 --- /dev/null +++ b/monorepo-migration/update_root_pom.py @@ -0,0 +1,56 @@ +#!/usr/bin/env python3 +# Copyright 2026 Google LLC +# +# Licensed under the Apache License, Version 2.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. + +import sys + +def update_root_pom(pom_path, module_name): + new_module = f' {module_name}\n' + with open(pom_path, 'r') as f: + content = f.read() + + start_tag = '' + end_tag = '' + start_idx = content.find(start_tag) + end_idx = content.find(end_tag) + + if start_idx == -1 or end_idx == -1: + print(f"Error: {start_tag} or {end_tag} not found in {pom_path}") + sys.exit(1) + + modules_section = content[start_idx + len(start_tag):end_idx] + lines = [l for l in modules_section.splitlines(keepends=True) if l.strip()] + + java_indices = [i for i, l in enumerate(lines) if 'java-' in l] + if java_indices: + start_java = java_indices[0] + end_java = java_indices[-1] + 1 + java_lines = lines[start_java:end_java] + if not any(f'{module_name}' in l for l in java_lines): + java_lines.append(new_module) + java_lines.sort() + lines = lines[:start_java] + java_lines + lines[end_java:] + else: + if not any(f'{module_name}' in l for l in lines): + lines.append(new_module) + + new_content = content[:start_idx + len(start_tag)] + '\n' + ''.join(lines) + ' ' + content[end_idx:] + with open(pom_path, 'w') as f: + f.write(new_content) + +if __name__ == "__main__": + if len(sys.argv) != 3: + print("Usage: update_root_pom.py ") + sys.exit(1) + update_root_pom(sys.argv[1], sys.argv[2]) diff --git a/pom.xml b/pom.xml index 96bd03560242..803fdf50b764 100644 --- a/pom.xml +++ b/pom.xml @@ -85,6 +85,7 @@ java-dataplex java-dataproc java-dataproc-metastore + java-datastore java-datastream java-deploy java-developerconnect diff --git a/versions.txt b/versions.txt index b402889bf022..988fbb4fce6c 100644 --- a/versions.txt +++ b/versions.txt @@ -937,3 +937,10 @@ grpc-google-cloud-gkerecommender-v1:0.2.0:0.3.0-SNAPSHOT google-cloud-cloudapiregistry:0.1.0:0.2.0-SNAPSHOT proto-google-cloud-cloudapiregistry-v1beta:0.1.0:0.2.0-SNAPSHOT grpc-google-cloud-cloudapiregistry-v1beta:0.1.0:0.2.0-SNAPSHOT +google-cloud-datastore:2.33.2:2.33.2 +google-cloud-datastore-bom:2.33.2:2.33.2 +proto-google-cloud-datastore-v1:0.124.2:0.124.2 +datastore-v1-proto-client:2.33.2:2.33.2 +proto-google-cloud-datastore-admin-v1:2.33.2:2.33.2 +grpc-google-cloud-datastore-admin-v1:2.33.2:2.33.2 +grpc-google-cloud-datastore-v1:2.33.2:2.33.2