diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot-hermetic.yaml similarity index 100% rename from .github/.OwlBot.yaml rename to .github/.OwlBot-hermetic.yaml diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml deleted file mode 100644 index f817c5f4499..00000000000 --- a/.github/.OwlBot.lock.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright 2024 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -docker: - image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:31aa2ef27b071c2e7844b0eb1d5a24254daff06615b1b138b994dd6345c0b0ea -# created: 2024-05-17T15:15:57.6714113Z diff --git a/.github/release-please.yml b/.github/release-please.yml index be8096d847d..2853b1763cf 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -38,3 +38,7 @@ branches: bumpMinorPreMajor: true handleGHRelease: true branch: 6.67.x + - releaseType: java-backport + bumpMinorPreMajor: true + handleGHRelease: true + branch: 6.66.x diff --git a/.github/scripts/hermetic_library_generation.sh b/.github/scripts/hermetic_library_generation.sh new file mode 100644 index 00000000000..6c3f22d8f9e --- /dev/null +++ b/.github/scripts/hermetic_library_generation.sh @@ -0,0 +1,117 @@ +#!/bin/bash +set -e +# This script should be run at the root of the repository. +# This script is used to, when a pull request changes the generation +# configuration (generation_config.yaml by default): +# 1. Find whether the last commit in this pull request contains changes to +# the generation configuration and exit early if it doesn't have such a change +# since the generation result would be the same. +# 2. Compare generation configurations in the current branch (with which the +# pull request associated) and target branch (into which the pull request is +# merged); +# 3. Generate changed libraries using library_generation image; +# 4. Commit the changes to the pull request, if any. +# 5. Edit the PR body with generated pull request description, if applicable. + +# The following commands need to be installed before running the script: +# 1. git +# 2. gh +# 3. docker + +# The parameters of this script is: +# 1. target_branch, the branch into which the pull request is merged. +# 2. current_branch, the branch with which the pull request is associated. +# 3. [optional] generation_config, the path to the generation configuration, +# the default value is generation_config.yaml in the repository root. +while [[ $# -gt 0 ]]; do +key="$1" +case "${key}" in + --target_branch) + target_branch="$2" + shift + ;; + --current_branch) + current_branch="$2" + shift + ;; + --generation_config) + generation_config="$2" + shift + ;; + *) + echo "Invalid option: [$1]" + exit 1 + ;; +esac +shift +done + +if [ -z "${target_branch}" ]; then + echo "missing required argument --target_branch" + exit 1 +fi + +if [ -z "${current_branch}" ]; then + echo "missing required argument --current_branch" + exit 1 +fi + +if [ -z "${generation_config}" ]; then + generation_config=generation_config.yaml + echo "Using default generation config: ${generation_config}" +fi + +workspace_name="/workspace" +baseline_generation_config="baseline_generation_config.yaml" +message="chore: generate libraries at $(date)" + +git checkout "${target_branch}" +git checkout "${current_branch}" +# if the last commit doesn't contain changes to generation configuration, +# do not generate again as the result will be the same. +change_of_last_commit="$(git diff-tree --no-commit-id --name-only HEAD~1..HEAD -r)" +if [[ ! ("${change_of_last_commit}" == *"${generation_config}"*) ]]; then + echo "The last commit doesn't contain any changes to the generation_config.yaml, skipping the whole generation process." || true + exit 0 +fi +# copy generation configuration from target branch to current branch. +git show "${target_branch}":"${generation_config}" > "${baseline_generation_config}" +config_diff=$(diff "${generation_config}" "${baseline_generation_config}" || true) + +# parse image tag from the generation configuration. +image_tag=$(grep "gapic_generator_version" "${generation_config}" | cut -d ':' -f 2 | xargs) + +# run hermetic code generation docker image. +docker run \ + --rm \ + -u "$(id -u):$(id -g)" \ + -v "$(pwd):${workspace_name}" \ + gcr.io/cloud-devrel-public-resources/java-library-generation:"${image_tag}" \ + --baseline-generation-config-path="${workspace_name}/${baseline_generation_config}" \ + --current-generation-config-path="${workspace_name}/${generation_config}" + + +# commit the change to the pull request. +if [[ $(basename $(pwd)) == "google-cloud-java" ]]; then + git add java-* pom.xml gapic-libraries-bom/pom.xml versions.txt +else + # The image leaves intermediate folders and files it works with. Here we remove them + rm -rdf output googleapis "${baseline_generation_config}" + git add --all -- ':!pr_description.txt' +fi +changed_files=$(git diff --cached --name-only) +if [[ "${changed_files}" == "" ]]; then + echo "There is no generated code change with the generation config change ${config_diff}." + echo "Skip committing to the pull request." + exit 0 +fi + +echo "Configuration diff:" +echo "${config_diff}" +git commit -m "${message}" +git push +# set pr body if pr_description.txt is generated. +if [[ -f "pr_description.txt" ]]; then + pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number") + gh pr edit "${pr_num}" --body "$(cat pr_description.txt)" +fi diff --git a/.github/scripts/update_generation_config.sh b/.github/scripts/update_generation_config.sh new file mode 100644 index 00000000000..561a313040f --- /dev/null +++ b/.github/scripts/update_generation_config.sh @@ -0,0 +1,121 @@ +#!/bin/bash +set -e +# This script should be run at the root of the repository. +# This script is used to update googleapis_commitish, gapic_generator_version, +# and libraries_bom_version in generation configuration at the time of running +# and create a pull request. + +# The following commands need to be installed before running the script: +# 1. git +# 2. gh +# 3. jq + +# Utility functions +# Get the latest released version of a Maven artifact. +function get_latest_released_version() { + local group_id=$1 + local artifact_id=$2 + latest=$(curl -s "https://search.maven.org/solrsearch/select?q=g:${group_id}+AND+a:${artifact_id}&core=gav&rows=500&wt=json" | jq -r '.response.docs[] | select(.v | test("^[0-9]+(\\.[0-9]+)*$")) | .v' | sort -V | tail -n 1) + echo "${latest}" +} + +# Update a key to a new value in the generation config. +function update_config() { + local key_word=$1 + local new_value=$2 + local file=$3 + echo "Update ${key_word} to ${new_value} in ${file}" + sed -i -e "s/^${key_word}.*$/${key_word}: ${new_value}/" "${file}" +} + +# The parameters of this script is: +# 1. base_branch, the base branch of the result pull request. +# 2. repo, organization/repo-name, e.g., googleapis/google-cloud-java +# 3. [optional] generation_config, the path to the generation configuration, +# the default value is generation_config.yaml in the repository root. +while [[ $# -gt 0 ]]; do +key="$1" +case "${key}" in + --base_branch) + base_branch="$2" + shift + ;; + --repo) + repo="$2" + shift + ;; + --generation_config) + generation_config="$2" + shift + ;; + *) + echo "Invalid option: [$1]" + exit 1 + ;; +esac +shift +done + +if [ -z "${base_branch}" ]; then + echo "missing required argument --base_branch" + exit 1 +fi + +if [ -z "${repo}" ]; then + echo "missing required argument --repo" + exit 1 +fi + +if [ -z "${generation_config}" ]; then + generation_config="generation_config.yaml" + echo "Use default generation config: ${generation_config}" +fi + +current_branch="generate-libraries-${base_branch}" +title="chore: Update generation configuration at $(date)" + +# try to find a open pull request associated with the branch +pr_num=$(gh pr list -s open -H "${current_branch}" -q . --json number | jq ".[] | .number") +# create a branch if there's no open pull request associated with the +# branch; otherwise checkout the pull request. +if [ -z "${pr_num}" ]; then + git checkout -b "${current_branch}" +else + gh pr checkout "${pr_num}" +fi + +mkdir tmp-googleapis +# use partial clone because only commit history is needed. +git clone --filter=blob:none https://github.com/googleapis/googleapis.git tmp-googleapis +pushd tmp-googleapis +git pull +latest_commit=$(git rev-parse HEAD) +popd +rm -rf tmp-googleapis +update_config "googleapis_commitish" "${latest_commit}" "${generation_config}" + +# update gapic-generator-java version to the latest +latest_version=$(get_latest_released_version "com.google.api" "gapic-generator-java") +update_config "gapic_generator_version" "${latest_version}" "${generation_config}" + +# update libraries-bom version to the latest +latest_version=$(get_latest_released_version "com.google.cloud" "libraries-bom") +update_config "libraries_bom_version" "${latest_version}" "${generation_config}" + +git add "${generation_config}" +changed_files=$(git diff --cached --name-only) +if [[ "${changed_files}" == "" ]]; then + echo "The latest generation config is not changed." + echo "Skip committing to the pull request." + exit 0 +fi +git commit -m "${title}" +if [ -z "${pr_num}" ]; then + git remote add remote_repo https://cloud-java-bot:"${GH_TOKEN}@github.com/${repo}.git" + git fetch -q --unshallow remote_repo + git push -f remote_repo "${current_branch}" + gh pr create --title "${title}" --head "${current_branch}" --body "${title}" --base "${base_branch}" +else + git push + gh pr edit "${pr_num}" --title "${title}" --body "${title}" +fi diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 9a71e7679c2..7ab67b223ec 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -19,7 +19,6 @@ branchProtectionRules: - checkstyle - compile (8) - compile (11) - - OwlBot Post Processor - units-with-multiplexed-session (8) - units-with-multiplexed-session (11) - pattern: 3.3.x @@ -141,7 +140,25 @@ branchProtectionRules: - checkstyle - compile (8) - compile (11) - - OwlBot Post Processor + - pattern: 6.66.x + isAdminEnforced: true + requiredApprovingReviewCount: 1 + requiresCodeOwnerReviews: true + requiresStrictStatusChecks: false + requiredStatusCheckContexts: + - dependencies (17) + - lint + - javadoc + - units (8) + - units (11) + - 'Kokoro - Test: Integration' + - 'Kokoro - Test: Integration with Multiplexed Sessions' + - cla/google + - checkstyle + - compile (8) + - compile (11) + - units-with-multiplexed-session (8) + - units-with-multiplexed-session (11) permissionRules: - team: yoshi-admins permission: admin diff --git a/.github/workflows/hermetic_library_generation.yaml b/.github/workflows/hermetic_library_generation.yaml new file mode 100644 index 00000000000..7146cc3dc1c --- /dev/null +++ b/.github/workflows/hermetic_library_generation.yaml @@ -0,0 +1,40 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# GitHub action job to test core java library features on +# downstream client libraries before they are released. +name: Hermetic library generation upon generation config change through pull requests +on: + pull_request: + +jobs: + library_generation: + # skip pull requests coming from a forked repository + if: github.event.pull_request.head.repo.full_name == github.repository + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + - name: Generate changed libraries + shell: bash + run: | + set -x + [ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com" + [ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot" + bash .github/scripts/hermetic_library_generation.sh \ + --target_branch ${{ github.base_ref }} \ + --current_branch ${{ github.head_ref }} + env: + GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} diff --git a/.github/workflows/unmanaged_dependency_check.yaml b/.github/workflows/unmanaged_dependency_check.yaml index eb740eb8ba0..2e6ec1a12bf 100644 --- a/.github/workflows/unmanaged_dependency_check.yaml +++ b/.github/workflows/unmanaged_dependency_check.yaml @@ -17,6 +17,6 @@ jobs: # repository .kokoro/build.sh - name: Unmanaged dependency check - uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.32.0 + uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v3.33.0 with: bom-path: google-cloud-spanner-bom/pom.xml diff --git a/.github/workflows/update_generation_config.yaml b/.github/workflows/update_generation_config.yaml new file mode 100644 index 00000000000..3cf77399264 --- /dev/null +++ b/.github/workflows/update_generation_config.yaml @@ -0,0 +1,42 @@ +# Copyright 2024 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# GitHub action job to test core java library features on +# downstream client libraries before they are released. +name: Update generation configuration +on: + schedule: + - cron: '0 2 * * *' + workflow_dispatch: + +jobs: + update-generation-config: + runs-on: ubuntu-22.04 + env: + # the branch into which the pull request is merged + base_branch: main + steps: + - uses: actions/checkout@v4 + with: + token: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} + - name: Update params in generation config to latest + shell: bash + run: | + set -x + [ -z "$(git config user.email)" ] && git config --global user.email "cloud-java-bot@google.com" + [ -z "$(git config user.name)" ] && git config --global user.name "cloud-java-bot" + bash .github/scripts/update_generation_config.sh \ + --base_branch "${base_branch}"\ + --repo ${{ github.repository }} + env: + GH_TOKEN: ${{ secrets.CLOUD_JAVA_BOT_TOKEN }} diff --git a/.kokoro/build.sh b/.kokoro/build.sh index d3eaf9922bb..f8ae5a96f37 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -48,6 +48,16 @@ if [[ ! -z "${GOOGLE_APPLICATION_CREDENTIALS}" && "${GOOGLE_APPLICATION_CREDENTI export GOOGLE_APPLICATION_CREDENTIALS=$(realpath ${KOKORO_GFILE_DIR}/${GOOGLE_APPLICATION_CREDENTIALS}) fi +# Start the Spanner emulator if the environment variable for it has been set. +# TODO: Change if statement once the env var can be set in the config. +#if [[ ! -z "${SPANNER_EMULATOR_HOST}" ]]; then +if [[ "$JOB_TYPE" == "graalvm" ]] || [[ "$JOB_TYPE" == "graalvm17" ]]; then + echo "Starting emulator" + export SPANNER_EMULATOR_HOST=localhost:9010 + docker pull gcr.io/cloud-spanner-emulator/emulator + docker run -d --rm --name spanner-emulator -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator +fi + # Kokoro integration test uses both JDK 11 and JDK 8. We ensure the generated class files # are compatible with Java 8 when running tests. if [ -n "${JAVA8_HOME}" ]; then @@ -233,6 +243,11 @@ clirr) ;; esac +if [[ ! -z "${SPANNER_EMULATOR_HOST}" ]]; then + echo "Stopping emulator" + docker container stop spanner-emulator +fi + if [ "${REPORT_COVERAGE}" == "true" ] then bash ${KOKORO_GFILE_DIR}/codecov.sh diff --git a/.kokoro/presubmit/graalvm-native-17.cfg b/.kokoro/presubmit/graalvm-native-17.cfg index 7d5ab3a25c4..7008a721567 100644 --- a/.kokoro/presubmit/graalvm-native-17.cfg +++ b/.kokoro/presubmit/graalvm-native-17.cfg @@ -3,7 +3,7 @@ # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.32.0" + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_b:3.33.0" } env_vars: { diff --git a/.kokoro/presubmit/graalvm-native.cfg b/.kokoro/presubmit/graalvm-native.cfg index 519c2e3ce37..931f9bb0052 100644 --- a/.kokoro/presubmit/graalvm-native.cfg +++ b/.kokoro/presubmit/graalvm-native.cfg @@ -3,7 +3,7 @@ # Configure the docker image for kokoro-trampoline. env_vars: { key: "TRAMPOLINE_IMAGE" - value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.32.0" + value: "gcr.io/cloud-devrel-public-resources/graalvm_sdk_platform_a:3.33.0" } env_vars: { diff --git a/.readme-partials.yaml b/.readme-partials.yaml index 09b3632d24f..65ae24d8b58 100644 --- a/.readme-partials.yaml +++ b/.readme-partials.yaml @@ -183,6 +183,7 @@ custom_content: | > Note: The attribute keys that are used for additional information about retry attempts and the number of requests might change in a future release. + ### Instrument with OpenCensus > Note: OpenCensus project is deprecated. See [Sunsetting OpenCensus](https://opentelemetry.io/blog/2023/sunsetting-opencensus/). @@ -315,6 +316,38 @@ custom_content: | Spanner spanner = options.getService(); ``` + + #### OpenTelemetry SQL Statement Tracing + The OpenTelemetry traces that are generated by the Java client include any request and transaction + tags that have been set. The traces can also include the SQL statements that are executed and the + name of the thread that executes the statement. Enable this with the `enableExtendedTracing` + option: + + ``` + SpannerOptions options = SpannerOptions.newBuilder() + .setOpenTelemetry(openTelemetry) + .setEnableExtendedTracing(true) + .build(); + ``` + + This option can also be enabled by setting the environment variable + `SPANNER_ENABLE_EXTENDED_TRACING=true`. + + #### OpenTelemetry API Tracing + You can enable tracing of each API call that the Spanner client executes with the `enableApiTracing` + option. These traces also include any retry attempts for an API call: + + ``` + SpannerOptions options = SpannerOptions.newBuilder() + .setOpenTelemetry(openTelemetry) + .setEnableApiTracing(true) + .build(); + ``` + + This option can also be enabled by setting the environment variable + `SPANNER_ENABLE_API_TRACING=true`. + + > Note: The attribute keys that are used for additional information about retry attempts and the number of requests might change in a future release. ## Migrate from OpenCensus to OpenTelemetry diff --git a/.repo-metadata.json b/.repo-metadata.json index 80355fa2aff..7848b32f2b6 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -2,21 +2,20 @@ "api_shortname": "spanner", "name_pretty": "Cloud Spanner", "product_documentation": "https://cloud.google.com/spanner/docs/", + "api_description": "is a fully managed, mission-critical, relational database service that offers transactional consistency at global scale, \\nschemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication \\nfor high availability.\\n\\nBe sure to activate the Cloud Spanner API on the Developer's Console to\\nuse Cloud Spanner from your project.", "client_documentation": "https://cloud.google.com/java/docs/reference/google-cloud-spanner/latest/history", - "api_description": "is a fully managed, mission-critical, \nrelational database service that offers transactional consistency at global scale, \nschemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication \nfor high availability.\n\nBe sure to activate the Cloud Spanner API on the Developer's Console to\nuse Cloud Spanner from your project.", - "issue_tracker": "https://issuetracker.google.com/issues?q=componentid:190851%2B%20status:open", "release_level": "stable", + "transport": "grpc", "language": "java", - "min_java_version": 8, "repo": "googleapis/java-spanner", "repo_short": "java-spanner", "distribution_name": "com.google.cloud:google-cloud-spanner", "api_id": "spanner.googleapis.com", - "transport": "grpc", + "library_type": "GAPIC_COMBO", "requires_billing": true, "codeowner_team": "@googleapis/api-spanner-java", - "library_type": "GAPIC_COMBO", "excluded_poms": "google-cloud-spanner-bom", - "recommended_package": "com.google.cloud.spanner" -} - + "issue_tracker": "https://issuetracker.google.com/issues?q=componentid:190851%2B%20status:open", + "recommended_package": "com.google.cloud.spanner", + "min_java_version": 8 +} \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e996cccc5a4..fc0757052a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,36 @@ # Changelog +## [6.72.0](https://github.com/googleapis/java-spanner/compare/v6.71.0...v6.72.0) (2024-08-07) + + +### Features + +* Add `RESOURCE_EXHAUSTED` to the list of retryable error codes ([e859b29](https://github.com/googleapis/java-spanner/commit/e859b29ccf4e68b1ab62cffdd4cf197011ba9878)) +* Add field order_by in spanner.proto ([e859b29](https://github.com/googleapis/java-spanner/commit/e859b29ccf4e68b1ab62cffdd4cf197011ba9878)) +* Add QueryCancellationAction message in executor protos ([e859b29](https://github.com/googleapis/java-spanner/commit/e859b29ccf4e68b1ab62cffdd4cf197011ba9878)) +* Add SessionPoolOptions, SpannerOptions protos in executor protos ([e859b29](https://github.com/googleapis/java-spanner/commit/e859b29ccf4e68b1ab62cffdd4cf197011ba9878)) +* Add support for multi region encryption config ([e859b29](https://github.com/googleapis/java-spanner/commit/e859b29ccf4e68b1ab62cffdd4cf197011ba9878)) +* Enable hermetic library generation ([#3129](https://github.com/googleapis/java-spanner/issues/3129)) ([94b2a86](https://github.com/googleapis/java-spanner/commit/94b2a8610ac02d2b4212c421f03b4e9561ec9949)) +* **spanner:** Add samples for instance partitions ([#3221](https://github.com/googleapis/java-spanner/issues/3221)) ([bc48bf2](https://github.com/googleapis/java-spanner/commit/bc48bf212e37441221b3b6c8742b07ff601f6c41)) +* **spanner:** Add support for Cloud Spanner Scheduled Backups ([e859b29](https://github.com/googleapis/java-spanner/commit/e859b29ccf4e68b1ab62cffdd4cf197011ba9878)) +* **spanner:** Adding `EXPECTED_FULFILLMENT_PERIOD` to the indicate instance creation times (with `FULFILLMENT_PERIOD_NORMAL` or `FULFILLMENT_PERIOD_EXTENDED` ENUM) with the extended instance creation time triggered by On-Demand Capacity Feature ([e859b29](https://github.com/googleapis/java-spanner/commit/e859b29ccf4e68b1ab62cffdd4cf197011ba9878)) +* **spanner:** Set manual affinity incase of gRPC-GCP extenstion ([#3215](https://github.com/googleapis/java-spanner/issues/3215)) ([86b306a](https://github.com/googleapis/java-spanner/commit/86b306a4189483a5fd2746052bed817443630567)) +* Support Read RPC OrderBy ([#3180](https://github.com/googleapis/java-spanner/issues/3180)) ([735bca5](https://github.com/googleapis/java-spanner/commit/735bca523e4ea53a24929fb2c27d282c41350e91)) + + +### Bug Fixes + +* Make sure commitAsync always finishes ([#3216](https://github.com/googleapis/java-spanner/issues/3216)) ([440c88b](https://github.com/googleapis/java-spanner/commit/440c88bd67e1c9d08445fe26b01bf243f7fd1ca4)) +* SessionPoolOptions.Builder#toBuilder() skipped useMultiplexedSessions ([#3197](https://github.com/googleapis/java-spanner/issues/3197)) ([027f92c](https://github.com/googleapis/java-spanner/commit/027f92cf32fee8217d2075db61fe0be58d43a40d)) + + +### Dependencies + +* Bump sdk-platform-java-config to 3.33.0 ([#3243](https://github.com/googleapis/java-spanner/issues/3243)) ([35907c6](https://github.com/googleapis/java-spanner/commit/35907c63ae981612ba24dd9605db493b5b864217)) +* Update dependencies to latest ([#3250](https://github.com/googleapis/java-spanner/issues/3250)) ([d1d566b](https://github.com/googleapis/java-spanner/commit/d1d566b096915a537e0978715c81bfca00e34ceb)) +* Update dependency com.google.auto.value:auto-value-annotations to v1.11.0 ([#3191](https://github.com/googleapis/java-spanner/issues/3191)) ([065cd48](https://github.com/googleapis/java-spanner/commit/065cd489964aaee42fffe1e71327906bde907205)) +* Update dependency com.google.cloud:google-cloud-trace to v2.47.0 ([#3067](https://github.com/googleapis/java-spanner/issues/3067)) ([e336ab8](https://github.com/googleapis/java-spanner/commit/e336ab81a1d392d56386f9302bf51bf14e385dad)) + ## [6.71.0](https://github.com/googleapis/java-spanner/compare/v6.70.0...v6.71.0) (2024-07-03) diff --git a/README.md b/README.md index 979d8832013..352b0c44967 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file: com.google.cloud libraries-bom - 26.39.0 + 26.43.0 pom import @@ -42,7 +42,7 @@ If you are using Maven without the BOM, add this to your dependencies: com.google.cloud google-cloud-spanner - 6.67.0 + 6.71.0 ``` @@ -50,20 +50,20 @@ If you are using Maven without the BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies: ```Groovy -implementation platform('com.google.cloud:libraries-bom:26.42.0') +implementation platform('com.google.cloud:libraries-bom:26.43.0') implementation 'com.google.cloud:google-cloud-spanner' ``` If you are using Gradle without BOM, add this to your dependencies: ```Groovy -implementation 'com.google.cloud:google-cloud-spanner:6.70.0' +implementation 'com.google.cloud:google-cloud-spanner:6.71.0' ``` If you are using SBT, add this to your dependencies: ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.70.0" +libraryDependencies += "com.google.cloud" % "google-cloud-spanner" % "6.71.0" ``` @@ -93,13 +93,7 @@ to add `google-cloud-spanner` as a dependency in your code. ## About Cloud Spanner -[Cloud Spanner][product-docs] is a fully managed, mission-critical, -relational database service that offers transactional consistency at global scale, -schemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication -for high availability. - -Be sure to activate the Cloud Spanner API on the Developer's Console to -use Cloud Spanner from your project. +[Cloud Spanner][product-docs] is a fully managed, mission-critical, relational database service that offers transactional consistency at global scale, \nschemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication \nfor high availability.\n\nBe sure to activate the Cloud Spanner API on the Developer's Console to\nuse Cloud Spanner from your project. See the [Cloud Spanner client library docs][javadocs] to learn how to use this Cloud Spanner Client Library. @@ -289,6 +283,7 @@ This option can also be enabled by setting the environment variable > Note: The attribute keys that are used for additional information about retry attempts and the number of requests might change in a future release. + ### Instrument with OpenCensus > Note: OpenCensus project is deprecated. See [Sunsetting OpenCensus](https://opentelemetry.io/blog/2023/sunsetting-opencensus/). @@ -422,6 +417,38 @@ SpannerOptions options = SpannerOptions.newBuilder() Spanner spanner = options.getService(); ``` +#### OpenTelemetry SQL Statement Tracing +The OpenTelemetry traces that are generated by the Java client include any request and transaction +tags that have been set. The traces can also include the SQL statements that are executed and the +name of the thread that executes the statement. Enable this with the `enableExtendedTracing` +option: + +``` +SpannerOptions options = SpannerOptions.newBuilder() + .setOpenTelemetry(openTelemetry) + .setEnableExtendedTracing(true) + .build(); +``` + +This option can also be enabled by setting the environment variable +`SPANNER_ENABLE_EXTENDED_TRACING=true`. + +#### OpenTelemetry API Tracing +You can enable tracing of each API call that the Spanner client executes with the `enableApiTracing` +option. These traces also include any retry attempts for an API call: + +``` +SpannerOptions options = SpannerOptions.newBuilder() +.setOpenTelemetry(openTelemetry) +.setEnableApiTracing(true) +.build(); +``` + +This option can also be enabled by setting the environment variable +`SPANNER_ENABLE_API_TRACING=true`. + +> Note: The attribute keys that are used for additional information about retry attempts and the number of requests might change in a future release. + ## Migrate from OpenCensus to OpenTelemetry > Using the [OpenTelemetry OpenCensus Bridge](https://mvnrepository.com/artifact/io.opentelemetry/opentelemetry-opencensus-shim), you can immediately begin exporting your metrics and traces with OpenTelemetry @@ -688,7 +715,7 @@ Java is a registered trademark of Oracle and/or its affiliates. [kokoro-badge-link-5]: http://storage.googleapis.com/cloud-devrel-public/java/badges/java-spanner/java11.html [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-spanner.svg -[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-spanner/6.70.0 +[maven-version-link]: https://central.sonatype.com/artifact/com.google.cloud/google-cloud-spanner/6.71.0 [authentication]: https://github.com/googleapis/google-cloud-java#authentication [auth-scopes]: https://developers.google.com/identity/protocols/oauth2/scopes [predefined-iam-roles]: https://cloud.google.com/iam/docs/understanding-roles#predefined_roles diff --git a/benchmarks/pom.xml b/benchmarks/pom.xml index 7244dd6eb6b..ae700bd3372 100644 --- a/benchmarks/pom.xml +++ b/benchmarks/pom.xml @@ -24,7 +24,7 @@ com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 @@ -33,8 +33,8 @@ 1.8 UTF-8 UTF-8 - 2.9.1 - 1.39.0 + 2.10.0 + 1.40.0 @@ -49,12 +49,12 @@ com.google.cloud.opentelemetry exporter-trace - 0.29.0 + 0.31.0 com.google.cloud.opentelemetry exporter-metrics - 0.29.0 + 0.31.0 @@ -85,14 +85,14 @@ io.opentelemetry opentelemetry-bom - 1.39.0 + 1.40.0 pom import com.google.cloud google-cloud-spanner - 6.67.0 + 6.71.0 commons-cli @@ -102,7 +102,7 @@ com.google.auto.value auto-value-annotations - 1.10.4 + 1.11.0 com.kohlschutter.junixsocket @@ -133,7 +133,7 @@ org.codehaus.mojo exec-maven-plugin - 3.3.0 + 3.4.0 com.google.cloud.spanner.benchmark.LatencyBenchmark false diff --git a/generation_config.yaml b/generation_config.yaml new file mode 100644 index 00000000000..07eb1e3ac06 --- /dev/null +++ b/generation_config.yaml @@ -0,0 +1,28 @@ +gapic_generator_version: 2.43.0 +googleapis_commitish: 7314e20f5e3b2550b2e10a8c53f58ae57c511773 +libraries_bom_version: 26.43.0 +libraries: + - api_shortname: spanner + name_pretty: Cloud Spanner + product_documentation: https://cloud.google.com/spanner/docs/ + client_documentation: https://cloud.google.com/java/docs/reference/google-cloud-spanner/latest/history + api_description: is a fully managed, mission-critical, relational database service that offers transactional consistency at global scale, \nschemas, SQL (ANSI 2011 with extensions), and automatic, synchronous replication \nfor high availability.\n\nBe sure to activate the Cloud Spanner API on the Developer's Console to\nuse Cloud Spanner from your project. + issue_tracker: https://issuetracker.google.com/issues?q=componentid:190851%2B%20status:open + release_level: stable + language: java + min_java_version: 8 + repo: googleapis/java-spanner + repo_short: java-spanner + distribution_name: com.google.cloud:google-cloud-spanner + api_id: spanner.googleapis.com + transport: grpc + requires_billing: true + codeowner_team: '@googleapis/api-spanner-java' + library_type: GAPIC_COMBO + excluded_poms: google-cloud-spanner-bom + recommended_package: com.google.cloud.spanner + GAPICs: + - proto_path: google/spanner/admin/database/v1 + - proto_path: google/spanner/admin/instance/v1 + - proto_path: google/spanner/executor/v1 + - proto_path: google/spanner/v1 diff --git a/google-cloud-spanner-bom/pom.xml b/google-cloud-spanner-bom/pom.xml index 48bbd634f53..fa9e6207a2c 100644 --- a/google-cloud-spanner-bom/pom.xml +++ b/google-cloud-spanner-bom/pom.xml @@ -3,12 +3,12 @@ 4.0.0 com.google.cloud google-cloud-spanner-bom - 6.71.0 + 6.72.0 pom com.google.cloud sdk-platform-java-config - 3.32.0 + 3.33.0 Google Cloud Spanner BOM @@ -53,43 +53,43 @@ com.google.cloud google-cloud-spanner - 6.71.0 + 6.72.0 com.google.cloud google-cloud-spanner test-jar - 6.71.0 + 6.72.0 com.google.api.grpc grpc-google-cloud-spanner-v1 - 6.71.0 + 6.72.0 com.google.api.grpc grpc-google-cloud-spanner-admin-instance-v1 - 6.71.0 + 6.72.0 com.google.api.grpc grpc-google-cloud-spanner-admin-database-v1 - 6.71.0 + 6.72.0 com.google.api.grpc proto-google-cloud-spanner-admin-instance-v1 - 6.71.0 + 6.72.0 com.google.api.grpc proto-google-cloud-spanner-v1 - 6.71.0 + 6.72.0 com.google.api.grpc proto-google-cloud-spanner-admin-database-v1 - 6.71.0 + 6.72.0 diff --git a/google-cloud-spanner-executor/pom.xml b/google-cloud-spanner-executor/pom.xml index 63ef3b9cecf..3a99cd00624 100644 --- a/google-cloud-spanner-executor/pom.xml +++ b/google-cloud-spanner-executor/pom.xml @@ -5,14 +5,14 @@ 4.0.0 com.google.cloud google-cloud-spanner-executor - 6.71.0 + 6.72.0 jar Google Cloud Spanner Executor com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 @@ -188,7 +188,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.3.0 + 3.3.1 diff --git a/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java b/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java index 6d8ef262454..4de2e277ffa 100644 --- a/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java +++ b/google-cloud-spanner-executor/src/main/java/com/google/cloud/executor/spanner/CloudClientExecutor.java @@ -2665,6 +2665,7 @@ private Status processResults( executionContext.finishRead(Status.OK); return sender.finishWithOK(); } catch (SpannerException e) { + LOGGER.log(Level.WARNING, "Encountered exception: ", e); Status status = toStatus(e); LOGGER.log( Level.WARNING, diff --git a/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/executor/v1/stub/SpannerExecutorProxyStubSettings.java b/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/executor/v1/stub/SpannerExecutorProxyStubSettings.java index 2b8c17ada97..88843026f4f 100644 --- a/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/executor/v1/stub/SpannerExecutorProxyStubSettings.java +++ b/google-cloud-spanner-executor/src/main/java/com/google/cloud/spanner/executor/v1/stub/SpannerExecutorProxyStubSettings.java @@ -17,6 +17,7 @@ package com.google.cloud.spanner.executor.v1.stub; import com.google.api.core.ApiFunction; +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; @@ -119,6 +120,7 @@ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuild } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "spanner-cloud-executor.googleapis.com:443"; } diff --git a/google-cloud-spanner-executor/src/main/resources/META-INF/native-image/com.google.cloud.spanner.executor.v1/reflect-config.json b/google-cloud-spanner-executor/src/main/resources/META-INF/native-image/com.google.cloud.spanner.executor.v1/reflect-config.json index 1bbd31bc982..e28206a3de9 100644 --- a/google-cloud-spanner-executor/src/main/resources/META-INF/native-image/com.google.cloud.spanner.executor.v1/reflect-config.json +++ b/google-cloud-spanner-executor/src/main/resources/META-INF/native-image/com.google.cloud.spanner.executor.v1/reflect-config.json @@ -1709,6 +1709,42 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.BackupSchedule", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.BackupSchedule$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.BackupScheduleSpec", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.BackupScheduleSpec$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig", "queryAllDeclaredConstructors": true, @@ -1835,6 +1871,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.CreateBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.CreateBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.CreateDatabaseMetadata", "queryAllDeclaredConstructors": true, @@ -1871,6 +1925,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.CrontabSpec", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.CrontabSpec$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.Database", "queryAllDeclaredConstructors": true, @@ -1961,6 +2033,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.DropDatabaseRequest", "queryAllDeclaredConstructors": true, @@ -2024,6 +2114,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.FullBackupSpec", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.FullBackupSpec$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.GetBackupRequest", "queryAllDeclaredConstructors": true, @@ -2042,6 +2150,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.GetBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.GetBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.GetDatabaseDdlRequest", "queryAllDeclaredConstructors": true, @@ -2096,6 +2222,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.IncrementalBackupSpec", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.IncrementalBackupSpec$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.ListBackupOperationsRequest", "queryAllDeclaredConstructors": true, @@ -2132,6 +2276,42 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.ListBackupSchedulesRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.ListBackupSchedulesRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.ListBackupSchedulesResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.ListBackupSchedulesResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.ListBackupsRequest", "queryAllDeclaredConstructors": true, @@ -2420,6 +2600,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata", "queryAllDeclaredConstructors": true, diff --git a/google-cloud-spanner/pom.xml b/google-cloud-spanner/pom.xml index e56fdb154a6..5f42b91fd7e 100644 --- a/google-cloud-spanner/pom.xml +++ b/google-cloud-spanner/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-spanner - 6.71.0 + 6.72.0 jar Google Cloud Spanner https://github.com/googleapis/java-spanner @@ -11,7 +11,7 @@ com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 google-cloud-spanner @@ -107,7 +107,7 @@ com.google.cloud.spanner.ParallelIntegrationTest - 8 + 12 true com.google.cloud.spanner.ParallelIntegrationTest @@ -266,12 +266,12 @@ com.google.cloud google-cloud-monitoring - 3.38.0 + 3.48.0 com.google.api.grpc proto-google-cloud-monitoring-v3 - 3.38.0 + 3.48.0 com.google.auth diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractReadContext.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractReadContext.java index a424a93115a..92ebf006d29 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractReadContext.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/AbstractReadContext.java @@ -902,6 +902,9 @@ ResultSet readInternalWithOptions( if (readOptions.hasDataBoostEnabled()) { builder.setDataBoostEnabled(readOptions.dataBoostEnabled()); } + if (readOptions.hasOrderBy()) { + builder.setOrderBy(readOptions.orderBy()); + } if (readOptions.hasDirectedReadOptions()) { builder.setDirectedReadOptions(readOptions.directedReadOptions()); } else if (defaultDirectedReadOptions != null) { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java index eed687c416d..07d1310e91b 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/CompositeTracer.java @@ -114,6 +114,13 @@ public void attemptFailed(Throwable error, Duration delay) { } } + @Override + public void attemptFailedDuration(Throwable error, java.time.Duration delay) { + for (ApiTracer child : children) { + child.attemptFailedDuration(error, delay); + } + } + @Override public void attemptFailedRetriesExhausted(Throwable error) { for (ApiTracer child : children) { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Options.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Options.java index 58123ae36b8..9c3257586fb 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Options.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Options.java @@ -18,6 +18,7 @@ import com.google.common.base.Preconditions; import com.google.spanner.v1.DirectedReadOptions; +import com.google.spanner.v1.ReadRequest.OrderBy; import com.google.spanner.v1.RequestOptions.Priority; import java.io.Serializable; import java.time.Duration; @@ -51,6 +52,29 @@ public static RpcPriority fromProto(Priority proto) { } } + /** + * OrderBy for an RPC invocation. The default orderby is {@link #PRIMARY_KEY}. This enum can be + * used to control the order in which rows are returned from a read. + */ + public enum RpcOrderBy { + PRIMARY_KEY(OrderBy.ORDER_BY_PRIMARY_KEY), + NO_ORDER(OrderBy.ORDER_BY_NO_ORDER), + UNSPECIFIED(OrderBy.ORDER_BY_UNSPECIFIED); + + private final OrderBy proto; + + RpcOrderBy(OrderBy proto) { + this.proto = Preconditions.checkNotNull(proto); + } + + public static RpcOrderBy fromProto(OrderBy proto) { + for (RpcOrderBy e : RpcOrderBy.values()) { + if (e.proto.equals(proto)) return e; + } + return RpcOrderBy.UNSPECIFIED; + } + } + /** Marker interface to mark options applicable to both Read and Query operations */ public interface ReadAndQueryOption extends ReadOption, QueryOption {} @@ -131,6 +155,11 @@ public static ReadOption limit(long limit) { return new LimitOption(limit); } + /** Specifies the order_by to use for the RPC. */ + public static ReadOption orderBy(RpcOrderBy orderBy) { + return new OrderByOption(orderBy); + } + /** * Specifying this will allow the client to prefetch up to {@code prefetchChunks} {@code * PartialResultSet} chunks for read and query. The data size of each chunk depends on the server @@ -439,6 +468,7 @@ void appendToOptions(Options options) { private Boolean dataBoostEnabled; private DirectedReadOptions directedReadOptions; private DecodeMode decodeMode; + private RpcOrderBy orderBy; // Construction is via factory methods below. private Options() {} @@ -567,6 +597,14 @@ DecodeMode decodeMode() { return decodeMode; } + boolean hasOrderBy() { + return orderBy != null; + } + + OrderBy orderBy() { + return orderBy == null ? null : orderBy.proto; + } + @Override public String toString() { StringBuilder b = new StringBuilder(); @@ -620,6 +658,9 @@ public String toString() { if (decodeMode != null) { b.append("decodeMode: ").append(decodeMode).append(' '); } + if (orderBy != null) { + b.append("orderBy: ").append(orderBy).append(' '); + } return b.toString(); } @@ -658,7 +699,8 @@ public boolean equals(Object o) { && Objects.equals(withOptimisticLock(), that.withOptimisticLock()) && Objects.equals(withExcludeTxnFromChangeStreams(), that.withExcludeTxnFromChangeStreams()) && Objects.equals(dataBoostEnabled(), that.dataBoostEnabled()) - && Objects.equals(directedReadOptions(), that.directedReadOptions()); + && Objects.equals(directedReadOptions(), that.directedReadOptions()) + && Objects.equals(orderBy(), that.orderBy()); } @Override @@ -715,6 +757,9 @@ public int hashCode() { if (decodeMode != null) { result = 31 * result + decodeMode.hashCode(); } + if (orderBy != null) { + result = 31 * result + orderBy.hashCode(); + } return result; } @@ -795,6 +840,19 @@ void appendToOptions(Options options) { } } + static class OrderByOption extends InternalOption implements ReadOption { + private final RpcOrderBy orderBy; + + OrderByOption(RpcOrderBy orderBy) { + this.orderBy = orderBy; + } + + @Override + void appendToOptions(Options options) { + options.orderBy = orderBy; + } + } + static final class DataBoostQueryOption extends InternalOption implements ReadAndQueryOption { private final Boolean dataBoostEnabled; diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java index f36da57a816..1819224495d 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPool.java @@ -65,7 +65,6 @@ import com.google.cloud.spanner.SpannerImpl.ClosedException; import com.google.cloud.spanner.spi.v1.SpannerRpc; import com.google.common.annotations.VisibleForTesting; -import com.google.common.base.Function; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -107,9 +106,10 @@ import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicLong; -import java.util.concurrent.atomic.AtomicReference; +import java.util.function.Function; import java.util.logging.Level; import java.util.logging.Logger; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import javax.annotation.concurrent.GuardedBy; import org.threeten.bp.Duration; @@ -144,14 +144,6 @@ void maybeWaitOnMinSessions() { ErrorCode.DEADLINE_EXCEEDED, "Timed out after waiting " + timeoutMillis + "ms for session pool creation"); } - - if (useMultiplexedSessions() - && !waitOnMultiplexedSessionsLatch.await(timeoutNanos, TimeUnit.NANOSECONDS)) { - final long timeoutMillis = options.getWaitForMinSessions().toMillis(); - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.DEADLINE_EXCEEDED, - "Timed out after waiting " + timeoutMillis + "ms for multiplexed session creation"); - } } catch (InterruptedException e) { throw SpannerExceptionFactory.propagateInterrupt(e); } @@ -241,7 +233,7 @@ public ApiFuture setCallback(Executor exec, ReadyCallback cb) { private AutoClosingReadContext( Function delegateSupplier, SessionPool sessionPool, - SessionReplacementHandler sessionReplacementHandler, + SessionReplacementHandler sessionReplacementHandler, I session, boolean isSingleUse) { this.readContextDelegateSupplier = delegateSupplier; @@ -554,7 +546,7 @@ private static class AutoClosingReadTransaction AutoClosingReadTransaction( Function txnSupplier, SessionPool sessionPool, - SessionReplacementHandler sessionReplacementHandler, + SessionReplacementHandler sessionReplacementHandler, I session, boolean isSingleUse) { super(txnSupplier, sessionPool, sessionReplacementHandler, session, isSingleUse); @@ -590,23 +582,6 @@ public PooledSessionFuture replaceSession( } } - static class MultiplexedSessionReplacementHandler - implements SessionReplacementHandler { - @Override - public MultiplexedSessionFuture replaceSession( - SessionNotFoundException e, MultiplexedSessionFuture session) { - /** - * For multiplexed sessions, we would never obtain a {@link SessionNotFoundException}. Hence, - * this method will ideally never be invoked. - */ - logger.log( - Level.WARNING, - String.format( - "Replace session invoked for multiplexed session => %s", session.getName())); - throw e; - } - } - interface SessionNotFoundHandler { /** * Handles the given {@link SessionNotFoundException} by possibly converting it to a different @@ -781,10 +756,13 @@ public ApiFuture bufferAsync(Iterable mutations) { return delegate.bufferAsync(mutations); } + @SuppressWarnings("deprecation") @Override public ResultSetStats analyzeUpdate( Statement statement, QueryAnalyzeMode analyzeMode, UpdateOption... options) { - return analyzeUpdateStatement(statement, analyzeMode, options).getStats(); + try (ResultSet resultSet = analyzeUpdateStatement(statement, analyzeMode, options)) { + return resultSet.getStats(); + } } @Override @@ -870,7 +848,7 @@ private static class AutoClosingTransactionManager AutoClosingTransactionManager( T session, - SessionReplacementHandler sessionReplacementHandler, + SessionReplacementHandler sessionReplacementHandler, TransactionOption... options) { this.session = session; this.options = options; @@ -1000,7 +978,7 @@ private static final class SessionPoolTransactionRunner private SessionPoolTransactionRunner( I session, - SessionReplacementHandler sessionReplacementHandler, + SessionReplacementHandler sessionReplacementHandler, TransactionOption... options) { this.session = session; this.options = options; @@ -1032,6 +1010,7 @@ public T run(TransactionCallable callable) { session.get().markUsed(); return result; } catch (SpannerException e) { + //noinspection ThrowableNotThrown session.get().setLastException(e); throw e; } finally { @@ -1064,7 +1043,7 @@ private static class SessionPoolAsyncRunner implements private SessionPoolAsyncRunner( I session, - SessionReplacementHandler sessionReplacementHandler, + SessionReplacementHandler sessionReplacementHandler, TransactionOption... options) { this.session = session; this.options = options; @@ -1100,7 +1079,6 @@ public ApiFuture runAsync(final AsyncWork work, Executor executor) { session = sessionReplacementHandler.replaceSession( (SessionNotFoundException) se, session); - se = null; } catch (SessionNotFoundException e) { exception = e; break; @@ -1266,39 +1244,6 @@ public PooledSessionFuture get() { } } - class MultiplexedSessionFutureWrapper implements SessionFutureWrapper { - private ISpan span; - private volatile MultiplexedSessionFuture multiplexedSessionFuture; - - public MultiplexedSessionFutureWrapper(ISpan span) { - this.span = span; - } - - @Override - public MultiplexedSessionFuture get() { - if (resourceNotFoundException != null) { - span.addAnnotation("Database has been deleted"); - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.NOT_FOUND, - String.format( - "The session pool has been invalidated because a previous RPC returned 'Database not found': %s", - resourceNotFoundException.getMessage()), - resourceNotFoundException); - } - if (multiplexedSessionFuture == null) { - synchronized (lock) { - if (multiplexedSessionFuture == null) { - // Creating a new reference where the request's span state can be stored. - MultiplexedSessionFuture multiplexedSessionFuture = new MultiplexedSessionFuture(span); - this.multiplexedSessionFuture = multiplexedSessionFuture; - return multiplexedSessionFuture; - } - } - } - return multiplexedSessionFuture; - } - } - interface SessionFuture extends Session { /** @@ -1318,8 +1263,8 @@ class PooledSessionFuture extends SimpleForwardingListenableFuture(this, pooledSessionReplacementHandler, options); } @Override @@ -1563,7 +1508,7 @@ PooledSession get(final boolean eligibleForLongRunning) { res.markBusy(span); span.addAnnotation("Using Session", "sessionId", res.getName()); synchronized (lock) { - incrementNumSessionsInUse(false); + incrementNumSessionsInUse(); checkedOutSessions.add(this); } res.eligibleForLongRunning = eligibleForLongRunning; @@ -1581,247 +1526,6 @@ PooledSession get(final boolean eligibleForLongRunning) { } } - class MultiplexedSessionFuture implements SessionFuture { - - private final ISpan span; - private volatile MultiplexedSession multiplexedSession; - - MultiplexedSessionFuture(ISpan span) { - this.span = span; - } - - @Override - public Timestamp write(Iterable mutations) throws SpannerException { - return writeWithOptions(mutations).getCommitTimestamp(); - } - - @Override - public CommitResponse writeWithOptions( - Iterable mutations, TransactionOption... options) throws SpannerException { - try { - return get().writeWithOptions(mutations, options); - } finally { - close(); - } - } - - @Override - public Timestamp writeAtLeastOnce(Iterable mutations) throws SpannerException { - return writeAtLeastOnceWithOptions(mutations).getCommitTimestamp(); - } - - @Override - public CommitResponse writeAtLeastOnceWithOptions( - Iterable mutations, TransactionOption... options) throws SpannerException { - try { - return get().writeAtLeastOnceWithOptions(mutations, options); - } finally { - close(); - } - } - - @Override - public ServerStream batchWriteAtLeastOnce( - Iterable mutationGroups, TransactionOption... options) - throws SpannerException { - try { - return get().batchWriteAtLeastOnce(mutationGroups, options); - } finally { - close(); - } - } - - @Override - public ReadContext singleUse() { - try { - return new AutoClosingReadContext<>( - session -> { - MultiplexedSession multiplexedSession = session.get(); - return multiplexedSession.getDelegate().singleUse(); - }, - SessionPool.this, - multiplexedSessionReplacementHandler, - this, - true); - } catch (Exception e) { - close(); - throw e; - } - } - - @Override - public ReadContext singleUse(final TimestampBound bound) { - try { - return new AutoClosingReadContext<>( - session -> { - MultiplexedSession multiplexedSession = session.get(); - return multiplexedSession.getDelegate().singleUse(bound); - }, - SessionPool.this, - multiplexedSessionReplacementHandler, - this, - true); - } catch (Exception e) { - close(); - throw e; - } - } - - @Override - public ReadOnlyTransaction singleUseReadOnlyTransaction() { - return internalReadOnlyTransaction( - session -> { - MultiplexedSession multiplexedSession = session.get(); - return multiplexedSession.getDelegate().singleUseReadOnlyTransaction(); - }, - true); - } - - @Override - public ReadOnlyTransaction singleUseReadOnlyTransaction(final TimestampBound bound) { - return internalReadOnlyTransaction( - session -> { - MultiplexedSession multiplexedSession = session.get(); - return multiplexedSession.getDelegate().singleUseReadOnlyTransaction(bound); - }, - true); - } - - @Override - public ReadOnlyTransaction readOnlyTransaction() { - return internalReadOnlyTransaction( - session -> { - MultiplexedSession multiplexedSession = session.get(); - return multiplexedSession.getDelegate().readOnlyTransaction(); - }, - false); - } - - @Override - public ReadOnlyTransaction readOnlyTransaction(final TimestampBound bound) { - return internalReadOnlyTransaction( - session -> { - MultiplexedSession multiplexedSession = session.get(); - return multiplexedSession.getDelegate().readOnlyTransaction(bound); - }, - false); - } - - private ReadOnlyTransaction internalReadOnlyTransaction( - Function transactionSupplier, - boolean isSingleUse) { - try { - return new AutoClosingReadTransaction<>( - transactionSupplier, - SessionPool.this, - multiplexedSessionReplacementHandler, - this, - isSingleUse); - } catch (Exception e) { - close(); - throw e; - } - } - - @Override - public TransactionRunner readWriteTransaction(TransactionOption... options) { - return new SessionPoolTransactionRunner<>( - this, multiplexedSessionReplacementHandler, options); - } - - @Override - public TransactionManager transactionManager(TransactionOption... options) { - return new AutoClosingTransactionManager<>( - this, multiplexedSessionReplacementHandler, options); - } - - @Override - public AsyncRunner runAsync(TransactionOption... options) { - return new SessionPoolAsyncRunner(this, multiplexedSessionReplacementHandler, options); - } - - @Override - public AsyncTransactionManager transactionManagerAsync(TransactionOption... options) { - return new SessionPoolAsyncTransactionManager<>( - multiplexedSessionReplacementHandler, this, options); - } - - @Override - public long executePartitionedUpdate(Statement stmt, UpdateOption... options) { - try { - return get().executePartitionedUpdate(stmt, options); - } finally { - close(); - } - } - - @Override - public String getName() { - return get().getName(); - } - - @Override - public void close() { - try { - asyncClose().get(); - } catch (InterruptedException e) { - throw SpannerExceptionFactory.propagateInterrupt(e); - } catch (ExecutionException e) { - throw asSpannerException(e.getCause()); - } - } - - @Override - public ApiFuture asyncClose() { - MultiplexedSession delegate = getOrNull(); - if (delegate != null) { - return delegate.asyncClose(); - } - return ApiFutures.immediateFuture(Empty.getDefaultInstance()); - } - - private MultiplexedSession getOrNull() { - try { - return get(); - } catch (Throwable ignore) { - // this exception will never be thrown for a multiplexed session since the Future - // object is already initialised. - return null; - } - } - - @Override - public MultiplexedSession get() { - try { - if (multiplexedSession == null) { - boolean created = false; - synchronized (this) { - if (multiplexedSession == null) { - SessionImpl sessionImpl = - new SessionImpl( - sessionClient.getSpanner(), currentMultiplexedSessionReference.get().get()); - MultiplexedSession multiplexedSession = new MultiplexedSession(sessionImpl); - multiplexedSession.markBusy(span); - span.addAnnotation("Using Session", "sessionId", multiplexedSession.getName()); - this.multiplexedSession = multiplexedSession; - created = true; - } - } - if (created) { - synchronized (lock) { - incrementNumSessionsInUse(true); - } - } - } - return multiplexedSession; - } catch (ExecutionException e) { - throw SpannerExceptionFactory.newSpannerException(e.getCause()); - } catch (InterruptedException e) { - throw SpannerExceptionFactory.propagateInterrupt(e); - } - } - } - interface CachedSession extends Session { SessionImpl getDelegate(); @@ -1832,9 +1536,6 @@ interface CachedSession extends Session { SpannerException setLastException(SpannerException exception); - // TODO This method can be removed once we fully migrate to multiplexed sessions. - boolean isAllowReplacing(); - AsyncTransactionManagerImpl transactionManagerAsync(TransactionOption... options); void setAllowReplacing(boolean b); @@ -2024,7 +1725,7 @@ public void close() { if ((lastException != null && isSessionNotFound(lastException)) || isRemovedFromPool) { invalidateSession(this); } else { - if (lastException != null && isDatabaseOrInstanceNotFound(lastException)) { + if (isDatabaseOrInstanceNotFound(lastException)) { // Mark this session pool as no longer valid and then release the session into the pool as // there is nothing we can do with it anyways. synchronized (lock) { @@ -2116,8 +1817,7 @@ public SpannerException setLastException(SpannerException exception) { return exception; } - @Override - public boolean isAllowReplacing() { + boolean isAllowReplacing() { return this.allowReplacing; } @@ -2127,172 +1827,12 @@ public TransactionManager transactionManager(TransactionOption... options) { } } - class MultiplexedSession implements CachedSession { - final SessionImpl delegate; - private volatile SpannerException lastException; - - MultiplexedSession(SessionImpl session) { - this.delegate = session; - } - - @Override - public boolean isAllowReplacing() { - // for multiplexed session there is only 1 session, hence there is nothing that we - // can replace. - return false; - } - - @Override - public void setAllowReplacing(boolean allowReplacing) { - // for multiplexed session there is only 1 session, there is nothing that can be replaced. - // hence this is no-op. - } - - @Override - public void markBusy(ISpan span) { - this.delegate.setCurrentSpan(span); - } - - @Override - public void markUsed() { - // no-op for a multiplexed session since we don't track the last-used time - // in case of multiplexed session - } - - @Override - public SpannerException setLastException(SpannerException exception) { - this.lastException = exception; - return exception; - } - - @Override - public SessionImpl getDelegate() { - return delegate; - } - - @Override - public Timestamp write(Iterable mutations) throws SpannerException { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNIMPLEMENTED, "Unimplemented with Multiplexed Session"); - } - - @Override - public CommitResponse writeWithOptions( - Iterable mutations, TransactionOption... options) throws SpannerException { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNIMPLEMENTED, "Unimplemented with Multiplexed Session"); - } - - @Override - public Timestamp writeAtLeastOnce(Iterable mutations) throws SpannerException { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNIMPLEMENTED, "Unimplemented with Multiplexed Session"); - } - - @Override - public CommitResponse writeAtLeastOnceWithOptions( - Iterable mutations, TransactionOption... options) throws SpannerException { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNIMPLEMENTED, "Unimplemented with Multiplexed Session"); - } - - @Override - public ServerStream batchWriteAtLeastOnce( - Iterable mutationGroups, TransactionOption... options) - throws SpannerException { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNIMPLEMENTED, "Unimplemented with Multiplexed Session"); - } - - @Override - public ReadContext singleUse() { - return delegate.singleUse(); - } - - @Override - public ReadContext singleUse(TimestampBound bound) { - return delegate.singleUse(bound); - } - - @Override - public ReadOnlyTransaction singleUseReadOnlyTransaction() { - return delegate.singleUseReadOnlyTransaction(); - } - - @Override - public ReadOnlyTransaction singleUseReadOnlyTransaction(TimestampBound bound) { - return delegate.singleUseReadOnlyTransaction(bound); - } - - @Override - public ReadOnlyTransaction readOnlyTransaction() { - return delegate.readOnlyTransaction(); - } - - @Override - public ReadOnlyTransaction readOnlyTransaction(TimestampBound bound) { - return delegate.readOnlyTransaction(bound); - } - - @Override - public TransactionRunner readWriteTransaction(TransactionOption... options) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNIMPLEMENTED, "Unimplemented with Multiplexed Session"); - } - - @Override - public TransactionManager transactionManager(TransactionOption... options) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNIMPLEMENTED, "Unimplemented with Multiplexed Session"); - } - - @Override - public AsyncRunner runAsync(TransactionOption... options) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNIMPLEMENTED, "Unimplemented with Multiplexed Session"); - } - - @Override - public AsyncTransactionManagerImpl transactionManagerAsync(TransactionOption... options) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNIMPLEMENTED, "Unimplemented with Multiplexed Session"); - } - - @Override - public long executePartitionedUpdate(Statement stmt, UpdateOption... options) { - throw SpannerExceptionFactory.newSpannerException( - ErrorCode.UNIMPLEMENTED, "Unimplemented with Multiplexed Session"); - } - - @Override - public String getName() { - return delegate.getName(); - } - - @Override - public void close() { - synchronized (lock) { - if (lastException != null && isDatabaseOrInstanceNotFound(lastException)) { - SessionPool.this.resourceNotFoundException = - MoreObjects.firstNonNull( - SessionPool.this.resourceNotFoundException, - (ResourceNotFoundException) lastException); - } - } - } - - @Override - public ApiFuture asyncClose() { - close(); - return ApiFutures.immediateFuture(Empty.getDefaultInstance()); - } - } - private final class WaiterFuture extends ForwardingListenableFuture { private static final long MAX_SESSION_WAIT_TIMEOUT = 240_000L; private final SettableFuture waiter = SettableFuture.create(); @Override + @Nonnull protected ListenableFuture delegate() { return waiter; } @@ -2310,7 +1850,7 @@ public PooledSession get() { long currentTimeout = options.getInitialWaitForSessionTimeoutMillis(); while (true) { ISpan span = tracer.spanBuilder(WAIT_FOR_SESSION); - try (IScope waitScope = tracer.withSpan(span)) { + try (IScope ignore = tracer.withSpan(span)) { PooledSession s = pollUninterruptiblyWithTimeout(currentTimeout, options.getAcquireSessionTimeout()); if (s == null) { @@ -2395,9 +1935,6 @@ private PooledSession pollUninterruptiblyWithTimeout( */ final class PoolMaintainer { - // Delay post which the maintainer will retry creating/replacing the current multiplexed session - private final Duration multiplexedSessionCreationRetryDelay = Duration.ofMinutes(10); - // Length of the window in millis over which we keep track of maximum number of concurrent // sessions in use. private final Duration windowLength = Duration.ofMillis(TimeUnit.MINUTES.toMillis(10)); @@ -2421,8 +1958,6 @@ final class PoolMaintainer { */ @VisibleForTesting Instant lastExecutionTime; - @VisibleForTesting Instant multiplexedSessionReplacementAttemptTime; - /** * The previous numSessionsAcquired seen by the maintainer. This is used to calculate the * transactions per second, which again is used to determine whether to randomize the order of @@ -2440,7 +1975,6 @@ final class PoolMaintainer { void init() { lastExecutionTime = clock.instant(); - multiplexedSessionReplacementAttemptTime = clock.instant(); // Scheduled pool maintenance worker. synchronized (lock) { @@ -2483,7 +2017,6 @@ void maintainPool() { this.prevNumSessionsAcquired = SessionPool.this.numSessionsAcquired; } Instant currTime = clock.instant(); - maintainMultiplexedSession(currTime); removeIdleSessions(currTime); // Now go over all the remaining sessions and see if they need to be kept alive explicitly. keepAliveSessions(currTime); @@ -2652,44 +2185,6 @@ private void removeLongRunningSessions( } } } - - void maintainMultiplexedSession(Instant currentTime) { - try { - if (useMultiplexedSessions()) { - if (currentMultiplexedSessionReference.get().isDone()) { - SessionReference sessionReference = getMultiplexedSessionInstance(); - if (sessionReference != null - && isMultiplexedSessionStale(sessionReference, currentTime)) { - final Instant minExecutionTime = - multiplexedSessionReplacementAttemptTime.plus( - multiplexedSessionCreationRetryDelay); - if (currentTime.isBefore(minExecutionTime)) { - return; - } - /* - This will attempt to create a new multiplexed session. if successfully created then - the existing session will be replaced. Note that there maybe active transactions - running on the stale session. Hence, it is important that we only replace the reference - and not invoke a DeleteSession RPC. - */ - maybeCreateMultiplexedSession(multiplexedMaintainerConsumer); - - // update this only after we have attempted to replace the multiplexed session - multiplexedSessionReplacementAttemptTime = currentTime; - } - } - } - } catch (final Throwable t) { - logger.log(Level.WARNING, "Failed to maintain multiplexed session", t); - } - } - - boolean isMultiplexedSessionStale(SessionReference sessionReference, Instant currentTime) { - final Duration durationFromCreationTime = - Duration.between(sessionReference.getCreateTime(), currentTime); - return durationFromCreationTime.compareTo(options.getMultiplexedSessionMaintenanceDuration()) - > 0; - } } enum Position { @@ -2754,9 +2249,6 @@ enum Position { @GuardedBy("lock") private ResourceNotFoundException resourceNotFoundException; - @GuardedBy("lock") - private boolean stopAutomaticPrepare; - @GuardedBy("lock") private final LinkedList sessions = new LinkedList<>(); @@ -2766,9 +2258,6 @@ enum Position { @GuardedBy("lock") private int numSessionsBeingCreated = 0; - @GuardedBy("lock") - private boolean multiplexedSessionBeingCreated = false; - @GuardedBy("lock") private int numSessionsInUse = 0; @@ -2790,10 +2279,7 @@ enum Position { @GuardedBy("lock") private long numLeakedSessionsRemoved = 0; - private AtomicLong numWaiterTimeouts = new AtomicLong(); - - private final AtomicReference> - currentMultiplexedSessionReference = new AtomicReference<>(SettableApiFuture.create()); + private final AtomicLong numWaiterTimeouts = new AtomicLong(); @GuardedBy("lock") private final Set allSessions = new HashSet<>(); @@ -2807,21 +2293,12 @@ enum Position { private final SessionConsumer sessionConsumer = new SessionConsumerImpl(); - private final MultiplexedSessionInitializationConsumer multiplexedSessionInitializationConsumer = - new MultiplexedSessionInitializationConsumer(); - private final MultiplexedSessionMaintainerConsumer multiplexedMaintainerConsumer = - new MultiplexedSessionMaintainerConsumer(); - @VisibleForTesting Function idleSessionRemovedListener; @VisibleForTesting Function longRunningSessionRemovedListener; - @VisibleForTesting Function multiplexedSessionRemovedListener; private final CountDownLatch waitOnMinSessionsLatch; - private final CountDownLatch waitOnMultiplexedSessionsLatch; - private final SessionReplacementHandler pooledSessionReplacementHandler = + private final PooledSessionReplacementHandler pooledSessionReplacementHandler = new PooledSessionReplacementHandler(); - private static final SessionReplacementHandler multiplexedSessionReplacementHandler = - new MultiplexedSessionReplacementHandler(); /** * Create a session pool with the given options and for the given database. It will also start @@ -2965,13 +2442,6 @@ private SessionPool( openTelemetry, attributes, numMultiplexedSessionsAcquired, numMultiplexedSessionsReleased); this.waitOnMinSessionsLatch = options.getMinSessions() > 0 ? new CountDownLatch(1) : new CountDownLatch(0); - this.waitOnMultiplexedSessionsLatch = new CountDownLatch(1); - } - - // TODO: Remove once all code for multiplexed sessions has been removed from the pool. - private boolean useMultiplexedSessions() { - // Multiplexed sessions have moved to MultiplexedSessionDatabaseClient - return false; } /** @@ -3007,7 +2477,7 @@ Dialect getDialect() { } } - SessionReplacementHandler getPooledSessionReplacementHandler() { + PooledSessionReplacementHandler getPooledSessionReplacementHandler() { return pooledSessionReplacementHandler; } @@ -3087,13 +2557,6 @@ int getTotalSessionsPlusNumSessionsBeingCreated() { } } - @VisibleForTesting - boolean isMultiplexedSessionBeingCreated() { - synchronized (lock) { - return multiplexedSessionBeingCreated; - } - } - @VisibleForTesting long getNumWaiterTimeouts() { return numWaiterTimeouts.get(); @@ -3105,9 +2568,6 @@ private void initPool() { if (options.getMinSessions() > 0) { createSessions(options.getMinSessions(), true); } - if (useMultiplexedSessions()) { - maybeCreateMultiplexedSession(multiplexedSessionInitializationConsumer); - } } } @@ -3173,36 +2633,8 @@ boolean isValid() { * Returns a multiplexed session. The method fallbacks to a regular session if {@link * SessionPoolOptions#getUseMultiplexedSession} is not set. */ - SessionFutureWrapper getMultiplexedSessionWithFallback() throws SpannerException { - if (useMultiplexedSessions()) { - ISpan span = tracer.getCurrentSpan(); - try { - return getWrappedMultiplexedSessionFuture(span); - } catch (Throwable t) { - span.addAnnotation("No multiplexed session available."); - throw asSpannerException(t.getCause()); - } - } else { - return new PooledSessionFutureWrapper(getSession()); - } - } - - SessionFutureWrapper getWrappedMultiplexedSessionFuture(ISpan span) { - return new MultiplexedSessionFutureWrapper(span); - } - - /** - * This method is a blocking method. It will block until the underlying {@code - * SettableApiFuture} is resolved. - */ - SessionReference getMultiplexedSessionInstance() { - try { - return currentMultiplexedSessionReference.get().get(); - } catch (InterruptedException e) { - throw SpannerExceptionFactory.propagateInterrupt(e); - } catch (ExecutionException e) { - throw asSpannerException(e.getCause()); - } + PooledSessionFutureWrapper getMultiplexedSessionWithFallback() throws SpannerException { + return new PooledSessionFutureWrapper(getSession()); } /** @@ -3271,14 +2703,12 @@ private PooledSessionFuture checkoutSession( return res; } - private void incrementNumSessionsInUse(boolean isMultiplexed) { + private void incrementNumSessionsInUse() { synchronized (lock) { - if (!isMultiplexed) { - if (maxSessionsInUse < ++numSessionsInUse) { - maxSessionsInUse = numSessionsInUse; - } - numSessionsAcquired++; + if (maxSessionsInUse < ++numSessionsInUse) { + maxSessionsInUse = numSessionsInUse; } + numSessionsAcquired++; } } @@ -3496,7 +2926,7 @@ static boolean isUnbalanced( private void handleCreateSessionsFailure(SpannerException e, int count) { synchronized (lock) { for (int i = 0; i < count; i++) { - if (waiters.size() > 0) { + if (!waiters.isEmpty()) { waiters.poll().put(e); } else { break; @@ -3638,20 +3068,6 @@ private boolean canCreateSession() { } } - private void maybeCreateMultiplexedSession(SessionConsumer sessionConsumer) { - synchronized (lock) { - if (!multiplexedSessionBeingCreated) { - logger.log(Level.FINE, String.format("Creating multiplexed sessions")); - try { - multiplexedSessionBeingCreated = true; - sessionClient.asyncCreateMultiplexedSession(sessionConsumer); - } catch (Throwable ignore) { - // such an exception will never be thrown. the exception will be passed onto the consumer. - } - } - } - } - private void createSessions(final int sessionCount, boolean distributeOverChannels) { logger.log(Level.FINE, String.format("Creating %d sessions", sessionCount)); synchronized (lock) { @@ -3674,99 +3090,6 @@ private void createSessions(final int sessionCount, boolean distributeOverChanne } } - /** - * Callback interface which is invoked when a multiplexed session is being replaced by the - * background maintenance thread. When a multiplexed session creation fails during background - * thread, it would simply log the exception and retry the session creation in the next background - * thread invocation. - * - *

This consumer is not used when the multiplexed session is getting initialized for the first - * time during application startup. We instead use {@link - * MultiplexedSessionInitializationConsumer} for the first time when multiplexed session is - * getting created. - */ - class MultiplexedSessionMaintainerConsumer implements SessionConsumer { - @Override - public void onSessionReady(SessionImpl sessionImpl) { - final SessionReference sessionReference = sessionImpl.getSessionReference(); - final SettableFuture settableFuture = SettableFuture.create(); - settableFuture.set(sessionReference); - - synchronized (lock) { - SessionReference oldSession = null; - if (currentMultiplexedSessionReference.get().isDone()) { - oldSession = getMultiplexedSessionInstance(); - } - SettableApiFuture settableApiFuture = SettableApiFuture.create(); - settableApiFuture.set(sessionReference); - currentMultiplexedSessionReference.set(settableApiFuture); - if (oldSession != null) { - logger.log( - Level.INFO, - String.format( - "Removed Multiplexed Session => %s created at => %s", - oldSession.getName(), oldSession.getCreateTime())); - if (multiplexedSessionRemovedListener != null) { - multiplexedSessionRemovedListener.apply(oldSession); - } - } - multiplexedSessionBeingCreated = false; - } - } - - /** - * Method which logs the exception so that session creation can be re-attempted in the next - * background thread invocation. - */ - @Override - public void onSessionCreateFailure(Throwable t, int createFailureForSessionCount) { - synchronized (lock) { - multiplexedSessionBeingCreated = false; - } - logger.log( - Level.WARNING, - String.format( - "Failed to create multiplexed session. " - + "Pending replacing stale multiplexed session", - t)); - } - } - - /** - * Callback interface which is invoked when a multiplexed session is getting initialised for the - * first time when a session is getting created. - */ - class MultiplexedSessionInitializationConsumer implements SessionConsumer { - @Override - public void onSessionReady(SessionImpl sessionImpl) { - final SessionReference sessionReference = sessionImpl.getSessionReference(); - synchronized (lock) { - SettableApiFuture settableApiFuture = - currentMultiplexedSessionReference.get(); - settableApiFuture.set(sessionReference); - multiplexedSessionBeingCreated = false; - waitOnMultiplexedSessionsLatch.countDown(); - } - } - - /** - * When a multiplexed session fails during initialization we would like all pending threads to - * receive the exception and throw the error. This is done because at the time of start up there - * is no other multiplexed session which could have been assigned to the pending requests. - */ - @Override - public void onSessionCreateFailure(Throwable t, int createFailureForSessionCount) { - synchronized (lock) { - multiplexedSessionBeingCreated = false; - if (isDatabaseOrInstanceNotFound(asSpannerException(t))) { - setResourceNotFoundException((ResourceNotFoundException) t); - poolMaintainer.close(); - } - currentMultiplexedSessionReference.get().setException(asSpannerException(t)); - } - } - } - /** * {@link SessionConsumer} that receives the created sessions from a {@link SessionClient} and * releases these into the pool. The session pool only needs one instance of this, as all sessions diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java index 2a065c8b2ce..ba2eedbccb8 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SessionPoolOptions.java @@ -569,6 +569,8 @@ private Builder(SessionPoolOptions options) { this.acquireSessionTimeout = options.acquireSessionTimeout; this.randomizePositionQPSThreshold = options.randomizePositionQPSThreshold; this.inactiveTransactionRemovalOptions = options.inactiveTransactionRemovalOptions; + this.useMultiplexedSession = options.useMultiplexedSession; + this.multiplexedSessionMaintenanceDuration = options.multiplexedSessionMaintenanceDuration; this.poolMaintainerClock = options.poolMaintainerClock; } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java index 692a60e97b5..7219389e775 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/TransactionRunnerImpl.java @@ -306,12 +306,23 @@ private void createTxnAsync(final SettableApiFuture res) { void commit() { try { - commitResponse = commitAsync().get(); - } catch (InterruptedException e) { + // Normally, Gax will take care of any timeouts, but we add a timeout for getting the value + // from the future here as well to make sure the call always finishes, even if the future + // never resolves. + commitResponse = + commitAsync() + .get( + rpc.getCommitRetrySettings().getTotalTimeout().getSeconds() + 5, + TimeUnit.SECONDS); + } catch (InterruptedException | TimeoutException e) { if (commitFuture != null) { commitFuture.cancel(true); } - throw SpannerExceptionFactory.propagateInterrupt(e); + if (e instanceof InterruptedException) { + throw SpannerExceptionFactory.propagateInterrupt((InterruptedException) e); + } else { + throw SpannerExceptionFactory.propagateTimeout((TimeoutException) e); + } } catch (ExecutionException e) { throw SpannerExceptionFactory.newSpannerException(e.getCause() == null ? e : e.getCause()); } @@ -422,6 +433,14 @@ public void run() { commitFuture.addListener( () -> { try (IScope ignore = tracer.withSpan(opSpan)) { + if (!commitFuture.isDone()) { + // This should not be possible, considering that we are in a listener for the + // future, but we add a result here as well as a safety precaution. + res.setException( + SpannerExceptionFactory.newSpannerException( + ErrorCode.INTERNAL, "commitFuture is not done")); + return; + } com.google.spanner.v1.CommitResponse proto = commitFuture.get(); if (!proto.hasCommitTimestamp()) { throw newSpannerException( @@ -430,20 +449,28 @@ public void run() { span.addAnnotation("Commit Done"); opSpan.end(); res.set(new CommitResponse(proto)); - } catch (Throwable e) { - if (e instanceof ExecutionException) { - e = - SpannerExceptionFactory.newSpannerException( - e.getCause() == null ? e : e.getCause()); - } else if (e instanceof InterruptedException) { - e = SpannerExceptionFactory.propagateInterrupt((InterruptedException) e); - } else { - e = SpannerExceptionFactory.newSpannerException(e); + } catch (Throwable throwable) { + SpannerException resultException; + try { + if (throwable instanceof ExecutionException) { + resultException = + SpannerExceptionFactory.asSpannerException( + throwable.getCause() == null ? throwable : throwable.getCause()); + } else if (throwable instanceof InterruptedException) { + resultException = + SpannerExceptionFactory.propagateInterrupt( + (InterruptedException) throwable); + } else { + resultException = SpannerExceptionFactory.asSpannerException(throwable); + } + span.addAnnotation("Commit Failed", resultException); + opSpan.setStatus(resultException); + opSpan.end(); + res.setException(onError(resultException, false)); + } catch (Throwable unexpectedError) { + // This is a safety precaution to make sure that a result is always returned. + res.setException(unexpectedError); } - span.addAnnotation("Commit Failed", e); - opSpan.setStatus(e); - opSpan.end(); - res.setException(onError((SpannerException) e, false)); } }, MoreExecutors.directExecutor()); @@ -451,9 +478,6 @@ public void run() { res.setException(SpannerExceptionFactory.propagateInterrupt(e)); } catch (TimeoutException e) { res.setException(SpannerExceptionFactory.propagateTimeout(e)); - } catch (ExecutionException e) { - res.setException( - SpannerExceptionFactory.newSpannerException(e.getCause() == null ? e : e.getCause())); } catch (Throwable e) { res.setException( SpannerExceptionFactory.newSpannerException(e.getCause() == null ? e : e.getCause())); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClient.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClient.java index e518198549b..dd00f6750c7 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClient.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClient.java @@ -43,24 +43,31 @@ import com.google.protobuf.Timestamp; import com.google.spanner.admin.database.v1.Backup; import com.google.spanner.admin.database.v1.BackupName; +import com.google.spanner.admin.database.v1.BackupSchedule; +import com.google.spanner.admin.database.v1.BackupScheduleName; import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; +import com.google.spanner.admin.database.v1.CreateBackupScheduleRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; import com.google.spanner.admin.database.v1.Database; import com.google.spanner.admin.database.v1.DatabaseName; import com.google.spanner.admin.database.v1.DatabaseRole; import com.google.spanner.admin.database.v1.DeleteBackupRequest; +import com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest; import com.google.spanner.admin.database.v1.DropDatabaseRequest; import com.google.spanner.admin.database.v1.GetBackupRequest; +import com.google.spanner.admin.database.v1.GetBackupScheduleRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse; import com.google.spanner.admin.database.v1.GetDatabaseRequest; import com.google.spanner.admin.database.v1.InstanceName; import com.google.spanner.admin.database.v1.ListBackupOperationsRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsResponse; +import com.google.spanner.admin.database.v1.ListBackupSchedulesRequest; +import com.google.spanner.admin.database.v1.ListBackupSchedulesResponse; import com.google.spanner.admin.database.v1.ListBackupsRequest; import com.google.spanner.admin.database.v1.ListBackupsResponse; import com.google.spanner.admin.database.v1.ListDatabaseOperationsRequest; @@ -72,6 +79,7 @@ import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata; import com.google.spanner.admin.database.v1.RestoreDatabaseRequest; import com.google.spanner.admin.database.v1.UpdateBackupRequest; +import com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseMetadata; @@ -515,6 +523,101 @@ * * * + * + *

CreateBackupSchedule + *

Creates a new backup schedule. + * + *

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

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

+ *

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

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

  • createBackupSchedule(String parent, BackupSchedule backupSchedule, String backupScheduleId) + *

+ *

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

+ *
    + *
  • createBackupScheduleCallable() + *

+ * + * + * + *

GetBackupSchedule + *

Gets backup schedule for the input schedule name. + * + *

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

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

+ *

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

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

  • getBackupSchedule(String name) + *

+ *

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

+ *
    + *
  • getBackupScheduleCallable() + *

+ * + * + * + *

UpdateBackupSchedule + *

Updates a backup schedule. + * + *

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

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

+ *

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

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

+ *

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

+ *
    + *
  • updateBackupScheduleCallable() + *

+ * + * + * + *

DeleteBackupSchedule + *

Deletes a backup schedule. + * + *

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

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

+ *

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

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

  • deleteBackupSchedule(String name) + *

+ *

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

+ *
    + *
  • deleteBackupScheduleCallable() + *

+ * + * + * + *

ListBackupSchedules + *

Lists all the backup schedules for the database. + * + *

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

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

+ *

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

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

  • listBackupSchedules(String parent) + *

+ *

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

+ *
    + *
  • listBackupSchedulesPagedCallable() + *

  • listBackupSchedulesCallable() + *

+ * + * * * *

See the individual methods for example code. @@ -4215,62 +4318,707 @@ public final ListDatabaseRolesPagedResponse listDatabaseRoles(ListDatabaseRolesR return stub.listDatabaseRolesCallable(); } - @Override - public final void close() { - stub.close(); + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   DatabaseName parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
+   *   BackupSchedule backupSchedule = BackupSchedule.newBuilder().build();
+   *   String backupScheduleId = "backupScheduleId1704974708";
+   *   BackupSchedule response =
+   *       databaseAdminClient.createBackupSchedule(parent, backupSchedule, backupScheduleId);
+   * }
+   * }
+ * + * @param parent Required. The name of the database that this backup schedule applies to. + * @param backupSchedule Required. The backup schedule to create. + * @param backupScheduleId Required. The Id to use for the backup schedule. The + * `backup_schedule_id` appended to `parent` forms the full backup schedule name of the form + * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule createBackupSchedule( + DatabaseName parent, BackupSchedule backupSchedule, String backupScheduleId) { + CreateBackupScheduleRequest request = + CreateBackupScheduleRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .setBackupSchedule(backupSchedule) + .setBackupScheduleId(backupScheduleId) + .build(); + return createBackupSchedule(request); } - @Override - public void shutdown() { - stub.shutdown(); + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   String parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
+   *   BackupSchedule backupSchedule = BackupSchedule.newBuilder().build();
+   *   String backupScheduleId = "backupScheduleId1704974708";
+   *   BackupSchedule response =
+   *       databaseAdminClient.createBackupSchedule(parent, backupSchedule, backupScheduleId);
+   * }
+   * }
+ * + * @param parent Required. The name of the database that this backup schedule applies to. + * @param backupSchedule Required. The backup schedule to create. + * @param backupScheduleId Required. The Id to use for the backup schedule. The + * `backup_schedule_id` appended to `parent` forms the full backup schedule name of the form + * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule createBackupSchedule( + String parent, BackupSchedule backupSchedule, String backupScheduleId) { + CreateBackupScheduleRequest request = + CreateBackupScheduleRequest.newBuilder() + .setParent(parent) + .setBackupSchedule(backupSchedule) + .setBackupScheduleId(backupScheduleId) + .build(); + return createBackupSchedule(request); } - @Override - public boolean isShutdown() { - return stub.isShutdown(); + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   CreateBackupScheduleRequest request =
+   *       CreateBackupScheduleRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
+   *           .setBackupScheduleId("backupScheduleId1704974708")
+   *           .setBackupSchedule(BackupSchedule.newBuilder().build())
+   *           .build();
+   *   BackupSchedule response = databaseAdminClient.createBackupSchedule(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule createBackupSchedule(CreateBackupScheduleRequest request) { + return createBackupScheduleCallable().call(request); } - @Override - public boolean isTerminated() { - return stub.isTerminated(); + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Creates a new backup schedule. + * + *

Sample code: + * + *

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

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 (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   BackupScheduleName name =
+   *       BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]");
+   *   BackupSchedule response = databaseAdminClient.getBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the schedule to retrieve. Values are of the form + * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule getBackupSchedule(BackupScheduleName name) { + GetBackupScheduleRequest request = + GetBackupScheduleRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + return getBackupSchedule(request); } - @Override - public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { - return stub.awaitTermination(duration, unit); + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets backup schedule for the input schedule name. + * + *

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 (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   String name =
+   *       BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]").toString();
+   *   BackupSchedule response = databaseAdminClient.getBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the schedule to retrieve. Values are of the form + * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule getBackupSchedule(String name) { + GetBackupScheduleRequest request = GetBackupScheduleRequest.newBuilder().setName(name).build(); + return getBackupSchedule(request); } - public static class ListDatabasesPagedResponse - extends AbstractPagedListResponse< - ListDatabasesRequest, - ListDatabasesResponse, - Database, - ListDatabasesPage, - ListDatabasesFixedSizeCollection> { - - public static ApiFuture createAsync( - PageContext context, - ApiFuture futureResponse) { - ApiFuture futurePage = - ListDatabasesPage.createEmptyPage().createPageAsync(context, futureResponse); - return ApiFutures.transform( - futurePage, - input -> new ListDatabasesPagedResponse(input), - MoreExecutors.directExecutor()); - } + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets backup schedule for the input schedule name. + * + *

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 (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   GetBackupScheduleRequest request =
+   *       GetBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]")
+   *                   .toString())
+   *           .build();
+   *   BackupSchedule response = databaseAdminClient.getBackupSchedule(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule getBackupSchedule(GetBackupScheduleRequest request) { + return getBackupScheduleCallable().call(request); + } - private ListDatabasesPagedResponse(ListDatabasesPage page) { - super(page, ListDatabasesFixedSizeCollection.createEmptyCollection()); - } + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Gets backup schedule for the input schedule name. + * + *

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 (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   GetBackupScheduleRequest request =
+   *       GetBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]")
+   *                   .toString())
+   *           .build();
+   *   ApiFuture future =
+   *       databaseAdminClient.getBackupScheduleCallable().futureCall(request);
+   *   // Do something.
+   *   BackupSchedule response = future.get();
+   * }
+   * }
+ */ + public final UnaryCallable getBackupScheduleCallable() { + return stub.getBackupScheduleCallable(); } - public static class ListDatabasesPage - extends AbstractPage< + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   BackupSchedule backupSchedule = BackupSchedule.newBuilder().build();
+   *   FieldMask updateMask = FieldMask.newBuilder().build();
+   *   BackupSchedule response =
+   *       databaseAdminClient.updateBackupSchedule(backupSchedule, updateMask);
+   * }
+   * }
+ * + * @param backupSchedule Required. The backup schedule to update. `backup_schedule.name`, and the + * fields to be updated as specified by `update_mask` are required. Other fields are ignored. + * @param updateMask Required. A mask specifying which fields in the BackupSchedule resource + * should be updated. This mask is relative to the BackupSchedule resource, not to the request + * message. The field mask must always be specified; this prevents any future fields from + * being erased accidentally. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final BackupSchedule updateBackupSchedule( + BackupSchedule backupSchedule, FieldMask updateMask) { + UpdateBackupScheduleRequest request = + UpdateBackupScheduleRequest.newBuilder() + .setBackupSchedule(backupSchedule) + .setUpdateMask(updateMask) + .build(); + return updateBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Updates a backup schedule. + * + *

Sample code: + * + *

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

Sample code: + * + *

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

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   BackupScheduleName name =
+   *       BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]");
+   *   databaseAdminClient.deleteBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the schedule to delete. Values are of the form + * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackupSchedule(BackupScheduleName name) { + DeleteBackupScheduleRequest request = + DeleteBackupScheduleRequest.newBuilder() + .setName(name == null ? null : name.toString()) + .build(); + deleteBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   String name =
+   *       BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]").toString();
+   *   databaseAdminClient.deleteBackupSchedule(name);
+   * }
+   * }
+ * + * @param name Required. The name of the schedule to delete. Values are of the form + * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackupSchedule(String name) { + DeleteBackupScheduleRequest request = + DeleteBackupScheduleRequest.newBuilder().setName(name).build(); + deleteBackupSchedule(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   DeleteBackupScheduleRequest request =
+   *       DeleteBackupScheduleRequest.newBuilder()
+   *           .setName(
+   *               BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]")
+   *                   .toString())
+   *           .build();
+   *   databaseAdminClient.deleteBackupSchedule(request);
+   * }
+   * }
+ * + * @param request The request object containing all of the parameters for the API call. + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final void deleteBackupSchedule(DeleteBackupScheduleRequest request) { + deleteBackupScheduleCallable().call(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Deletes a backup schedule. + * + *

Sample code: + * + *

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

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   DatabaseName parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]");
+   *   for (BackupSchedule element : databaseAdminClient.listBackupSchedules(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. Database is the parent resource whose backup schedules should be + * listed. Values are of the form + * projects/<project>/instances/<instance>/databases/<database> + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupSchedulesPagedResponse listBackupSchedules(DatabaseName parent) { + ListBackupSchedulesRequest request = + ListBackupSchedulesRequest.newBuilder() + .setParent(parent == null ? null : parent.toString()) + .build(); + return listBackupSchedules(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the backup schedules for the database. + * + *

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   String parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString();
+   *   for (BackupSchedule element : databaseAdminClient.listBackupSchedules(parent).iterateAll()) {
+   *     // doThingsWith(element);
+   *   }
+   * }
+   * }
+ * + * @param parent Required. Database is the parent resource whose backup schedules should be + * listed. Values are of the form + * projects/<project>/instances/<instance>/databases/<database> + * @throws com.google.api.gax.rpc.ApiException if the remote call fails + */ + public final ListBackupSchedulesPagedResponse listBackupSchedules(String parent) { + ListBackupSchedulesRequest request = + ListBackupSchedulesRequest.newBuilder().setParent(parent).build(); + return listBackupSchedules(request); + } + + // AUTO-GENERATED DOCUMENTATION AND METHOD. + /** + * Lists all the backup schedules for the database. + * + *

Sample code: + * + *

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

Sample code: + * + *

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

Sample code: + * + *

{@code
+   * // This snippet has been automatically generated and should be regarded as a code template only.
+   * // It will require modifications to work:
+   * // - It may require correct/in-range values for request initialization.
+   * // - It may require specifying regional endpoints when creating the service client as shown in
+   * // https://cloud.google.com/java/docs/setup#configure_endpoints_for_the_client_library
+   * try (DatabaseAdminClient databaseAdminClient = DatabaseAdminClient.create()) {
+   *   ListBackupSchedulesRequest request =
+   *       ListBackupSchedulesRequest.newBuilder()
+   *           .setParent(DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]").toString())
+   *           .setPageSize(883849137)
+   *           .setPageToken("pageToken873572522")
+   *           .build();
+   *   while (true) {
+   *     ListBackupSchedulesResponse response =
+   *         databaseAdminClient.listBackupSchedulesCallable().call(request);
+   *     for (BackupSchedule element : response.getBackupSchedulesList()) {
+   *       // doThingsWith(element);
+   *     }
+   *     String nextPageToken = response.getNextPageToken();
+   *     if (!Strings.isNullOrEmpty(nextPageToken)) {
+   *       request = request.toBuilder().setPageToken(nextPageToken).build();
+   *     } else {
+   *       break;
+   *     }
+   *   }
+   * }
+   * }
+ */ + public final UnaryCallable + listBackupSchedulesCallable() { + return stub.listBackupSchedulesCallable(); + } + + @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 ListDatabasesPagedResponse + extends AbstractPagedListResponse< + ListDatabasesRequest, + ListDatabasesResponse, + Database, + ListDatabasesPage, + ListDatabasesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListDatabasesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new ListDatabasesPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private ListDatabasesPagedResponse(ListDatabasesPage page) { + super(page, ListDatabasesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListDatabasesPage + extends AbstractPage< ListDatabasesRequest, ListDatabasesResponse, Database, ListDatabasesPage> { private ListDatabasesPage( @@ -4637,4 +5385,88 @@ protected ListDatabaseRolesFixedSizeCollection createCollection( return new ListDatabaseRolesFixedSizeCollection(pages, collectionSize); } } + + public static class ListBackupSchedulesPagedResponse + extends AbstractPagedListResponse< + ListBackupSchedulesRequest, + ListBackupSchedulesResponse, + BackupSchedule, + ListBackupSchedulesPage, + ListBackupSchedulesFixedSizeCollection> { + + public static ApiFuture createAsync( + PageContext + context, + ApiFuture futureResponse) { + ApiFuture futurePage = + ListBackupSchedulesPage.createEmptyPage().createPageAsync(context, futureResponse); + return ApiFutures.transform( + futurePage, + input -> new ListBackupSchedulesPagedResponse(input), + MoreExecutors.directExecutor()); + } + + private ListBackupSchedulesPagedResponse(ListBackupSchedulesPage page) { + super(page, ListBackupSchedulesFixedSizeCollection.createEmptyCollection()); + } + } + + public static class ListBackupSchedulesPage + extends AbstractPage< + ListBackupSchedulesRequest, + ListBackupSchedulesResponse, + BackupSchedule, + ListBackupSchedulesPage> { + + private ListBackupSchedulesPage( + PageContext + context, + ListBackupSchedulesResponse response) { + super(context, response); + } + + private static ListBackupSchedulesPage createEmptyPage() { + return new ListBackupSchedulesPage(null, null); + } + + @Override + protected ListBackupSchedulesPage createPage( + PageContext + context, + ListBackupSchedulesResponse response) { + return new ListBackupSchedulesPage(context, response); + } + + @Override + public ApiFuture createPageAsync( + PageContext + context, + ApiFuture futureResponse) { + return super.createPageAsync(context, futureResponse); + } + } + + public static class ListBackupSchedulesFixedSizeCollection + extends AbstractFixedSizeCollection< + ListBackupSchedulesRequest, + ListBackupSchedulesResponse, + BackupSchedule, + ListBackupSchedulesPage, + ListBackupSchedulesFixedSizeCollection> { + + private ListBackupSchedulesFixedSizeCollection( + List pages, int collectionSize) { + super(pages, collectionSize); + } + + private static ListBackupSchedulesFixedSizeCollection createEmptyCollection() { + return new ListBackupSchedulesFixedSizeCollection(null, 0); + } + + @Override + protected ListBackupSchedulesFixedSizeCollection createCollection( + List pages, int collectionSize) { + return new ListBackupSchedulesFixedSizeCollection(pages, collectionSize); + } + } } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminSettings.java index 50d6900e1ce..513f91e7100 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminSettings.java @@ -17,6 +17,7 @@ package com.google.cloud.spanner.admin.database.v1; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse; +import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupSchedulesPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseOperationsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseRolesPagedResponse; @@ -44,21 +45,27 @@ import com.google.longrunning.Operation; import com.google.protobuf.Empty; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.BackupSchedule; import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; +import com.google.spanner.admin.database.v1.CreateBackupScheduleRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; import com.google.spanner.admin.database.v1.Database; import com.google.spanner.admin.database.v1.DeleteBackupRequest; +import com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest; import com.google.spanner.admin.database.v1.DropDatabaseRequest; import com.google.spanner.admin.database.v1.GetBackupRequest; +import com.google.spanner.admin.database.v1.GetBackupScheduleRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse; import com.google.spanner.admin.database.v1.GetDatabaseRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsResponse; +import com.google.spanner.admin.database.v1.ListBackupSchedulesRequest; +import com.google.spanner.admin.database.v1.ListBackupSchedulesResponse; import com.google.spanner.admin.database.v1.ListBackupsRequest; import com.google.spanner.admin.database.v1.ListBackupsResponse; import com.google.spanner.admin.database.v1.ListDatabaseOperationsRequest; @@ -70,6 +77,7 @@ import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata; import com.google.spanner.admin.database.v1.RestoreDatabaseRequest; import com.google.spanner.admin.database.v1.UpdateBackupRequest; +import com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseMetadata; @@ -266,6 +274,35 @@ public UnaryCallSettings restoreDatabaseSetti return ((DatabaseAdminStubSettings) getStubSettings()).listDatabaseRolesSettings(); } + /** Returns the object with the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings + createBackupScheduleSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).createBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings getBackupScheduleSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).getBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings + updateBackupScheduleSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).updateBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings deleteBackupScheduleSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).deleteBackupScheduleSettings(); + } + + /** Returns the object with the settings used for calls to listBackupSchedules. */ + public PagedCallSettings< + ListBackupSchedulesRequest, ListBackupSchedulesResponse, ListBackupSchedulesPagedResponse> + listBackupSchedulesSettings() { + return ((DatabaseAdminStubSettings) getStubSettings()).listBackupSchedulesSettings(); + } + public static final DatabaseAdminSettings create(DatabaseAdminStubSettings stub) throws IOException { return new DatabaseAdminSettings.Builder(stub.toBuilder()).build(); @@ -531,6 +568,39 @@ public UnaryCallSettings.Builder restoreDatab return getStubSettingsBuilder().listDatabaseRolesSettings(); } + /** Returns the builder for the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings.Builder + createBackupScheduleSettings() { + return getStubSettingsBuilder().createBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings.Builder + getBackupScheduleSettings() { + return getStubSettingsBuilder().getBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings.Builder + updateBackupScheduleSettings() { + return getStubSettingsBuilder().updateBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings.Builder + deleteBackupScheduleSettings() { + return getStubSettingsBuilder().deleteBackupScheduleSettings(); + } + + /** Returns the builder for the settings used for calls to listBackupSchedules. */ + public PagedCallSettings.Builder< + ListBackupSchedulesRequest, + ListBackupSchedulesResponse, + ListBackupSchedulesPagedResponse> + listBackupSchedulesSettings() { + return getStubSettingsBuilder().listBackupSchedulesSettings(); + } + @Override public DatabaseAdminSettings build() throws IOException { return new DatabaseAdminSettings(this); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/gapic_metadata.json b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/gapic_metadata.json index 01fcbd4de1a..7d6c894d7b6 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/gapic_metadata.json +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/gapic_metadata.json @@ -16,18 +16,27 @@ "CreateBackup": { "methods": ["createBackupAsync", "createBackupAsync", "createBackupAsync", "createBackupOperationCallable", "createBackupCallable"] }, + "CreateBackupSchedule": { + "methods": ["createBackupSchedule", "createBackupSchedule", "createBackupSchedule", "createBackupScheduleCallable"] + }, "CreateDatabase": { "methods": ["createDatabaseAsync", "createDatabaseAsync", "createDatabaseAsync", "createDatabaseOperationCallable", "createDatabaseCallable"] }, "DeleteBackup": { "methods": ["deleteBackup", "deleteBackup", "deleteBackup", "deleteBackupCallable"] }, + "DeleteBackupSchedule": { + "methods": ["deleteBackupSchedule", "deleteBackupSchedule", "deleteBackupSchedule", "deleteBackupScheduleCallable"] + }, "DropDatabase": { "methods": ["dropDatabase", "dropDatabase", "dropDatabase", "dropDatabaseCallable"] }, "GetBackup": { "methods": ["getBackup", "getBackup", "getBackup", "getBackupCallable"] }, + "GetBackupSchedule": { + "methods": ["getBackupSchedule", "getBackupSchedule", "getBackupSchedule", "getBackupScheduleCallable"] + }, "GetDatabase": { "methods": ["getDatabase", "getDatabase", "getDatabase", "getDatabaseCallable"] }, @@ -40,6 +49,9 @@ "ListBackupOperations": { "methods": ["listBackupOperations", "listBackupOperations", "listBackupOperations", "listBackupOperationsPagedCallable", "listBackupOperationsCallable"] }, + "ListBackupSchedules": { + "methods": ["listBackupSchedules", "listBackupSchedules", "listBackupSchedules", "listBackupSchedulesPagedCallable", "listBackupSchedulesCallable"] + }, "ListBackups": { "methods": ["listBackups", "listBackups", "listBackups", "listBackupsPagedCallable", "listBackupsCallable"] }, @@ -64,6 +76,9 @@ "UpdateBackup": { "methods": ["updateBackup", "updateBackup", "updateBackupCallable"] }, + "UpdateBackupSchedule": { + "methods": ["updateBackupSchedule", "updateBackupSchedule", "updateBackupScheduleCallable"] + }, "UpdateDatabase": { "methods": ["updateDatabaseAsync", "updateDatabaseAsync", "updateDatabaseOperationCallable", "updateDatabaseCallable"] }, diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStub.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStub.java index 37fb433c3eb..2f53f6cf5b4 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStub.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStub.java @@ -17,6 +17,7 @@ package com.google.cloud.spanner.admin.database.v1.stub; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse; +import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupSchedulesPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseOperationsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseRolesPagedResponse; @@ -34,21 +35,27 @@ import com.google.longrunning.stub.OperationsStub; import com.google.protobuf.Empty; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.BackupSchedule; import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; +import com.google.spanner.admin.database.v1.CreateBackupScheduleRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; import com.google.spanner.admin.database.v1.Database; import com.google.spanner.admin.database.v1.DeleteBackupRequest; +import com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest; import com.google.spanner.admin.database.v1.DropDatabaseRequest; import com.google.spanner.admin.database.v1.GetBackupRequest; +import com.google.spanner.admin.database.v1.GetBackupScheduleRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse; import com.google.spanner.admin.database.v1.GetDatabaseRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsResponse; +import com.google.spanner.admin.database.v1.ListBackupSchedulesRequest; +import com.google.spanner.admin.database.v1.ListBackupSchedulesResponse; import com.google.spanner.admin.database.v1.ListBackupsRequest; import com.google.spanner.admin.database.v1.ListBackupsResponse; import com.google.spanner.admin.database.v1.ListDatabaseOperationsRequest; @@ -60,6 +67,7 @@ import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata; import com.google.spanner.admin.database.v1.RestoreDatabaseRequest; import com.google.spanner.admin.database.v1.UpdateBackupRequest; +import com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseMetadata; @@ -223,6 +231,32 @@ public UnaryCallable restoreDatabaseCallable( throw new UnsupportedOperationException("Not implemented: listDatabaseRolesCallable()"); } + public UnaryCallable createBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: createBackupScheduleCallable()"); + } + + public UnaryCallable getBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: getBackupScheduleCallable()"); + } + + public UnaryCallable updateBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: updateBackupScheduleCallable()"); + } + + public UnaryCallable deleteBackupScheduleCallable() { + throw new UnsupportedOperationException("Not implemented: deleteBackupScheduleCallable()"); + } + + public UnaryCallable + listBackupSchedulesPagedCallable() { + throw new UnsupportedOperationException("Not implemented: listBackupSchedulesPagedCallable()"); + } + + public UnaryCallable + listBackupSchedulesCallable() { + throw new UnsupportedOperationException("Not implemented: listBackupSchedulesCallable()"); + } + @Override public abstract void close(); } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStubSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStubSettings.java index 4808f1553e9..2865fcd8d08 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStubSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/DatabaseAdminStubSettings.java @@ -17,6 +17,7 @@ package com.google.cloud.spanner.admin.database.v1.stub; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse; +import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupSchedulesPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseOperationsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseRolesPagedResponse; @@ -25,6 +26,7 @@ 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; @@ -63,22 +65,28 @@ import com.google.longrunning.Operation; import com.google.protobuf.Empty; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.BackupSchedule; import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; +import com.google.spanner.admin.database.v1.CreateBackupScheduleRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; import com.google.spanner.admin.database.v1.Database; import com.google.spanner.admin.database.v1.DatabaseRole; import com.google.spanner.admin.database.v1.DeleteBackupRequest; +import com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest; import com.google.spanner.admin.database.v1.DropDatabaseRequest; import com.google.spanner.admin.database.v1.GetBackupRequest; +import com.google.spanner.admin.database.v1.GetBackupScheduleRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse; import com.google.spanner.admin.database.v1.GetDatabaseRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsResponse; +import com.google.spanner.admin.database.v1.ListBackupSchedulesRequest; +import com.google.spanner.admin.database.v1.ListBackupSchedulesResponse; import com.google.spanner.admin.database.v1.ListBackupsRequest; import com.google.spanner.admin.database.v1.ListBackupsResponse; import com.google.spanner.admin.database.v1.ListDatabaseOperationsRequest; @@ -90,6 +98,7 @@ import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata; import com.google.spanner.admin.database.v1.RestoreDatabaseRequest; import com.google.spanner.admin.database.v1.UpdateBackupRequest; +import com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseMetadata; @@ -192,6 +201,16 @@ public class DatabaseAdminStubSettings extends StubSettings listDatabaseRolesSettings; + private final UnaryCallSettings + createBackupScheduleSettings; + private final UnaryCallSettings + getBackupScheduleSettings; + private final UnaryCallSettings + updateBackupScheduleSettings; + private final UnaryCallSettings deleteBackupScheduleSettings; + private final PagedCallSettings< + ListBackupSchedulesRequest, ListBackupSchedulesResponse, ListBackupSchedulesPagedResponse> + listBackupSchedulesSettings; private static final PagedListDescriptor LIST_DATABASES_PAGE_STR_DESC = @@ -387,6 +406,46 @@ public Iterable extractResources(ListDatabaseRolesResponse payload } }; + private static final PagedListDescriptor< + ListBackupSchedulesRequest, ListBackupSchedulesResponse, BackupSchedule> + LIST_BACKUP_SCHEDULES_PAGE_STR_DESC = + new PagedListDescriptor< + ListBackupSchedulesRequest, ListBackupSchedulesResponse, BackupSchedule>() { + @Override + public String emptyToken() { + return ""; + } + + @Override + public ListBackupSchedulesRequest injectToken( + ListBackupSchedulesRequest payload, String token) { + return ListBackupSchedulesRequest.newBuilder(payload).setPageToken(token).build(); + } + + @Override + public ListBackupSchedulesRequest injectPageSize( + ListBackupSchedulesRequest payload, int pageSize) { + return ListBackupSchedulesRequest.newBuilder(payload).setPageSize(pageSize).build(); + } + + @Override + public Integer extractPageSize(ListBackupSchedulesRequest payload) { + return payload.getPageSize(); + } + + @Override + public String extractNextToken(ListBackupSchedulesResponse payload) { + return payload.getNextPageToken(); + } + + @Override + public Iterable extractResources(ListBackupSchedulesResponse payload) { + return payload.getBackupSchedulesList() == null + ? ImmutableList.of() + : payload.getBackupSchedulesList(); + } + }; + private static final PagedListResponseFactory< ListDatabasesRequest, ListDatabasesResponse, ListDatabasesPagedResponse> LIST_DATABASES_PAGE_STR_FACT = @@ -489,6 +548,27 @@ public ApiFuture getFuturePagedResponse( } }; + private static final PagedListResponseFactory< + ListBackupSchedulesRequest, ListBackupSchedulesResponse, ListBackupSchedulesPagedResponse> + LIST_BACKUP_SCHEDULES_PAGE_STR_FACT = + new PagedListResponseFactory< + ListBackupSchedulesRequest, + ListBackupSchedulesResponse, + ListBackupSchedulesPagedResponse>() { + @Override + public ApiFuture getFuturePagedResponse( + UnaryCallable callable, + ListBackupSchedulesRequest request, + ApiCallContext context, + ApiFuture futureResponse) { + PageContext + pageContext = + PageContext.create( + callable, LIST_BACKUP_SCHEDULES_PAGE_STR_DESC, request, context); + return ListBackupSchedulesPagedResponse.createAsync(pageContext, futureResponse); + } + }; + /** Returns the object with the settings used for calls to listDatabases. */ public PagedCallSettings listDatabasesSettings() { @@ -638,6 +718,35 @@ public UnaryCallSettings restoreDatabaseSetti return listDatabaseRolesSettings; } + /** Returns the object with the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings + createBackupScheduleSettings() { + return createBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings getBackupScheduleSettings() { + return getBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings + updateBackupScheduleSettings() { + return updateBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings deleteBackupScheduleSettings() { + return deleteBackupScheduleSettings; + } + + /** Returns the object with the settings used for calls to listBackupSchedules. */ + public PagedCallSettings< + ListBackupSchedulesRequest, ListBackupSchedulesResponse, ListBackupSchedulesPagedResponse> + listBackupSchedulesSettings() { + return listBackupSchedulesSettings; + } + public DatabaseAdminStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() @@ -666,6 +775,7 @@ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuild } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "spanner.googleapis.com:443"; } @@ -775,6 +885,11 @@ protected DatabaseAdminStubSettings(Builder settingsBuilder) throws IOException listDatabaseOperationsSettings = settingsBuilder.listDatabaseOperationsSettings().build(); listBackupOperationsSettings = settingsBuilder.listBackupOperationsSettings().build(); listDatabaseRolesSettings = settingsBuilder.listDatabaseRolesSettings().build(); + createBackupScheduleSettings = settingsBuilder.createBackupScheduleSettings().build(); + getBackupScheduleSettings = settingsBuilder.getBackupScheduleSettings().build(); + updateBackupScheduleSettings = settingsBuilder.updateBackupScheduleSettings().build(); + deleteBackupScheduleSettings = settingsBuilder.deleteBackupScheduleSettings().build(); + listBackupSchedulesSettings = settingsBuilder.listBackupSchedulesSettings().build(); } /** Builder for DatabaseAdminStubSettings. */ @@ -836,6 +951,19 @@ public static class Builder extends StubSettings.Builder listDatabaseRolesSettings; + private final UnaryCallSettings.Builder + createBackupScheduleSettings; + private final UnaryCallSettings.Builder + getBackupScheduleSettings; + private final UnaryCallSettings.Builder + updateBackupScheduleSettings; + private final UnaryCallSettings.Builder + deleteBackupScheduleSettings; + private final PagedCallSettings.Builder< + ListBackupSchedulesRequest, + ListBackupSchedulesResponse, + ListBackupSchedulesPagedResponse> + listBackupSchedulesSettings; private static final ImmutableMap> RETRYABLE_CODE_DEFINITIONS; @@ -940,6 +1068,12 @@ protected Builder(ClientContext clientContext) { listBackupOperationsSettings = PagedCallSettings.newBuilder(LIST_BACKUP_OPERATIONS_PAGE_STR_FACT); listDatabaseRolesSettings = PagedCallSettings.newBuilder(LIST_DATABASE_ROLES_PAGE_STR_FACT); + createBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + getBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + updateBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + deleteBackupScheduleSettings = UnaryCallSettings.newUnaryCallSettingsBuilder(); + listBackupSchedulesSettings = + PagedCallSettings.newBuilder(LIST_BACKUP_SCHEDULES_PAGE_STR_FACT); unaryMethodSettingsBuilders = ImmutableList.>of( @@ -962,7 +1096,12 @@ protected Builder(ClientContext clientContext) { restoreDatabaseSettings, listDatabaseOperationsSettings, listBackupOperationsSettings, - listDatabaseRolesSettings); + listDatabaseRolesSettings, + createBackupScheduleSettings, + getBackupScheduleSettings, + updateBackupScheduleSettings, + deleteBackupScheduleSettings, + listBackupSchedulesSettings); initDefaults(this); } @@ -995,6 +1134,11 @@ protected Builder(DatabaseAdminStubSettings settings) { listDatabaseOperationsSettings = settings.listDatabaseOperationsSettings.toBuilder(); listBackupOperationsSettings = settings.listBackupOperationsSettings.toBuilder(); listDatabaseRolesSettings = settings.listDatabaseRolesSettings.toBuilder(); + createBackupScheduleSettings = settings.createBackupScheduleSettings.toBuilder(); + getBackupScheduleSettings = settings.getBackupScheduleSettings.toBuilder(); + updateBackupScheduleSettings = settings.updateBackupScheduleSettings.toBuilder(); + deleteBackupScheduleSettings = settings.deleteBackupScheduleSettings.toBuilder(); + listBackupSchedulesSettings = settings.listBackupSchedulesSettings.toBuilder(); unaryMethodSettingsBuilders = ImmutableList.>of( @@ -1017,7 +1161,12 @@ protected Builder(DatabaseAdminStubSettings settings) { restoreDatabaseSettings, listDatabaseOperationsSettings, listBackupOperationsSettings, - listDatabaseRolesSettings); + listDatabaseRolesSettings, + createBackupScheduleSettings, + getBackupScheduleSettings, + updateBackupScheduleSettings, + deleteBackupScheduleSettings, + listBackupSchedulesSettings); } private static Builder createDefault() { @@ -1145,6 +1294,31 @@ private static Builder initDefaults(Builder builder) { .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + builder + .createBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .getBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .updateBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .deleteBackupScheduleSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + + builder + .listBackupSchedulesSettings() + .setRetryableCodes(RETRYABLE_CODE_DEFINITIONS.get("retry_policy_0_codes")) + .setRetrySettings(RETRY_PARAM_DEFINITIONS.get("retry_policy_0_params")); + builder .createDatabaseOperationSettings() .setInitialCallSettings( @@ -1460,6 +1634,39 @@ public UnaryCallSettings.Builder restoreDatab return listDatabaseRolesSettings; } + /** Returns the builder for the settings used for calls to createBackupSchedule. */ + public UnaryCallSettings.Builder + createBackupScheduleSettings() { + return createBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to getBackupSchedule. */ + public UnaryCallSettings.Builder + getBackupScheduleSettings() { + return getBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to updateBackupSchedule. */ + public UnaryCallSettings.Builder + updateBackupScheduleSettings() { + return updateBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to deleteBackupSchedule. */ + public UnaryCallSettings.Builder + deleteBackupScheduleSettings() { + return deleteBackupScheduleSettings; + } + + /** Returns the builder for the settings used for calls to listBackupSchedules. */ + public PagedCallSettings.Builder< + ListBackupSchedulesRequest, + ListBackupSchedulesResponse, + ListBackupSchedulesPagedResponse> + listBackupSchedulesSettings() { + return listBackupSchedulesSettings; + } + @Override public DatabaseAdminStubSettings build() throws IOException { return new DatabaseAdminStubSettings(this); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/GrpcDatabaseAdminStub.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/GrpcDatabaseAdminStub.java index 875ff8443fc..8207ebcbce5 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/GrpcDatabaseAdminStub.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/GrpcDatabaseAdminStub.java @@ -17,6 +17,7 @@ package com.google.cloud.spanner.admin.database.v1.stub; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse; +import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupSchedulesPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseOperationsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseRolesPagedResponse; @@ -39,21 +40,27 @@ import com.google.longrunning.stub.GrpcOperationsStub; import com.google.protobuf.Empty; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.BackupSchedule; import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; +import com.google.spanner.admin.database.v1.CreateBackupScheduleRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; import com.google.spanner.admin.database.v1.Database; import com.google.spanner.admin.database.v1.DeleteBackupRequest; +import com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest; import com.google.spanner.admin.database.v1.DropDatabaseRequest; import com.google.spanner.admin.database.v1.GetBackupRequest; +import com.google.spanner.admin.database.v1.GetBackupScheduleRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse; import com.google.spanner.admin.database.v1.GetDatabaseRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsResponse; +import com.google.spanner.admin.database.v1.ListBackupSchedulesRequest; +import com.google.spanner.admin.database.v1.ListBackupSchedulesResponse; import com.google.spanner.admin.database.v1.ListBackupsRequest; import com.google.spanner.admin.database.v1.ListBackupsResponse; import com.google.spanner.admin.database.v1.ListDatabaseOperationsRequest; @@ -65,6 +72,7 @@ import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata; import com.google.spanner.admin.database.v1.RestoreDatabaseRequest; import com.google.spanner.admin.database.v1.UpdateBackupRequest; +import com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseMetadata; @@ -277,6 +285,61 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub { ProtoUtils.marshaller(ListDatabaseRolesResponse.getDefaultInstance())) .build(); + private static final MethodDescriptor + createBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.spanner.admin.database.v1.DatabaseAdmin/CreateBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(CreateBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(BackupSchedule.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + getBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/GetBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(GetBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(BackupSchedule.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + updateBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(UpdateBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(BackupSchedule.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + deleteBackupScheduleMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackupSchedule") + .setRequestMarshaller( + ProtoUtils.marshaller(DeleteBackupScheduleRequest.getDefaultInstance())) + .setResponseMarshaller(ProtoUtils.marshaller(Empty.getDefaultInstance())) + .build(); + + private static final MethodDescriptor + listBackupSchedulesMethodDescriptor = + MethodDescriptor.newBuilder() + .setType(MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + "google.spanner.admin.database.v1.DatabaseAdmin/ListBackupSchedules") + .setRequestMarshaller( + ProtoUtils.marshaller(ListBackupSchedulesRequest.getDefaultInstance())) + .setResponseMarshaller( + ProtoUtils.marshaller(ListBackupSchedulesResponse.getDefaultInstance())) + .build(); + private final UnaryCallable listDatabasesCallable; private final UnaryCallable listDatabasesPagedCallable; @@ -323,6 +386,16 @@ public class GrpcDatabaseAdminStub extends DatabaseAdminStub { listDatabaseRolesCallable; private final UnaryCallable listDatabaseRolesPagedCallable; + private final UnaryCallable + createBackupScheduleCallable; + private final UnaryCallable getBackupScheduleCallable; + private final UnaryCallable + updateBackupScheduleCallable; + private final UnaryCallable deleteBackupScheduleCallable; + private final UnaryCallable + listBackupSchedulesCallable; + private final UnaryCallable + listBackupSchedulesPagedCallable; private final BackgroundResource backgroundResources; private final GrpcOperationsStub operationsStub; @@ -572,6 +645,61 @@ protected GrpcDatabaseAdminStub( return builder.build(); }) .build(); + GrpcCallSettings + createBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(createBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + GrpcCallSettings getBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(getBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings + updateBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(updateBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + "backup_schedule.name", + String.valueOf(request.getBackupSchedule().getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings deleteBackupScheduleTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupScheduleMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + GrpcCallSettings + listBackupSchedulesTransportSettings = + GrpcCallSettings.newBuilder() + .setMethodDescriptor(listBackupSchedulesMethodDescriptor) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); this.listDatabasesCallable = callableFactory.createUnaryCallable( @@ -700,6 +828,36 @@ protected GrpcDatabaseAdminStub( listDatabaseRolesTransportSettings, settings.listDatabaseRolesSettings(), clientContext); + this.createBackupScheduleCallable = + callableFactory.createUnaryCallable( + createBackupScheduleTransportSettings, + settings.createBackupScheduleSettings(), + clientContext); + this.getBackupScheduleCallable = + callableFactory.createUnaryCallable( + getBackupScheduleTransportSettings, + settings.getBackupScheduleSettings(), + clientContext); + this.updateBackupScheduleCallable = + callableFactory.createUnaryCallable( + updateBackupScheduleTransportSettings, + settings.updateBackupScheduleSettings(), + clientContext); + this.deleteBackupScheduleCallable = + callableFactory.createUnaryCallable( + deleteBackupScheduleTransportSettings, + settings.deleteBackupScheduleSettings(), + clientContext); + this.listBackupSchedulesCallable = + callableFactory.createUnaryCallable( + listBackupSchedulesTransportSettings, + settings.listBackupSchedulesSettings(), + clientContext); + this.listBackupSchedulesPagedCallable = + callableFactory.createPagedCallable( + listBackupSchedulesTransportSettings, + settings.listBackupSchedulesSettings(), + clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -878,6 +1036,38 @@ public UnaryCallable restoreDatabaseCallable( return listDatabaseRolesPagedCallable; } + @Override + public UnaryCallable createBackupScheduleCallable() { + return createBackupScheduleCallable; + } + + @Override + public UnaryCallable getBackupScheduleCallable() { + return getBackupScheduleCallable; + } + + @Override + public UnaryCallable updateBackupScheduleCallable() { + return updateBackupScheduleCallable; + } + + @Override + public UnaryCallable deleteBackupScheduleCallable() { + return deleteBackupScheduleCallable; + } + + @Override + public UnaryCallable + listBackupSchedulesCallable() { + return listBackupSchedulesCallable; + } + + @Override + public UnaryCallable + listBackupSchedulesPagedCallable() { + return listBackupSchedulesPagedCallable; + } + @Override public final void close() { try { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/HttpJsonDatabaseAdminStub.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/HttpJsonDatabaseAdminStub.java index 1eaa5055133..fbe9f02b1f8 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/HttpJsonDatabaseAdminStub.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/database/v1/stub/HttpJsonDatabaseAdminStub.java @@ -17,6 +17,7 @@ package com.google.cloud.spanner.admin.database.v1.stub; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse; +import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupSchedulesPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseOperationsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseRolesPagedResponse; @@ -48,21 +49,27 @@ import com.google.protobuf.Empty; import com.google.protobuf.TypeRegistry; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.BackupSchedule; import com.google.spanner.admin.database.v1.CopyBackupMetadata; import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupMetadata; import com.google.spanner.admin.database.v1.CreateBackupRequest; +import com.google.spanner.admin.database.v1.CreateBackupScheduleRequest; import com.google.spanner.admin.database.v1.CreateDatabaseMetadata; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; import com.google.spanner.admin.database.v1.Database; import com.google.spanner.admin.database.v1.DeleteBackupRequest; +import com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest; import com.google.spanner.admin.database.v1.DropDatabaseRequest; import com.google.spanner.admin.database.v1.GetBackupRequest; +import com.google.spanner.admin.database.v1.GetBackupScheduleRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse; import com.google.spanner.admin.database.v1.GetDatabaseRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsResponse; +import com.google.spanner.admin.database.v1.ListBackupSchedulesRequest; +import com.google.spanner.admin.database.v1.ListBackupSchedulesResponse; import com.google.spanner.admin.database.v1.ListBackupsRequest; import com.google.spanner.admin.database.v1.ListBackupsResponse; import com.google.spanner.admin.database.v1.ListDatabaseOperationsRequest; @@ -74,6 +81,7 @@ import com.google.spanner.admin.database.v1.RestoreDatabaseMetadata; import com.google.spanner.admin.database.v1.RestoreDatabaseRequest; import com.google.spanner.admin.database.v1.UpdateBackupRequest; +import com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseMetadata; @@ -385,7 +393,8 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub { return fields; }) .setAdditionalPaths( - "/v1/{resource=projects/*/instances/*/backups/*}:setIamPolicy") + "/v1/{resource=projects/*/instances/*/backups/*}:setIamPolicy", + "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:setIamPolicy") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); @@ -424,7 +433,8 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub { return fields; }) .setAdditionalPaths( - "/v1/{resource=projects/*/instances/*/backups/*}:getIamPolicy") + "/v1/{resource=projects/*/instances/*/backups/*}:getIamPolicy", + "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:getIamPolicy") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); @@ -465,6 +475,7 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub { }) .setAdditionalPaths( "/v1/{resource=projects/*/instances/*/backups/*}:testIamPermissions", + "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:testIamPermissions", "/v1/{resource=projects/*/instances/*/databases/*/databaseRoles/*}:testIamPermissions") .setQueryParamsExtractor( request -> { @@ -868,6 +879,194 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub { .build()) .build(); + private static final ApiMethodDescriptor + createBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.spanner.admin.database.v1.DatabaseAdmin/CreateBackupSchedule") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/instances/*/databases/*}/backupSchedules", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "backupScheduleId", request.getBackupScheduleId()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("backupSchedule", request.getBackupSchedule(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BackupSchedule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.spanner.admin.database.v1.DatabaseAdmin/GetBackupSchedule") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/instances/*/databases/*/backupSchedules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BackupSchedule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackupSchedule") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{backupSchedule.name=projects/*/instances/*/databases/*/backupSchedules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "backupSchedule.name", + request.getBackupSchedule().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("backupSchedule", request.getBackupSchedule(), true)) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(BackupSchedule.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteBackupScheduleMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackupSchedule") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/instances/*/databases/*/backupSchedules/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listBackupSchedulesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.spanner.admin.database.v1.DatabaseAdmin/ListBackupSchedules") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/instances/*/databases/*}/backupSchedules", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "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(ListBackupSchedulesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + private final UnaryCallable listDatabasesCallable; private final UnaryCallable listDatabasesPagedCallable; @@ -914,6 +1113,16 @@ public class HttpJsonDatabaseAdminStub extends DatabaseAdminStub { listDatabaseRolesCallable; private final UnaryCallable listDatabaseRolesPagedCallable; + private final UnaryCallable + createBackupScheduleCallable; + private final UnaryCallable getBackupScheduleCallable; + private final UnaryCallable + updateBackupScheduleCallable; + private final UnaryCallable deleteBackupScheduleCallable; + private final UnaryCallable + listBackupSchedulesCallable; + private final UnaryCallable + listBackupSchedulesPagedCallable; private final BackgroundResource backgroundResources; private final HttpJsonOperationsStub httpJsonOperationsStub; @@ -1265,6 +1474,68 @@ protected HttpJsonDatabaseAdminStub( return builder.build(); }) .build(); + HttpJsonCallSettings + createBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + getBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + updateBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add( + "backup_schedule.name", + String.valueOf(request.getBackupSchedule().getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings deleteBackupScheduleTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupScheduleMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("name", String.valueOf(request.getName())); + return builder.build(); + }) + .build(); + HttpJsonCallSettings + listBackupSchedulesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listBackupSchedulesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .setParamsExtractor( + request -> { + RequestParamsBuilder builder = RequestParamsBuilder.create(); + builder.add("parent", String.valueOf(request.getParent())); + return builder.build(); + }) + .build(); this.listDatabasesCallable = callableFactory.createUnaryCallable( @@ -1393,6 +1664,36 @@ protected HttpJsonDatabaseAdminStub( listDatabaseRolesTransportSettings, settings.listDatabaseRolesSettings(), clientContext); + this.createBackupScheduleCallable = + callableFactory.createUnaryCallable( + createBackupScheduleTransportSettings, + settings.createBackupScheduleSettings(), + clientContext); + this.getBackupScheduleCallable = + callableFactory.createUnaryCallable( + getBackupScheduleTransportSettings, + settings.getBackupScheduleSettings(), + clientContext); + this.updateBackupScheduleCallable = + callableFactory.createUnaryCallable( + updateBackupScheduleTransportSettings, + settings.updateBackupScheduleSettings(), + clientContext); + this.deleteBackupScheduleCallable = + callableFactory.createUnaryCallable( + deleteBackupScheduleTransportSettings, + settings.deleteBackupScheduleSettings(), + clientContext); + this.listBackupSchedulesCallable = + callableFactory.createUnaryCallable( + listBackupSchedulesTransportSettings, + settings.listBackupSchedulesSettings(), + clientContext); + this.listBackupSchedulesPagedCallable = + callableFactory.createPagedCallable( + listBackupSchedulesTransportSettings, + settings.listBackupSchedulesSettings(), + clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); @@ -1421,6 +1722,11 @@ public static List getMethodDescriptors() { methodDescriptors.add(listDatabaseOperationsMethodDescriptor); methodDescriptors.add(listBackupOperationsMethodDescriptor); methodDescriptors.add(listDatabaseRolesMethodDescriptor); + methodDescriptors.add(createBackupScheduleMethodDescriptor); + methodDescriptors.add(getBackupScheduleMethodDescriptor); + methodDescriptors.add(updateBackupScheduleMethodDescriptor); + methodDescriptors.add(deleteBackupScheduleMethodDescriptor); + methodDescriptors.add(listBackupSchedulesMethodDescriptor); return methodDescriptors; } @@ -1597,6 +1903,38 @@ public UnaryCallable restoreDatabaseCallable( return listDatabaseRolesPagedCallable; } + @Override + public UnaryCallable createBackupScheduleCallable() { + return createBackupScheduleCallable; + } + + @Override + public UnaryCallable getBackupScheduleCallable() { + return getBackupScheduleCallable; + } + + @Override + public UnaryCallable updateBackupScheduleCallable() { + return updateBackupScheduleCallable; + } + + @Override + public UnaryCallable deleteBackupScheduleCallable() { + return deleteBackupScheduleCallable; + } + + @Override + public UnaryCallable + listBackupSchedulesCallable() { + return listBackupSchedulesCallable; + } + + @Override + public UnaryCallable + listBackupSchedulesPagedCallable() { + return listBackupSchedulesPagedCallable; + } + @Override public final void close() { try { diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStubSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStubSettings.java index 9a00b312c61..a74094a3149 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStubSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/admin/instance/v1/stub/InstanceAdminStubSettings.java @@ -25,6 +25,7 @@ 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; @@ -738,6 +739,7 @@ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuild } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "spanner.googleapis.com:443"; } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ReadWriteTransaction.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ReadWriteTransaction.java index 520a2e180e5..0362ffc2050 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ReadWriteTransaction.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ReadWriteTransaction.java @@ -461,7 +461,10 @@ public void run() { CallType.SYNC, SELECT1_STATEMENT, AnalyzeMode.NONE, - Options.tag("connection.transaction-keep-alive")); + Options.tag( + System.getProperty( + "spanner.connection.keep_alive_query_tag", + "connection.transaction-keep-alive"))); future.addListener( ReadWriteTransaction.this::maybeScheduleKeepAlivePing, MoreExecutors.directExecutor()); } diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java index b6016f04f78..00ae72f169a 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/GapicSpannerRpc.java @@ -56,6 +56,7 @@ import com.google.api.pathtemplate.PathTemplate; import com.google.cloud.RetryHelper; import com.google.cloud.RetryHelper.RetryHelperException; +import com.google.cloud.grpc.GcpManagedChannel; import com.google.cloud.grpc.GcpManagedChannelBuilder; import com.google.cloud.grpc.GcpManagedChannelOptions; import com.google.cloud.grpc.GcpManagedChannelOptions.GcpMetricsOptions; @@ -240,6 +241,7 @@ public class GapicSpannerRpc implements SpannerRpc { private final Set executeQueryRetryableCodes; private final RetrySettings readRetrySettings; private final Set readRetryableCodes; + private final RetrySettings commitRetrySettings; private final SpannerStub partitionedDmlStub; private final RetrySettings partitionedDmlRetrySettings; private final InstanceAdminStubSettings instanceAdminStubSettings; @@ -266,6 +268,8 @@ public class GapicSpannerRpc implements SpannerRpc { private static final ConcurrentMap ADMINISTRATIVE_REQUESTS_RATE_LIMITERS = new ConcurrentHashMap<>(); private final boolean leaderAwareRoutingEnabled; + private final int numChannels; + private final boolean isGrpcGcpExtensionEnabled; public static GapicSpannerRpc create(SpannerOptions options) { return new GapicSpannerRpc(options); @@ -317,6 +321,8 @@ public GapicSpannerRpc(final SpannerOptions options) { this.callCredentialsProvider = options.getCallCredentialsProvider(); this.compressorName = options.getCompressorName(); this.leaderAwareRoutingEnabled = options.isLeaderAwareRoutingEnabled(); + this.numChannels = options.getNumChannels(); + this.isGrpcGcpExtensionEnabled = options.isGrpcGcpExtensionEnabled(); if (initializeStubs) { // First check if SpannerOptions provides a TransportChannelProvider. Create one @@ -398,6 +404,8 @@ public GapicSpannerRpc(final SpannerOptions options) { options.getSpannerStubSettings().executeStreamingSqlSettings().getRetrySettings(); this.executeQueryRetryableCodes = options.getSpannerStubSettings().executeStreamingSqlSettings().getRetryableCodes(); + this.commitRetrySettings = + options.getSpannerStubSettings().commitSettings().getRetrySettings(); partitionedDmlRetrySettings = options .getSpannerStubSettings() @@ -508,6 +516,8 @@ public UnaryCallable createUnaryCalla this.readRetryableCodes = null; this.executeQueryRetrySettings = null; this.executeQueryRetryableCodes = null; + this.commitRetrySettings = + SpannerStubSettings.newBuilder().commitSettings().getRetrySettings(); this.partitionedDmlStub = null; this.databaseAdminStubSettings = null; this.instanceAdminStubSettings = null; @@ -1801,6 +1811,11 @@ public CommitResponse commit(CommitRequest commitRequest, @Nullable Map rollbackAsync(RollbackRequest request, @Nullable Map options) { GrpcCallContext context = @@ -1950,7 +1965,20 @@ GrpcCallContext newCallContext( boolean routeToLeader) { GrpcCallContext context = GrpcCallContext.createDefault(); if (options != null) { - context = context.withChannelAffinity(Option.CHANNEL_HINT.getLong(options).intValue()); + if (this.isGrpcGcpExtensionEnabled) { + // Set channel affinity in gRPC-GCP. + // Compute bounded channel hint to prevent gRPC-GCP affinity map from getting unbounded. + int boundedChannelHint = Option.CHANNEL_HINT.getLong(options).intValue() % this.numChannels; + context = + context.withCallOptions( + context + .getCallOptions() + .withOption( + GcpManagedChannel.AFFINITY_KEY, String.valueOf(boundedChannelHint))); + } else { + // Set channel affinity in GAX. + context = context.withChannelAffinity(Option.CHANNEL_HINT.getLong(options).intValue()); + } } if (compressorName != null) { // This sets the compressor for Client -> Server. diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java index f063a7a3138..f07a28fb918 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/spi/v1/SpannerRpc.java @@ -469,6 +469,10 @@ CommitResponse commit(CommitRequest commitRequest, @Nullable Map opti ApiFuture commitAsync( CommitRequest commitRequest, @Nullable Map options); + default RetrySettings getCommitRetrySettings() { + return SpannerStubSettings.newBuilder().commitSettings().getRetrySettings(); + } + void rollback(RollbackRequest request, @Nullable Map options) throws SpannerException; ApiFuture rollbackAsync(RollbackRequest request, @Nullable Map options); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java index db96f17542a..fa6b86633b3 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/v1/stub/SpannerStubSettings.java @@ -21,6 +21,7 @@ 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; @@ -311,6 +312,7 @@ public static InstantiatingExecutorProvider.Builder defaultExecutorProviderBuild } /** Returns the default service endpoint. */ + @ObsoleteApi("Use getEndpoint() instead") public static String getDefaultEndpoint() { return "spanner.googleapis.com:443"; } diff --git a/google-cloud-spanner/src/main/resources/META-INF/native-image/com.google.cloud.spanner.admin.database.v1/reflect-config.json b/google-cloud-spanner/src/main/resources/META-INF/native-image/com.google.cloud.spanner.admin.database.v1/reflect-config.json index 9518d8b2191..37bd9977c19 100644 --- a/google-cloud-spanner/src/main/resources/META-INF/native-image/com.google.cloud.spanner.admin.database.v1/reflect-config.json +++ b/google-cloud-spanner/src/main/resources/META-INF/native-image/com.google.cloud.spanner.admin.database.v1/reflect-config.json @@ -1646,6 +1646,42 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.BackupSchedule", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.BackupSchedule$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.BackupScheduleSpec", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.BackupScheduleSpec$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.CopyBackupEncryptionConfig", "queryAllDeclaredConstructors": true, @@ -1772,6 +1808,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.CreateBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.CreateBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.CreateDatabaseMetadata", "queryAllDeclaredConstructors": true, @@ -1808,6 +1862,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.CrontabSpec", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.CrontabSpec$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.Database", "queryAllDeclaredConstructors": true, @@ -1898,6 +1970,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.DropDatabaseRequest", "queryAllDeclaredConstructors": true, @@ -1961,6 +2051,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.FullBackupSpec", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.FullBackupSpec$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.GetBackupRequest", "queryAllDeclaredConstructors": true, @@ -1979,6 +2087,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.GetBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.GetBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.GetDatabaseDdlRequest", "queryAllDeclaredConstructors": true, @@ -2033,6 +2159,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.IncrementalBackupSpec", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.IncrementalBackupSpec$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.ListBackupOperationsRequest", "queryAllDeclaredConstructors": true, @@ -2069,6 +2213,42 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.ListBackupSchedulesRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.ListBackupSchedulesRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.ListBackupSchedulesResponse", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.ListBackupSchedulesResponse$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.ListBackupsRequest", "queryAllDeclaredConstructors": true, @@ -2357,6 +2537,24 @@ "allDeclaredClasses": true, "allPublicClasses": true }, + { + "name": "com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, + { + "name": "com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest$Builder", + "queryAllDeclaredConstructors": true, + "queryAllPublicConstructors": true, + "queryAllDeclaredMethods": true, + "allPublicMethods": true, + "allDeclaredClasses": true, + "allPublicClasses": true + }, { "name": "com.google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata", "queryAllDeclaredConstructors": true, diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AbstractReadContextTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AbstractReadContextTest.java index 65f27d55810..ce7d6b300d1 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AbstractReadContextTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AbstractReadContextTest.java @@ -33,8 +33,11 @@ import com.google.spanner.v1.ExecuteSqlRequest; import com.google.spanner.v1.ExecuteSqlRequest.QueryMode; import com.google.spanner.v1.ExecuteSqlRequest.QueryOptions; +import com.google.spanner.v1.ReadRequest; +import com.google.spanner.v1.ReadRequest.OrderBy; import com.google.spanner.v1.RequestOptions; import com.google.spanner.v1.RequestOptions.Priority; +import com.google.spanner.v1.SessionName; import com.google.spanner.v1.TransactionSelector; import java.util.ArrayList; import java.util.Collection; @@ -223,6 +226,21 @@ public void testGetExecuteSqlRequestBuilderWithDataBoost() { assertTrue(request.getDataBoostEnabled()); } + @Test + public void testGetReadRequestBuilderWithOrderBy() { + ReadRequest request = + ReadRequest.newBuilder() + .setSession( + SessionName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SESSION]").toString()) + .setTransaction(TransactionSelector.newBuilder().build()) + .setTable("table110115790") + .setIndex("index100346066") + .addAllColumns(new ArrayList()) + .setOrderByValue(2) + .build(); + assertEquals(OrderBy.ORDER_BY_NO_ORDER, request.getOrderBy()); + } + @Test public void testGetExecuteBatchDmlRequestBuilderWithPriority() { ExecuteBatchDmlRequest.Builder request = diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchCreateSessionsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchCreateSessionsTest.java index c252bb19238..8d359428c77 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchCreateSessionsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/BatchCreateSessionsTest.java @@ -207,13 +207,13 @@ public void testSpannerReturnsAllAvailableSessionsAndThenNoSessions() } @Test - public void testSpannerReturnsResourceExhausted() throws InterruptedException { + public void testSpannerReturnsFailedPrecondition() throws InterruptedException { int minSessions = 100; int maxSessions = 1000; int expectedSessions; DatabaseClientImpl client; // Make the first BatchCreateSessions return an error. - mockSpanner.addException(Status.RESOURCE_EXHAUSTED.asRuntimeException()); + mockSpanner.addException(Status.FAILED_PRECONDITION.asRuntimeException()); try (Spanner spanner = createSpanner(minSessions, maxSessions)) { // Create a database client which will create a session pool. client = diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java index 6443c904b86..62a10c0adb4 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java @@ -52,6 +52,7 @@ import com.google.cloud.spanner.AsyncTransactionManager.TransactionContextFuture; import com.google.cloud.spanner.MockSpannerServiceImpl.SimulatedExecutionTime; import com.google.cloud.spanner.MockSpannerServiceImpl.StatementResult; +import com.google.cloud.spanner.Options.RpcOrderBy; import com.google.cloud.spanner.Options.RpcPriority; import com.google.cloud.spanner.Options.TransactionOption; import com.google.cloud.spanner.ReadContext.QueryAnalyzeMode; @@ -89,6 +90,7 @@ import com.google.spanner.v1.ExecuteSqlRequest.QueryMode; import com.google.spanner.v1.ExecuteSqlRequest.QueryOptions; import com.google.spanner.v1.ReadRequest; +import com.google.spanner.v1.ReadRequest.OrderBy; import com.google.spanner.v1.RequestOptions.Priority; import com.google.spanner.v1.ResultSetMetadata; import com.google.spanner.v1.ResultSetStats; @@ -1722,6 +1724,27 @@ public void testExecuteReadWithTag() { assertThat(request.getRequestOptions().getTransactionTag()).isEmpty(); } + @Test + public void testExecuteReadWithOrderByOption() { + DatabaseClient client = + spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE)); + try (ResultSet resultSet = + client + .singleUse() + .read( + READ_TABLE_NAME, + KeySet.singleKey(Key.of(1L)), + READ_COLUMN_NAMES, + Options.orderBy(RpcOrderBy.NO_ORDER))) { + consumeResults(resultSet); + } + + List requests = mockSpanner.getRequestsOfType(ReadRequest.class); + assertThat(requests).hasSize(1); + ReadRequest request = requests.get(0); + assertEquals(OrderBy.ORDER_BY_NO_ORDER, request.getOrderBy()); + } + @Test public void testExecuteReadWithDirectedReadOptions() { DatabaseClient client = @@ -3836,7 +3859,8 @@ public void testBatchCreateSessionsFailure_shouldNotPropagateToCloseMethod() { try { // Simulate session creation failures on the backend. mockSpanner.setBatchCreateSessionsExecutionTime( - SimulatedExecutionTime.ofStickyException(Status.RESOURCE_EXHAUSTED.asRuntimeException())); + SimulatedExecutionTime.ofStickyException( + Status.FAILED_PRECONDITION.asRuntimeException())); DatabaseClient client = spannerWithEmptySessionPool.getDatabaseClient( DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE)); @@ -3844,7 +3868,7 @@ public void testBatchCreateSessionsFailure_shouldNotPropagateToCloseMethod() { // non-blocking, and any exceptions will be delayed until actual query execution. try (ResultSet rs = client.singleUse().executeQuery(SELECT1)) { SpannerException e = assertThrows(SpannerException.class, rs::next); - assertThat(e.getErrorCode()).isEqualTo(ErrorCode.RESOURCE_EXHAUSTED); + assertThat(e.getErrorCode()).isEqualTo(ErrorCode.FAILED_PRECONDITION); } } finally { mockSpanner.setBatchCreateSessionsExecutionTime(SimulatedExecutionTime.none()); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java index 6dd9c29e23f..2c6f886522e 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/IntegrationTestEnv.java @@ -87,6 +87,10 @@ protected void initializeConfig() throw new NullPointerException("Property " + TEST_ENV_CONFIG_CLASS_NAME + " needs to be set"); } Class configClass; + if (EmulatorSpannerHelper.isUsingEmulator()) { + // Make sure that we use an owned instance on the emulator. + System.setProperty(TEST_INSTANCE_PROPERTY, ""); + } configClass = (Class) Class.forName(CONFIG_CLASS); config = configClass.newInstance(); } @@ -143,7 +147,7 @@ protected void after() { private void initializeInstance(InstanceId instanceId) throws Exception { InstanceConfig instanceConfig; try { - instanceConfig = instanceAdminClient.getInstanceConfig("regional-us-central1"); + instanceConfig = instanceAdminClient.getInstanceConfig("regional-us-east4"); } catch (Throwable ignore) { instanceConfig = Iterators.get(instanceAdminClient.listInstanceConfigs().iterateAll().iterator(), 0, null); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java index 54b992b69ff..5266ecad7c8 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MockSpannerServiceImpl.java @@ -808,7 +808,7 @@ public void batchCreateSessions( batchCreateSessionsExecutionTime.simulateExecutionTime( exceptions, stickyGlobalExceptions, freezeLock); if (sessions.size() >= maxTotalSessions) { - throw Status.RESOURCE_EXHAUSTED + throw Status.FAILED_PRECONDITION .withDescription("Maximum number of sessions reached") .asRuntimeException(); } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionMaintainerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionMaintainerTest.java deleted file mode 100644 index ca7f8386894..00000000000 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionMaintainerTest.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.cloud.spanner; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import com.google.cloud.Timestamp; -import com.google.cloud.spanner.SessionPool.CachedSession; -import com.google.cloud.spanner.SessionPool.MultiplexedSessionInitializationConsumer; -import com.google.cloud.spanner.SessionPool.MultiplexedSessionMaintainerConsumer; -import com.google.cloud.spanner.SessionPool.Position; -import com.google.cloud.spanner.SessionPool.SessionFutureWrapper; -import io.opencensus.trace.Tracing; -import io.opentelemetry.api.OpenTelemetry; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.stream.Collectors; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; -import org.mockito.Mock; -import org.threeten.bp.Duration; -import org.threeten.bp.Instant; - -@RunWith(JUnit4.class) -public class MultiplexedSessionMaintainerTest extends BaseSessionPoolTest { - - private ExecutorService executor = Executors.newSingleThreadExecutor(); - private @Mock SpannerImpl client; - private @Mock SessionClient sessionClient; - private @Mock SpannerOptions spannerOptions; - private DatabaseId db = DatabaseId.of("projects/p/instances/i/databases/unused"); - private SessionPoolOptions options; - private FakeClock clock = new FakeClock(); - private List multiplexedSessionsRemoved = new ArrayList<>(); - - @BeforeClass - public static void checkUsesMultiplexedSessionPool() { - assumeTrue("Only run if the maintainer in the session pool is used", false); - } - - @Before - public void setUp() { - initMocks(this); - when(client.getOptions()).thenReturn(spannerOptions); - when(client.getSessionClient(db)).thenReturn(sessionClient); - when(sessionClient.getSpanner()).thenReturn(client); - when(spannerOptions.getNumChannels()).thenReturn(4); - when(spannerOptions.getDatabaseRole()).thenReturn("role"); - options = - SessionPoolOptions.newBuilder() - .setMinSessions(1) - .setMaxIdleSessions(1) - .setMaxSessions(5) - .setIncStep(1) - .setKeepAliveIntervalMinutes(2) - .setUseMultiplexedSession(true) - .setPoolMaintainerClock(clock) - .build(); - when(spannerOptions.getSessionPoolOptions()).thenReturn(options); - assumeTrue(options.getUseMultiplexedSession()); - multiplexedSessionsRemoved.clear(); - } - - @Test - public void testMaintainMultiplexedSession_whenNewSessionCreated_assertThatStaleSessionIsRemoved() - throws Exception { - doAnswer( - invocation -> { - MultiplexedSessionInitializationConsumer consumer = - invocation.getArgument(0, MultiplexedSessionInitializationConsumer.class); - ReadContext mockContext = mock(ReadContext.class); - Timestamp timestamp = - Timestamp.ofTimeSecondsAndNanos( - Instant.ofEpochMilli(clock.currentTimeMillis.get()).getEpochSecond(), 0); - consumer.onSessionReady( - setupMockSession( - buildMockMultiplexedSession(client, mockContext, timestamp.toProto()), - mockContext)); - return null; - }) - .when(sessionClient) - .asyncCreateMultiplexedSession(any(MultiplexedSessionInitializationConsumer.class)); - doAnswer( - invocation -> { - MultiplexedSessionMaintainerConsumer consumer = - invocation.getArgument(0, MultiplexedSessionMaintainerConsumer.class); - ReadContext mockContext = mock(ReadContext.class); - Timestamp timestamp = - Timestamp.ofTimeSecondsAndNanos( - Instant.ofEpochMilli(clock.currentTimeMillis.get()).getEpochSecond(), 0); - consumer.onSessionReady( - setupMockSession( - buildMockMultiplexedSession(client, mockContext, timestamp.toProto()), - mockContext)); - return null; - }) - .when(sessionClient) - .asyncCreateMultiplexedSession(any(MultiplexedSessionMaintainerConsumer.class)); - - SessionPool pool = createPool(); - - // Run one maintenance loop. - CachedSession session1 = pool.getMultiplexedSessionWithFallback().get().get(); - runMaintenanceLoop(clock, pool, 1); - assertTrue(multiplexedSessionsRemoved.isEmpty()); - - // Advance clock by 8 days - clock.currentTimeMillis.addAndGet(Duration.ofDays(8).toMillis()); - - // Run second maintenance loop. the first session would now be stale since it has now existed - // for more than 7 days. - runMaintenanceLoop(clock, pool, 1); - - CachedSession session2 = pool.getMultiplexedSessionWithFallback().get().get(); - assertNotEquals(session1.getName(), session2.getName()); - assertEquals(1, multiplexedSessionsRemoved.size()); - assertTrue(getNameOfSessionRemoved().contains(session1.getName())); - - // Advance clock by 8 days - clock.currentTimeMillis.addAndGet(Duration.ofDays(8).toMillis()); - - // Run third maintenance loop. the second session would now be stale since it has now existed - // for more than 7 days - runMaintenanceLoop(clock, pool, 1); - - CachedSession session3 = pool.getMultiplexedSessionWithFallback().get().get(); - assertNotEquals(session2.getName(), session3.getName()); - assertEquals(2, multiplexedSessionsRemoved.size()); - assertTrue(getNameOfSessionRemoved().contains(session2.getName())); - } - - @Test - public void - testMaintainMultiplexedSession_whenMultiplexedSessionNotStale_assertThatSessionIsNotRemoved() { - doAnswer( - invocation -> { - MultiplexedSessionInitializationConsumer consumer = - invocation.getArgument(0, MultiplexedSessionInitializationConsumer.class); - ReadContext mockContext = mock(ReadContext.class); - Timestamp timestamp = - Timestamp.ofTimeSecondsAndNanos( - Instant.ofEpochMilli(clock.currentTimeMillis.get()).getEpochSecond(), 0); - consumer.onSessionReady( - setupMockSession( - buildMockMultiplexedSession(client, mockContext, timestamp.toProto()), - mockContext)); - return null; - }) - .when(sessionClient) - .asyncCreateMultiplexedSession(any(MultiplexedSessionInitializationConsumer.class)); - SessionPool pool = createPool(); - - // Run one maintenance loop. - SessionFutureWrapper session1 = pool.getMultiplexedSessionWithFallback(); - runMaintenanceLoop(clock, pool, 1); - assertTrue(multiplexedSessionsRemoved.isEmpty()); - - // Advance clock by 4 days - clock.currentTimeMillis.addAndGet(Duration.ofDays(4).toMillis()); - // Run one maintenance loop. the first session would not be stale yet since it has now existed - // for less than 7 days. - runMaintenanceLoop(clock, pool, 1); - SessionFutureWrapper session2 = pool.getMultiplexedSessionWithFallback(); - assertTrue(multiplexedSessionsRemoved.isEmpty()); - assertEquals(session1.get().getName(), session2.get().getName()); - } - - @Test - public void - testMaintainMultiplexedSession_whenMultiplexedSessionCreationFailed_testRetryAfterDelay() { - doAnswer( - invocation -> { - MultiplexedSessionInitializationConsumer consumer = - invocation.getArgument(0, MultiplexedSessionInitializationConsumer.class); - ReadContext mockContext = mock(ReadContext.class); - Timestamp timestamp = - Timestamp.ofTimeSecondsAndNanos( - Instant.ofEpochMilli(clock.currentTimeMillis.get()).getEpochSecond(), 0); - consumer.onSessionReady( - setupMockSession( - buildMockMultiplexedSession(client, mockContext, timestamp.toProto()), - mockContext)); - return null; - }) - .when(sessionClient) - .asyncCreateMultiplexedSession(any(MultiplexedSessionInitializationConsumer.class)); - doAnswer( - invocation -> { - MultiplexedSessionMaintainerConsumer consumer = - invocation.getArgument(0, MultiplexedSessionMaintainerConsumer.class); - consumer.onSessionCreateFailure( - SpannerExceptionFactory.newSpannerException(ErrorCode.DEADLINE_EXCEEDED, ""), 1); - return null; - }) - .when(sessionClient) - .asyncCreateMultiplexedSession(any(MultiplexedSessionMaintainerConsumer.class)); - SessionPool pool = createPool(); - - // Advance clock by 8 days - clock.currentTimeMillis.addAndGet(Duration.ofDays(8).toMillis()); - - // Run one maintenance loop. Attempt replacing stale session should fail. - SessionFutureWrapper session1 = pool.getMultiplexedSessionWithFallback(); - runMaintenanceLoop(clock, pool, 1); - assertTrue(multiplexedSessionsRemoved.isEmpty()); - verify(sessionClient, times(1)) - .asyncCreateMultiplexedSession(any(MultiplexedSessionMaintainerConsumer.class)); - - // Advance clock by 10s and now mock session creation to be successful. - clock.currentTimeMillis.addAndGet(Duration.ofSeconds(10).toMillis()); - doAnswer( - invocation -> { - MultiplexedSessionMaintainerConsumer consumer = - invocation.getArgument(0, MultiplexedSessionMaintainerConsumer.class); - ReadContext mockContext = mock(ReadContext.class); - Timestamp timestamp = - Timestamp.ofTimeSecondsAndNanos( - Instant.ofEpochMilli(clock.currentTimeMillis.get()).getEpochSecond(), 0); - consumer.onSessionReady( - setupMockSession( - buildMockMultiplexedSession(client, mockContext, timestamp.toProto()), - mockContext)); - return null; - }) - .when(sessionClient) - .asyncCreateMultiplexedSession(any(MultiplexedSessionMaintainerConsumer.class)); - // Run one maintenance loop. Attempt should be ignored as it has not been 10 minutes since last - // attempt. - runMaintenanceLoop(clock, pool, 1); - SessionFutureWrapper session2 = pool.getMultiplexedSessionWithFallback(); - assertTrue(multiplexedSessionsRemoved.isEmpty()); - assertEquals(session1.get().getName(), session2.get().getName()); - verify(sessionClient, times(1)) - .asyncCreateMultiplexedSession(any(MultiplexedSessionMaintainerConsumer.class)); - - // Advance clock by 15 minutes - clock.currentTimeMillis.addAndGet(Duration.ofMinutes(15).toMillis()); - // Run one maintenance loop. Attempt should succeed since its already more than 10 minutes since - // the last attempt. - runMaintenanceLoop(clock, pool, 1); - SessionFutureWrapper session3 = pool.getMultiplexedSessionWithFallback(); - assertTrue(getNameOfSessionRemoved().contains(session1.get().get().getName())); - assertNotEquals(session1.get().getName(), session3.get().getName()); - verify(sessionClient, times(2)) - .asyncCreateMultiplexedSession(any(MultiplexedSessionMaintainerConsumer.class)); - } - - private SessionImpl setupMockSession(final SessionImpl session, final ReadContext mockContext) { - final ResultSet mockResult = mock(ResultSet.class); - when(mockContext.executeQuery(any(Statement.class))).thenAnswer(invocation -> mockResult); - when(mockResult.next()).thenReturn(true); - return session; - } - - private SessionPool createPool() { - // Allow sessions to be added to the head of the pool in all cases in this test, as it is - // otherwise impossible to know which session exactly is getting pinged at what point in time. - SessionPool pool = - SessionPool.createPool( - options, - new TestExecutorFactory(), - client.getSessionClient(db), - clock, - Position.FIRST, - new TraceWrapper(Tracing.getTracer(), OpenTelemetry.noop().getTracer(""), false), - OpenTelemetry.noop()); - pool.multiplexedSessionRemovedListener = - input -> { - multiplexedSessionsRemoved.add(input); - return null; - }; - return pool; - } - - Set getNameOfSessionRemoved() { - return multiplexedSessionsRemoved.stream() - .map(session -> session.getName()) - .collect(Collectors.toSet()); - } -} diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionPoolTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionPoolTest.java deleted file mode 100644 index fcad1ff22c6..00000000000 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MultiplexedSessionPoolTest.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * Copyright 2024 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.cloud.spanner; - -import static com.google.common.truth.Truth.assertThat; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertThrows; -import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.doAnswer; -import static org.mockito.Mockito.times; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; - -import com.google.cloud.spanner.SessionPool.MultiplexedSessionFuture; -import com.google.cloud.spanner.SessionPool.MultiplexedSessionInitializationConsumer; -import com.google.cloud.spanner.SessionPool.SessionFutureWrapper; -import com.google.cloud.spanner.SpannerImpl.ClosedException; -import io.opencensus.trace.Tracing; -import io.opentelemetry.api.OpenTelemetry; -import java.io.PrintWriter; -import java.io.StringWriter; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.mockito.Mock; -import org.threeten.bp.Duration; - -/** - * Tests for {@link com.google.cloud.spanner.SessionPool.MultiplexedSession} component within the - * {@link SessionPool} class. - */ -public class MultiplexedSessionPoolTest extends BaseSessionPoolTest { - - @Mock SpannerImpl client; - @Mock SessionClient sessionClient; - @Mock SpannerOptions spannerOptions; - private final DatabaseId db = DatabaseId.of("projects/p/instances/i/databases/unused"); - private final TraceWrapper tracer = - new TraceWrapper(Tracing.getTracer(), OpenTelemetry.noop().getTracer(""), false); - SessionPoolOptions options; - SessionPool pool; - - private SessionPool createPool() { - return SessionPool.createPool( - options, - new TestExecutorFactory(), - client.getSessionClient(db), - tracer, - OpenTelemetry.noop()); - } - - @BeforeClass - public static void checkUsesMultiplexedSessionPool() { - assumeTrue("Only run if the maintainer in the session pool is used", false); - } - - @Before - public void setUp() { - initMocks(this); - SpannerOptions.resetActiveTracingFramework(); - SpannerOptions.enableOpenTelemetryTraces(); - when(client.getOptions()).thenReturn(spannerOptions); - when(client.getSessionClient(db)).thenReturn(sessionClient); - when(sessionClient.getSpanner()).thenReturn(client); - when(spannerOptions.getNumChannels()).thenReturn(4); - when(spannerOptions.getDatabaseRole()).thenReturn("role"); - options = - SessionPoolOptions.newBuilder() - .setMinSessions(2) - .setMaxSessions(2) - .setUseMultiplexedSession(true) - .build(); - when(spannerOptions.getSessionPoolOptions()).thenReturn(options); - assumeTrue(options.getUseMultiplexedSession()); - } - - @Test - public void testGetMultiplexedSession_whenSessionInitializationSucceeded_assertSessionReturned() { - setupMockMultiplexedSessionCreation(); - - pool = createPool(); - assertTrue(pool.isValid()); - - // create 5 requests which require a session - for (int i = 0; i < 5; i++) { - // checking out a multiplexed session - SessionFutureWrapper multiplexedSessionFuture = pool.getMultiplexedSessionWithFallback(); - assertNotNull(multiplexedSessionFuture.get()); - } - verify(sessionClient, times(1)) - .asyncCreateMultiplexedSession(any(MultiplexedSessionInitializationConsumer.class)); - } - - @Test - public void testGetMultiplexedSession_whenClosedPool_assertSessionReturned() { - setupMockMultiplexedSessionCreation(); - - pool = createPool(); - assertTrue(pool.isValid()); - closePoolWithStacktrace(); - - // checking out a multiplexed session does not throw error even if pool is closed - MultiplexedSessionFuture multiplexedSessionFuture = - (MultiplexedSessionFuture) pool.getMultiplexedSessionWithFallback().get(); - assertNotNull(multiplexedSessionFuture); - - // checking out a regular session throws error. - IllegalStateException e = assertThrows(IllegalStateException.class, () -> pool.getSession()); - assertThat(e.getCause()).isInstanceOf(ClosedException.class); - StringWriter sw = new StringWriter(); - e.getCause().printStackTrace(new PrintWriter(sw)); - assertThat(sw.toString()).contains("closePoolWithStacktrace"); - } - - private void closePoolWithStacktrace() { - pool.closeAsync(new SpannerImpl.ClosedException()); - } - - @Test - public void testGetMultiplexedSession_whenSessionCreationFailed_assertErrorForWaiters() { - doAnswer( - invocation -> { - MultiplexedSessionInitializationConsumer consumer = - invocation.getArgument(0, MultiplexedSessionInitializationConsumer.class); - consumer.onSessionCreateFailure( - SpannerExceptionFactory.newSpannerException(ErrorCode.DEADLINE_EXCEEDED, ""), 1); - return null; - }) - .when(sessionClient) - .asyncCreateMultiplexedSession(any(MultiplexedSessionInitializationConsumer.class)); - options = - options - .toBuilder() - .setMinSessions(2) - .setUseMultiplexedSession(true) - .setAcquireSessionTimeout( - Duration.ofMillis(50)) // block for a max of 50 ms for session to be available - .build(); - pool = createPool(); - - // create 5 requests which require a session - for (int i = 0; i < 5; i++) { - SpannerException e = - assertThrows( - SpannerException.class, () -> pool.getMultiplexedSessionWithFallback().get().get()); - assertEquals(ErrorCode.DEADLINE_EXCEEDED, e.getErrorCode()); - } - // assert that all 5 requests failed with exception - assertEquals(0, pool.getNumWaiterTimeouts()); - assertEquals(0, pool.getNumberOfSessionsInPool()); - } - - private void setupMockMultiplexedSessionCreation() { - doAnswer( - invocation -> { - MultiplexedSessionInitializationConsumer consumer = - invocation.getArgument(0, MultiplexedSessionInitializationConsumer.class); - consumer.onSessionReady(mockSession()); - return null; - }) - .when(sessionClient) - .asyncCreateMultiplexedSession(any(MultiplexedSessionInitializationConsumer.class)); - } -} diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OptionsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OptionsTest.java index 8c9a5d957e8..38b7a121731 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OptionsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/OptionsTest.java @@ -18,16 +18,19 @@ 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.assertThrows; import static org.junit.Assert.assertTrue; +import com.google.cloud.spanner.Options.RpcOrderBy; import com.google.cloud.spanner.Options.RpcPriority; import com.google.spanner.v1.DirectedReadOptions; import com.google.spanner.v1.DirectedReadOptions.IncludeReplicas; import com.google.spanner.v1.DirectedReadOptions.ReplicaSelection; +import com.google.spanner.v1.ReadRequest.OrderBy; import com.google.spanner.v1.RequestOptions.Priority; import org.junit.Test; import org.junit.runner.RunWith; @@ -79,7 +82,8 @@ public void allOptionsPresent() { Options.limit(10), Options.prefetchChunks(1), Options.dataBoostEnabled(true), - Options.directedRead(DIRECTED_READ_OPTIONS)); + Options.directedRead(DIRECTED_READ_OPTIONS), + Options.orderBy(RpcOrderBy.NO_ORDER)); assertThat(options.hasLimit()).isTrue(); assertThat(options.limit()).isEqualTo(10); assertThat(options.hasPrefetchChunks()).isTrue(); @@ -87,6 +91,7 @@ public void allOptionsPresent() { assertThat(options.hasDataBoostEnabled()).isTrue(); assertTrue(options.dataBoostEnabled()); assertTrue(options.hasDirectedReadOptions()); + assertTrue(options.hasOrderBy()); assertEquals(DIRECTED_READ_OPTIONS, options.directedReadOptions()); } @@ -101,6 +106,7 @@ public void allOptionsAbsent() { assertThat(options.hasTag()).isFalse(); assertThat(options.hasDataBoostEnabled()).isFalse(); assertThat(options.hasDirectedReadOptions()).isFalse(); + assertThat(options.hasOrderBy()).isFalse(); assertNull(options.withExcludeTxnFromChangeStreams()); assertThat(options.toString()).isEqualTo(""); assertThat(options.equals(options)).isTrue(); @@ -182,7 +188,8 @@ public void readOptionsTest() { Options.limit(limit), Options.tag(tag), Options.dataBoostEnabled(true), - Options.directedRead(DIRECTED_READ_OPTIONS)); + Options.directedRead(DIRECTED_READ_OPTIONS), + Options.orderBy(RpcOrderBy.NO_ORDER)); assertThat(options.toString()) .isEqualTo( @@ -197,10 +204,14 @@ public void readOptionsTest() { + " " + "directedReadOptions: " + DIRECTED_READ_OPTIONS + + " " + + "orderBy: " + + RpcOrderBy.NO_ORDER + " "); assertThat(options.tag()).isEqualTo(tag); assertEquals(dataBoost, options.dataBoostEnabled()); assertEquals(DIRECTED_READ_OPTIONS, options.directedReadOptions()); + assertEquals(OrderBy.ORDER_BY_NO_ORDER, options.orderBy()); } @Test @@ -354,6 +365,24 @@ public void testTransactionOptionsPriority() { assertEquals("priority: " + priority + " ", options.toString()); } + @Test + public void testReadOptionsOrderBy() { + RpcOrderBy orderBy = RpcOrderBy.NO_ORDER; + Options options = Options.fromReadOptions(Options.orderBy(orderBy)); + assertTrue(options.hasOrderBy()); + assertEquals("orderBy: " + orderBy + " ", options.toString()); + } + + @Test + public void testReadOptionsWithOrderByEquality() { + Options optionsWithNoOrderBy1 = Options.fromReadOptions(Options.orderBy(RpcOrderBy.NO_ORDER)); + Options optionsWithNoOrderBy2 = Options.fromReadOptions(Options.orderBy(RpcOrderBy.NO_ORDER)); + assertTrue(optionsWithNoOrderBy1.equals(optionsWithNoOrderBy2)); + + Options optionsWithPkOrder = Options.fromReadOptions(Options.orderBy(RpcOrderBy.PRIMARY_KEY)); + assertFalse(optionsWithNoOrderBy1.equals(optionsWithPkOrder)); + } + @Test public void testQueryOptionsPriority() { RpcPriority priority = RpcPriority.MEDIUM; diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionImplTest.java index 72befe8a2b4..2a850514d0d 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionImplTest.java @@ -138,6 +138,8 @@ public void setUp() { when(rpc.getExecuteQueryRetryableCodes()) .thenReturn( SpannerStubSettings.newBuilder().executeStreamingSqlSettings().getRetryableCodes()); + when(rpc.getCommitRetrySettings()) + .thenReturn(SpannerStubSettings.newBuilder().commitSettings().getRetrySettings()); session = spanner.getSessionClient(db).createSession(); Span oTspan = mock(Span.class); ISpan span = new OpenTelemetrySpan(oTspan); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolOptionsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolOptionsTest.java index b678d6e46bc..9b15ddea13b 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolOptionsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolOptionsTest.java @@ -318,4 +318,95 @@ public void testMultiplexedSessionMaintenanceDuration() { .build() .getMultiplexedSessionMaintenanceDuration()); } + + @Test + public void testToBuilder() { + assertToBuilderRoundtrip(SessionPoolOptions.newBuilder().build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setUseMultiplexedSession(ThreadLocalRandom.current().nextBoolean()) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setMinSessions(ThreadLocalRandom.current().nextInt(400)) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setMaxSessions(ThreadLocalRandom.current().nextInt(1, 1000)) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setIncStep(ThreadLocalRandom.current().nextInt(1, 1000)) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setMaxIdleSessions(ThreadLocalRandom.current().nextInt(1000)) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setWriteSessionsFraction(ThreadLocalRandom.current().nextFloat()) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setInactiveTransactionRemovalOptions( + InactiveTransactionRemovalOptions.newBuilder() + .setUsedSessionsRatioThreshold(ThreadLocalRandom.current().nextDouble()) + .build()) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setLoopFrequency(ThreadLocalRandom.current().nextInt(1000)) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setMultiplexedSessionMaintenanceLoopFrequency( + java.time.Duration.ofMillis(ThreadLocalRandom.current().nextInt(1000))) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setKeepAliveIntervalMinutes(ThreadLocalRandom.current().nextInt(60)) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setRemoveInactiveSessionAfter( + Duration.ofMillis(ThreadLocalRandom.current().nextLong(10000))) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder().setCloseIfInactiveTransactions().build()); + assertToBuilderRoundtrip(SessionPoolOptions.newBuilder().setFailOnSessionLeak().build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setTrackStackTraceOfSessionCheckout(ThreadLocalRandom.current().nextBoolean()) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setInitialWaitForSessionTimeoutMillis(ThreadLocalRandom.current().nextLong(1000)) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setAutoDetectDialect(ThreadLocalRandom.current().nextBoolean()) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setWaitForMinSessions(Duration.ofMillis(ThreadLocalRandom.current().nextLong(10000))) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setAcquireSessionTimeout( + Duration.ofMillis(ThreadLocalRandom.current().nextLong(1, 10000))) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setRandomizePositionQPSThreshold(ThreadLocalRandom.current().nextLong(10000)) + .build()); + assertToBuilderRoundtrip( + SessionPoolOptions.newBuilder() + .setMultiplexedSessionMaintenanceDuration( + Duration.ofMillis(ThreadLocalRandom.current().nextLong(10000))) + .build()); + } + + static void assertToBuilderRoundtrip(SessionPoolOptions options) { + assertEquals(options, options.toBuilder().build()); + } } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolTest.java index 8ffc4f21a10..58b0280cf08 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SessionPoolTest.java @@ -64,7 +64,6 @@ import com.google.cloud.spanner.MetricRegistryTestUtils.PointWithFunction; import com.google.cloud.spanner.ReadContext.QueryAnalyzeMode; import com.google.cloud.spanner.SessionClient.SessionConsumer; -import com.google.cloud.spanner.SessionPool.MultiplexedSessionInitializationConsumer; import com.google.cloud.spanner.SessionPool.PooledSession; import com.google.cloud.spanner.SessionPool.PooledSessionFuture; import com.google.cloud.spanner.SessionPool.Position; @@ -75,6 +74,7 @@ import com.google.cloud.spanner.spi.v1.SpannerRpc; import com.google.cloud.spanner.spi.v1.SpannerRpc.ResultStreamConsumer; import com.google.cloud.spanner.v1.stub.SpannerStubSettings; +import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; import com.google.common.util.concurrent.ListenableFuture; import com.google.common.util.concurrent.Uninterruptibles; @@ -2023,14 +2023,16 @@ public void testOpenCensusMetricsDisable() { public void testOpenTelemetrySessionMetrics() throws Exception { SpannerOptions.resetActiveTracingFramework(); SpannerOptions.enableOpenTelemetryMetrics(); - // Create a session pool with max 2 session and a low timeout for waiting for a session. + // Create a session pool with max 3 session and a low timeout for waiting for a session. if (minSessions == 1) { options = SessionPoolOptions.newBuilder() .setMinSessions(1) .setMaxSessions(3) - .setMaxIdleSessions(0) - .setInitialWaitForSessionTimeoutMillis(50L) + // This must be set to null for the setInitialWaitForSessionTimeoutMillis call to have + // any effect. + .setAcquireSessionTimeout(null) + .setInitialWaitForSessionTimeoutMillis(1L) .build(); FakeClock clock = new FakeClock(); clock.currentTimeMillis.set(System.currentTimeMillis()); @@ -2081,26 +2083,29 @@ public void testOpenTelemetrySessionMetrics() throws Exception { Future fut = executor.submit( () -> { + PooledSessionFuture session = pool.getSession(); latch.countDown(); - Session session = pool.getSession(); + session.get(); session.close(); return null; }); // Wait until the background thread is actually waiting for a session. latch.await(); // Wait until the request has timed out. - int waitCount = 0; - while (pool.getNumWaiterTimeouts() == 0L && waitCount < 1000) { - Thread.sleep(5L); - waitCount++; + Stopwatch watch = Stopwatch.createStarted(); + while (pool.getNumWaiterTimeouts() == 0L && watch.elapsed(TimeUnit.MILLISECONDS) < 100) { + Thread.yield(); } + assertTrue(pool.getNumWaiterTimeouts() > 0); // Return the checked out session to the pool so the async request will get a session and // finish. session2.close(); // Verify that the async request also succeeds. fut.get(10L, TimeUnit.SECONDS); executor.shutdown(); + assertTrue(executor.awaitTermination(10L, TimeUnit.SECONDS)); + inMemoryMetricReader.forceFlush(); metricDataCollection = inMemoryMetricReader.collectAllMetrics(); // Max Allowed sessions should be 3 @@ -2212,16 +2217,6 @@ public void testWaitOnMinSessionsWhenSessionsAreCreatedBeforeTimeout() { })) .when(sessionClient) .asyncBatchCreateSessions(Mockito.eq(1), Mockito.anyBoolean(), any(SessionConsumer.class)); - doAnswer( - invocation -> - executor.submit( - () -> { - MultiplexedSessionInitializationConsumer consumer = - invocation.getArgument(0, MultiplexedSessionInitializationConsumer.class); - consumer.onSessionReady(mockMultiplexedSession()); - })) - .when(sessionClient) - .asyncCreateMultiplexedSession(any(MultiplexedSessionInitializationConsumer.class)); pool = createPool(new FakeClock(), new FakeMetricRegistry(), SPANNER_DEFAULT_LABEL_VALUES); pool.maybeWaitOnMinSessions(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionContextImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionContextImplTest.java index c1da423760d..561bfb89008 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionContextImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionContextImplTest.java @@ -28,6 +28,7 @@ import com.google.api.core.ApiFutures; import com.google.cloud.spanner.TransactionRunnerImpl.TransactionContextImpl; import com.google.cloud.spanner.spi.v1.SpannerRpc; +import com.google.cloud.spanner.v1.stub.SpannerStubSettings; import com.google.protobuf.ByteString; import com.google.protobuf.Timestamp; import com.google.rpc.Code; @@ -80,6 +81,8 @@ public void setup() { when(tracer.spanBuilderWithExplicitParent( eq(SpannerImpl.BATCH_UPDATE), eq(span), any(Attributes.class))) .thenReturn(span); + when(rpc.getCommitRetrySettings()) + .thenReturn(SpannerStubSettings.newBuilder().commitSettings().getRetrySettings()); } private TransactionContextImpl createContext() { diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionManagerImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionManagerImplTest.java index dc28b333c4f..c3fcf1c7480 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionManagerImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionManagerImplTest.java @@ -35,6 +35,7 @@ import com.google.cloud.grpc.GrpcTransportOptions.ExecutorFactory; import com.google.cloud.spanner.TransactionManager.TransactionState; import com.google.cloud.spanner.spi.v1.SpannerRpc; +import com.google.cloud.spanner.v1.stub.SpannerStubSettings; import com.google.protobuf.ByteString; import com.google.protobuf.Empty; import com.google.spanner.v1.BeginTransactionRequest; @@ -248,6 +249,8 @@ public void usesPreparedTransaction() { com.google.protobuf.Timestamp.newBuilder() .setSeconds(System.currentTimeMillis() * 1000)) .build())); + when(rpc.getCommitRetrySettings()) + .thenReturn(SpannerStubSettings.newBuilder().commitSettings().getRetrySettings()); DatabaseId db = DatabaseId.of("test", "test", "test"); try (SpannerImpl spanner = new SpannerImpl(rpc, options)) { DatabaseClient client = spanner.getDatabaseClient(db); @@ -332,6 +335,8 @@ public void inlineBegin() { com.google.protobuf.Timestamp.newBuilder() .setSeconds(System.currentTimeMillis() * 1000)) .build())); + when(rpc.getCommitRetrySettings()) + .thenReturn(SpannerStubSettings.newBuilder().commitSettings().getRetrySettings()); DatabaseId db = DatabaseId.of("test", "test", "test"); try (SpannerImpl spanner = new SpannerImpl(rpc, options)) { DatabaseClient client = spanner.getDatabaseClient(db); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionRunnerImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionRunnerImplTest.java index 6a707a490dc..f5d9f1841a2 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionRunnerImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/TransactionRunnerImplTest.java @@ -35,6 +35,7 @@ import com.google.cloud.spanner.SessionClient.SessionId; import com.google.cloud.spanner.TransactionRunnerImpl.TransactionContextImpl; import com.google.cloud.spanner.spi.v1.SpannerRpc; +import com.google.cloud.spanner.v1.stub.SpannerStubSettings; import com.google.common.base.Preconditions; import com.google.protobuf.ByteString; import com.google.protobuf.Duration; @@ -141,6 +142,8 @@ public void setUp() { CommitResponse.newBuilder() .setCommitTimestamp(Timestamp.getDefaultInstance()) .build())); + when(rpc.getCommitRetrySettings()) + .thenReturn(SpannerStubSettings.newBuilder().commitSettings().getRetrySettings()); when(rpc.rollbackAsync(Mockito.any(RollbackRequest.class), Mockito.anyMap())) .thenReturn(ApiFutures.immediateFuture(Empty.getDefaultInstance())); Span oTspan = mock(Span.class); @@ -196,6 +199,8 @@ public void usesPreparedTransaction() { .setCommitTimestamp( Timestamp.newBuilder().setSeconds(System.currentTimeMillis() * 1000)) .build())); + when(rpc.getCommitRetrySettings()) + .thenReturn(SpannerStubSettings.newBuilder().commitSettings().getRetrySettings()); DatabaseId db = DatabaseId.of("test", "test", "test"); try (SpannerImpl spanner = new SpannerImpl(rpc, options)) { DatabaseClient client = spanner.getDatabaseClient(db); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientHttpJsonTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientHttpJsonTest.java index 368868a2dce..b5a045b24a0 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientHttpJsonTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientHttpJsonTest.java @@ -17,6 +17,7 @@ package com.google.cloud.spanner.admin.database.v1; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse; +import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupSchedulesPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseOperationsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseRolesPagedResponse; @@ -41,11 +42,16 @@ import com.google.longrunning.Operation; import com.google.protobuf.Any; import com.google.protobuf.ByteString; +import com.google.protobuf.Duration; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.Timestamp; import com.google.spanner.admin.database.v1.Backup; import com.google.spanner.admin.database.v1.BackupName; +import com.google.spanner.admin.database.v1.BackupSchedule; +import com.google.spanner.admin.database.v1.BackupScheduleName; +import com.google.spanner.admin.database.v1.BackupScheduleSpec; +import com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig; import com.google.spanner.admin.database.v1.Database; import com.google.spanner.admin.database.v1.DatabaseDialect; import com.google.spanner.admin.database.v1.DatabaseName; @@ -55,6 +61,7 @@ import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse; import com.google.spanner.admin.database.v1.InstanceName; import com.google.spanner.admin.database.v1.ListBackupOperationsResponse; +import com.google.spanner.admin.database.v1.ListBackupSchedulesResponse; import com.google.spanner.admin.database.v1.ListBackupsResponse; import com.google.spanner.admin.database.v1.ListDatabaseOperationsResponse; import com.google.spanner.admin.database.v1.ListDatabaseRolesResponse; @@ -1079,12 +1086,17 @@ public void createBackupTest() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1143,12 +1155,17 @@ public void createBackupTest2() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1207,12 +1224,17 @@ public void copyBackupTest() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1274,12 +1296,17 @@ public void copyBackupTest2() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1341,12 +1368,17 @@ public void copyBackupTest3() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1408,12 +1440,17 @@ public void copyBackupTest4() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1475,12 +1512,17 @@ public void getBackupTest() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); mockService.addResponse(expectedResponse); @@ -1530,12 +1572,17 @@ public void getBackupTest2() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); mockService.addResponse(expectedResponse); @@ -1585,12 +1632,17 @@ public void updateBackupTest() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); mockService.addResponse(expectedResponse); @@ -1602,12 +1654,17 @@ public void updateBackupTest() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); FieldMask updateMask = FieldMask.newBuilder().build(); @@ -1645,12 +1702,17 @@ public void updateBackupExceptionTest() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); FieldMask updateMask = FieldMask.newBuilder().build(); client.updateBackup(backup, updateMask); @@ -2391,4 +2453,472 @@ public void listDatabaseRolesExceptionTest2() throws Exception { // Expected exception. } } + + @Test + public void createBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + String backupScheduleId = "backupScheduleId1704974708"; + + BackupSchedule actualResponse = + client.createBackupSchedule(parent, backupSchedule, backupScheduleId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + String backupScheduleId = "backupScheduleId1704974708"; + client.createBackupSchedule(parent, backupSchedule, backupScheduleId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9347/instances/instance-9347/databases/database-9347"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + String backupScheduleId = "backupScheduleId1704974708"; + + BackupSchedule actualResponse = + client.createBackupSchedule(parent, backupSchedule, backupScheduleId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createBackupScheduleExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9347/instances/instance-9347/databases/database-9347"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + String backupScheduleId = "backupScheduleId1704974708"; + client.createBackupSchedule(parent, backupSchedule, backupScheduleId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]"); + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]"); + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-8764/instances/instance-8764/databases/database-8764/backupSchedules/backupSchedule-8764"; + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getBackupScheduleExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-8764/instances/instance-8764/databases/database-8764/backupSchedules/backupSchedule-8764"; + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + BackupSchedule backupSchedule = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + BackupSchedule actualResponse = client.updateBackupSchedule(backupSchedule, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupSchedule backupSchedule = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBackupSchedule(backupSchedule, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]"); + + client.deleteBackupSchedule(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBackupScheduleExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]"); + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-8764/instances/instance-8764/databases/database-8764/backupSchedules/backupSchedule-8764"; + + client.deleteBackupSchedule(name); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteBackupScheduleExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-8764/instances/instance-8764/databases/database-8764/backupSchedules/backupSchedule-8764"; + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest() throws Exception { + BackupSchedule responsesElement = BackupSchedule.newBuilder().build(); + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .setNextPageToken("") + .addAllBackupSchedules(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + + ListBackupSchedulesPagedResponse pagedListResponse = client.listBackupSchedules(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBackupSchedulesList().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 listBackupSchedulesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest2() throws Exception { + BackupSchedule responsesElement = BackupSchedule.newBuilder().build(); + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .setNextPageToken("") + .addAllBackupSchedules(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-9347/instances/instance-9347/databases/database-9347"; + + ListBackupSchedulesPagedResponse pagedListResponse = client.listBackupSchedules(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBackupSchedulesList().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 listBackupSchedulesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-9347/instances/instance-9347/databases/database-9347"; + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientTest.java index 3766ca90a8f..a4de864ee6f 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/DatabaseAdminClientTest.java @@ -17,6 +17,7 @@ package com.google.cloud.spanner.admin.database.v1; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupOperationsPagedResponse; +import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupSchedulesPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListBackupsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseOperationsPagedResponse; import static com.google.cloud.spanner.admin.database.v1.DatabaseAdminClient.ListDatabaseRolesPagedResponse; @@ -43,29 +44,39 @@ import com.google.protobuf.AbstractMessage; import com.google.protobuf.Any; import com.google.protobuf.ByteString; +import com.google.protobuf.Duration; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import com.google.protobuf.Timestamp; import com.google.spanner.admin.database.v1.Backup; import com.google.spanner.admin.database.v1.BackupName; +import com.google.spanner.admin.database.v1.BackupSchedule; +import com.google.spanner.admin.database.v1.BackupScheduleName; +import com.google.spanner.admin.database.v1.BackupScheduleSpec; import com.google.spanner.admin.database.v1.CopyBackupRequest; +import com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig; import com.google.spanner.admin.database.v1.CreateBackupRequest; +import com.google.spanner.admin.database.v1.CreateBackupScheduleRequest; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; import com.google.spanner.admin.database.v1.Database; import com.google.spanner.admin.database.v1.DatabaseDialect; import com.google.spanner.admin.database.v1.DatabaseName; import com.google.spanner.admin.database.v1.DatabaseRole; import com.google.spanner.admin.database.v1.DeleteBackupRequest; +import com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest; import com.google.spanner.admin.database.v1.DropDatabaseRequest; import com.google.spanner.admin.database.v1.EncryptionConfig; import com.google.spanner.admin.database.v1.EncryptionInfo; import com.google.spanner.admin.database.v1.GetBackupRequest; +import com.google.spanner.admin.database.v1.GetBackupScheduleRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse; import com.google.spanner.admin.database.v1.GetDatabaseRequest; import com.google.spanner.admin.database.v1.InstanceName; import com.google.spanner.admin.database.v1.ListBackupOperationsRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsResponse; +import com.google.spanner.admin.database.v1.ListBackupSchedulesRequest; +import com.google.spanner.admin.database.v1.ListBackupSchedulesResponse; import com.google.spanner.admin.database.v1.ListBackupsRequest; import com.google.spanner.admin.database.v1.ListBackupsResponse; import com.google.spanner.admin.database.v1.ListDatabaseOperationsRequest; @@ -77,6 +88,7 @@ import com.google.spanner.admin.database.v1.RestoreDatabaseRequest; import com.google.spanner.admin.database.v1.RestoreInfo; import com.google.spanner.admin.database.v1.UpdateBackupRequest; +import com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseRequest; import io.grpc.StatusRuntimeException; @@ -987,12 +999,17 @@ public void createBackupTest() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1050,12 +1067,17 @@ public void createBackupTest2() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1113,12 +1135,17 @@ public void copyBackupTest() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1180,12 +1207,17 @@ public void copyBackupTest2() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1247,12 +1279,17 @@ public void copyBackupTest3() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1314,12 +1351,17 @@ public void copyBackupTest4() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); Operation resultOperation = Operation.newBuilder() @@ -1381,12 +1423,17 @@ public void getBackupTest() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); mockDatabaseAdmin.addResponse(expectedResponse); @@ -1430,12 +1477,17 @@ public void getBackupTest2() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); mockDatabaseAdmin.addResponse(expectedResponse); @@ -1479,12 +1531,17 @@ public void updateBackupTest() throws Exception { .setName(BackupName.of("[PROJECT]", "[INSTANCE]", "[BACKUP]").toString()) .setCreateTime(Timestamp.newBuilder().build()) .setSizeBytes(-1796325715) + .setFreeableSizeBytes(1302251206) + .setExclusiveSizeBytes(-1085921554) .addAllReferencingDatabases(new ArrayList()) .setEncryptionInfo(EncryptionInfo.newBuilder().build()) .addAllEncryptionInformation(new ArrayList()) .setDatabaseDialect(DatabaseDialect.forNumber(0)) .addAllReferencingBackups(new ArrayList()) .setMaxExpireTime(Timestamp.newBuilder().build()) + .addAllBackupSchedules(new ArrayList()) + .setIncrementalBackupChainId("incrementalBackupChainId1926005216") + .setOldestVersionTime(Timestamp.newBuilder().build()) .build(); mockDatabaseAdmin.addResponse(expectedResponse); @@ -2192,4 +2249,406 @@ public void listDatabaseRolesExceptionTest2() throws Exception { // Expected exception. } } + + @Test + public void createBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + String backupScheduleId = "backupScheduleId1704974708"; + + BackupSchedule actualResponse = + client.createBackupSchedule(parent, backupSchedule, backupScheduleId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateBackupScheduleRequest actualRequest = + ((CreateBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertEquals(backupSchedule, actualRequest.getBackupSchedule()); + Assert.assertEquals(backupScheduleId, actualRequest.getBackupScheduleId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + String backupScheduleId = "backupScheduleId1704974708"; + client.createBackupSchedule(parent, backupSchedule, backupScheduleId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + String backupScheduleId = "backupScheduleId1704974708"; + + BackupSchedule actualResponse = + client.createBackupSchedule(parent, backupSchedule, backupScheduleId); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + CreateBackupScheduleRequest actualRequest = + ((CreateBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertEquals(backupSchedule, actualRequest.getBackupSchedule()); + Assert.assertEquals(backupScheduleId, actualRequest.getBackupScheduleId()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void createBackupScheduleExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + String backupScheduleId = "backupScheduleId1704974708"; + client.createBackupSchedule(parent, backupSchedule, backupScheduleId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]"); + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetBackupScheduleRequest actualRequest = ((GetBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]"); + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupScheduleTest2() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + BackupSchedule actualResponse = client.getBackupSchedule(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + GetBackupScheduleRequest actualRequest = ((GetBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void getBackupScheduleExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + String name = "name3373707"; + client.getBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateBackupScheduleTest() throws Exception { + BackupSchedule expectedResponse = + BackupSchedule.newBuilder() + .setName( + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]") + .toString()) + .setSpec(BackupScheduleSpec.newBuilder().build()) + .setRetentionDuration(Duration.newBuilder().build()) + .setEncryptionConfig(CreateBackupEncryptionConfig.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + BackupSchedule actualResponse = client.updateBackupSchedule(backupSchedule, updateMask); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + UpdateBackupScheduleRequest actualRequest = + ((UpdateBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(backupSchedule, actualRequest.getBackupSchedule()); + Assert.assertEquals(updateMask, actualRequest.getUpdateMask()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void updateBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + BackupSchedule backupSchedule = BackupSchedule.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBackupSchedule(backupSchedule, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]"); + + client.deleteBackupSchedule(name); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteBackupScheduleRequest actualRequest = + ((DeleteBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name.toString(), actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteBackupScheduleExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + BackupScheduleName name = + BackupScheduleName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]", "[SCHEDULE]"); + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteBackupScheduleTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + String name = "name3373707"; + + client.deleteBackupSchedule(name); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + DeleteBackupScheduleRequest actualRequest = + ((DeleteBackupScheduleRequest) actualRequests.get(0)); + + Assert.assertEquals(name, actualRequest.getName()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void deleteBackupScheduleExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + String name = "name3373707"; + client.deleteBackupSchedule(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest() throws Exception { + BackupSchedule responsesElement = BackupSchedule.newBuilder().build(); + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .setNextPageToken("") + .addAllBackupSchedules(Arrays.asList(responsesElement)) + .build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + DatabaseName parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + + ListBackupSchedulesPagedResponse pagedListResponse = client.listBackupSchedules(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBackupSchedulesList().get(0), resources.get(0)); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListBackupSchedulesRequest actualRequest = ((ListBackupSchedulesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent.toString(), actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listBackupSchedulesExceptionTest() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + DatabaseName parent = DatabaseName.of("[PROJECT]", "[INSTANCE]", "[DATABASE]"); + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupSchedulesTest2() throws Exception { + BackupSchedule responsesElement = BackupSchedule.newBuilder().build(); + ListBackupSchedulesResponse expectedResponse = + ListBackupSchedulesResponse.newBuilder() + .setNextPageToken("") + .addAllBackupSchedules(Arrays.asList(responsesElement)) + .build(); + mockDatabaseAdmin.addResponse(expectedResponse); + + String parent = "parent-995424086"; + + ListBackupSchedulesPagedResponse pagedListResponse = client.listBackupSchedules(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBackupSchedulesList().get(0), resources.get(0)); + + List actualRequests = mockDatabaseAdmin.getRequests(); + Assert.assertEquals(1, actualRequests.size()); + ListBackupSchedulesRequest actualRequest = ((ListBackupSchedulesRequest) actualRequests.get(0)); + + Assert.assertEquals(parent, actualRequest.getParent()); + Assert.assertTrue( + channelProvider.isHeaderSent( + ApiClientHeaderProvider.getDefaultApiClientHeaderKey(), + GaxGrpcProperties.getDefaultApiClientHeaderPattern())); + } + + @Test + public void listBackupSchedulesExceptionTest2() throws Exception { + StatusRuntimeException exception = new StatusRuntimeException(io.grpc.Status.INVALID_ARGUMENT); + mockDatabaseAdmin.addException(exception); + + try { + String parent = "parent-995424086"; + client.listBackupSchedules(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/MockDatabaseAdminImpl.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/MockDatabaseAdminImpl.java index f77ad2edbc8..9e273ed1550 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/MockDatabaseAdminImpl.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/admin/database/v1/MockDatabaseAdminImpl.java @@ -26,19 +26,25 @@ import com.google.protobuf.AbstractMessage; import com.google.protobuf.Empty; import com.google.spanner.admin.database.v1.Backup; +import com.google.spanner.admin.database.v1.BackupSchedule; import com.google.spanner.admin.database.v1.CopyBackupRequest; import com.google.spanner.admin.database.v1.CreateBackupRequest; +import com.google.spanner.admin.database.v1.CreateBackupScheduleRequest; import com.google.spanner.admin.database.v1.CreateDatabaseRequest; import com.google.spanner.admin.database.v1.Database; import com.google.spanner.admin.database.v1.DatabaseAdminGrpc.DatabaseAdminImplBase; import com.google.spanner.admin.database.v1.DeleteBackupRequest; +import com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest; import com.google.spanner.admin.database.v1.DropDatabaseRequest; import com.google.spanner.admin.database.v1.GetBackupRequest; +import com.google.spanner.admin.database.v1.GetBackupScheduleRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlRequest; import com.google.spanner.admin.database.v1.GetDatabaseDdlResponse; import com.google.spanner.admin.database.v1.GetDatabaseRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsRequest; import com.google.spanner.admin.database.v1.ListBackupOperationsResponse; +import com.google.spanner.admin.database.v1.ListBackupSchedulesRequest; +import com.google.spanner.admin.database.v1.ListBackupSchedulesResponse; import com.google.spanner.admin.database.v1.ListBackupsRequest; import com.google.spanner.admin.database.v1.ListBackupsResponse; import com.google.spanner.admin.database.v1.ListDatabaseOperationsRequest; @@ -49,6 +55,7 @@ import com.google.spanner.admin.database.v1.ListDatabasesResponse; import com.google.spanner.admin.database.v1.RestoreDatabaseRequest; import com.google.spanner.admin.database.v1.UpdateBackupRequest; +import com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest; import com.google.spanner.admin.database.v1.UpdateDatabaseRequest; import io.grpc.stub.StreamObserver; @@ -505,4 +512,110 @@ public void listDatabaseRoles( Exception.class.getName()))); } } + + @Override + public void createBackupSchedule( + CreateBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof BackupSchedule) { + requests.add(request); + responseObserver.onNext(((BackupSchedule) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method CreateBackupSchedule, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + BackupSchedule.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void getBackupSchedule( + GetBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof BackupSchedule) { + requests.add(request); + responseObserver.onNext(((BackupSchedule) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method GetBackupSchedule, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + BackupSchedule.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void updateBackupSchedule( + UpdateBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof BackupSchedule) { + requests.add(request); + responseObserver.onNext(((BackupSchedule) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method UpdateBackupSchedule, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + BackupSchedule.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void deleteBackupSchedule( + DeleteBackupScheduleRequest request, StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof Empty) { + requests.add(request); + responseObserver.onNext(((Empty) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method DeleteBackupSchedule, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + Empty.class.getName(), + Exception.class.getName()))); + } + } + + @Override + public void listBackupSchedules( + ListBackupSchedulesRequest request, + StreamObserver responseObserver) { + Object response = responses.poll(); + if (response instanceof ListBackupSchedulesResponse) { + requests.add(request); + responseObserver.onNext(((ListBackupSchedulesResponse) response)); + responseObserver.onCompleted(); + } else if (response instanceof Exception) { + responseObserver.onError(((Exception) response)); + } else { + responseObserver.onError( + new IllegalArgumentException( + String.format( + "Unrecognized response type %s for method ListBackupSchedules, expected %s or %s", + response == null ? "null" : response.getClass().getName(), + ListBackupSchedulesResponse.class.getName(), + Exception.class.getName()))); + } + } } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/SavepointMockServerTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/SavepointMockServerTest.java index e615b78e9de..31972481629 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/SavepointMockServerTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/SavepointMockServerTest.java @@ -682,14 +682,16 @@ public void testRollbackToSavepointWithoutInternalRetriesInReadOnlyTransaction() @Test public void testKeepAlive() throws InterruptedException, TimeoutException { + String keepAliveTag = "test_keep_alive_tag"; System.setProperty("spanner.connection.keep_alive_interval_millis", "1"); + System.setProperty("spanner.connection.keep_alive_query_tag", keepAliveTag); try (Connection connection = createConnection()) { connection.setSavepointSupport(SavepointSupport.ENABLED); connection.setKeepTransactionAlive(true); // Start a transaction by executing a statement. connection.execute(INSERT_STATEMENT); // Verify that we get a keep-alive request. - verifyHasKeepAliveRequest(); + verifyHasKeepAliveRequest(keepAliveTag); // Set a savepoint, execute another statement, and rollback to the savepoint. // The keep-alive should not be sent after the transaction has been rolled back to the // savepoint. @@ -697,38 +699,22 @@ public void testKeepAlive() throws InterruptedException, TimeoutException { connection.execute(INSERT_STATEMENT); connection.rollbackToSavepoint("s1"); mockSpanner.waitForRequestsToContain(RollbackRequest.class, 1000L); - // Wait for up to 2 milliseconds to make sure that any keep-alive requests that were in flight - // have finished. - try { - mockSpanner.waitForRequestsToContain( - r -> { - if (!(r instanceof ExecuteSqlRequest)) { - return false; - } - ExecuteSqlRequest request = (ExecuteSqlRequest) r; - return request.getSql().equals("SELECT 1") - && request - .getRequestOptions() - .getRequestTag() - .equals("connection.transaction-keep-alive"); - }, - 2L); - } catch (TimeoutException ignore) { - } + String keepAliveTagAfterRollback = "test_keep_alive_tag_after_rollback"; + System.setProperty("spanner.connection.keep_alive_query_tag", keepAliveTagAfterRollback); - // Verify that we don't get any keep-alive requests from this point. - mockSpanner.clearRequests(); + // Verify that we don't get any new keep-alive requests from this point. Thread.sleep(2L); - assertEquals(0, countKeepAliveRequest()); + assertEquals(0, countKeepAliveRequest(keepAliveTagAfterRollback)); // Resume the transaction and verify that we get a keep-alive again. connection.execute(INSERT_STATEMENT); - verifyHasKeepAliveRequest(); + verifyHasKeepAliveRequest(keepAliveTagAfterRollback); } finally { System.clearProperty("spanner.connection.keep_alive_interval_millis"); + System.clearProperty("spanner.connection.keep_alive_query_tag"); } } - private void verifyHasKeepAliveRequest() throws InterruptedException, TimeoutException { + private void verifyHasKeepAliveRequest(String tag) throws InterruptedException, TimeoutException { mockSpanner.waitForRequestsToContain( r -> { if (!(r instanceof ExecuteSqlRequest)) { @@ -736,23 +722,17 @@ private void verifyHasKeepAliveRequest() throws InterruptedException, TimeoutExc } ExecuteSqlRequest request = (ExecuteSqlRequest) r; return request.getSql().equals("SELECT 1") - && request - .getRequestOptions() - .getRequestTag() - .equals("connection.transaction-keep-alive"); + && request.getRequestOptions().getRequestTag().equals(tag); }, 1000L); } - private long countKeepAliveRequest() { + private long countKeepAliveRequest(String tag) { return mockSpanner.getRequestsOfType(ExecuteSqlRequest.class).stream() .filter( request -> request.getSql().equals("SELECT 1") - && request - .getRequestOptions() - .getRequestTag() - .equals("connection.transaction-keep-alive")) + && request.getRequestOptions().getRequestTag().equals(tag)) .count(); } } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITBulkConnectionTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITBulkConnectionTest.java index 9cc46e6ee13..42358a647a1 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITBulkConnectionTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITBulkConnectionTest.java @@ -36,8 +36,8 @@ /** * Test opening multiple generic (not JDBC) Spanner connections. This test should not be run in - * parallel with other tests, as it tries to close all active connections, and should not try to - * close connections of other integration tests. + * parallel with other tests in the same JVM, as it tries to close all active connections, and + * should not try to close connections of other integration tests. */ @Category(SerialIntegrationTest.class) @RunWith(JUnit4.class) diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITDmlReturningTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITDmlReturningTest.java index 5e5ca800402..83f9beb7cf7 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITDmlReturningTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITDmlReturningTest.java @@ -22,12 +22,13 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThrows; import static org.junit.Assert.assertTrue; -import static org.junit.Assume.assumeFalse; import com.google.cloud.spanner.AsyncResultSet; import com.google.cloud.spanner.AsyncResultSet.CallbackResponse; +import com.google.cloud.spanner.DatabaseClient; import com.google.cloud.spanner.Dialect; import com.google.cloud.spanner.ErrorCode; +import com.google.cloud.spanner.KeySet; import com.google.cloud.spanner.Mutation; import com.google.cloud.spanner.ParallelIntegrationTest; import com.google.cloud.spanner.ResultSet; @@ -39,15 +40,15 @@ import com.google.cloud.spanner.connection.StatementResult; import com.google.cloud.spanner.connection.StatementResult.ResultType; import com.google.cloud.spanner.connection.TransactionMode; -import com.google.cloud.spanner.testing.EmulatorSpannerHelper; +import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.HashMap; +import java.util.HashSet; import java.util.List; -import java.util.Map; +import java.util.Set; import java.util.concurrent.ExecutionException; import java.util.concurrent.Executors; import org.junit.Before; @@ -81,12 +82,7 @@ public class ITDmlReturningTest extends ITAbstractSpannerTest { + " SingerId BIGINT PRIMARY KEY," + " FirstName character varying(1024)," + " LastName character varying(1024))"); - private final Map IS_INITIALIZED = new HashMap<>(); - - public ITDmlReturningTest() { - IS_INITIALIZED.put(Dialect.GOOGLE_STANDARD_SQL, false); - IS_INITIALIZED.put(Dialect.POSTGRESQL, false); - } + private static final Set IS_INITIALIZED = new HashSet<>(); @Parameter public Dialect dialect; @@ -96,41 +92,34 @@ public static Object[] data() { } private boolean checkAndSetInitialized() { - if ((dialect == Dialect.GOOGLE_STANDARD_SQL) && !IS_INITIALIZED.get(dialect)) { - IS_INITIALIZED.put(dialect, true); - return true; - } - if ((dialect == Dialect.POSTGRESQL) && !IS_INITIALIZED.get(dialect)) { - IS_INITIALIZED.put(dialect, true); - return true; - } - return false; + return !IS_INITIALIZED.add(dialect); } @Before public void setupTable() { - assumeFalse( - "DML Returning is not supported in the emulator", EmulatorSpannerHelper.isUsingEmulator()); - if (checkAndSetInitialized()) { + if (!checkAndSetInitialized()) { database = env.getTestHelper() .createTestDatabase(dialect, Collections.singleton(DDL_MAP.get(dialect))); - List firstNames = Arrays.asList("ABC", "ABC", "DEF", "PQR", "ABC"); - List lastNames = Arrays.asList("XYZ", "DEF", "XYZ", "ABC", "GHI"); - List mutations = new ArrayList<>(); - for (int id = 1; id <= 5; id++) { - mutations.add( - Mutation.newInsertBuilder("SINGERS") - .set("SINGERID") - .to(id) - .set("FIRSTNAME") - .to(firstNames.get(id - 1)) - .set("LASTNAME") - .to(lastNames.get(id - 1)) - .build()); - } - env.getTestHelper().getDatabaseClient(database).write(mutations); } + DatabaseClient client = env.getTestHelper().getDatabaseClient(database); + client.write(ImmutableList.of(Mutation.delete("SINGERS", KeySet.all()))); + + List firstNames = Arrays.asList("ABC", "ABC", "DEF", "PQR", "ABC"); + List lastNames = Arrays.asList("XYZ", "DEF", "XYZ", "ABC", "GHI"); + List mutations = new ArrayList<>(); + for (int id = 1; id <= 5; id++) { + mutations.add( + Mutation.newInsertBuilder("SINGERS") + .set("SINGERID") + .to(id) + .set("FIRSTNAME") + .to(firstNames.get(id - 1)) + .set("LASTNAME") + .to(lastNames.get(id - 1)) + .build()); + } + env.getTestHelper().getDatabaseClient(database).write(mutations); } @Test @@ -211,9 +200,9 @@ public void testDmlReturningExecuteUpdateAsync() { public void testDmlReturningExecuteBatchUpdate() { try (Connection connection = createConnection()) { connection.setAutocommit(false); - final Statement UPDATE_STMT = UPDATE_RETURNING_MAP.get(dialect); + final Statement updateStmt = Preconditions.checkNotNull(UPDATE_RETURNING_MAP.get(dialect)); long[] counts = - connection.executeBatchUpdate(ImmutableList.of(UPDATE_STMT, UPDATE_STMT, UPDATE_STMT)); + connection.executeBatchUpdate(ImmutableList.of(updateStmt, updateStmt, updateStmt)); assertArrayEquals(counts, new long[] {3, 3, 3}); } } @@ -222,10 +211,10 @@ public void testDmlReturningExecuteBatchUpdate() { public void testDmlReturningExecuteBatchUpdateAsync() { try (Connection connection = createConnection()) { connection.setAutocommit(false); - final Statement UPDATE_STMT = UPDATE_RETURNING_MAP.get(dialect); + final Statement updateStmt = Preconditions.checkNotNull(UPDATE_RETURNING_MAP.get(dialect)); long[] counts = connection - .executeBatchUpdateAsync(ImmutableList.of(UPDATE_STMT, UPDATE_STMT, UPDATE_STMT)) + .executeBatchUpdateAsync(ImmutableList.of(updateStmt, updateStmt, updateStmt)) .get(); assertArrayEquals(counts, new long[] {3, 3, 3}); } catch (ExecutionException | InterruptedException e) { diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITQueryOptionsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITQueryOptionsTest.java index 09f4ada43a8..62eba4f4315 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITQueryOptionsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/it/ITQueryOptionsTest.java @@ -16,12 +16,18 @@ package com.google.cloud.spanner.connection.it; +import com.google.cloud.spanner.ParallelIntegrationTest; import com.google.cloud.spanner.connection.ITAbstractSpannerTest; import com.google.cloud.spanner.connection.SqlScriptVerifier; import com.google.cloud.spanner.connection.SqlScriptVerifier.SpannerGenericConnection; import org.junit.Before; import org.junit.Test; +import org.junit.experimental.categories.Category; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; +@Category(ParallelIntegrationTest.class) +@RunWith(JUnit4.class) public class ITQueryOptionsTest extends ITAbstractSpannerTest { private static final String TEST_QUERY_OPTIONS = "ITSqlScriptTest_TestQueryOptions.sql"; diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITAsyncAPITest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITAsyncAPITest.java index ebd3ab4883f..1e408fadf33 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITAsyncAPITest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITAsyncAPITest.java @@ -42,7 +42,7 @@ import com.google.cloud.spanner.KeySet; import com.google.cloud.spanner.Mutation; import com.google.cloud.spanner.Options; -import com.google.cloud.spanner.SerialIntegrationTest; +import com.google.cloud.spanner.ParallelIntegrationTest; import com.google.cloud.spanner.SpannerException; import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.Struct; @@ -68,7 +68,7 @@ import org.junit.runners.JUnit4; /** Integration tests for asynchronous APIs. */ -@Category(SerialIntegrationTest.class) +@Category(ParallelIntegrationTest.class) @RunWith(JUnit4.class) public class ITAsyncAPITest { @ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITAsyncExamplesTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITAsyncExamplesTest.java index 87f26da9049..dc5abd77afd 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITAsyncExamplesTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITAsyncExamplesTest.java @@ -33,8 +33,8 @@ import com.google.cloud.spanner.Key; import com.google.cloud.spanner.KeySet; import com.google.cloud.spanner.Mutation; +import com.google.cloud.spanner.ParallelIntegrationTest; import com.google.cloud.spanner.ReadOnlyTransaction; -import com.google.cloud.spanner.SerialIntegrationTest; import com.google.cloud.spanner.SpannerException; import com.google.cloud.spanner.Statement; import com.google.cloud.spanner.Struct; @@ -59,7 +59,7 @@ import org.junit.runners.JUnit4; /** Integration tests for asynchronous APIs. */ -@Category(SerialIntegrationTest.class) +@Category(ParallelIntegrationTest.class) @RunWith(JUnit4.class) public class ITAsyncExamplesTest { @ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GfeLatencyTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GfeLatencyTest.java index 9bb09aace70..908a4ad5573 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GfeLatencyTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/spi/v1/GfeLatencyTest.java @@ -17,6 +17,7 @@ package com.google.cloud.spanner.spi.v1; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import com.google.auth.oauth2.AccessToken; import com.google.auth.oauth2.OAuth2Credentials; @@ -27,6 +28,8 @@ import com.google.cloud.spanner.Spanner; import com.google.cloud.spanner.SpannerOptions; import com.google.cloud.spanner.Statement; +import com.google.common.base.MoreObjects; +import com.google.common.base.Preconditions; import com.google.protobuf.ListValue; import com.google.spanner.v1.ResultSetMetadata; import com.google.spanner.v1.StructType; @@ -47,7 +50,6 @@ import io.opencensus.tags.TagValue; import java.io.IOException; import java.net.InetSocketAddress; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; @@ -80,26 +82,22 @@ public class GfeLatencyTest { private static MockSpannerServiceImpl mockSpanner; private static Server server; - private static InetSocketAddress address; private static Spanner spanner; private static DatabaseClient databaseClient; - private static final Map optionsMap = new HashMap<>(); - private static MockSpannerServiceImpl mockSpannerNoHeader; private static Server serverNoHeader; - private static InetSocketAddress addressNoHeader; private static Spanner spannerNoHeader; private static DatabaseClient databaseClientNoHeader; - private static String instanceId = "fake-instance"; - private static String databaseId = "fake-database"; - private static String projectId = "fake-project"; + private static final String INSTANCE_ID = "fake-instance"; + private static final String DATABASE_ID = "fake-database"; + private static final String PROJECT_ID = "fake-project"; - private static final long WAIT_FOR_METRICS_TIME_MS = 1_000; - private static final int MAXIMUM_RETRIES = 5; + private static final int MAXIMUM_RETRIES = 50000; - private static AtomicInteger fakeServerTiming = new AtomicInteger(new Random().nextInt(1000) + 1); + private static final AtomicInteger FAKE_SERVER_TIMING = + new AtomicInteger(new Random().nextInt(1000) + 1); private static final Statement SELECT1AND2 = Statement.of("SELECT 1 AS COL1 UNION ALL SELECT 2 AS COL1"); @@ -135,6 +133,7 @@ public class GfeLatencyTest { @BeforeClass public static void startServer() throws IOException { + //noinspection deprecation SpannerRpcViews.registerGfeLatencyAndHeaderMissingCountViews(); mockSpanner = new MockSpannerServiceImpl(); @@ -143,7 +142,7 @@ public static void startServer() throws IOException { MockSpannerServiceImpl.StatementResult.query(SELECT1AND2, SELECT1_RESULTSET)); mockSpanner.putStatementResult( MockSpannerServiceImpl.StatementResult.update(UPDATE_FOO_STATEMENT, 1L)); - address = new InetSocketAddress("localhost", 0); + InetSocketAddress address = new InetSocketAddress("localhost", 0); server = NettyServerBuilder.forAddress(address) .addService(mockSpanner) @@ -161,7 +160,7 @@ public ServerCall.Listener interceptCall( public void sendHeaders(Metadata headers) { headers.put( Metadata.Key.of("server-timing", Metadata.ASCII_STRING_MARSHALLER), - String.format("gfet4t7; dur=%d", fakeServerTiming.get())); + String.format("gfet4t7; dur=%d", FAKE_SERVER_TIMING.get())); super.sendHeaders(headers); } }, @@ -170,9 +169,8 @@ public void sendHeaders(Metadata headers) { }) .build() .start(); - optionsMap.put(SpannerRpc.Option.CHANNEL_HINT, 1L); spanner = createSpannerOptions(address, server).getService(); - databaseClient = spanner.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId)); + databaseClient = spanner.getDatabaseClient(DatabaseId.of(PROJECT_ID, INSTANCE_ID, DATABASE_ID)); mockSpannerNoHeader = new MockSpannerServiceImpl(); mockSpannerNoHeader.setAbortProbability(0.0D); @@ -180,7 +178,7 @@ public void sendHeaders(Metadata headers) { MockSpannerServiceImpl.StatementResult.query(SELECT1AND2, SELECT1_RESULTSET)); mockSpannerNoHeader.putStatementResult( MockSpannerServiceImpl.StatementResult.update(UPDATE_FOO_STATEMENT, 1L)); - addressNoHeader = new InetSocketAddress("localhost", 0); + InetSocketAddress addressNoHeader = new InetSocketAddress("localhost", 0); serverNoHeader = NettyServerBuilder.forAddress(addressNoHeader) .addService(mockSpannerNoHeader) @@ -188,7 +186,7 @@ public void sendHeaders(Metadata headers) { .start(); spannerNoHeader = createSpannerOptions(addressNoHeader, serverNoHeader).getService(); databaseClientNoHeader = - spannerNoHeader.getDatabaseClient(DatabaseId.of(projectId, instanceId, databaseId)); + spannerNoHeader.getDatabaseClient(DatabaseId.of(PROJECT_ID, INSTANCE_ID, DATABASE_ID)); } @AfterClass @@ -221,12 +219,9 @@ public void testGfeLatencyExecuteStreamingSql() throws InterruptedException { long latency = getMetric( SpannerRpcViews.SPANNER_GFE_LATENCY_VIEW, - projectId, - instanceId, - databaseId, "google.spanner.v1.Spanner/ExecuteStreamingSql", false); - assertEquals(fakeServerTiming.get(), latency); + assertEquals(FAKE_SERVER_TIMING.get(), latency); } @Test @@ -238,12 +233,9 @@ public void testGfeLatencyExecuteSql() throws InterruptedException { long latency = getMetric( SpannerRpcViews.SPANNER_GFE_LATENCY_VIEW, - projectId, - instanceId, - databaseId, "google.spanner.v1.Spanner/ExecuteSql", false); - assertEquals(fakeServerTiming.get(), latency); + assertEquals(FAKE_SERVER_TIMING.get(), latency); } @Test @@ -254,9 +246,6 @@ public void testGfeMissingHeaderCountExecuteStreamingSql() throws InterruptedExc long count = getMetric( SpannerRpcViews.SPANNER_GFE_HEADER_MISSING_COUNT_VIEW, - projectId, - instanceId, - databaseId, "google.spanner.v1.Spanner/ExecuteStreamingSql", false); assertEquals(0, count); @@ -267,9 +256,6 @@ public void testGfeMissingHeaderCountExecuteStreamingSql() throws InterruptedExc long count1 = getMetric( SpannerRpcViews.SPANNER_GFE_HEADER_MISSING_COUNT_VIEW, - projectId, - instanceId, - databaseId, "google.spanner.v1.Spanner/ExecuteStreamingSql", true); assertEquals(1, count1); @@ -283,9 +269,6 @@ public void testGfeMissingHeaderExecuteSql() throws InterruptedException { long count = getMetric( SpannerRpcViews.SPANNER_GFE_HEADER_MISSING_COUNT_VIEW, - projectId, - instanceId, - databaseId, "google.spanner.v1.Spanner/ExecuteSql", false); assertEquals(0, count); @@ -296,9 +279,6 @@ public void testGfeMissingHeaderExecuteSql() throws InterruptedException { long count1 = getMetric( SpannerRpcViews.SPANNER_GFE_HEADER_MISSING_COUNT_VIEW, - projectId, - instanceId, - databaseId, "google.spanner.v1.Spanner/ExecuteSql", true); assertEquals(1, count1); @@ -321,78 +301,75 @@ private static SpannerOptions createSpannerOptions(InetSocketAddress address, Se } private long getAggregationValueAsLong(AggregationData aggregationData) { - return aggregationData.match( - new io.opencensus.common.Function() { - @Override - public Long apply(AggregationData.SumDataDouble arg) { - return (long) arg.getSum(); - } - }, - new io.opencensus.common.Function() { - @Override - public Long apply(AggregationData.SumDataLong arg) { - return arg.getSum(); - } - }, - new io.opencensus.common.Function() { - @Override - public Long apply(AggregationData.CountData arg) { - return arg.getCount(); - } - }, - new io.opencensus.common.Function() { - @Override - public Long apply(AggregationData.DistributionData arg) { - return (long) arg.getMean(); - } - }, - new io.opencensus.common.Function() { - @Override - public Long apply(AggregationData.LastValueDataDouble arg) { - return (long) arg.getLastValue(); - } - }, - new io.opencensus.common.Function() { - @Override - public Long apply(AggregationData.LastValueDataLong arg) { - return arg.getLastValue(); - } - }, - new io.opencensus.common.Function() { - @Override - public Long apply(AggregationData arg) { - throw new UnsupportedOperationException(); - } - }); + return MoreObjects.firstNonNull( + aggregationData.match( + new io.opencensus.common.Function() { + @Override + public Long apply(AggregationData.SumDataDouble arg) { + return (long) Preconditions.checkNotNull(arg).getSum(); + } + }, + new io.opencensus.common.Function() { + @Override + public Long apply(AggregationData.SumDataLong arg) { + return Preconditions.checkNotNull(arg).getSum(); + } + }, + new io.opencensus.common.Function() { + @Override + public Long apply(AggregationData.CountData arg) { + return Preconditions.checkNotNull(arg).getCount(); + } + }, + new io.opencensus.common.Function() { + @Override + public Long apply(AggregationData.DistributionData arg) { + return (long) Preconditions.checkNotNull(arg).getMean(); + } + }, + new io.opencensus.common.Function() { + @Override + public Long apply(AggregationData.LastValueDataDouble arg) { + return (long) Preconditions.checkNotNull(arg).getLastValue(); + } + }, + new io.opencensus.common.Function() { + @Override + public Long apply(AggregationData.LastValueDataLong arg) { + return Preconditions.checkNotNull(arg).getLastValue(); + } + }, + new io.opencensus.common.Function() { + @Override + public Long apply(AggregationData arg) { + throw new UnsupportedOperationException(); + } + }), + -1L); } - private long getMetric( - View view, - String projectId, - String instanceId, - String databaseId, - String method, - boolean withOverride) - throws InterruptedException { + private long getMetric(View view, String method, boolean withOverride) { List tagValues = new java.util.ArrayList<>(); for (TagKey column : view.getColumns()) { if (column == SpannerRpcViews.INSTANCE_ID) { - tagValues.add(TagValue.create(instanceId)); + tagValues.add(TagValue.create(INSTANCE_ID)); } else if (column == SpannerRpcViews.DATABASE_ID) { - tagValues.add(TagValue.create(databaseId)); + tagValues.add(TagValue.create(DATABASE_ID)); } else if (column == SpannerRpcViews.METHOD) { tagValues.add(TagValue.create(method)); } else if (column == SpannerRpcViews.PROJECT_ID) { - tagValues.add(TagValue.create(projectId)); + tagValues.add(TagValue.create(PROJECT_ID)); } } for (int i = 0; i < MAXIMUM_RETRIES; i++) { - Thread.sleep(WAIT_FOR_METRICS_TIME_MS); + Thread.yield(); ViewData viewData = SpannerRpcViews.viewManager.getView(view.getName()); + assertNotNull(viewData); if (viewData.getAggregationMap() != null) { Map, AggregationData> aggregationMap = viewData.getAggregationMap(); AggregationData aggregationData = aggregationMap.get(tagValues); - if (withOverride && getAggregationValueAsLong(aggregationData) == 0) { + if (aggregationData == null + || withOverride && getAggregationValueAsLong(aggregationData) == 0) { continue; } return getAggregationValueAsLong(aggregationData); diff --git a/grpc-google-cloud-spanner-admin-database-v1/clirr-ignored-differences.xml b/grpc-google-cloud-spanner-admin-database-v1/clirr-ignored-differences.xml new file mode 100644 index 00000000000..80e6f1d59cb --- /dev/null +++ b/grpc-google-cloud-spanner-admin-database-v1/clirr-ignored-differences.xml @@ -0,0 +1,9 @@ + + + + + 7012 + com/google/spanner/admin/database/v1/* + * + + diff --git a/grpc-google-cloud-spanner-admin-database-v1/pom.xml b/grpc-google-cloud-spanner-admin-database-v1/pom.xml index d5e8fbb36be..d316ece2b6c 100644 --- a/grpc-google-cloud-spanner-admin-database-v1/pom.xml +++ b/grpc-google-cloud-spanner-admin-database-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-spanner-admin-database-v1 - 6.71.0 + 6.72.0 grpc-google-cloud-spanner-admin-database-v1 GRPC library for grpc-google-cloud-spanner-admin-database-v1 com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 diff --git a/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java b/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java index 2314cd8965b..01592c14be9 100644 --- a/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java +++ b/grpc-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DatabaseAdminGrpc.java @@ -943,6 +943,248 @@ private DatabaseAdminGrpc() {} return getListDatabaseRolesMethod; } + private static volatile io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule> + getCreateBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "CreateBackupSchedule", + requestType = com.google.spanner.admin.database.v1.CreateBackupScheduleRequest.class, + responseType = com.google.spanner.admin.database.v1.BackupSchedule.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule> + getCreateBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule> + getCreateBackupScheduleMethod; + if ((getCreateBackupScheduleMethod = DatabaseAdminGrpc.getCreateBackupScheduleMethod) == null) { + synchronized (DatabaseAdminGrpc.class) { + if ((getCreateBackupScheduleMethod = DatabaseAdminGrpc.getCreateBackupScheduleMethod) + == null) { + DatabaseAdminGrpc.getCreateBackupScheduleMethod = + getCreateBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "CreateBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.spanner.admin.database.v1.BackupSchedule + .getDefaultInstance())) + .setSchemaDescriptor( + new DatabaseAdminMethodDescriptorSupplier("CreateBackupSchedule")) + .build(); + } + } + } + return getCreateBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.GetBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule> + getGetBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "GetBackupSchedule", + requestType = com.google.spanner.admin.database.v1.GetBackupScheduleRequest.class, + responseType = com.google.spanner.admin.database.v1.BackupSchedule.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.GetBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule> + getGetBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.GetBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule> + getGetBackupScheduleMethod; + if ((getGetBackupScheduleMethod = DatabaseAdminGrpc.getGetBackupScheduleMethod) == null) { + synchronized (DatabaseAdminGrpc.class) { + if ((getGetBackupScheduleMethod = DatabaseAdminGrpc.getGetBackupScheduleMethod) == null) { + DatabaseAdminGrpc.getGetBackupScheduleMethod = + getGetBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName(generateFullMethodName(SERVICE_NAME, "GetBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.spanner.admin.database.v1.GetBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.spanner.admin.database.v1.BackupSchedule + .getDefaultInstance())) + .setSchemaDescriptor( + new DatabaseAdminMethodDescriptorSupplier("GetBackupSchedule")) + .build(); + } + } + } + return getGetBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule> + getUpdateBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "UpdateBackupSchedule", + requestType = com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest.class, + responseType = com.google.spanner.admin.database.v1.BackupSchedule.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule> + getUpdateBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule> + getUpdateBackupScheduleMethod; + if ((getUpdateBackupScheduleMethod = DatabaseAdminGrpc.getUpdateBackupScheduleMethod) == null) { + synchronized (DatabaseAdminGrpc.class) { + if ((getUpdateBackupScheduleMethod = DatabaseAdminGrpc.getUpdateBackupScheduleMethod) + == null) { + DatabaseAdminGrpc.getUpdateBackupScheduleMethod = + getUpdateBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "UpdateBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.spanner.admin.database.v1.BackupSchedule + .getDefaultInstance())) + .setSchemaDescriptor( + new DatabaseAdminMethodDescriptorSupplier("UpdateBackupSchedule")) + .build(); + } + } + } + return getUpdateBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest, + com.google.protobuf.Empty> + getDeleteBackupScheduleMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "DeleteBackupSchedule", + requestType = com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest.class, + responseType = com.google.protobuf.Empty.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest, + com.google.protobuf.Empty> + getDeleteBackupScheduleMethod() { + io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest, + com.google.protobuf.Empty> + getDeleteBackupScheduleMethod; + if ((getDeleteBackupScheduleMethod = DatabaseAdminGrpc.getDeleteBackupScheduleMethod) == null) { + synchronized (DatabaseAdminGrpc.class) { + if ((getDeleteBackupScheduleMethod = DatabaseAdminGrpc.getDeleteBackupScheduleMethod) + == null) { + DatabaseAdminGrpc.getDeleteBackupScheduleMethod = + getDeleteBackupScheduleMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "DeleteBackupSchedule")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.protobuf.Empty.getDefaultInstance())) + .setSchemaDescriptor( + new DatabaseAdminMethodDescriptorSupplier("DeleteBackupSchedule")) + .build(); + } + } + } + return getDeleteBackupScheduleMethod; + } + + private static volatile io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest, + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse> + getListBackupSchedulesMethod; + + @io.grpc.stub.annotations.RpcMethod( + fullMethodName = SERVICE_NAME + '/' + "ListBackupSchedules", + requestType = com.google.spanner.admin.database.v1.ListBackupSchedulesRequest.class, + responseType = com.google.spanner.admin.database.v1.ListBackupSchedulesResponse.class, + methodType = io.grpc.MethodDescriptor.MethodType.UNARY) + public static io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest, + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse> + getListBackupSchedulesMethod() { + io.grpc.MethodDescriptor< + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest, + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse> + getListBackupSchedulesMethod; + if ((getListBackupSchedulesMethod = DatabaseAdminGrpc.getListBackupSchedulesMethod) == null) { + synchronized (DatabaseAdminGrpc.class) { + if ((getListBackupSchedulesMethod = DatabaseAdminGrpc.getListBackupSchedulesMethod) + == null) { + DatabaseAdminGrpc.getListBackupSchedulesMethod = + getListBackupSchedulesMethod = + io.grpc.MethodDescriptor + . + newBuilder() + .setType(io.grpc.MethodDescriptor.MethodType.UNARY) + .setFullMethodName( + generateFullMethodName(SERVICE_NAME, "ListBackupSchedules")) + .setSampledToLocalTracing(true) + .setRequestMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest + .getDefaultInstance())) + .setResponseMarshaller( + io.grpc.protobuf.ProtoUtils.marshaller( + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse + .getDefaultInstance())) + .setSchemaDescriptor( + new DatabaseAdminMethodDescriptorSupplier("ListBackupSchedules")) + .build(); + } + } + } + return getListBackupSchedulesMethod; + } + /** Creates a new async stub that supports all call types for the service */ public static DatabaseAdminStub newStub(io.grpc.Channel channel) { io.grpc.stub.AbstractStub.StubFactory factory = @@ -1414,6 +1656,81 @@ default void listDatabaseRoles( io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( getListDatabaseRolesMethod(), responseObserver); } + + /** + * + * + *
+     * Creates a new backup schedule.
+     * 
+ */ + default void createBackupSchedule( + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getCreateBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * Gets backup schedule for the input schedule name.
+     * 
+ */ + default void getBackupSchedule( + com.google.spanner.admin.database.v1.GetBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getGetBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + default void updateBackupSchedule( + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getUpdateBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + default void deleteBackupSchedule( + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getDeleteBackupScheduleMethod(), responseObserver); + } + + /** + * + * + *
+     * Lists all the backup schedules for the database.
+     * 
+ */ + default void listBackupSchedules( + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest request, + io.grpc.stub.StreamObserver< + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse> + responseObserver) { + io.grpc.stub.ServerCalls.asyncUnimplementedUnaryCall( + getListBackupSchedulesMethod(), responseObserver); + } } /** @@ -1914,6 +2231,91 @@ public void listDatabaseRoles( request, responseObserver); } + + /** + * + * + *
+     * Creates a new backup schedule.
+     * 
+ */ + public void createBackupSchedule( + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getCreateBackupScheduleMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Gets backup schedule for the input schedule name.
+     * 
+ */ + public void getBackupSchedule( + com.google.spanner.admin.database.v1.GetBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getGetBackupScheduleMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + public void updateBackupSchedule( + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest request, + io.grpc.stub.StreamObserver + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getUpdateBackupScheduleMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + public void deleteBackupSchedule( + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest request, + io.grpc.stub.StreamObserver responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getDeleteBackupScheduleMethod(), getCallOptions()), + request, + responseObserver); + } + + /** + * + * + *
+     * Lists all the backup schedules for the database.
+     * 
+ */ + public void listBackupSchedules( + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest request, + io.grpc.stub.StreamObserver< + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse> + responseObserver) { + io.grpc.stub.ClientCalls.asyncUnaryCall( + getChannel().newCall(getListBackupSchedulesMethod(), getCallOptions()), + request, + responseObserver); + } } /** @@ -2327,6 +2729,71 @@ public com.google.spanner.admin.database.v1.ListDatabaseRolesResponse listDataba return io.grpc.stub.ClientCalls.blockingUnaryCall( getChannel(), getListDatabaseRolesMethod(), getCallOptions(), request); } + + /** + * + * + *
+     * Creates a new backup schedule.
+     * 
+ */ + public com.google.spanner.admin.database.v1.BackupSchedule createBackupSchedule( + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getCreateBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Gets backup schedule for the input schedule name.
+     * 
+ */ + public com.google.spanner.admin.database.v1.BackupSchedule getBackupSchedule( + com.google.spanner.admin.database.v1.GetBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getGetBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + public com.google.spanner.admin.database.v1.BackupSchedule updateBackupSchedule( + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getUpdateBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + public com.google.protobuf.Empty deleteBackupSchedule( + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getDeleteBackupScheduleMethod(), getCallOptions(), request); + } + + /** + * + * + *
+     * Lists all the backup schedules for the database.
+     * 
+ */ + public com.google.spanner.admin.database.v1.ListBackupSchedulesResponse listBackupSchedules( + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest request) { + return io.grpc.stub.ClientCalls.blockingUnaryCall( + getChannel(), getListBackupSchedulesMethod(), getCallOptions(), request); + } } /** @@ -2753,6 +3220,79 @@ protected DatabaseAdminFutureStub build( return io.grpc.stub.ClientCalls.futureUnaryCall( getChannel().newCall(getListDatabaseRolesMethod(), getCallOptions()), request); } + + /** + * + * + *
+     * Creates a new backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.spanner.admin.database.v1.BackupSchedule> + createBackupSchedule( + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getCreateBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Gets backup schedule for the input schedule name.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.spanner.admin.database.v1.BackupSchedule> + getBackupSchedule(com.google.spanner.admin.database.v1.GetBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getGetBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Updates a backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.spanner.admin.database.v1.BackupSchedule> + updateBackupSchedule( + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getUpdateBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Deletes a backup schedule.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture + deleteBackupSchedule( + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getDeleteBackupScheduleMethod(), getCallOptions()), request); + } + + /** + * + * + *
+     * Lists all the backup schedules for the database.
+     * 
+ */ + public com.google.common.util.concurrent.ListenableFuture< + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse> + listBackupSchedules( + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest request) { + return io.grpc.stub.ClientCalls.futureUnaryCall( + getChannel().newCall(getListBackupSchedulesMethod(), getCallOptions()), request); + } } private static final int METHODID_LIST_DATABASES = 0; @@ -2775,6 +3315,11 @@ protected DatabaseAdminFutureStub build( private static final int METHODID_LIST_DATABASE_OPERATIONS = 17; private static final int METHODID_LIST_BACKUP_OPERATIONS = 18; private static final int METHODID_LIST_DATABASE_ROLES = 19; + private static final int METHODID_CREATE_BACKUP_SCHEDULE = 20; + private static final int METHODID_GET_BACKUP_SCHEDULE = 21; + private static final int METHODID_UPDATE_BACKUP_SCHEDULE = 22; + private static final int METHODID_DELETE_BACKUP_SCHEDULE = 23; + private static final int METHODID_LIST_BACKUP_SCHEDULES = 24; private static final class MethodHandlers implements io.grpc.stub.ServerCalls.UnaryMethod, @@ -2909,6 +3454,36 @@ public void invoke(Req request, io.grpc.stub.StreamObserver responseObserv com.google.spanner.admin.database.v1.ListDatabaseRolesResponse>) responseObserver); break; + case METHODID_CREATE_BACKUP_SCHEDULE: + serviceImpl.createBackupSchedule( + (com.google.spanner.admin.database.v1.CreateBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_GET_BACKUP_SCHEDULE: + serviceImpl.getBackupSchedule( + (com.google.spanner.admin.database.v1.GetBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_UPDATE_BACKUP_SCHEDULE: + serviceImpl.updateBackupSchedule( + (com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) + responseObserver); + break; + case METHODID_DELETE_BACKUP_SCHEDULE: + serviceImpl.deleteBackupSchedule( + (com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest) request, + (io.grpc.stub.StreamObserver) responseObserver); + break; + case METHODID_LIST_BACKUP_SCHEDULES: + serviceImpl.listBackupSchedules( + (com.google.spanner.admin.database.v1.ListBackupSchedulesRequest) request, + (io.grpc.stub.StreamObserver< + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse>) + responseObserver); + break; default: throw new AssertionError(); } @@ -3052,6 +3627,40 @@ public static final io.grpc.ServerServiceDefinition bindService(AsyncService ser com.google.spanner.admin.database.v1.ListDatabaseRolesRequest, com.google.spanner.admin.database.v1.ListDatabaseRolesResponse>( service, METHODID_LIST_DATABASE_ROLES))) + .addMethod( + getCreateBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule>( + service, METHODID_CREATE_BACKUP_SCHEDULE))) + .addMethod( + getGetBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.spanner.admin.database.v1.GetBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule>( + service, METHODID_GET_BACKUP_SCHEDULE))) + .addMethod( + getUpdateBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest, + com.google.spanner.admin.database.v1.BackupSchedule>( + service, METHODID_UPDATE_BACKUP_SCHEDULE))) + .addMethod( + getDeleteBackupScheduleMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest, + com.google.protobuf.Empty>(service, METHODID_DELETE_BACKUP_SCHEDULE))) + .addMethod( + getListBackupSchedulesMethod(), + io.grpc.stub.ServerCalls.asyncUnaryCall( + new MethodHandlers< + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest, + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse>( + service, METHODID_LIST_BACKUP_SCHEDULES))) .build(); } @@ -3123,6 +3732,11 @@ public static io.grpc.ServiceDescriptor getServiceDescriptor() { .addMethod(getListDatabaseOperationsMethod()) .addMethod(getListBackupOperationsMethod()) .addMethod(getListDatabaseRolesMethod()) + .addMethod(getCreateBackupScheduleMethod()) + .addMethod(getGetBackupScheduleMethod()) + .addMethod(getUpdateBackupScheduleMethod()) + .addMethod(getDeleteBackupScheduleMethod()) + .addMethod(getListBackupSchedulesMethod()) .build(); } } diff --git a/grpc-google-cloud-spanner-admin-instance-v1/pom.xml b/grpc-google-cloud-spanner-admin-instance-v1/pom.xml index 9cf83ee4f31..d971f88fdce 100644 --- a/grpc-google-cloud-spanner-admin-instance-v1/pom.xml +++ b/grpc-google-cloud-spanner-admin-instance-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-spanner-admin-instance-v1 - 6.71.0 + 6.72.0 grpc-google-cloud-spanner-admin-instance-v1 GRPC library for grpc-google-cloud-spanner-admin-instance-v1 com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 diff --git a/grpc-google-cloud-spanner-executor-v1/pom.xml b/grpc-google-cloud-spanner-executor-v1/pom.xml index 2f22fe1d990..ac9f792bd3d 100644 --- a/grpc-google-cloud-spanner-executor-v1/pom.xml +++ b/grpc-google-cloud-spanner-executor-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-spanner-executor-v1 - 6.71.0 + 6.72.0 grpc-google-cloud-spanner-executor-v1 GRPC library for google-cloud-spanner com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 diff --git a/grpc-google-cloud-spanner-v1/pom.xml b/grpc-google-cloud-spanner-v1/pom.xml index 3811e8ed439..d7723c6e774 100644 --- a/grpc-google-cloud-spanner-v1/pom.xml +++ b/grpc-google-cloud-spanner-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-spanner-v1 - 6.71.0 + 6.72.0 grpc-google-cloud-spanner-v1 GRPC library for grpc-google-cloud-spanner-v1 com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 diff --git a/pom.xml b/pom.xml index ecef9ba83cf..955e456f999 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-spanner-parent pom - 6.71.0 + 6.72.0 Google Cloud Spanner Parent https://github.com/googleapis/java-spanner @@ -14,7 +14,7 @@ com.google.cloud sdk-platform-java-config - 3.32.0 + 3.33.0 @@ -61,47 +61,47 @@ com.google.api.grpc proto-google-cloud-spanner-admin-instance-v1 - 6.71.0 + 6.72.0 com.google.api.grpc proto-google-cloud-spanner-executor-v1 - 6.71.0 + 6.72.0 com.google.api.grpc grpc-google-cloud-spanner-executor-v1 - 6.71.0 + 6.72.0 com.google.api.grpc proto-google-cloud-spanner-v1 - 6.71.0 + 6.72.0 com.google.api.grpc proto-google-cloud-spanner-admin-database-v1 - 6.71.0 + 6.72.0 com.google.api.grpc grpc-google-cloud-spanner-v1 - 6.71.0 + 6.72.0 com.google.api.grpc grpc-google-cloud-spanner-admin-instance-v1 - 6.71.0 + 6.72.0 com.google.api.grpc grpc-google-cloud-spanner-admin-database-v1 - 6.71.0 + 6.72.0 com.google.cloud google-cloud-spanner - 6.71.0 + 6.72.0 @@ -121,7 +121,7 @@ com.google.truth truth - 1.4.2 + 1.4.4 test @@ -171,7 +171,7 @@ org.apache.maven.plugins maven-project-info-reports-plugin - 3.5.0 + 3.6.2 diff --git a/proto-google-cloud-spanner-admin-database-v1/pom.xml b/proto-google-cloud-spanner-admin-database-v1/pom.xml index e62834bdd4e..e9cc23ac3ab 100644 --- a/proto-google-cloud-spanner-admin-database-v1/pom.xml +++ b/proto-google-cloud-spanner-admin-database-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-spanner-admin-database-v1 - 6.71.0 + 6.72.0 proto-google-cloud-spanner-admin-database-v1 PROTO library for proto-google-cloud-spanner-admin-database-v1 com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Backup.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Backup.java index 1284d3e6cfc..96dc6990ec0 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Backup.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/Backup.java @@ -46,6 +46,8 @@ private Backup() { encryptionInformation_ = java.util.Collections.emptyList(); databaseDialect_ = 0; referencingBackups_ = com.google.protobuf.LazyStringArrayList.emptyList(); + backupSchedules_ = com.google.protobuf.LazyStringArrayList.emptyList(); + incrementalBackupChainId_ = ""; } @java.lang.Override @@ -564,6 +566,54 @@ public long getSizeBytes() { return sizeBytes_; } + public static final int FREEABLE_SIZE_BYTES_FIELD_NUMBER = 15; + private long freeableSizeBytes_ = 0L; + /** + * + * + *
+   * Output only. The number of bytes that will be freed by deleting this
+   * backup. This value will be zero if, for example, this backup is part of an
+   * incremental backup chain and younger backups in the chain require that we
+   * keep its data. For backups not in an incremental backup chain, this is
+   * always the size of the backup. This value may change if backups on the same
+   * chain get created, deleted or expired.
+   * 
+ * + * int64 freeable_size_bytes = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The freeableSizeBytes. + */ + @java.lang.Override + public long getFreeableSizeBytes() { + return freeableSizeBytes_; + } + + public static final int EXCLUSIVE_SIZE_BYTES_FIELD_NUMBER = 16; + private long exclusiveSizeBytes_ = 0L; + /** + * + * + *
+   * Output only. For a backup in an incremental backup chain, this is the
+   * storage space needed to keep the data that has changed since the previous
+   * backup. For all other backups, this is always the size of the backup. This
+   * value may change if backups on the same chain get deleted or expired.
+   *
+   * This field can be used to calculate the total storage space used by a set
+   * of backups. For example, the total space used by all backups of a database
+   * can be computed by summing up this field.
+   * 
+ * + * int64 exclusive_size_bytes = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The exclusiveSizeBytes. + */ + @java.lang.Override + public long getExclusiveSizeBytes() { + return exclusiveSizeBytes_; + } + public static final int STATE_FIELD_NUMBER = 6; private int state_ = 0; /** @@ -1069,6 +1119,238 @@ public com.google.protobuf.TimestampOrBuilder getMaxExpireTimeOrBuilder() { : maxExpireTime_; } + public static final int BACKUP_SCHEDULES_FIELD_NUMBER = 14; + + @SuppressWarnings("serial") + private com.google.protobuf.LazyStringArrayList backupSchedules_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + /** + * + * + *
+   * Output only. List of backup schedule URIs that are associated with
+   * creating this backup. This is only applicable for scheduled backups, and
+   * is empty for on-demand backups.
+   *
+   * To optimize for storage, whenever possible, multiple schedules are
+   * collapsed together to create one backup. In such cases, this field captures
+   * the list of all backup schedule URIs that are associated with creating
+   * this backup. If collapsing is not done, then this field captures the
+   * single backup schedule URI associated with creating this backup.
+   * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return A list containing the backupSchedules. + */ + public com.google.protobuf.ProtocolStringList getBackupSchedulesList() { + return backupSchedules_; + } + /** + * + * + *
+   * Output only. List of backup schedule URIs that are associated with
+   * creating this backup. This is only applicable for scheduled backups, and
+   * is empty for on-demand backups.
+   *
+   * To optimize for storage, whenever possible, multiple schedules are
+   * collapsed together to create one backup. In such cases, this field captures
+   * the list of all backup schedule URIs that are associated with creating
+   * this backup. If collapsing is not done, then this field captures the
+   * single backup schedule URI associated with creating this backup.
+   * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The count of backupSchedules. + */ + public int getBackupSchedulesCount() { + return backupSchedules_.size(); + } + /** + * + * + *
+   * Output only. List of backup schedule URIs that are associated with
+   * creating this backup. This is only applicable for scheduled backups, and
+   * is empty for on-demand backups.
+   *
+   * To optimize for storage, whenever possible, multiple schedules are
+   * collapsed together to create one backup. In such cases, this field captures
+   * the list of all backup schedule URIs that are associated with creating
+   * this backup. If collapsing is not done, then this field captures the
+   * single backup schedule URI associated with creating this backup.
+   * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the element to return. + * @return The backupSchedules at the given index. + */ + public java.lang.String getBackupSchedules(int index) { + return backupSchedules_.get(index); + } + /** + * + * + *
+   * Output only. List of backup schedule URIs that are associated with
+   * creating this backup. This is only applicable for scheduled backups, and
+   * is empty for on-demand backups.
+   *
+   * To optimize for storage, whenever possible, multiple schedules are
+   * collapsed together to create one backup. In such cases, this field captures
+   * the list of all backup schedule URIs that are associated with creating
+   * this backup. If collapsing is not done, then this field captures the
+   * single backup schedule URI associated with creating this backup.
+   * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the value to return. + * @return The bytes of the backupSchedules at the given index. + */ + public com.google.protobuf.ByteString getBackupSchedulesBytes(int index) { + return backupSchedules_.getByteString(index); + } + + public static final int INCREMENTAL_BACKUP_CHAIN_ID_FIELD_NUMBER = 17; + + @SuppressWarnings("serial") + private volatile java.lang.Object incrementalBackupChainId_ = ""; + /** + * + * + *
+   * Output only. Populated only for backups in an incremental backup chain.
+   * Backups share the same chain id if and only if they belong to the same
+   * incremental backup chain. Use this field to determine which backups are
+   * part of the same incremental backup chain. The ordering of backups in the
+   * chain can be determined by ordering the backup `version_time`.
+   * 
+ * + * string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The incrementalBackupChainId. + */ + @java.lang.Override + public java.lang.String getIncrementalBackupChainId() { + java.lang.Object ref = incrementalBackupChainId_; + 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(); + incrementalBackupChainId_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. Populated only for backups in an incremental backup chain.
+   * Backups share the same chain id if and only if they belong to the same
+   * incremental backup chain. Use this field to determine which backups are
+   * part of the same incremental backup chain. The ordering of backups in the
+   * chain can be determined by ordering the backup `version_time`.
+   * 
+ * + * string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The bytes for incrementalBackupChainId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getIncrementalBackupChainIdBytes() { + java.lang.Object ref = incrementalBackupChainId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + incrementalBackupChainId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int OLDEST_VERSION_TIME_FIELD_NUMBER = 18; + private com.google.protobuf.Timestamp oldestVersionTime_; + /** + * + * + *
+   * Output only. Data deleted at a time older than this is guaranteed not to be
+   * retained in order to support this backup. For a backup in an incremental
+   * backup chain, this is the version time of the oldest backup that exists or
+   * ever existed in the chain. For all other backups, this is the version time
+   * of the backup. This field can be used to understand what data is being
+   * retained by the backup system.
+   * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the oldestVersionTime field is set. + */ + @java.lang.Override + public boolean hasOldestVersionTime() { + return ((bitField0_ & 0x00000020) != 0); + } + /** + * + * + *
+   * Output only. Data deleted at a time older than this is guaranteed not to be
+   * retained in order to support this backup. For a backup in an incremental
+   * backup chain, this is the version time of the oldest backup that exists or
+   * ever existed in the chain. For all other backups, this is the version time
+   * of the backup. This field can be used to understand what data is being
+   * retained by the backup system.
+   * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The oldestVersionTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getOldestVersionTime() { + return oldestVersionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : oldestVersionTime_; + } + /** + * + * + *
+   * Output only. Data deleted at a time older than this is guaranteed not to be
+   * retained in order to support this backup. For a backup in an incremental
+   * backup chain, this is the version time of the oldest backup that exists or
+   * ever existed in the chain. For all other backups, this is the version time
+   * of the backup. This field can be used to understand what data is being
+   * retained by the backup system.
+   * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getOldestVersionTimeOrBuilder() { + return oldestVersionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : oldestVersionTime_; + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -1125,6 +1407,21 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io for (int i = 0; i < encryptionInformation_.size(); i++) { output.writeMessage(13, encryptionInformation_.get(i)); } + for (int i = 0; i < backupSchedules_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 14, backupSchedules_.getRaw(i)); + } + if (freeableSizeBytes_ != 0L) { + output.writeInt64(15, freeableSizeBytes_); + } + if (exclusiveSizeBytes_ != 0L) { + output.writeInt64(16, exclusiveSizeBytes_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(incrementalBackupChainId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 17, incrementalBackupChainId_); + } + if (((bitField0_ & 0x00000020) != 0)) { + output.writeMessage(18, getOldestVersionTime()); + } getUnknownFields().writeTo(output); } @@ -1187,6 +1484,27 @@ public int getSerializedSize() { com.google.protobuf.CodedOutputStream.computeMessageSize( 13, encryptionInformation_.get(i)); } + { + int dataSize = 0; + for (int i = 0; i < backupSchedules_.size(); i++) { + dataSize += computeStringSizeNoTag(backupSchedules_.getRaw(i)); + } + size += dataSize; + size += 1 * getBackupSchedulesList().size(); + } + if (freeableSizeBytes_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(15, freeableSizeBytes_); + } + if (exclusiveSizeBytes_ != 0L) { + size += com.google.protobuf.CodedOutputStream.computeInt64Size(16, exclusiveSizeBytes_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(incrementalBackupChainId_)) { + size += + com.google.protobuf.GeneratedMessageV3.computeStringSize(17, incrementalBackupChainId_); + } + if (((bitField0_ & 0x00000020) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(18, getOldestVersionTime()); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -1218,6 +1536,8 @@ public boolean equals(final java.lang.Object obj) { if (!getCreateTime().equals(other.getCreateTime())) return false; } if (getSizeBytes() != other.getSizeBytes()) return false; + if (getFreeableSizeBytes() != other.getFreeableSizeBytes()) return false; + if (getExclusiveSizeBytes() != other.getExclusiveSizeBytes()) return false; if (state_ != other.state_) return false; if (!getReferencingDatabasesList().equals(other.getReferencingDatabasesList())) return false; if (hasEncryptionInfo() != other.hasEncryptionInfo()) return false; @@ -1231,6 +1551,12 @@ public boolean equals(final java.lang.Object obj) { if (hasMaxExpireTime()) { if (!getMaxExpireTime().equals(other.getMaxExpireTime())) return false; } + if (!getBackupSchedulesList().equals(other.getBackupSchedulesList())) return false; + if (!getIncrementalBackupChainId().equals(other.getIncrementalBackupChainId())) return false; + if (hasOldestVersionTime() != other.hasOldestVersionTime()) return false; + if (hasOldestVersionTime()) { + if (!getOldestVersionTime().equals(other.getOldestVersionTime())) return false; + } if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; } @@ -1260,6 +1586,10 @@ public int hashCode() { } hash = (37 * hash) + SIZE_BYTES_FIELD_NUMBER; hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getSizeBytes()); + hash = (37 * hash) + FREEABLE_SIZE_BYTES_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getFreeableSizeBytes()); + hash = (37 * hash) + EXCLUSIVE_SIZE_BYTES_FIELD_NUMBER; + hash = (53 * hash) + com.google.protobuf.Internal.hashLong(getExclusiveSizeBytes()); hash = (37 * hash) + STATE_FIELD_NUMBER; hash = (53 * hash) + state_; if (getReferencingDatabasesCount() > 0) { @@ -1284,6 +1614,16 @@ public int hashCode() { hash = (37 * hash) + MAX_EXPIRE_TIME_FIELD_NUMBER; hash = (53 * hash) + getMaxExpireTime().hashCode(); } + if (getBackupSchedulesCount() > 0) { + hash = (37 * hash) + BACKUP_SCHEDULES_FIELD_NUMBER; + hash = (53 * hash) + getBackupSchedulesList().hashCode(); + } + hash = (37 * hash) + INCREMENTAL_BACKUP_CHAIN_ID_FIELD_NUMBER; + hash = (53 * hash) + getIncrementalBackupChainId().hashCode(); + if (hasOldestVersionTime()) { + hash = (37 * hash) + OLDEST_VERSION_TIME_FIELD_NUMBER; + hash = (53 * hash) + getOldestVersionTime().hashCode(); + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -1430,6 +1770,7 @@ private void maybeForceBuilderInitialization() { getEncryptionInfoFieldBuilder(); getEncryptionInformationFieldBuilder(); getMaxExpireTimeFieldBuilder(); + getOldestVersionTimeFieldBuilder(); } } @@ -1455,6 +1796,8 @@ public Builder clear() { createTimeBuilder_ = null; } sizeBytes_ = 0L; + freeableSizeBytes_ = 0L; + exclusiveSizeBytes_ = 0L; state_ = 0; referencingDatabases_ = com.google.protobuf.LazyStringArrayList.emptyList(); encryptionInfo_ = null; @@ -1468,7 +1811,7 @@ public Builder clear() { encryptionInformation_ = null; encryptionInformationBuilder_.clear(); } - bitField0_ = (bitField0_ & ~0x00000200); + bitField0_ = (bitField0_ & ~0x00000800); databaseDialect_ = 0; referencingBackups_ = com.google.protobuf.LazyStringArrayList.emptyList(); maxExpireTime_ = null; @@ -1476,6 +1819,13 @@ public Builder clear() { maxExpireTimeBuilder_.dispose(); maxExpireTimeBuilder_ = null; } + backupSchedules_ = com.google.protobuf.LazyStringArrayList.emptyList(); + incrementalBackupChainId_ = ""; + oldestVersionTime_ = null; + if (oldestVersionTimeBuilder_ != null) { + oldestVersionTimeBuilder_.dispose(); + oldestVersionTimeBuilder_ = null; + } return this; } @@ -1513,9 +1863,9 @@ public com.google.spanner.admin.database.v1.Backup buildPartial() { private void buildPartialRepeatedFields(com.google.spanner.admin.database.v1.Backup result) { if (encryptionInformationBuilder_ == null) { - if (((bitField0_ & 0x00000200) != 0)) { + if (((bitField0_ & 0x00000800) != 0)) { encryptionInformation_ = java.util.Collections.unmodifiableList(encryptionInformation_); - bitField0_ = (bitField0_ & ~0x00000200); + bitField0_ = (bitField0_ & ~0x00000800); } result.encryptionInformation_ = encryptionInformation_; } else { @@ -1549,29 +1899,49 @@ private void buildPartial0(com.google.spanner.admin.database.v1.Backup result) { result.sizeBytes_ = sizeBytes_; } if (((from_bitField0_ & 0x00000040) != 0)) { - result.state_ = state_; + result.freeableSizeBytes_ = freeableSizeBytes_; } if (((from_bitField0_ & 0x00000080) != 0)) { + result.exclusiveSizeBytes_ = exclusiveSizeBytes_; + } + if (((from_bitField0_ & 0x00000100) != 0)) { + result.state_ = state_; + } + if (((from_bitField0_ & 0x00000200) != 0)) { referencingDatabases_.makeImmutable(); result.referencingDatabases_ = referencingDatabases_; } - if (((from_bitField0_ & 0x00000100) != 0)) { + if (((from_bitField0_ & 0x00000400) != 0)) { result.encryptionInfo_ = encryptionInfoBuilder_ == null ? encryptionInfo_ : encryptionInfoBuilder_.build(); to_bitField0_ |= 0x00000008; } - if (((from_bitField0_ & 0x00000400) != 0)) { + if (((from_bitField0_ & 0x00001000) != 0)) { result.databaseDialect_ = databaseDialect_; } - if (((from_bitField0_ & 0x00000800) != 0)) { + if (((from_bitField0_ & 0x00002000) != 0)) { referencingBackups_.makeImmutable(); result.referencingBackups_ = referencingBackups_; } - if (((from_bitField0_ & 0x00001000) != 0)) { + if (((from_bitField0_ & 0x00004000) != 0)) { result.maxExpireTime_ = maxExpireTimeBuilder_ == null ? maxExpireTime_ : maxExpireTimeBuilder_.build(); to_bitField0_ |= 0x00000010; } + if (((from_bitField0_ & 0x00008000) != 0)) { + backupSchedules_.makeImmutable(); + result.backupSchedules_ = backupSchedules_; + } + if (((from_bitField0_ & 0x00010000) != 0)) { + result.incrementalBackupChainId_ = incrementalBackupChainId_; + } + if (((from_bitField0_ & 0x00020000) != 0)) { + result.oldestVersionTime_ = + oldestVersionTimeBuilder_ == null + ? oldestVersionTime_ + : oldestVersionTimeBuilder_.build(); + to_bitField0_ |= 0x00000020; + } result.bitField0_ |= to_bitField0_; } @@ -1642,13 +2012,19 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.Backup other) { if (other.getSizeBytes() != 0L) { setSizeBytes(other.getSizeBytes()); } + if (other.getFreeableSizeBytes() != 0L) { + setFreeableSizeBytes(other.getFreeableSizeBytes()); + } + if (other.getExclusiveSizeBytes() != 0L) { + setExclusiveSizeBytes(other.getExclusiveSizeBytes()); + } if (other.state_ != 0) { setStateValue(other.getStateValue()); } if (!other.referencingDatabases_.isEmpty()) { if (referencingDatabases_.isEmpty()) { referencingDatabases_ = other.referencingDatabases_; - bitField0_ |= 0x00000080; + bitField0_ |= 0x00000200; } else { ensureReferencingDatabasesIsMutable(); referencingDatabases_.addAll(other.referencingDatabases_); @@ -1662,7 +2038,7 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.Backup other) { if (!other.encryptionInformation_.isEmpty()) { if (encryptionInformation_.isEmpty()) { encryptionInformation_ = other.encryptionInformation_; - bitField0_ = (bitField0_ & ~0x00000200); + bitField0_ = (bitField0_ & ~0x00000800); } else { ensureEncryptionInformationIsMutable(); encryptionInformation_.addAll(other.encryptionInformation_); @@ -1675,7 +2051,7 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.Backup other) { encryptionInformationBuilder_.dispose(); encryptionInformationBuilder_ = null; encryptionInformation_ = other.encryptionInformation_; - bitField0_ = (bitField0_ & ~0x00000200); + bitField0_ = (bitField0_ & ~0x00000800); encryptionInformationBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getEncryptionInformationFieldBuilder() @@ -1691,7 +2067,7 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.Backup other) { if (!other.referencingBackups_.isEmpty()) { if (referencingBackups_.isEmpty()) { referencingBackups_ = other.referencingBackups_; - bitField0_ |= 0x00000800; + bitField0_ |= 0x00002000; } else { ensureReferencingBackupsIsMutable(); referencingBackups_.addAll(other.referencingBackups_); @@ -1701,6 +2077,24 @@ public Builder mergeFrom(com.google.spanner.admin.database.v1.Backup other) { if (other.hasMaxExpireTime()) { mergeMaxExpireTime(other.getMaxExpireTime()); } + if (!other.backupSchedules_.isEmpty()) { + if (backupSchedules_.isEmpty()) { + backupSchedules_ = other.backupSchedules_; + bitField0_ |= 0x00008000; + } else { + ensureBackupSchedulesIsMutable(); + backupSchedules_.addAll(other.backupSchedules_); + } + onChanged(); + } + if (!other.getIncrementalBackupChainId().isEmpty()) { + incrementalBackupChainId_ = other.incrementalBackupChainId_; + bitField0_ |= 0x00010000; + onChanged(); + } + if (other.hasOldestVersionTime()) { + mergeOldestVersionTime(other.getOldestVersionTime()); + } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; @@ -1760,7 +2154,7 @@ public Builder mergeFrom( case 48: { state_ = input.readEnum(); - bitField0_ |= 0x00000040; + bitField0_ |= 0x00000100; break; } // case 48 case 58: @@ -1773,7 +2167,7 @@ public Builder mergeFrom( case 66: { input.readMessage(getEncryptionInfoFieldBuilder().getBuilder(), extensionRegistry); - bitField0_ |= 0x00000100; + bitField0_ |= 0x00000400; break; } // case 66 case 74: @@ -1785,7 +2179,7 @@ public Builder mergeFrom( case 80: { databaseDialect_ = input.readEnum(); - bitField0_ |= 0x00000400; + bitField0_ |= 0x00001000; break; } // case 80 case 90: @@ -1798,7 +2192,7 @@ public Builder mergeFrom( case 98: { input.readMessage(getMaxExpireTimeFieldBuilder().getBuilder(), extensionRegistry); - bitField0_ |= 0x00001000; + bitField0_ |= 0x00004000; break; } // case 98 case 106: @@ -1815,6 +2209,38 @@ public Builder mergeFrom( } break; } // case 106 + case 114: + { + java.lang.String s = input.readStringRequireUtf8(); + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(s); + break; + } // case 114 + case 120: + { + freeableSizeBytes_ = input.readInt64(); + bitField0_ |= 0x00000040; + break; + } // case 120 + case 128: + { + exclusiveSizeBytes_ = input.readInt64(); + bitField0_ |= 0x00000080; + break; + } // case 128 + case 138: + { + incrementalBackupChainId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00010000; + break; + } // case 138 + case 146: + { + input.readMessage( + getOldestVersionTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00020000; + break; + } // case 146 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -2875,40 +3301,47 @@ public Builder clearSizeBytes() { return this; } - private int state_ = 0; + private long freeableSizeBytes_; /** * * *
-     * Output only. The current state of the backup.
+     * Output only. The number of bytes that will be freed by deleting this
+     * backup. This value will be zero if, for example, this backup is part of an
+     * incremental backup chain and younger backups in the chain require that we
+     * keep its data. For backups not in an incremental backup chain, this is
+     * always the size of the backup. This value may change if backups on the same
+     * chain get created, deleted or expired.
      * 
* - * - * .google.spanner.admin.database.v1.Backup.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * + * int64 freeable_size_bytes = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; * - * @return The enum numeric value on the wire for state. + * @return The freeableSizeBytes. */ @java.lang.Override - public int getStateValue() { - return state_; + public long getFreeableSizeBytes() { + return freeableSizeBytes_; } /** * * *
-     * Output only. The current state of the backup.
+     * Output only. The number of bytes that will be freed by deleting this
+     * backup. This value will be zero if, for example, this backup is part of an
+     * incremental backup chain and younger backups in the chain require that we
+     * keep its data. For backups not in an incremental backup chain, this is
+     * always the size of the backup. This value may change if backups on the same
+     * chain get created, deleted or expired.
      * 
* - * - * .google.spanner.admin.database.v1.Backup.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * + * int64 freeable_size_bytes = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; * - * @param value The enum numeric value on the wire for state to set. + * @param value The freeableSizeBytes to set. * @return This builder for chaining. */ - public Builder setStateValue(int value) { - state_ = value; + public Builder setFreeableSizeBytes(long value) { + + freeableSizeBytes_ = value; bitField0_ |= 0x00000040; onChanged(); return this; @@ -2917,51 +3350,186 @@ public Builder setStateValue(int value) { * * *
-     * Output only. The current state of the backup.
+     * Output only. The number of bytes that will be freed by deleting this
+     * backup. This value will be zero if, for example, this backup is part of an
+     * incremental backup chain and younger backups in the chain require that we
+     * keep its data. For backups not in an incremental backup chain, this is
+     * always the size of the backup. This value may change if backups on the same
+     * chain get created, deleted or expired.
      * 
* - * - * .google.spanner.admin.database.v1.Backup.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * + * int64 freeable_size_bytes = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; * - * @return The state. + * @return This builder for chaining. */ - @java.lang.Override - public com.google.spanner.admin.database.v1.Backup.State getState() { - com.google.spanner.admin.database.v1.Backup.State result = - com.google.spanner.admin.database.v1.Backup.State.forNumber(state_); - return result == null - ? com.google.spanner.admin.database.v1.Backup.State.UNRECOGNIZED - : result; + public Builder clearFreeableSizeBytes() { + bitField0_ = (bitField0_ & ~0x00000040); + freeableSizeBytes_ = 0L; + onChanged(); + return this; } + + private long exclusiveSizeBytes_; /** * * *
-     * Output only. The current state of the backup.
+     * Output only. For a backup in an incremental backup chain, this is the
+     * storage space needed to keep the data that has changed since the previous
+     * backup. For all other backups, this is always the size of the backup. This
+     * value may change if backups on the same chain get deleted or expired.
+     *
+     * This field can be used to calculate the total storage space used by a set
+     * of backups. For example, the total space used by all backups of a database
+     * can be computed by summing up this field.
      * 
* - * - * .google.spanner.admin.database.v1.Backup.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; - * + * int64 exclusive_size_bytes = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; * - * @param value The state to set. - * @return This builder for chaining. + * @return The exclusiveSizeBytes. */ - public Builder setState(com.google.spanner.admin.database.v1.Backup.State value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000040; - state_ = value.getNumber(); - onChanged(); - return this; + @java.lang.Override + public long getExclusiveSizeBytes() { + return exclusiveSizeBytes_; } /** * * *
-     * Output only. The current state of the backup.
+     * Output only. For a backup in an incremental backup chain, this is the
+     * storage space needed to keep the data that has changed since the previous
+     * backup. For all other backups, this is always the size of the backup. This
+     * value may change if backups on the same chain get deleted or expired.
+     *
+     * This field can be used to calculate the total storage space used by a set
+     * of backups. For example, the total space used by all backups of a database
+     * can be computed by summing up this field.
+     * 
+ * + * int64 exclusive_size_bytes = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The exclusiveSizeBytes to set. + * @return This builder for chaining. + */ + public Builder setExclusiveSizeBytes(long value) { + + exclusiveSizeBytes_ = value; + bitField0_ |= 0x00000080; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. For a backup in an incremental backup chain, this is the
+     * storage space needed to keep the data that has changed since the previous
+     * backup. For all other backups, this is always the size of the backup. This
+     * value may change if backups on the same chain get deleted or expired.
+     *
+     * This field can be used to calculate the total storage space used by a set
+     * of backups. For example, the total space used by all backups of a database
+     * can be computed by summing up this field.
+     * 
+ * + * int64 exclusive_size_bytes = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearExclusiveSizeBytes() { + bitField0_ = (bitField0_ & ~0x00000080); + exclusiveSizeBytes_ = 0L; + onChanged(); + return this; + } + + private int state_ = 0; + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.spanner.admin.database.v1.Backup.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The enum numeric value on the wire for state. + */ + @java.lang.Override + public int getStateValue() { + return state_; + } + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.spanner.admin.database.v1.Backup.State state = 6 [(.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_ |= 0x00000100; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.spanner.admin.database.v1.Backup.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The state. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.Backup.State getState() { + com.google.spanner.admin.database.v1.Backup.State result = + com.google.spanner.admin.database.v1.Backup.State.forNumber(state_); + return result == null + ? com.google.spanner.admin.database.v1.Backup.State.UNRECOGNIZED + : result; + } + /** + * + * + *
+     * Output only. The current state of the backup.
+     * 
+ * + * + * .google.spanner.admin.database.v1.Backup.State state = 6 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The state to set. + * @return This builder for chaining. + */ + public Builder setState(com.google.spanner.admin.database.v1.Backup.State value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000100; + state_ = value.getNumber(); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The current state of the backup.
      * 
* * @@ -2971,7 +3539,7 @@ public Builder setState(com.google.spanner.admin.database.v1.Backup.State value) * @return This builder for chaining. */ public Builder clearState() { - bitField0_ = (bitField0_ & ~0x00000040); + bitField0_ = (bitField0_ & ~0x00000100); state_ = 0; onChanged(); return this; @@ -2984,7 +3552,7 @@ private void ensureReferencingDatabasesIsMutable() { if (!referencingDatabases_.isModifiable()) { referencingDatabases_ = new com.google.protobuf.LazyStringArrayList(referencingDatabases_); } - bitField0_ |= 0x00000080; + bitField0_ |= 0x00000200; } /** * @@ -3104,7 +3672,7 @@ public Builder setReferencingDatabases(int index, java.lang.String value) { } ensureReferencingDatabasesIsMutable(); referencingDatabases_.set(index, value); - bitField0_ |= 0x00000080; + bitField0_ |= 0x00000200; onChanged(); return this; } @@ -3134,7 +3702,7 @@ public Builder addReferencingDatabases(java.lang.String value) { } ensureReferencingDatabasesIsMutable(); referencingDatabases_.add(value); - bitField0_ |= 0x00000080; + bitField0_ |= 0x00000200; onChanged(); return this; } @@ -3161,7 +3729,7 @@ public Builder addReferencingDatabases(java.lang.String value) { public Builder addAllReferencingDatabases(java.lang.Iterable values) { ensureReferencingDatabasesIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll(values, referencingDatabases_); - bitField0_ |= 0x00000080; + bitField0_ |= 0x00000200; onChanged(); return this; } @@ -3186,7 +3754,7 @@ public Builder addAllReferencingDatabases(java.lang.Iterable v */ public Builder clearReferencingDatabases() { referencingDatabases_ = com.google.protobuf.LazyStringArrayList.emptyList(); - bitField0_ = (bitField0_ & ~0x00000080); + bitField0_ = (bitField0_ & ~0x00000200); ; onChanged(); return this; @@ -3218,7 +3786,7 @@ public Builder addReferencingDatabasesBytes(com.google.protobuf.ByteString value checkByteStringIsUtf8(value); ensureReferencingDatabasesIsMutable(); referencingDatabases_.add(value); - bitField0_ |= 0x00000080; + bitField0_ |= 0x00000200; onChanged(); return this; } @@ -3243,7 +3811,7 @@ public Builder addReferencingDatabasesBytes(com.google.protobuf.ByteString value * @return Whether the encryptionInfo field is set. */ public boolean hasEncryptionInfo() { - return ((bitField0_ & 0x00000100) != 0); + return ((bitField0_ & 0x00000400) != 0); } /** * @@ -3287,7 +3855,7 @@ public Builder setEncryptionInfo(com.google.spanner.admin.database.v1.Encryption } else { encryptionInfoBuilder_.setMessage(value); } - bitField0_ |= 0x00000100; + bitField0_ |= 0x00000400; onChanged(); return this; } @@ -3309,7 +3877,7 @@ public Builder setEncryptionInfo( } else { encryptionInfoBuilder_.setMessage(builderForValue.build()); } - bitField0_ |= 0x00000100; + bitField0_ |= 0x00000400; onChanged(); return this; } @@ -3326,7 +3894,7 @@ public Builder setEncryptionInfo( */ public Builder mergeEncryptionInfo(com.google.spanner.admin.database.v1.EncryptionInfo value) { if (encryptionInfoBuilder_ == null) { - if (((bitField0_ & 0x00000100) != 0) + if (((bitField0_ & 0x00000400) != 0) && encryptionInfo_ != null && encryptionInfo_ != com.google.spanner.admin.database.v1.EncryptionInfo.getDefaultInstance()) { @@ -3338,7 +3906,7 @@ public Builder mergeEncryptionInfo(com.google.spanner.admin.database.v1.Encrypti encryptionInfoBuilder_.mergeFrom(value); } if (encryptionInfo_ != null) { - bitField0_ |= 0x00000100; + bitField0_ |= 0x00000400; onChanged(); } return this; @@ -3355,7 +3923,7 @@ public Builder mergeEncryptionInfo(com.google.spanner.admin.database.v1.Encrypti * */ public Builder clearEncryptionInfo() { - bitField0_ = (bitField0_ & ~0x00000100); + bitField0_ = (bitField0_ & ~0x00000400); encryptionInfo_ = null; if (encryptionInfoBuilder_ != null) { encryptionInfoBuilder_.dispose(); @@ -3376,7 +3944,7 @@ public Builder clearEncryptionInfo() { *
*/ public com.google.spanner.admin.database.v1.EncryptionInfo.Builder getEncryptionInfoBuilder() { - bitField0_ |= 0x00000100; + bitField0_ |= 0x00000400; onChanged(); return getEncryptionInfoFieldBuilder().getBuilder(); } @@ -3433,11 +4001,11 @@ public com.google.spanner.admin.database.v1.EncryptionInfo.Builder getEncryption encryptionInformation_ = java.util.Collections.emptyList(); private void ensureEncryptionInformationIsMutable() { - if (!((bitField0_ & 0x00000200) != 0)) { + if (!((bitField0_ & 0x00000800) != 0)) { encryptionInformation_ = new java.util.ArrayList( encryptionInformation_); - bitField0_ |= 0x00000200; + bitField0_ |= 0x00000800; } } @@ -3734,7 +4302,7 @@ public Builder addAllEncryptionInformation( public Builder clearEncryptionInformation() { if (encryptionInformationBuilder_ == null) { encryptionInformation_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000200); + bitField0_ = (bitField0_ & ~0x00000800); onChanged(); } else { encryptionInformationBuilder_.clear(); @@ -3911,7 +4479,7 @@ public Builder removeEncryptionInformation(int index) { com.google.spanner.admin.database.v1.EncryptionInfo.Builder, com.google.spanner.admin.database.v1.EncryptionInfoOrBuilder>( encryptionInformation_, - ((bitField0_ & 0x00000200) != 0), + ((bitField0_ & 0x00000800) != 0), getParentForChildren(), isClean()); encryptionInformation_ = null; @@ -3953,7 +4521,7 @@ public int getDatabaseDialectValue() { */ public Builder setDatabaseDialectValue(int value) { databaseDialect_ = value; - bitField0_ |= 0x00000400; + bitField0_ |= 0x00001000; onChanged(); return this; } @@ -3996,7 +4564,7 @@ public Builder setDatabaseDialect(com.google.spanner.admin.database.v1.DatabaseD if (value == null) { throw new NullPointerException(); } - bitField0_ |= 0x00000400; + bitField0_ |= 0x00001000; databaseDialect_ = value.getNumber(); onChanged(); return this; @@ -4015,7 +4583,7 @@ public Builder setDatabaseDialect(com.google.spanner.admin.database.v1.DatabaseD * @return This builder for chaining. */ public Builder clearDatabaseDialect() { - bitField0_ = (bitField0_ & ~0x00000400); + bitField0_ = (bitField0_ & ~0x00001000); databaseDialect_ = 0; onChanged(); return this; @@ -4028,7 +4596,7 @@ private void ensureReferencingBackupsIsMutable() { if (!referencingBackups_.isModifiable()) { referencingBackups_ = new com.google.protobuf.LazyStringArrayList(referencingBackups_); } - bitField0_ |= 0x00000800; + bitField0_ |= 0x00002000; } /** * @@ -4148,7 +4716,7 @@ public Builder setReferencingBackups(int index, java.lang.String value) { } ensureReferencingBackupsIsMutable(); referencingBackups_.set(index, value); - bitField0_ |= 0x00000800; + bitField0_ |= 0x00002000; onChanged(); return this; } @@ -4178,7 +4746,7 @@ public Builder addReferencingBackups(java.lang.String value) { } ensureReferencingBackupsIsMutable(); referencingBackups_.add(value); - bitField0_ |= 0x00000800; + bitField0_ |= 0x00002000; onChanged(); return this; } @@ -4205,7 +4773,7 @@ public Builder addReferencingBackups(java.lang.String value) { public Builder addAllReferencingBackups(java.lang.Iterable values) { ensureReferencingBackupsIsMutable(); com.google.protobuf.AbstractMessageLite.Builder.addAll(values, referencingBackups_); - bitField0_ |= 0x00000800; + bitField0_ |= 0x00002000; onChanged(); return this; } @@ -4230,7 +4798,7 @@ public Builder addAllReferencingBackups(java.lang.Iterable val */ public Builder clearReferencingBackups() { referencingBackups_ = com.google.protobuf.LazyStringArrayList.emptyList(); - bitField0_ = (bitField0_ & ~0x00000800); + bitField0_ = (bitField0_ & ~0x00002000); ; onChanged(); return this; @@ -4262,7 +4830,7 @@ public Builder addReferencingBackupsBytes(com.google.protobuf.ByteString value) checkByteStringIsUtf8(value); ensureReferencingBackupsIsMutable(); referencingBackups_.add(value); - bitField0_ |= 0x00000800; + bitField0_ |= 0x00002000; onChanged(); return this; } @@ -4291,7 +4859,7 @@ public Builder addReferencingBackupsBytes(com.google.protobuf.ByteString value) * @return Whether the maxExpireTime field is set. */ public boolean hasMaxExpireTime() { - return ((bitField0_ & 0x00001000) != 0); + return ((bitField0_ & 0x00004000) != 0); } /** * @@ -4343,7 +4911,7 @@ public Builder setMaxExpireTime(com.google.protobuf.Timestamp value) { } else { maxExpireTimeBuilder_.setMessage(value); } - bitField0_ |= 0x00001000; + bitField0_ |= 0x00004000; onChanged(); return this; } @@ -4368,7 +4936,7 @@ public Builder setMaxExpireTime(com.google.protobuf.Timestamp.Builder builderFor } else { maxExpireTimeBuilder_.setMessage(builderForValue.build()); } - bitField0_ |= 0x00001000; + bitField0_ |= 0x00004000; onChanged(); return this; } @@ -4389,7 +4957,7 @@ public Builder setMaxExpireTime(com.google.protobuf.Timestamp.Builder builderFor */ public Builder mergeMaxExpireTime(com.google.protobuf.Timestamp value) { if (maxExpireTimeBuilder_ == null) { - if (((bitField0_ & 0x00001000) != 0) + if (((bitField0_ & 0x00004000) != 0) && maxExpireTime_ != null && maxExpireTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { getMaxExpireTimeBuilder().mergeFrom(value); @@ -4400,7 +4968,7 @@ public Builder mergeMaxExpireTime(com.google.protobuf.Timestamp value) { maxExpireTimeBuilder_.mergeFrom(value); } if (maxExpireTime_ != null) { - bitField0_ |= 0x00001000; + bitField0_ |= 0x00004000; onChanged(); } return this; @@ -4421,7 +4989,7 @@ public Builder mergeMaxExpireTime(com.google.protobuf.Timestamp value) { *
*/ public Builder clearMaxExpireTime() { - bitField0_ = (bitField0_ & ~0x00001000); + bitField0_ = (bitField0_ & ~0x00004000); maxExpireTime_ = null; if (maxExpireTimeBuilder_ != null) { maxExpireTimeBuilder_.dispose(); @@ -4446,7 +5014,7 @@ public Builder clearMaxExpireTime() { * */ public com.google.protobuf.Timestamp.Builder getMaxExpireTimeBuilder() { - bitField0_ |= 0x00001000; + bitField0_ |= 0x00004000; onChanged(); return getMaxExpireTimeFieldBuilder().getBuilder(); } @@ -4506,6 +5074,640 @@ public com.google.protobuf.TimestampOrBuilder getMaxExpireTimeOrBuilder() { return maxExpireTimeBuilder_; } + private com.google.protobuf.LazyStringArrayList backupSchedules_ = + com.google.protobuf.LazyStringArrayList.emptyList(); + + private void ensureBackupSchedulesIsMutable() { + if (!backupSchedules_.isModifiable()) { + backupSchedules_ = new com.google.protobuf.LazyStringArrayList(backupSchedules_); + } + bitField0_ |= 0x00008000; + } + /** + * + * + *
+     * Output only. List of backup schedule URIs that are associated with
+     * creating this backup. This is only applicable for scheduled backups, and
+     * is empty for on-demand backups.
+     *
+     * To optimize for storage, whenever possible, multiple schedules are
+     * collapsed together to create one backup. In such cases, this field captures
+     * the list of all backup schedule URIs that are associated with creating
+     * this backup. If collapsing is not done, then this field captures the
+     * single backup schedule URI associated with creating this backup.
+     * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return A list containing the backupSchedules. + */ + public com.google.protobuf.ProtocolStringList getBackupSchedulesList() { + backupSchedules_.makeImmutable(); + return backupSchedules_; + } + /** + * + * + *
+     * Output only. List of backup schedule URIs that are associated with
+     * creating this backup. This is only applicable for scheduled backups, and
+     * is empty for on-demand backups.
+     *
+     * To optimize for storage, whenever possible, multiple schedules are
+     * collapsed together to create one backup. In such cases, this field captures
+     * the list of all backup schedule URIs that are associated with creating
+     * this backup. If collapsing is not done, then this field captures the
+     * single backup schedule URI associated with creating this backup.
+     * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The count of backupSchedules. + */ + public int getBackupSchedulesCount() { + return backupSchedules_.size(); + } + /** + * + * + *
+     * Output only. List of backup schedule URIs that are associated with
+     * creating this backup. This is only applicable for scheduled backups, and
+     * is empty for on-demand backups.
+     *
+     * To optimize for storage, whenever possible, multiple schedules are
+     * collapsed together to create one backup. In such cases, this field captures
+     * the list of all backup schedule URIs that are associated with creating
+     * this backup. If collapsing is not done, then this field captures the
+     * single backup schedule URI associated with creating this backup.
+     * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the element to return. + * @return The backupSchedules at the given index. + */ + public java.lang.String getBackupSchedules(int index) { + return backupSchedules_.get(index); + } + /** + * + * + *
+     * Output only. List of backup schedule URIs that are associated with
+     * creating this backup. This is only applicable for scheduled backups, and
+     * is empty for on-demand backups.
+     *
+     * To optimize for storage, whenever possible, multiple schedules are
+     * collapsed together to create one backup. In such cases, this field captures
+     * the list of all backup schedule URIs that are associated with creating
+     * this backup. If collapsing is not done, then this field captures the
+     * single backup schedule URI associated with creating this backup.
+     * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the value to return. + * @return The bytes of the backupSchedules at the given index. + */ + public com.google.protobuf.ByteString getBackupSchedulesBytes(int index) { + return backupSchedules_.getByteString(index); + } + /** + * + * + *
+     * Output only. List of backup schedule URIs that are associated with
+     * creating this backup. This is only applicable for scheduled backups, and
+     * is empty for on-demand backups.
+     *
+     * To optimize for storage, whenever possible, multiple schedules are
+     * collapsed together to create one backup. In such cases, this field captures
+     * the list of all backup schedule URIs that are associated with creating
+     * this backup. If collapsing is not done, then this field captures the
+     * single backup schedule URI associated with creating this backup.
+     * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index to set the value at. + * @param value The backupSchedules to set. + * @return This builder for chaining. + */ + public Builder setBackupSchedules(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.set(index, value); + bitField0_ |= 0x00008000; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. List of backup schedule URIs that are associated with
+     * creating this backup. This is only applicable for scheduled backups, and
+     * is empty for on-demand backups.
+     *
+     * To optimize for storage, whenever possible, multiple schedules are
+     * collapsed together to create one backup. In such cases, this field captures
+     * the list of all backup schedule URIs that are associated with creating
+     * this backup. If collapsing is not done, then this field captures the
+     * single backup schedule URI associated with creating this backup.
+     * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The backupSchedules to add. + * @return This builder for chaining. + */ + public Builder addBackupSchedules(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(value); + bitField0_ |= 0x00008000; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. List of backup schedule URIs that are associated with
+     * creating this backup. This is only applicable for scheduled backups, and
+     * is empty for on-demand backups.
+     *
+     * To optimize for storage, whenever possible, multiple schedules are
+     * collapsed together to create one backup. In such cases, this field captures
+     * the list of all backup schedule URIs that are associated with creating
+     * this backup. If collapsing is not done, then this field captures the
+     * single backup schedule URI associated with creating this backup.
+     * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param values The backupSchedules to add. + * @return This builder for chaining. + */ + public Builder addAllBackupSchedules(java.lang.Iterable values) { + ensureBackupSchedulesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, backupSchedules_); + bitField0_ |= 0x00008000; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. List of backup schedule URIs that are associated with
+     * creating this backup. This is only applicable for scheduled backups, and
+     * is empty for on-demand backups.
+     *
+     * To optimize for storage, whenever possible, multiple schedules are
+     * collapsed together to create one backup. In such cases, this field captures
+     * the list of all backup schedule URIs that are associated with creating
+     * this backup. If collapsing is not done, then this field captures the
+     * single backup schedule URI associated with creating this backup.
+     * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearBackupSchedules() { + backupSchedules_ = com.google.protobuf.LazyStringArrayList.emptyList(); + bitField0_ = (bitField0_ & ~0x00008000); + ; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. List of backup schedule URIs that are associated with
+     * creating this backup. This is only applicable for scheduled backups, and
+     * is empty for on-demand backups.
+     *
+     * To optimize for storage, whenever possible, multiple schedules are
+     * collapsed together to create one backup. In such cases, this field captures
+     * the list of all backup schedule URIs that are associated with creating
+     * this backup. If collapsing is not done, then this field captures the
+     * single backup schedule URI associated with creating this backup.
+     * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The bytes of the backupSchedules to add. + * @return This builder for chaining. + */ + public Builder addBackupSchedulesBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(value); + bitField0_ |= 0x00008000; + onChanged(); + return this; + } + + private java.lang.Object incrementalBackupChainId_ = ""; + /** + * + * + *
+     * Output only. Populated only for backups in an incremental backup chain.
+     * Backups share the same chain id if and only if they belong to the same
+     * incremental backup chain. Use this field to determine which backups are
+     * part of the same incremental backup chain. The ordering of backups in the
+     * chain can be determined by ordering the backup `version_time`.
+     * 
+ * + * string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The incrementalBackupChainId. + */ + public java.lang.String getIncrementalBackupChainId() { + java.lang.Object ref = incrementalBackupChainId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + incrementalBackupChainId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. Populated only for backups in an incremental backup chain.
+     * Backups share the same chain id if and only if they belong to the same
+     * incremental backup chain. Use this field to determine which backups are
+     * part of the same incremental backup chain. The ordering of backups in the
+     * chain can be determined by ordering the backup `version_time`.
+     * 
+ * + * string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The bytes for incrementalBackupChainId. + */ + public com.google.protobuf.ByteString getIncrementalBackupChainIdBytes() { + java.lang.Object ref = incrementalBackupChainId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + incrementalBackupChainId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. Populated only for backups in an incremental backup chain.
+     * Backups share the same chain id if and only if they belong to the same
+     * incremental backup chain. Use this field to determine which backups are
+     * part of the same incremental backup chain. The ordering of backups in the
+     * chain can be determined by ordering the backup `version_time`.
+     * 
+ * + * string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The incrementalBackupChainId to set. + * @return This builder for chaining. + */ + public Builder setIncrementalBackupChainId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + incrementalBackupChainId_ = value; + bitField0_ |= 0x00010000; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Populated only for backups in an incremental backup chain.
+     * Backups share the same chain id if and only if they belong to the same
+     * incremental backup chain. Use this field to determine which backups are
+     * part of the same incremental backup chain. The ordering of backups in the
+     * chain can be determined by ordering the backup `version_time`.
+     * 
+ * + * string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return This builder for chaining. + */ + public Builder clearIncrementalBackupChainId() { + incrementalBackupChainId_ = getDefaultInstance().getIncrementalBackupChainId(); + bitField0_ = (bitField0_ & ~0x00010000); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Populated only for backups in an incremental backup chain.
+     * Backups share the same chain id if and only if they belong to the same
+     * incremental backup chain. Use this field to determine which backups are
+     * part of the same incremental backup chain. The ordering of backups in the
+     * chain can be determined by ordering the backup `version_time`.
+     * 
+ * + * string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param value The bytes for incrementalBackupChainId to set. + * @return This builder for chaining. + */ + public Builder setIncrementalBackupChainIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + incrementalBackupChainId_ = value; + bitField0_ |= 0x00010000; + onChanged(); + return this; + } + + private com.google.protobuf.Timestamp oldestVersionTime_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + oldestVersionTimeBuilder_; + /** + * + * + *
+     * Output only. Data deleted at a time older than this is guaranteed not to be
+     * retained in order to support this backup. For a backup in an incremental
+     * backup chain, this is the version time of the oldest backup that exists or
+     * ever existed in the chain. For all other backups, this is the version time
+     * of the backup. This field can be used to understand what data is being
+     * retained by the backup system.
+     * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the oldestVersionTime field is set. + */ + public boolean hasOldestVersionTime() { + return ((bitField0_ & 0x00020000) != 0); + } + /** + * + * + *
+     * Output only. Data deleted at a time older than this is guaranteed not to be
+     * retained in order to support this backup. For a backup in an incremental
+     * backup chain, this is the version time of the oldest backup that exists or
+     * ever existed in the chain. For all other backups, this is the version time
+     * of the backup. This field can be used to understand what data is being
+     * retained by the backup system.
+     * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The oldestVersionTime. + */ + public com.google.protobuf.Timestamp getOldestVersionTime() { + if (oldestVersionTimeBuilder_ == null) { + return oldestVersionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : oldestVersionTime_; + } else { + return oldestVersionTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. Data deleted at a time older than this is guaranteed not to be
+     * retained in order to support this backup. For a backup in an incremental
+     * backup chain, this is the version time of the oldest backup that exists or
+     * ever existed in the chain. For all other backups, this is the version time
+     * of the backup. This field can be used to understand what data is being
+     * retained by the backup system.
+     * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setOldestVersionTime(com.google.protobuf.Timestamp value) { + if (oldestVersionTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + oldestVersionTime_ = value; + } else { + oldestVersionTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00020000; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Data deleted at a time older than this is guaranteed not to be
+     * retained in order to support this backup. For a backup in an incremental
+     * backup chain, this is the version time of the oldest backup that exists or
+     * ever existed in the chain. For all other backups, this is the version time
+     * of the backup. This field can be used to understand what data is being
+     * retained by the backup system.
+     * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setOldestVersionTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (oldestVersionTimeBuilder_ == null) { + oldestVersionTime_ = builderForValue.build(); + } else { + oldestVersionTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00020000; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Data deleted at a time older than this is guaranteed not to be
+     * retained in order to support this backup. For a backup in an incremental
+     * backup chain, this is the version time of the oldest backup that exists or
+     * ever existed in the chain. For all other backups, this is the version time
+     * of the backup. This field can be used to understand what data is being
+     * retained by the backup system.
+     * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeOldestVersionTime(com.google.protobuf.Timestamp value) { + if (oldestVersionTimeBuilder_ == null) { + if (((bitField0_ & 0x00020000) != 0) + && oldestVersionTime_ != null + && oldestVersionTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getOldestVersionTimeBuilder().mergeFrom(value); + } else { + oldestVersionTime_ = value; + } + } else { + oldestVersionTimeBuilder_.mergeFrom(value); + } + if (oldestVersionTime_ != null) { + bitField0_ |= 0x00020000; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Output only. Data deleted at a time older than this is guaranteed not to be
+     * retained in order to support this backup. For a backup in an incremental
+     * backup chain, this is the version time of the oldest backup that exists or
+     * ever existed in the chain. For all other backups, this is the version time
+     * of the backup. This field can be used to understand what data is being
+     * retained by the backup system.
+     * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearOldestVersionTime() { + bitField0_ = (bitField0_ & ~0x00020000); + oldestVersionTime_ = null; + if (oldestVersionTimeBuilder_ != null) { + oldestVersionTimeBuilder_.dispose(); + oldestVersionTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Data deleted at a time older than this is guaranteed not to be
+     * retained in order to support this backup. For a backup in an incremental
+     * backup chain, this is the version time of the oldest backup that exists or
+     * ever existed in the chain. For all other backups, this is the version time
+     * of the backup. This field can be used to understand what data is being
+     * retained by the backup system.
+     * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getOldestVersionTimeBuilder() { + bitField0_ |= 0x00020000; + onChanged(); + return getOldestVersionTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. Data deleted at a time older than this is guaranteed not to be
+     * retained in order to support this backup. For a backup in an incremental
+     * backup chain, this is the version time of the oldest backup that exists or
+     * ever existed in the chain. For all other backups, this is the version time
+     * of the backup. This field can be used to understand what data is being
+     * retained by the backup system.
+     * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getOldestVersionTimeOrBuilder() { + if (oldestVersionTimeBuilder_ != null) { + return oldestVersionTimeBuilder_.getMessageOrBuilder(); + } else { + return oldestVersionTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : oldestVersionTime_; + } + } + /** + * + * + *
+     * Output only. Data deleted at a time older than this is guaranteed not to be
+     * retained in order to support this backup. For a backup in an incremental
+     * backup chain, this is the version time of the oldest backup that exists or
+     * ever existed in the chain. For all other backups, this is the version time
+     * of the backup. This field can be used to understand what data is being
+     * retained by the backup system.
+     * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder> + getOldestVersionTimeFieldBuilder() { + if (oldestVersionTimeBuilder_ == null) { + oldestVersionTimeBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Timestamp, + com.google.protobuf.Timestamp.Builder, + com.google.protobuf.TimestampOrBuilder>( + getOldestVersionTime(), getParentForChildren(), isClean()); + oldestVersionTime_ = null; + } + return oldestVersionTimeBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupOrBuilder.java index c3917c39f62..a89a0fdc2f8 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupOrBuilder.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupOrBuilder.java @@ -269,6 +269,44 @@ public interface BackupOrBuilder */ long getSizeBytes(); + /** + * + * + *
+   * Output only. The number of bytes that will be freed by deleting this
+   * backup. This value will be zero if, for example, this backup is part of an
+   * incremental backup chain and younger backups in the chain require that we
+   * keep its data. For backups not in an incremental backup chain, this is
+   * always the size of the backup. This value may change if backups on the same
+   * chain get created, deleted or expired.
+   * 
+ * + * int64 freeable_size_bytes = 15 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The freeableSizeBytes. + */ + long getFreeableSizeBytes(); + + /** + * + * + *
+   * Output only. For a backup in an incremental backup chain, this is the
+   * storage space needed to keep the data that has changed since the previous
+   * backup. For all other backups, this is always the size of the backup. This
+   * value may change if backups on the same chain get deleted or expired.
+   *
+   * This field can be used to calculate the total storage space used by a set
+   * of backups. For example, the total space used by all backups of a database
+   * can be computed by summing up this field.
+   * 
+ * + * int64 exclusive_size_bytes = 16 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The exclusiveSizeBytes. + */ + long getExclusiveSizeBytes(); + /** * * @@ -675,4 +713,182 @@ com.google.spanner.admin.database.v1.EncryptionInfoOrBuilder getEncryptionInform * */ com.google.protobuf.TimestampOrBuilder getMaxExpireTimeOrBuilder(); + + /** + * + * + *
+   * Output only. List of backup schedule URIs that are associated with
+   * creating this backup. This is only applicable for scheduled backups, and
+   * is empty for on-demand backups.
+   *
+   * To optimize for storage, whenever possible, multiple schedules are
+   * collapsed together to create one backup. In such cases, this field captures
+   * the list of all backup schedule URIs that are associated with creating
+   * this backup. If collapsing is not done, then this field captures the
+   * single backup schedule URI associated with creating this backup.
+   * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return A list containing the backupSchedules. + */ + java.util.List getBackupSchedulesList(); + /** + * + * + *
+   * Output only. List of backup schedule URIs that are associated with
+   * creating this backup. This is only applicable for scheduled backups, and
+   * is empty for on-demand backups.
+   *
+   * To optimize for storage, whenever possible, multiple schedules are
+   * collapsed together to create one backup. In such cases, this field captures
+   * the list of all backup schedule URIs that are associated with creating
+   * this backup. If collapsing is not done, then this field captures the
+   * single backup schedule URI associated with creating this backup.
+   * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The count of backupSchedules. + */ + int getBackupSchedulesCount(); + /** + * + * + *
+   * Output only. List of backup schedule URIs that are associated with
+   * creating this backup. This is only applicable for scheduled backups, and
+   * is empty for on-demand backups.
+   *
+   * To optimize for storage, whenever possible, multiple schedules are
+   * collapsed together to create one backup. In such cases, this field captures
+   * the list of all backup schedule URIs that are associated with creating
+   * this backup. If collapsing is not done, then this field captures the
+   * single backup schedule URI associated with creating this backup.
+   * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the element to return. + * @return The backupSchedules at the given index. + */ + java.lang.String getBackupSchedules(int index); + /** + * + * + *
+   * Output only. List of backup schedule URIs that are associated with
+   * creating this backup. This is only applicable for scheduled backups, and
+   * is empty for on-demand backups.
+   *
+   * To optimize for storage, whenever possible, multiple schedules are
+   * collapsed together to create one backup. In such cases, this field captures
+   * the list of all backup schedule URIs that are associated with creating
+   * this backup. If collapsing is not done, then this field captures the
+   * single backup schedule URI associated with creating this backup.
+   * 
+ * + * repeated string backup_schedules = 14 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @param index The index of the value to return. + * @return The bytes of the backupSchedules at the given index. + */ + com.google.protobuf.ByteString getBackupSchedulesBytes(int index); + + /** + * + * + *
+   * Output only. Populated only for backups in an incremental backup chain.
+   * Backups share the same chain id if and only if they belong to the same
+   * incremental backup chain. Use this field to determine which backups are
+   * part of the same incremental backup chain. The ordering of backups in the
+   * chain can be determined by ordering the backup `version_time`.
+   * 
+ * + * string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The incrementalBackupChainId. + */ + java.lang.String getIncrementalBackupChainId(); + /** + * + * + *
+   * Output only. Populated only for backups in an incremental backup chain.
+   * Backups share the same chain id if and only if they belong to the same
+   * incremental backup chain. Use this field to determine which backups are
+   * part of the same incremental backup chain. The ordering of backups in the
+   * chain can be determined by ordering the backup `version_time`.
+   * 
+ * + * string incremental_backup_chain_id = 17 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The bytes for incrementalBackupChainId. + */ + com.google.protobuf.ByteString getIncrementalBackupChainIdBytes(); + + /** + * + * + *
+   * Output only. Data deleted at a time older than this is guaranteed not to be
+   * retained in order to support this backup. For a backup in an incremental
+   * backup chain, this is the version time of the oldest backup that exists or
+   * ever existed in the chain. For all other backups, this is the version time
+   * of the backup. This field can be used to understand what data is being
+   * retained by the backup system.
+   * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the oldestVersionTime field is set. + */ + boolean hasOldestVersionTime(); + /** + * + * + *
+   * Output only. Data deleted at a time older than this is guaranteed not to be
+   * retained in order to support this backup. For a backup in an incremental
+   * backup chain, this is the version time of the oldest backup that exists or
+   * ever existed in the chain. For all other backups, this is the version time
+   * of the backup. This field can be used to understand what data is being
+   * retained by the backup system.
+   * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The oldestVersionTime. + */ + com.google.protobuf.Timestamp getOldestVersionTime(); + /** + * + * + *
+   * Output only. Data deleted at a time older than this is guaranteed not to be
+   * retained in order to support this backup. For a backup in an incremental
+   * backup chain, this is the version time of the oldest backup that exists or
+   * ever existed in the chain. For all other backups, this is the version time
+   * of the backup. This field can be used to understand what data is being
+   * retained by the backup system.
+   * 
+ * + * + * .google.protobuf.Timestamp oldest_version_time = 18 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getOldestVersionTimeOrBuilder(); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupProto.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupProto.java index 4ab53f9a43c..d2f0f5c38e3 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupProto.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupProto.java @@ -88,6 +88,14 @@ public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry r internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_descriptor; static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_google_spanner_admin_database_v1_CopyBackupEncryptionConfig_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_FullBackupSpec_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_FullBackupSpec_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_IncrementalBackupSpec_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_IncrementalBackupSpec_fieldAccessorTable; public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { return descriptor; @@ -104,110 +112,116 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "g/operations.proto\032 google/protobuf/fiel" + "d_mask.proto\032\037google/protobuf/timestamp." + "proto\032-google/spanner/admin/database/v1/" - + "common.proto\"\232\007\n\006Backup\0226\n\010database\030\002 \001(" + + "common.proto\"\346\010\n\006Backup\0226\n\010database\030\002 \001(" + "\tB$\372A!\n\037spanner.googleapis.com/Database\022" + "0\n\014version_time\030\t \001(\0132\032.google.protobuf." + "Timestamp\022/\n\013expire_time\030\003 \001(\0132\032.google." + "protobuf.Timestamp\022\014\n\004name\030\001 \001(\t\0224\n\013crea" + "te_time\030\004 \001(\0132\032.google.protobuf.Timestam" - + "pB\003\340A\003\022\027\n\nsize_bytes\030\005 \001(\003B\003\340A\003\022B\n\005state" - + "\030\006 \001(\0162..google.spanner.admin.database.v" - + "1.Backup.StateB\003\340A\003\022F\n\025referencing_datab" - + "ases\030\007 \003(\tB\'\340A\003\372A!\n\037spanner.googleapis.c" - + "om/Database\022N\n\017encryption_info\030\010 \001(\01320.g" - + "oogle.spanner.admin.database.v1.Encrypti" - + "onInfoB\003\340A\003\022U\n\026encryption_information\030\r " - + "\003(\01320.google.spanner.admin.database.v1.E" - + "ncryptionInfoB\003\340A\003\022P\n\020database_dialect\030\n" - + " \001(\01621.google.spanner.admin.database.v1." - + "DatabaseDialectB\003\340A\003\022B\n\023referencing_back" - + "ups\030\013 \003(\tB%\340A\003\372A\037\n\035spanner.googleapis.co" - + "m/Backup\0228\n\017max_expire_time\030\014 \001(\0132\032.goog" - + "le.protobuf.TimestampB\003\340A\003\"7\n\005State\022\025\n\021S" - + "TATE_UNSPECIFIED\020\000\022\014\n\010CREATING\020\001\022\t\n\005READ" - + "Y\020\002:\\\352AY\n\035spanner.googleapis.com/Backup\022" - + "8projects/{project}/instances/{instance}" - + "/backups/{backup}\"\205\002\n\023CreateBackupReques" - + "t\0227\n\006parent\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.googl" - + "eapis.com/Instance\022\026\n\tbackup_id\030\002 \001(\tB\003\340" - + "A\002\022=\n\006backup\030\003 \001(\0132(.google.spanner.admi" - + "n.database.v1.BackupB\003\340A\002\022^\n\021encryption_" - + "config\030\004 \001(\0132>.google.spanner.admin.data" - + "base.v1.CreateBackupEncryptionConfigB\003\340A" - + "\001\"\370\001\n\024CreateBackupMetadata\0220\n\004name\030\001 \001(\t" - + "B\"\372A\037\n\035spanner.googleapis.com/Backup\0226\n\010" - + "database\030\002 \001(\tB$\372A!\n\037spanner.googleapis." - + "com/Database\022E\n\010progress\030\003 \001(\01323.google." - + "spanner.admin.database.v1.OperationProgr" - + "ess\022/\n\013cancel_time\030\004 \001(\0132\032.google.protob" - + "uf.Timestamp\"\266\002\n\021CopyBackupRequest\0227\n\006pa" - + "rent\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.googleapis.c" - + "om/Instance\022\026\n\tbackup_id\030\002 \001(\tB\003\340A\002\022<\n\rs" - + "ource_backup\030\003 \001(\tB%\340A\002\372A\037\n\035spanner.goog" - + "leapis.com/Backup\0224\n\013expire_time\030\004 \001(\0132\032" - + ".google.protobuf.TimestampB\003\340A\002\022\\\n\021encry" - + "ption_config\030\005 \001(\0132<.google.spanner.admi" - + "n.database.v1.CopyBackupEncryptionConfig" - + "B\003\340A\001\"\371\001\n\022CopyBackupMetadata\0220\n\004name\030\001 \001" - + "(\tB\"\372A\037\n\035spanner.googleapis.com/Backup\0229" - + "\n\rsource_backup\030\002 \001(\tB\"\372A\037\n\035spanner.goog" - + "leapis.com/Backup\022E\n\010progress\030\003 \001(\01323.go" - + "ogle.spanner.admin.database.v1.Operation" - + "Progress\022/\n\013cancel_time\030\004 \001(\0132\032.google.p" - + "rotobuf.Timestamp\"\212\001\n\023UpdateBackupReques" - + "t\022=\n\006backup\030\001 \001(\0132(.google.spanner.admin" - + ".database.v1.BackupB\003\340A\002\0224\n\013update_mask\030" - + "\002 \001(\0132\032.google.protobuf.FieldMaskB\003\340A\002\"G" - + "\n\020GetBackupRequest\0223\n\004name\030\001 \001(\tB%\340A\002\372A\037" - + "\n\035spanner.googleapis.com/Backup\"J\n\023Delet" - + "eBackupRequest\0223\n\004name\030\001 \001(\tB%\340A\002\372A\037\n\035sp" - + "anner.googleapis.com/Backup\"\204\001\n\022ListBack" - + "upsRequest\0227\n\006parent\030\001 \001(\tB\'\340A\002\372A!\n\037span" - + "ner.googleapis.com/Instance\022\016\n\006filter\030\002 " - + "\001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n\npage_token\030\004 \001" - + "(\t\"i\n\023ListBackupsResponse\0229\n\007backups\030\001 \003" - + "(\0132(.google.spanner.admin.database.v1.Ba" - + "ckup\022\027\n\017next_page_token\030\002 \001(\t\"\215\001\n\033ListBa" - + "ckupOperationsRequest\0227\n\006parent\030\001 \001(\tB\'\340" - + "A\002\372A!\n\037spanner.googleapis.com/Instance\022\016" - + "\n\006filter\030\002 \001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n\npag" - + "e_token\030\004 \001(\t\"j\n\034ListBackupOperationsRes" - + "ponse\0221\n\noperations\030\001 \003(\0132\035.google.longr" - + "unning.Operation\022\027\n\017next_page_token\030\002 \001(" - + "\t\"\342\001\n\nBackupInfo\0222\n\006backup\030\001 \001(\tB\"\372A\037\n\035s" - + "panner.googleapis.com/Backup\0220\n\014version_" - + "time\030\004 \001(\0132\032.google.protobuf.Timestamp\022/" - + "\n\013create_time\030\002 \001(\0132\032.google.protobuf.Ti" - + "mestamp\022=\n\017source_database\030\003 \001(\tB$\372A!\n\037s" - + "panner.googleapis.com/Database\"\237\003\n\034Creat" - + "eBackupEncryptionConfig\022k\n\017encryption_ty" - + "pe\030\001 \001(\0162M.google.spanner.admin.database" - + ".v1.CreateBackupEncryptionConfig.Encrypt" - + "ionTypeB\003\340A\002\022?\n\014kms_key_name\030\002 \001(\tB)\340A\001\372" - + "A#\n!cloudkms.googleapis.com/CryptoKey\022@\n" - + "\rkms_key_names\030\003 \003(\tB)\340A\001\372A#\n!cloudkms.g" - + "oogleapis.com/CryptoKey\"\216\001\n\016EncryptionTy" - + "pe\022\037\n\033ENCRYPTION_TYPE_UNSPECIFIED\020\000\022\033\n\027U" - + "SE_DATABASE_ENCRYPTION\020\001\022\035\n\031GOOGLE_DEFAU" - + "LT_ENCRYPTION\020\002\022\037\n\033CUSTOMER_MANAGED_ENCR" - + "YPTION\020\003\"\253\003\n\032CopyBackupEncryptionConfig\022" - + "i\n\017encryption_type\030\001 \001(\0162K.google.spanne" - + "r.admin.database.v1.CopyBackupEncryption" - + "Config.EncryptionTypeB\003\340A\002\022?\n\014kms_key_na" - + "me\030\002 \001(\tB)\340A\001\372A#\n!cloudkms.googleapis.co" - + "m/CryptoKey\022@\n\rkms_key_names\030\003 \003(\tB)\340A\001\372" - + "A#\n!cloudkms.googleapis.com/CryptoKey\"\236\001" - + "\n\016EncryptionType\022\037\n\033ENCRYPTION_TYPE_UNSP" - + "ECIFIED\020\000\022+\n\'USE_CONFIG_DEFAULT_OR_BACKU" - + "P_ENCRYPTION\020\001\022\035\n\031GOOGLE_DEFAULT_ENCRYPT" - + "ION\020\002\022\037\n\033CUSTOMER_MANAGED_ENCRYPTION\020\003B\375" - + "\001\n$com.google.spanner.admin.database.v1B" - + "\013BackupProtoP\001ZFcloud.google.com/go/span" - + "ner/admin/database/apiv1/databasepb;data" - + "basepb\252\002&Google.Cloud.Spanner.Admin.Data" - + "base.V1\312\002&Google\\Cloud\\Spanner\\Admin\\Dat" - + "abase\\V1\352\002+Google::Cloud::Spanner::Admin" - + "::Database::V1b\006proto3" + + "pB\003\340A\003\022\027\n\nsize_bytes\030\005 \001(\003B\003\340A\003\022 \n\023freea" + + "ble_size_bytes\030\017 \001(\003B\003\340A\003\022!\n\024exclusive_s" + + "ize_bytes\030\020 \001(\003B\003\340A\003\022B\n\005state\030\006 \001(\0162..go" + + "ogle.spanner.admin.database.v1.Backup.St" + + "ateB\003\340A\003\022F\n\025referencing_databases\030\007 \003(\tB" + + "\'\340A\003\372A!\n\037spanner.googleapis.com/Database" + + "\022N\n\017encryption_info\030\010 \001(\01320.google.spann" + + "er.admin.database.v1.EncryptionInfoB\003\340A\003" + + "\022U\n\026encryption_information\030\r \003(\01320.googl" + + "e.spanner.admin.database.v1.EncryptionIn" + + "foB\003\340A\003\022P\n\020database_dialect\030\n \001(\01621.goog" + + "le.spanner.admin.database.v1.DatabaseDia" + + "lectB\003\340A\003\022B\n\023referencing_backups\030\013 \003(\tB%" + + "\340A\003\372A\037\n\035spanner.googleapis.com/Backup\0228\n" + + "\017max_expire_time\030\014 \001(\0132\032.google.protobuf" + + ".TimestampB\003\340A\003\022\035\n\020backup_schedules\030\016 \003(" + + "\tB\003\340A\003\022(\n\033incremental_backup_chain_id\030\021 " + + "\001(\tB\003\340A\003\022<\n\023oldest_version_time\030\022 \001(\0132\032." + + "google.protobuf.TimestampB\003\340A\003\"7\n\005State\022" + + "\025\n\021STATE_UNSPECIFIED\020\000\022\014\n\010CREATING\020\001\022\t\n\005" + + "READY\020\002:\\\352AY\n\035spanner.googleapis.com/Bac" + + "kup\0228projects/{project}/instances/{insta" + + "nce}/backups/{backup}\"\205\002\n\023CreateBackupRe" + + "quest\0227\n\006parent\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.g" + + "oogleapis.com/Instance\022\026\n\tbackup_id\030\002 \001(" + + "\tB\003\340A\002\022=\n\006backup\030\003 \001(\0132(.google.spanner." + + "admin.database.v1.BackupB\003\340A\002\022^\n\021encrypt" + + "ion_config\030\004 \001(\0132>.google.spanner.admin." + + "database.v1.CreateBackupEncryptionConfig" + + "B\003\340A\001\"\370\001\n\024CreateBackupMetadata\0220\n\004name\030\001" + + " \001(\tB\"\372A\037\n\035spanner.googleapis.com/Backup" + + "\0226\n\010database\030\002 \001(\tB$\372A!\n\037spanner.googlea" + + "pis.com/Database\022E\n\010progress\030\003 \001(\01323.goo" + + "gle.spanner.admin.database.v1.OperationP" + + "rogress\022/\n\013cancel_time\030\004 \001(\0132\032.google.pr" + + "otobuf.Timestamp\"\266\002\n\021CopyBackupRequest\0227" + + "\n\006parent\030\001 \001(\tB\'\340A\002\372A!\n\037spanner.googleap" + + "is.com/Instance\022\026\n\tbackup_id\030\002 \001(\tB\003\340A\002\022" + + "<\n\rsource_backup\030\003 \001(\tB%\340A\002\372A\037\n\035spanner." + + "googleapis.com/Backup\0224\n\013expire_time\030\004 \001" + + "(\0132\032.google.protobuf.TimestampB\003\340A\002\022\\\n\021e" + + "ncryption_config\030\005 \001(\0132<.google.spanner." + + "admin.database.v1.CopyBackupEncryptionCo" + + "nfigB\003\340A\001\"\371\001\n\022CopyBackupMetadata\0220\n\004name" + + "\030\001 \001(\tB\"\372A\037\n\035spanner.googleapis.com/Back" + + "up\0229\n\rsource_backup\030\002 \001(\tB\"\372A\037\n\035spanner." + + "googleapis.com/Backup\022E\n\010progress\030\003 \001(\0132" + + "3.google.spanner.admin.database.v1.Opera" + + "tionProgress\022/\n\013cancel_time\030\004 \001(\0132\032.goog" + + "le.protobuf.Timestamp\"\212\001\n\023UpdateBackupRe" + + "quest\022=\n\006backup\030\001 \001(\0132(.google.spanner.a" + + "dmin.database.v1.BackupB\003\340A\002\0224\n\013update_m" + + "ask\030\002 \001(\0132\032.google.protobuf.FieldMaskB\003\340" + + "A\002\"G\n\020GetBackupRequest\0223\n\004name\030\001 \001(\tB%\340A" + + "\002\372A\037\n\035spanner.googleapis.com/Backup\"J\n\023D" + + "eleteBackupRequest\0223\n\004name\030\001 \001(\tB%\340A\002\372A\037" + + "\n\035spanner.googleapis.com/Backup\"\204\001\n\022List" + + "BackupsRequest\0227\n\006parent\030\001 \001(\tB\'\340A\002\372A!\n\037" + + "spanner.googleapis.com/Instance\022\016\n\006filte" + + "r\030\002 \001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n\npage_token" + + "\030\004 \001(\t\"i\n\023ListBackupsResponse\0229\n\007backups" + + "\030\001 \003(\0132(.google.spanner.admin.database.v" + + "1.Backup\022\027\n\017next_page_token\030\002 \001(\t\"\215\001\n\033Li" + + "stBackupOperationsRequest\0227\n\006parent\030\001 \001(" + + "\tB\'\340A\002\372A!\n\037spanner.googleapis.com/Instan" + + "ce\022\016\n\006filter\030\002 \001(\t\022\021\n\tpage_size\030\003 \001(\005\022\022\n" + + "\npage_token\030\004 \001(\t\"j\n\034ListBackupOperation" + + "sResponse\0221\n\noperations\030\001 \003(\0132\035.google.l" + + "ongrunning.Operation\022\027\n\017next_page_token\030" + + "\002 \001(\t\"\342\001\n\nBackupInfo\0222\n\006backup\030\001 \001(\tB\"\372A" + + "\037\n\035spanner.googleapis.com/Backup\0220\n\014vers" + + "ion_time\030\004 \001(\0132\032.google.protobuf.Timesta" + + "mp\022/\n\013create_time\030\002 \001(\0132\032.google.protobu" + + "f.Timestamp\022=\n\017source_database\030\003 \001(\tB$\372A" + + "!\n\037spanner.googleapis.com/Database\"\237\003\n\034C" + + "reateBackupEncryptionConfig\022k\n\017encryptio" + + "n_type\030\001 \001(\0162M.google.spanner.admin.data" + + "base.v1.CreateBackupEncryptionConfig.Enc" + + "ryptionTypeB\003\340A\002\022?\n\014kms_key_name\030\002 \001(\tB)" + + "\340A\001\372A#\n!cloudkms.googleapis.com/CryptoKe" + + "y\022@\n\rkms_key_names\030\003 \003(\tB)\340A\001\372A#\n!cloudk" + + "ms.googleapis.com/CryptoKey\"\216\001\n\016Encrypti" + + "onType\022\037\n\033ENCRYPTION_TYPE_UNSPECIFIED\020\000\022" + + "\033\n\027USE_DATABASE_ENCRYPTION\020\001\022\035\n\031GOOGLE_D" + + "EFAULT_ENCRYPTION\020\002\022\037\n\033CUSTOMER_MANAGED_" + + "ENCRYPTION\020\003\"\253\003\n\032CopyBackupEncryptionCon" + + "fig\022i\n\017encryption_type\030\001 \001(\0162K.google.sp" + + "anner.admin.database.v1.CopyBackupEncryp" + + "tionConfig.EncryptionTypeB\003\340A\002\022?\n\014kms_ke" + + "y_name\030\002 \001(\tB)\340A\001\372A#\n!cloudkms.googleapi" + + "s.com/CryptoKey\022@\n\rkms_key_names\030\003 \003(\tB)" + + "\340A\001\372A#\n!cloudkms.googleapis.com/CryptoKe" + + "y\"\236\001\n\016EncryptionType\022\037\n\033ENCRYPTION_TYPE_" + + "UNSPECIFIED\020\000\022+\n\'USE_CONFIG_DEFAULT_OR_B" + + "ACKUP_ENCRYPTION\020\001\022\035\n\031GOOGLE_DEFAULT_ENC" + + "RYPTION\020\002\022\037\n\033CUSTOMER_MANAGED_ENCRYPTION" + + "\020\003\"\020\n\016FullBackupSpec\"\027\n\025IncrementalBacku" + + "pSpecB\375\001\n$com.google.spanner.admin.datab" + + "ase.v1B\013BackupProtoP\001ZFcloud.google.com/" + + "go/spanner/admin/database/apiv1/database" + + "pb;databasepb\252\002&Google.Cloud.Spanner.Adm" + + "in.Database.V1\312\002&Google\\Cloud\\Spanner\\Ad" + + "min\\Database\\V1\352\002+Google::Cloud::Spanner" + + "::Admin::Database::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -232,6 +246,8 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "Name", "CreateTime", "SizeBytes", + "FreeableSizeBytes", + "ExclusiveSizeBytes", "State", "ReferencingDatabases", "EncryptionInfo", @@ -239,6 +255,9 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { "DatabaseDialect", "ReferencingBackups", "MaxExpireTime", + "BackupSchedules", + "IncrementalBackupChainId", + "OldestVersionTime", }); internal_static_google_spanner_admin_database_v1_CreateBackupRequest_descriptor = getDescriptor().getMessageTypes().get(1); @@ -352,6 +371,18 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new java.lang.String[] { "EncryptionType", "KmsKeyName", "KmsKeyNames", }); + internal_static_google_spanner_admin_database_v1_FullBackupSpec_descriptor = + getDescriptor().getMessageTypes().get(15); + internal_static_google_spanner_admin_database_v1_FullBackupSpec_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_FullBackupSpec_descriptor, + new java.lang.String[] {}); + internal_static_google_spanner_admin_database_v1_IncrementalBackupSpec_descriptor = + getDescriptor().getMessageTypes().get(16); + internal_static_google_spanner_admin_database_v1_IncrementalBackupSpec_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_IncrementalBackupSpec_descriptor, + new java.lang.String[] {}); com.google.protobuf.ExtensionRegistry registry = com.google.protobuf.ExtensionRegistry.newInstance(); registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupSchedule.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupSchedule.java new file mode 100644 index 00000000000..c4f54956514 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupSchedule.java @@ -0,0 +1,2652 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * BackupSchedule expresses the automated backup creation specification for a
+ * Spanner database.
+ * Next ID: 10
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.BackupSchedule} + */ +public final class BackupSchedule extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.BackupSchedule) + BackupScheduleOrBuilder { + private static final long serialVersionUID = 0L; + // Use BackupSchedule.newBuilder() to construct. + private BackupSchedule(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private BackupSchedule() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new BackupSchedule(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_BackupSchedule_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_BackupSchedule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.BackupSchedule.class, + com.google.spanner.admin.database.v1.BackupSchedule.Builder.class); + } + + private int bitField0_; + private int backupTypeSpecCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object backupTypeSpec_; + + public enum BackupTypeSpecCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + FULL_BACKUP_SPEC(7), + INCREMENTAL_BACKUP_SPEC(8), + BACKUPTYPESPEC_NOT_SET(0); + private final int value; + + private BackupTypeSpecCase(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 BackupTypeSpecCase valueOf(int value) { + return forNumber(value); + } + + public static BackupTypeSpecCase forNumber(int value) { + switch (value) { + case 7: + return FULL_BACKUP_SPEC; + case 8: + return INCREMENTAL_BACKUP_SPEC; + case 0: + return BACKUPTYPESPEC_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public BackupTypeSpecCase getBackupTypeSpecCase() { + return BackupTypeSpecCase.forNumber(backupTypeSpecCase_); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Identifier. Output only for the
+   * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
+   * Required for the
+   * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
+   * operation. A globally unique identifier for the backup schedule which
+   * cannot be changed. Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
+   * The final segment of the name must be between 2 and 60 characters in
+   * length.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Identifier. Output only for the
+   * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
+   * Required for the
+   * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
+   * operation. A globally unique identifier for the backup schedule which
+   * cannot be changed. Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
+   * The final segment of the name must be between 2 and 60 characters in
+   * length.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int SPEC_FIELD_NUMBER = 6; + private com.google.spanner.admin.database.v1.BackupScheduleSpec spec_; + /** + * + * + *
+   * Optional. The schedule specification based on which the backup creations
+   * are triggered.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the spec field is set. + */ + @java.lang.Override + public boolean hasSpec() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Optional. The schedule specification based on which the backup creations
+   * are triggered.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The spec. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupScheduleSpec getSpec() { + return spec_ == null + ? com.google.spanner.admin.database.v1.BackupScheduleSpec.getDefaultInstance() + : spec_; + } + /** + * + * + *
+   * Optional. The schedule specification based on which the backup creations
+   * are triggered.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupScheduleSpecOrBuilder getSpecOrBuilder() { + return spec_ == null + ? com.google.spanner.admin.database.v1.BackupScheduleSpec.getDefaultInstance() + : spec_; + } + + public static final int RETENTION_DURATION_FIELD_NUMBER = 3; + private com.google.protobuf.Duration retentionDuration_; + /** + * + * + *
+   * Optional. The retention duration of a backup that must be at least 6 hours
+   * and at most 366 days. The backup is eligible to be automatically deleted
+   * once the retention period has elapsed.
+   * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the retentionDuration field is set. + */ + @java.lang.Override + public boolean hasRetentionDuration() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+   * Optional. The retention duration of a backup that must be at least 6 hours
+   * and at most 366 days. The backup is eligible to be automatically deleted
+   * once the retention period has elapsed.
+   * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The retentionDuration. + */ + @java.lang.Override + public com.google.protobuf.Duration getRetentionDuration() { + return retentionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : retentionDuration_; + } + /** + * + * + *
+   * Optional. The retention duration of a backup that must be at least 6 hours
+   * and at most 366 days. The backup is eligible to be automatically deleted
+   * once the retention period has elapsed.
+   * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.protobuf.DurationOrBuilder getRetentionDurationOrBuilder() { + return retentionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : retentionDuration_; + } + + public static final int ENCRYPTION_CONFIG_FIELD_NUMBER = 4; + private com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryptionConfig_; + /** + * + * + *
+   * Optional. The encryption configuration that will be used to encrypt the
+   * backup. If this field is not specified, the backup will use the same
+   * encryption configuration as the database.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + @java.lang.Override + public boolean hasEncryptionConfig() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+   * Optional. The encryption configuration that will be used to encrypt the
+   * backup. If this field is not specified, the backup will use the same
+   * encryption configuration as the database.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig getEncryptionConfig() { + return encryptionConfig_ == null + ? com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + /** + * + * + *
+   * Optional. The encryption configuration that will be used to encrypt the
+   * backup. If this field is not specified, the backup will use the same
+   * encryption configuration as the database.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.CreateBackupEncryptionConfigOrBuilder + getEncryptionConfigOrBuilder() { + return encryptionConfig_ == null + ? com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + + public static final int FULL_BACKUP_SPEC_FIELD_NUMBER = 7; + /** + * + * + *
+   * The schedule creates only full backups.
+   * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + * + * @return Whether the fullBackupSpec field is set. + */ + @java.lang.Override + public boolean hasFullBackupSpec() { + return backupTypeSpecCase_ == 7; + } + /** + * + * + *
+   * The schedule creates only full backups.
+   * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + * + * @return The fullBackupSpec. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.FullBackupSpec getFullBackupSpec() { + if (backupTypeSpecCase_ == 7) { + return (com.google.spanner.admin.database.v1.FullBackupSpec) backupTypeSpec_; + } + return com.google.spanner.admin.database.v1.FullBackupSpec.getDefaultInstance(); + } + /** + * + * + *
+   * The schedule creates only full backups.
+   * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.FullBackupSpecOrBuilder getFullBackupSpecOrBuilder() { + if (backupTypeSpecCase_ == 7) { + return (com.google.spanner.admin.database.v1.FullBackupSpec) backupTypeSpec_; + } + return com.google.spanner.admin.database.v1.FullBackupSpec.getDefaultInstance(); + } + + public static final int INCREMENTAL_BACKUP_SPEC_FIELD_NUMBER = 8; + /** + * + * + *
+   * The schedule creates incremental backup chains.
+   * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + * + * @return Whether the incrementalBackupSpec field is set. + */ + @java.lang.Override + public boolean hasIncrementalBackupSpec() { + return backupTypeSpecCase_ == 8; + } + /** + * + * + *
+   * The schedule creates incremental backup chains.
+   * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + * + * @return The incrementalBackupSpec. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.IncrementalBackupSpec getIncrementalBackupSpec() { + if (backupTypeSpecCase_ == 8) { + return (com.google.spanner.admin.database.v1.IncrementalBackupSpec) backupTypeSpec_; + } + return com.google.spanner.admin.database.v1.IncrementalBackupSpec.getDefaultInstance(); + } + /** + * + * + *
+   * The schedule creates incremental backup chains.
+   * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.IncrementalBackupSpecOrBuilder + getIncrementalBackupSpecOrBuilder() { + if (backupTypeSpecCase_ == 8) { + return (com.google.spanner.admin.database.v1.IncrementalBackupSpec) backupTypeSpec_; + } + return com.google.spanner.admin.database.v1.IncrementalBackupSpec.getDefaultInstance(); + } + + public static final int UPDATE_TIME_FIELD_NUMBER = 9; + private com.google.protobuf.Timestamp updateTime_; + /** + * + * + *
+   * Output only. The timestamp at which the schedule was last updated.
+   * If the schedule has never been updated, this field contains the timestamp
+   * when the schedule was first created.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + @java.lang.Override + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000008) != 0); + } + /** + * + * + *
+   * Output only. The timestamp at which the schedule was last updated.
+   * If the schedule has never been updated, this field contains the timestamp
+   * when the schedule was first created.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + @java.lang.Override + public com.google.protobuf.Timestamp getUpdateTime() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + /** + * + * + *
+   * Output only. The timestamp at which the schedule was last updated.
+   * If the schedule has never been updated, this field contains the timestamp
+   * when the schedule was first created.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + return updateTime_ == null ? com.google.protobuf.Timestamp.getDefaultInstance() : updateTime_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(name_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, name_); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(3, getRetentionDuration()); + } + if (((bitField0_ & 0x00000004) != 0)) { + output.writeMessage(4, getEncryptionConfig()); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(6, getSpec()); + } + if (backupTypeSpecCase_ == 7) { + output.writeMessage(7, (com.google.spanner.admin.database.v1.FullBackupSpec) backupTypeSpec_); + } + if (backupTypeSpecCase_ == 8) { + output.writeMessage( + 8, (com.google.spanner.admin.database.v1.IncrementalBackupSpec) backupTypeSpec_); + } + if (((bitField0_ & 0x00000008) != 0)) { + output.writeMessage(9, getUpdateTime()); + } + 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 (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getRetentionDuration()); + } + if (((bitField0_ & 0x00000004) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getEncryptionConfig()); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(6, getSpec()); + } + if (backupTypeSpecCase_ == 7) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 7, (com.google.spanner.admin.database.v1.FullBackupSpec) backupTypeSpec_); + } + if (backupTypeSpecCase_ == 8) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 8, (com.google.spanner.admin.database.v1.IncrementalBackupSpec) backupTypeSpec_); + } + if (((bitField0_ & 0x00000008) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(9, getUpdateTime()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.spanner.admin.database.v1.BackupSchedule)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.BackupSchedule other = + (com.google.spanner.admin.database.v1.BackupSchedule) obj; + + if (!getName().equals(other.getName())) return false; + if (hasSpec() != other.hasSpec()) return false; + if (hasSpec()) { + if (!getSpec().equals(other.getSpec())) return false; + } + if (hasRetentionDuration() != other.hasRetentionDuration()) return false; + if (hasRetentionDuration()) { + if (!getRetentionDuration().equals(other.getRetentionDuration())) return false; + } + if (hasEncryptionConfig() != other.hasEncryptionConfig()) return false; + if (hasEncryptionConfig()) { + if (!getEncryptionConfig().equals(other.getEncryptionConfig())) return false; + } + if (hasUpdateTime() != other.hasUpdateTime()) return false; + if (hasUpdateTime()) { + if (!getUpdateTime().equals(other.getUpdateTime())) return false; + } + if (!getBackupTypeSpecCase().equals(other.getBackupTypeSpecCase())) return false; + switch (backupTypeSpecCase_) { + case 7: + if (!getFullBackupSpec().equals(other.getFullBackupSpec())) return false; + break; + case 8: + if (!getIncrementalBackupSpec().equals(other.getIncrementalBackupSpec())) return false; + break; + case 0: + default: + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + if (hasSpec()) { + hash = (37 * hash) + SPEC_FIELD_NUMBER; + hash = (53 * hash) + getSpec().hashCode(); + } + if (hasRetentionDuration()) { + hash = (37 * hash) + RETENTION_DURATION_FIELD_NUMBER; + hash = (53 * hash) + getRetentionDuration().hashCode(); + } + if (hasEncryptionConfig()) { + hash = (37 * hash) + ENCRYPTION_CONFIG_FIELD_NUMBER; + hash = (53 * hash) + getEncryptionConfig().hashCode(); + } + if (hasUpdateTime()) { + hash = (37 * hash) + UPDATE_TIME_FIELD_NUMBER; + hash = (53 * hash) + getUpdateTime().hashCode(); + } + switch (backupTypeSpecCase_) { + case 7: + hash = (37 * hash) + FULL_BACKUP_SPEC_FIELD_NUMBER; + hash = (53 * hash) + getFullBackupSpec().hashCode(); + break; + case 8: + hash = (37 * hash) + INCREMENTAL_BACKUP_SPEC_FIELD_NUMBER; + hash = (53 * hash) + getIncrementalBackupSpec().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.spanner.admin.database.v1.BackupSchedule parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.BackupSchedule parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.BackupSchedule parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.BackupSchedule parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.BackupSchedule parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.BackupSchedule parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.BackupSchedule parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.BackupSchedule 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.spanner.admin.database.v1.BackupSchedule parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.BackupSchedule 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.spanner.admin.database.v1.BackupSchedule parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.BackupSchedule 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.spanner.admin.database.v1.BackupSchedule prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * BackupSchedule expresses the automated backup creation specification for a
+   * Spanner database.
+   * Next ID: 10
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.BackupSchedule} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.BackupSchedule) + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_BackupSchedule_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_BackupSchedule_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.BackupSchedule.class, + com.google.spanner.admin.database.v1.BackupSchedule.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.BackupSchedule.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getSpecFieldBuilder(); + getRetentionDurationFieldBuilder(); + getEncryptionConfigFieldBuilder(); + getUpdateTimeFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + name_ = ""; + spec_ = null; + if (specBuilder_ != null) { + specBuilder_.dispose(); + specBuilder_ = null; + } + retentionDuration_ = null; + if (retentionDurationBuilder_ != null) { + retentionDurationBuilder_.dispose(); + retentionDurationBuilder_ = null; + } + encryptionConfig_ = null; + if (encryptionConfigBuilder_ != null) { + encryptionConfigBuilder_.dispose(); + encryptionConfigBuilder_ = null; + } + if (fullBackupSpecBuilder_ != null) { + fullBackupSpecBuilder_.clear(); + } + if (incrementalBackupSpecBuilder_ != null) { + incrementalBackupSpecBuilder_.clear(); + } + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + backupTypeSpecCase_ = 0; + backupTypeSpec_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_BackupSchedule_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupSchedule getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupSchedule build() { + com.google.spanner.admin.database.v1.BackupSchedule result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupSchedule buildPartial() { + com.google.spanner.admin.database.v1.BackupSchedule result = + new com.google.spanner.admin.database.v1.BackupSchedule(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.spanner.admin.database.v1.BackupSchedule result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.name_ = name_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000002) != 0)) { + result.spec_ = specBuilder_ == null ? spec_ : specBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.retentionDuration_ = + retentionDurationBuilder_ == null + ? retentionDuration_ + : retentionDurationBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + if (((from_bitField0_ & 0x00000008) != 0)) { + result.encryptionConfig_ = + encryptionConfigBuilder_ == null ? encryptionConfig_ : encryptionConfigBuilder_.build(); + to_bitField0_ |= 0x00000004; + } + if (((from_bitField0_ & 0x00000040) != 0)) { + result.updateTime_ = updateTimeBuilder_ == null ? updateTime_ : updateTimeBuilder_.build(); + to_bitField0_ |= 0x00000008; + } + result.bitField0_ |= to_bitField0_; + } + + private void buildPartialOneofs(com.google.spanner.admin.database.v1.BackupSchedule result) { + result.backupTypeSpecCase_ = backupTypeSpecCase_; + result.backupTypeSpec_ = this.backupTypeSpec_; + if (backupTypeSpecCase_ == 7 && fullBackupSpecBuilder_ != null) { + result.backupTypeSpec_ = fullBackupSpecBuilder_.build(); + } + if (backupTypeSpecCase_ == 8 && incrementalBackupSpecBuilder_ != null) { + result.backupTypeSpec_ = incrementalBackupSpecBuilder_.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.spanner.admin.database.v1.BackupSchedule) { + return mergeFrom((com.google.spanner.admin.database.v1.BackupSchedule) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.spanner.admin.database.v1.BackupSchedule other) { + if (other == com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.hasSpec()) { + mergeSpec(other.getSpec()); + } + if (other.hasRetentionDuration()) { + mergeRetentionDuration(other.getRetentionDuration()); + } + if (other.hasEncryptionConfig()) { + mergeEncryptionConfig(other.getEncryptionConfig()); + } + if (other.hasUpdateTime()) { + mergeUpdateTime(other.getUpdateTime()); + } + switch (other.getBackupTypeSpecCase()) { + case FULL_BACKUP_SPEC: + { + mergeFullBackupSpec(other.getFullBackupSpec()); + break; + } + case INCREMENTAL_BACKUP_SPEC: + { + mergeIncrementalBackupSpec(other.getIncrementalBackupSpec()); + break; + } + case BACKUPTYPESPEC_NOT_SET: + { + break; + } + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 26: + { + input.readMessage( + getRetentionDurationFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + case 34: + { + input.readMessage( + getEncryptionConfigFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000008; + break; + } // case 34 + case 50: + { + input.readMessage(getSpecFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000002; + break; + } // case 50 + case 58: + { + input.readMessage(getFullBackupSpecFieldBuilder().getBuilder(), extensionRegistry); + backupTypeSpecCase_ = 7; + break; + } // case 58 + case 66: + { + input.readMessage( + getIncrementalBackupSpecFieldBuilder().getBuilder(), extensionRegistry); + backupTypeSpecCase_ = 8; + break; + } // case 66 + case 74: + { + input.readMessage(getUpdateTimeFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000040; + 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 backupTypeSpecCase_ = 0; + private java.lang.Object backupTypeSpec_; + + public BackupTypeSpecCase getBackupTypeSpecCase() { + return BackupTypeSpecCase.forNumber(backupTypeSpecCase_); + } + + public Builder clearBackupTypeSpec() { + backupTypeSpecCase_ = 0; + backupTypeSpec_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Identifier. Output only for the
+     * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
+     * Required for the
+     * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
+     * operation. A globally unique identifier for the backup schedule which
+     * cannot be changed. Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
+     * The final segment of the name must be between 2 and 60 characters in
+     * length.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Identifier. Output only for the
+     * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
+     * Required for the
+     * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
+     * operation. A globally unique identifier for the backup schedule which
+     * cannot be changed. Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
+     * The final segment of the name must be between 2 and 60 characters in
+     * length.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Identifier. Output only for the
+     * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
+     * Required for the
+     * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
+     * operation. A globally unique identifier for the backup schedule which
+     * cannot be changed. Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
+     * The final segment of the name must be between 2 and 60 characters in
+     * length.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Identifier. Output only for the
+     * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
+     * Required for the
+     * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
+     * operation. A globally unique identifier for the backup schedule which
+     * cannot be changed. Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
+     * The final segment of the name must be between 2 and 60 characters in
+     * length.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Identifier. Output only for the
+     * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
+     * Required for the
+     * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
+     * operation. A globally unique identifier for the backup schedule which
+     * cannot be changed. Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
+     * The final segment of the name must be between 2 and 60 characters in
+     * length.
+     * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private com.google.spanner.admin.database.v1.BackupScheduleSpec spec_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupScheduleSpec, + com.google.spanner.admin.database.v1.BackupScheduleSpec.Builder, + com.google.spanner.admin.database.v1.BackupScheduleSpecOrBuilder> + specBuilder_; + /** + * + * + *
+     * Optional. The schedule specification based on which the backup creations
+     * are triggered.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the spec field is set. + */ + public boolean hasSpec() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Optional. The schedule specification based on which the backup creations
+     * are triggered.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The spec. + */ + public com.google.spanner.admin.database.v1.BackupScheduleSpec getSpec() { + if (specBuilder_ == null) { + return spec_ == null + ? com.google.spanner.admin.database.v1.BackupScheduleSpec.getDefaultInstance() + : spec_; + } else { + return specBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Optional. The schedule specification based on which the backup creations
+     * are triggered.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setSpec(com.google.spanner.admin.database.v1.BackupScheduleSpec value) { + if (specBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + spec_ = value; + } else { + specBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The schedule specification based on which the backup creations
+     * are triggered.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setSpec( + com.google.spanner.admin.database.v1.BackupScheduleSpec.Builder builderForValue) { + if (specBuilder_ == null) { + spec_ = builderForValue.build(); + } else { + specBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The schedule specification based on which the backup creations
+     * are triggered.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeSpec(com.google.spanner.admin.database.v1.BackupScheduleSpec value) { + if (specBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && spec_ != null + && spec_ + != com.google.spanner.admin.database.v1.BackupScheduleSpec.getDefaultInstance()) { + getSpecBuilder().mergeFrom(value); + } else { + spec_ = value; + } + } else { + specBuilder_.mergeFrom(value); + } + if (spec_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Optional. The schedule specification based on which the backup creations
+     * are triggered.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearSpec() { + bitField0_ = (bitField0_ & ~0x00000002); + spec_ = null; + if (specBuilder_ != null) { + specBuilder_.dispose(); + specBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The schedule specification based on which the backup creations
+     * are triggered.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.spanner.admin.database.v1.BackupScheduleSpec.Builder getSpecBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getSpecFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Optional. The schedule specification based on which the backup creations
+     * are triggered.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.spanner.admin.database.v1.BackupScheduleSpecOrBuilder getSpecOrBuilder() { + if (specBuilder_ != null) { + return specBuilder_.getMessageOrBuilder(); + } else { + return spec_ == null + ? com.google.spanner.admin.database.v1.BackupScheduleSpec.getDefaultInstance() + : spec_; + } + } + /** + * + * + *
+     * Optional. The schedule specification based on which the backup creations
+     * are triggered.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupScheduleSpec, + com.google.spanner.admin.database.v1.BackupScheduleSpec.Builder, + com.google.spanner.admin.database.v1.BackupScheduleSpecOrBuilder> + getSpecFieldBuilder() { + if (specBuilder_ == null) { + specBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupScheduleSpec, + com.google.spanner.admin.database.v1.BackupScheduleSpec.Builder, + com.google.spanner.admin.database.v1.BackupScheduleSpecOrBuilder>( + getSpec(), getParentForChildren(), isClean()); + spec_ = null; + } + return specBuilder_; + } + + private com.google.protobuf.Duration retentionDuration_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + retentionDurationBuilder_; + /** + * + * + *
+     * Optional. The retention duration of a backup that must be at least 6 hours
+     * and at most 366 days. The backup is eligible to be automatically deleted
+     * once the retention period has elapsed.
+     * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the retentionDuration field is set. + */ + public boolean hasRetentionDuration() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+     * Optional. The retention duration of a backup that must be at least 6 hours
+     * and at most 366 days. The backup is eligible to be automatically deleted
+     * once the retention period has elapsed.
+     * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The retentionDuration. + */ + public com.google.protobuf.Duration getRetentionDuration() { + if (retentionDurationBuilder_ == null) { + return retentionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : retentionDuration_; + } else { + return retentionDurationBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Optional. The retention duration of a backup that must be at least 6 hours
+     * and at most 366 days. The backup is eligible to be automatically deleted
+     * once the retention period has elapsed.
+     * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setRetentionDuration(com.google.protobuf.Duration value) { + if (retentionDurationBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + retentionDuration_ = value; + } else { + retentionDurationBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The retention duration of a backup that must be at least 6 hours
+     * and at most 366 days. The backup is eligible to be automatically deleted
+     * once the retention period has elapsed.
+     * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setRetentionDuration(com.google.protobuf.Duration.Builder builderForValue) { + if (retentionDurationBuilder_ == null) { + retentionDuration_ = builderForValue.build(); + } else { + retentionDurationBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The retention duration of a backup that must be at least 6 hours
+     * and at most 366 days. The backup is eligible to be automatically deleted
+     * once the retention period has elapsed.
+     * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeRetentionDuration(com.google.protobuf.Duration value) { + if (retentionDurationBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && retentionDuration_ != null + && retentionDuration_ != com.google.protobuf.Duration.getDefaultInstance()) { + getRetentionDurationBuilder().mergeFrom(value); + } else { + retentionDuration_ = value; + } + } else { + retentionDurationBuilder_.mergeFrom(value); + } + if (retentionDuration_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Optional. The retention duration of a backup that must be at least 6 hours
+     * and at most 366 days. The backup is eligible to be automatically deleted
+     * once the retention period has elapsed.
+     * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearRetentionDuration() { + bitField0_ = (bitField0_ & ~0x00000004); + retentionDuration_ = null; + if (retentionDurationBuilder_ != null) { + retentionDurationBuilder_.dispose(); + retentionDurationBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The retention duration of a backup that must be at least 6 hours
+     * and at most 366 days. The backup is eligible to be automatically deleted
+     * once the retention period has elapsed.
+     * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.protobuf.Duration.Builder getRetentionDurationBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getRetentionDurationFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Optional. The retention duration of a backup that must be at least 6 hours
+     * and at most 366 days. The backup is eligible to be automatically deleted
+     * once the retention period has elapsed.
+     * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.protobuf.DurationOrBuilder getRetentionDurationOrBuilder() { + if (retentionDurationBuilder_ != null) { + return retentionDurationBuilder_.getMessageOrBuilder(); + } else { + return retentionDuration_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : retentionDuration_; + } + } + /** + * + * + *
+     * Optional. The retention duration of a backup that must be at least 6 hours
+     * and at most 366 days. The backup is eligible to be automatically deleted
+     * once the retention period has elapsed.
+     * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + getRetentionDurationFieldBuilder() { + if (retentionDurationBuilder_ == null) { + retentionDurationBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder>( + getRetentionDuration(), getParentForChildren(), isClean()); + retentionDuration_ = null; + } + return retentionDurationBuilder_; + } + + private com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryptionConfig_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig, + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig.Builder, + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfigOrBuilder> + encryptionConfigBuilder_; + /** + * + * + *
+     * Optional. The encryption configuration that will be used to encrypt the
+     * backup. If this field is not specified, the backup will use the same
+     * encryption configuration as the database.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + public boolean hasEncryptionConfig() { + return ((bitField0_ & 0x00000008) != 0); + } + /** + * + * + *
+     * Optional. The encryption configuration that will be used to encrypt the
+     * backup. If this field is not specified, the backup will use the same
+     * encryption configuration as the database.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + public com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig getEncryptionConfig() { + if (encryptionConfigBuilder_ == null) { + return encryptionConfig_ == null + ? com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } else { + return encryptionConfigBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Optional. The encryption configuration that will be used to encrypt the
+     * backup. If this field is not specified, the backup will use the same
+     * encryption configuration as the database.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setEncryptionConfig( + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig value) { + if (encryptionConfigBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + encryptionConfig_ = value; + } else { + encryptionConfigBuilder_.setMessage(value); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The encryption configuration that will be used to encrypt the
+     * backup. If this field is not specified, the backup will use the same
+     * encryption configuration as the database.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder setEncryptionConfig( + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig.Builder builderForValue) { + if (encryptionConfigBuilder_ == null) { + encryptionConfig_ = builderForValue.build(); + } else { + encryptionConfigBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000008; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The encryption configuration that will be used to encrypt the
+     * backup. If this field is not specified, the backup will use the same
+     * encryption configuration as the database.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder mergeEncryptionConfig( + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig value) { + if (encryptionConfigBuilder_ == null) { + if (((bitField0_ & 0x00000008) != 0) + && encryptionConfig_ != null + && encryptionConfig_ + != com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig + .getDefaultInstance()) { + getEncryptionConfigBuilder().mergeFrom(value); + } else { + encryptionConfig_ = value; + } + } else { + encryptionConfigBuilder_.mergeFrom(value); + } + if (encryptionConfig_ != null) { + bitField0_ |= 0x00000008; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Optional. The encryption configuration that will be used to encrypt the
+     * backup. If this field is not specified, the backup will use the same
+     * encryption configuration as the database.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public Builder clearEncryptionConfig() { + bitField0_ = (bitField0_ & ~0x00000008); + encryptionConfig_ = null; + if (encryptionConfigBuilder_ != null) { + encryptionConfigBuilder_.dispose(); + encryptionConfigBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. The encryption configuration that will be used to encrypt the
+     * backup. If this field is not specified, the backup will use the same
+     * encryption configuration as the database.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig.Builder + getEncryptionConfigBuilder() { + bitField0_ |= 0x00000008; + onChanged(); + return getEncryptionConfigFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Optional. The encryption configuration that will be used to encrypt the
+     * backup. If this field is not specified, the backup will use the same
+     * encryption configuration as the database.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + public com.google.spanner.admin.database.v1.CreateBackupEncryptionConfigOrBuilder + getEncryptionConfigOrBuilder() { + if (encryptionConfigBuilder_ != null) { + return encryptionConfigBuilder_.getMessageOrBuilder(); + } else { + return encryptionConfig_ == null + ? com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig.getDefaultInstance() + : encryptionConfig_; + } + } + /** + * + * + *
+     * Optional. The encryption configuration that will be used to encrypt the
+     * backup. If this field is not specified, the backup will use the same
+     * encryption configuration as the database.
+     * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig, + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig.Builder, + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfigOrBuilder> + getEncryptionConfigFieldBuilder() { + if (encryptionConfigBuilder_ == null) { + encryptionConfigBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig, + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig.Builder, + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfigOrBuilder>( + getEncryptionConfig(), getParentForChildren(), isClean()); + encryptionConfig_ = null; + } + return encryptionConfigBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.FullBackupSpec, + com.google.spanner.admin.database.v1.FullBackupSpec.Builder, + com.google.spanner.admin.database.v1.FullBackupSpecOrBuilder> + fullBackupSpecBuilder_; + /** + * + * + *
+     * The schedule creates only full backups.
+     * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + * + * @return Whether the fullBackupSpec field is set. + */ + @java.lang.Override + public boolean hasFullBackupSpec() { + return backupTypeSpecCase_ == 7; + } + /** + * + * + *
+     * The schedule creates only full backups.
+     * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + * + * @return The fullBackupSpec. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.FullBackupSpec getFullBackupSpec() { + if (fullBackupSpecBuilder_ == null) { + if (backupTypeSpecCase_ == 7) { + return (com.google.spanner.admin.database.v1.FullBackupSpec) backupTypeSpec_; + } + return com.google.spanner.admin.database.v1.FullBackupSpec.getDefaultInstance(); + } else { + if (backupTypeSpecCase_ == 7) { + return fullBackupSpecBuilder_.getMessage(); + } + return com.google.spanner.admin.database.v1.FullBackupSpec.getDefaultInstance(); + } + } + /** + * + * + *
+     * The schedule creates only full backups.
+     * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + */ + public Builder setFullBackupSpec(com.google.spanner.admin.database.v1.FullBackupSpec value) { + if (fullBackupSpecBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + backupTypeSpec_ = value; + onChanged(); + } else { + fullBackupSpecBuilder_.setMessage(value); + } + backupTypeSpecCase_ = 7; + return this; + } + /** + * + * + *
+     * The schedule creates only full backups.
+     * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + */ + public Builder setFullBackupSpec( + com.google.spanner.admin.database.v1.FullBackupSpec.Builder builderForValue) { + if (fullBackupSpecBuilder_ == null) { + backupTypeSpec_ = builderForValue.build(); + onChanged(); + } else { + fullBackupSpecBuilder_.setMessage(builderForValue.build()); + } + backupTypeSpecCase_ = 7; + return this; + } + /** + * + * + *
+     * The schedule creates only full backups.
+     * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + */ + public Builder mergeFullBackupSpec(com.google.spanner.admin.database.v1.FullBackupSpec value) { + if (fullBackupSpecBuilder_ == null) { + if (backupTypeSpecCase_ == 7 + && backupTypeSpec_ + != com.google.spanner.admin.database.v1.FullBackupSpec.getDefaultInstance()) { + backupTypeSpec_ = + com.google.spanner.admin.database.v1.FullBackupSpec.newBuilder( + (com.google.spanner.admin.database.v1.FullBackupSpec) backupTypeSpec_) + .mergeFrom(value) + .buildPartial(); + } else { + backupTypeSpec_ = value; + } + onChanged(); + } else { + if (backupTypeSpecCase_ == 7) { + fullBackupSpecBuilder_.mergeFrom(value); + } else { + fullBackupSpecBuilder_.setMessage(value); + } + } + backupTypeSpecCase_ = 7; + return this; + } + /** + * + * + *
+     * The schedule creates only full backups.
+     * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + */ + public Builder clearFullBackupSpec() { + if (fullBackupSpecBuilder_ == null) { + if (backupTypeSpecCase_ == 7) { + backupTypeSpecCase_ = 0; + backupTypeSpec_ = null; + onChanged(); + } + } else { + if (backupTypeSpecCase_ == 7) { + backupTypeSpecCase_ = 0; + backupTypeSpec_ = null; + } + fullBackupSpecBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * The schedule creates only full backups.
+     * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + */ + public com.google.spanner.admin.database.v1.FullBackupSpec.Builder getFullBackupSpecBuilder() { + return getFullBackupSpecFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The schedule creates only full backups.
+     * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.FullBackupSpecOrBuilder + getFullBackupSpecOrBuilder() { + if ((backupTypeSpecCase_ == 7) && (fullBackupSpecBuilder_ != null)) { + return fullBackupSpecBuilder_.getMessageOrBuilder(); + } else { + if (backupTypeSpecCase_ == 7) { + return (com.google.spanner.admin.database.v1.FullBackupSpec) backupTypeSpec_; + } + return com.google.spanner.admin.database.v1.FullBackupSpec.getDefaultInstance(); + } + } + /** + * + * + *
+     * The schedule creates only full backups.
+     * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.FullBackupSpec, + com.google.spanner.admin.database.v1.FullBackupSpec.Builder, + com.google.spanner.admin.database.v1.FullBackupSpecOrBuilder> + getFullBackupSpecFieldBuilder() { + if (fullBackupSpecBuilder_ == null) { + if (!(backupTypeSpecCase_ == 7)) { + backupTypeSpec_ = + com.google.spanner.admin.database.v1.FullBackupSpec.getDefaultInstance(); + } + fullBackupSpecBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.FullBackupSpec, + com.google.spanner.admin.database.v1.FullBackupSpec.Builder, + com.google.spanner.admin.database.v1.FullBackupSpecOrBuilder>( + (com.google.spanner.admin.database.v1.FullBackupSpec) backupTypeSpec_, + getParentForChildren(), + isClean()); + backupTypeSpec_ = null; + } + backupTypeSpecCase_ = 7; + onChanged(); + return fullBackupSpecBuilder_; + } + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.IncrementalBackupSpec, + com.google.spanner.admin.database.v1.IncrementalBackupSpec.Builder, + com.google.spanner.admin.database.v1.IncrementalBackupSpecOrBuilder> + incrementalBackupSpecBuilder_; + /** + * + * + *
+     * The schedule creates incremental backup chains.
+     * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + * + * @return Whether the incrementalBackupSpec field is set. + */ + @java.lang.Override + public boolean hasIncrementalBackupSpec() { + return backupTypeSpecCase_ == 8; + } + /** + * + * + *
+     * The schedule creates incremental backup chains.
+     * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + * + * @return The incrementalBackupSpec. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.IncrementalBackupSpec getIncrementalBackupSpec() { + if (incrementalBackupSpecBuilder_ == null) { + if (backupTypeSpecCase_ == 8) { + return (com.google.spanner.admin.database.v1.IncrementalBackupSpec) backupTypeSpec_; + } + return com.google.spanner.admin.database.v1.IncrementalBackupSpec.getDefaultInstance(); + } else { + if (backupTypeSpecCase_ == 8) { + return incrementalBackupSpecBuilder_.getMessage(); + } + return com.google.spanner.admin.database.v1.IncrementalBackupSpec.getDefaultInstance(); + } + } + /** + * + * + *
+     * The schedule creates incremental backup chains.
+     * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + */ + public Builder setIncrementalBackupSpec( + com.google.spanner.admin.database.v1.IncrementalBackupSpec value) { + if (incrementalBackupSpecBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + backupTypeSpec_ = value; + onChanged(); + } else { + incrementalBackupSpecBuilder_.setMessage(value); + } + backupTypeSpecCase_ = 8; + return this; + } + /** + * + * + *
+     * The schedule creates incremental backup chains.
+     * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + */ + public Builder setIncrementalBackupSpec( + com.google.spanner.admin.database.v1.IncrementalBackupSpec.Builder builderForValue) { + if (incrementalBackupSpecBuilder_ == null) { + backupTypeSpec_ = builderForValue.build(); + onChanged(); + } else { + incrementalBackupSpecBuilder_.setMessage(builderForValue.build()); + } + backupTypeSpecCase_ = 8; + return this; + } + /** + * + * + *
+     * The schedule creates incremental backup chains.
+     * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + */ + public Builder mergeIncrementalBackupSpec( + com.google.spanner.admin.database.v1.IncrementalBackupSpec value) { + if (incrementalBackupSpecBuilder_ == null) { + if (backupTypeSpecCase_ == 8 + && backupTypeSpec_ + != com.google.spanner.admin.database.v1.IncrementalBackupSpec + .getDefaultInstance()) { + backupTypeSpec_ = + com.google.spanner.admin.database.v1.IncrementalBackupSpec.newBuilder( + (com.google.spanner.admin.database.v1.IncrementalBackupSpec) backupTypeSpec_) + .mergeFrom(value) + .buildPartial(); + } else { + backupTypeSpec_ = value; + } + onChanged(); + } else { + if (backupTypeSpecCase_ == 8) { + incrementalBackupSpecBuilder_.mergeFrom(value); + } else { + incrementalBackupSpecBuilder_.setMessage(value); + } + } + backupTypeSpecCase_ = 8; + return this; + } + /** + * + * + *
+     * The schedule creates incremental backup chains.
+     * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + */ + public Builder clearIncrementalBackupSpec() { + if (incrementalBackupSpecBuilder_ == null) { + if (backupTypeSpecCase_ == 8) { + backupTypeSpecCase_ = 0; + backupTypeSpec_ = null; + onChanged(); + } + } else { + if (backupTypeSpecCase_ == 8) { + backupTypeSpecCase_ = 0; + backupTypeSpec_ = null; + } + incrementalBackupSpecBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * The schedule creates incremental backup chains.
+     * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + */ + public com.google.spanner.admin.database.v1.IncrementalBackupSpec.Builder + getIncrementalBackupSpecBuilder() { + return getIncrementalBackupSpecFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * The schedule creates incremental backup chains.
+     * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.IncrementalBackupSpecOrBuilder + getIncrementalBackupSpecOrBuilder() { + if ((backupTypeSpecCase_ == 8) && (incrementalBackupSpecBuilder_ != null)) { + return incrementalBackupSpecBuilder_.getMessageOrBuilder(); + } else { + if (backupTypeSpecCase_ == 8) { + return (com.google.spanner.admin.database.v1.IncrementalBackupSpec) backupTypeSpec_; + } + return com.google.spanner.admin.database.v1.IncrementalBackupSpec.getDefaultInstance(); + } + } + /** + * + * + *
+     * The schedule creates incremental backup chains.
+     * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.IncrementalBackupSpec, + com.google.spanner.admin.database.v1.IncrementalBackupSpec.Builder, + com.google.spanner.admin.database.v1.IncrementalBackupSpecOrBuilder> + getIncrementalBackupSpecFieldBuilder() { + if (incrementalBackupSpecBuilder_ == null) { + if (!(backupTypeSpecCase_ == 8)) { + backupTypeSpec_ = + com.google.spanner.admin.database.v1.IncrementalBackupSpec.getDefaultInstance(); + } + incrementalBackupSpecBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.IncrementalBackupSpec, + com.google.spanner.admin.database.v1.IncrementalBackupSpec.Builder, + com.google.spanner.admin.database.v1.IncrementalBackupSpecOrBuilder>( + (com.google.spanner.admin.database.v1.IncrementalBackupSpec) backupTypeSpec_, + getParentForChildren(), + isClean()); + backupTypeSpec_ = null; + } + backupTypeSpecCase_ = 8; + onChanged(); + return incrementalBackupSpecBuilder_; + } + + 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_; + /** + * + * + *
+     * Output only. The timestamp at which the schedule was last updated.
+     * If the schedule has never been updated, this field contains the timestamp
+     * when the schedule was first created.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + public boolean hasUpdateTime() { + return ((bitField0_ & 0x00000040) != 0); + } + /** + * + * + *
+     * Output only. The timestamp at which the schedule was last updated.
+     * If the schedule has never been updated, this field contains the timestamp
+     * when the schedule was first created.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + public com.google.protobuf.Timestamp getUpdateTime() { + if (updateTimeBuilder_ == null) { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } else { + return updateTimeBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. The timestamp at which the schedule was last updated.
+     * If the schedule has never been updated, this field contains the timestamp
+     * when the schedule was first created.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateTime_ = value; + } else { + updateTimeBuilder_.setMessage(value); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which the schedule was last updated.
+     * If the schedule has never been updated, this field contains the timestamp
+     * when the schedule was first created.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setUpdateTime(com.google.protobuf.Timestamp.Builder builderForValue) { + if (updateTimeBuilder_ == null) { + updateTime_ = builderForValue.build(); + } else { + updateTimeBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000040; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which the schedule was last updated.
+     * If the schedule has never been updated, this field contains the timestamp
+     * when the schedule was first created.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeUpdateTime(com.google.protobuf.Timestamp value) { + if (updateTimeBuilder_ == null) { + if (((bitField0_ & 0x00000040) != 0) + && updateTime_ != null + && updateTime_ != com.google.protobuf.Timestamp.getDefaultInstance()) { + getUpdateTimeBuilder().mergeFrom(value); + } else { + updateTime_ = value; + } + } else { + updateTimeBuilder_.mergeFrom(value); + } + if (updateTime_ != null) { + bitField0_ |= 0x00000040; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which the schedule was last updated.
+     * If the schedule has never been updated, this field contains the timestamp
+     * when the schedule was first created.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearUpdateTime() { + bitField0_ = (bitField0_ & ~0x00000040); + updateTime_ = null; + if (updateTimeBuilder_ != null) { + updateTimeBuilder_.dispose(); + updateTimeBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The timestamp at which the schedule was last updated.
+     * If the schedule has never been updated, this field contains the timestamp
+     * when the schedule was first created.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Timestamp.Builder getUpdateTimeBuilder() { + bitField0_ |= 0x00000040; + onChanged(); + return getUpdateTimeFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. The timestamp at which the schedule was last updated.
+     * If the schedule has never been updated, this field contains the timestamp
+     * when the schedule was first created.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder() { + if (updateTimeBuilder_ != null) { + return updateTimeBuilder_.getMessageOrBuilder(); + } else { + return updateTime_ == null + ? com.google.protobuf.Timestamp.getDefaultInstance() + : updateTime_; + } + } + /** + * + * + *
+     * Output only. The timestamp at which the schedule was last updated.
+     * If the schedule has never been updated, this field contains the timestamp
+     * when the schedule was first created.
+     * 
+ * + * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + 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_; + } + + @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.spanner.admin.database.v1.BackupSchedule) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.BackupSchedule) + private static final com.google.spanner.admin.database.v1.BackupSchedule DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.BackupSchedule(); + } + + public static com.google.spanner.admin.database.v1.BackupSchedule getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BackupSchedule parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupSchedule getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleName.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleName.java new file mode 100644 index 00000000000..4ab35282678 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleName.java @@ -0,0 +1,261 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.spanner.admin.database.v1; + +import com.google.api.pathtemplate.PathTemplate; +import com.google.api.resourcenames.ResourceName; +import com.google.common.base.Preconditions; +import com.google.common.collect.ImmutableMap; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +@Generated("by gapic-generator-java") +public class BackupScheduleName implements ResourceName { + private static final PathTemplate PROJECT_INSTANCE_DATABASE_SCHEDULE = + PathTemplate.createWithoutUrlEncoding( + "projects/{project}/instances/{instance}/databases/{database}/backupSchedules/{schedule}"); + private volatile Map fieldValuesMap; + private final String project; + private final String instance; + private final String database; + private final String schedule; + + @Deprecated + protected BackupScheduleName() { + project = null; + instance = null; + database = null; + schedule = null; + } + + private BackupScheduleName(Builder builder) { + project = Preconditions.checkNotNull(builder.getProject()); + instance = Preconditions.checkNotNull(builder.getInstance()); + database = Preconditions.checkNotNull(builder.getDatabase()); + schedule = Preconditions.checkNotNull(builder.getSchedule()); + } + + public String getProject() { + return project; + } + + public String getInstance() { + return instance; + } + + public String getDatabase() { + return database; + } + + public String getSchedule() { + return schedule; + } + + public static Builder newBuilder() { + return new Builder(); + } + + public Builder toBuilder() { + return new Builder(this); + } + + public static BackupScheduleName of( + String project, String instance, String database, String schedule) { + return newBuilder() + .setProject(project) + .setInstance(instance) + .setDatabase(database) + .setSchedule(schedule) + .build(); + } + + public static String format(String project, String instance, String database, String schedule) { + return newBuilder() + .setProject(project) + .setInstance(instance) + .setDatabase(database) + .setSchedule(schedule) + .build() + .toString(); + } + + public static BackupScheduleName parse(String formattedString) { + if (formattedString.isEmpty()) { + return null; + } + Map matchMap = + PROJECT_INSTANCE_DATABASE_SCHEDULE.validatedMatch( + formattedString, "BackupScheduleName.parse: formattedString not in valid format"); + return of( + matchMap.get("project"), + matchMap.get("instance"), + matchMap.get("database"), + matchMap.get("schedule")); + } + + public static List parseList(List formattedStrings) { + List list = new ArrayList<>(formattedStrings.size()); + for (String formattedString : formattedStrings) { + list.add(parse(formattedString)); + } + return list; + } + + public static List toStringList(List values) { + List list = new ArrayList<>(values.size()); + for (BackupScheduleName value : values) { + if (value == null) { + list.add(""); + } else { + list.add(value.toString()); + } + } + return list; + } + + public static boolean isParsableFrom(String formattedString) { + return PROJECT_INSTANCE_DATABASE_SCHEDULE.matches(formattedString); + } + + @Override + public Map getFieldValuesMap() { + if (fieldValuesMap == null) { + synchronized (this) { + if (fieldValuesMap == null) { + ImmutableMap.Builder fieldMapBuilder = ImmutableMap.builder(); + if (project != null) { + fieldMapBuilder.put("project", project); + } + if (instance != null) { + fieldMapBuilder.put("instance", instance); + } + if (database != null) { + fieldMapBuilder.put("database", database); + } + if (schedule != null) { + fieldMapBuilder.put("schedule", schedule); + } + fieldValuesMap = fieldMapBuilder.build(); + } + } + } + return fieldValuesMap; + } + + public String getFieldValue(String fieldName) { + return getFieldValuesMap().get(fieldName); + } + + @Override + public String toString() { + return PROJECT_INSTANCE_DATABASE_SCHEDULE.instantiate( + "project", project, "instance", instance, "database", database, "schedule", schedule); + } + + @Override + public boolean equals(Object o) { + if (o == this) { + return true; + } + if (o != null && getClass() == o.getClass()) { + BackupScheduleName that = ((BackupScheduleName) o); + return Objects.equals(this.project, that.project) + && Objects.equals(this.instance, that.instance) + && Objects.equals(this.database, that.database) + && Objects.equals(this.schedule, that.schedule); + } + return false; + } + + @Override + public int hashCode() { + int h = 1; + h *= 1000003; + h ^= Objects.hashCode(project); + h *= 1000003; + h ^= Objects.hashCode(instance); + h *= 1000003; + h ^= Objects.hashCode(database); + h *= 1000003; + h ^= Objects.hashCode(schedule); + return h; + } + + /** + * Builder for + * projects/{project}/instances/{instance}/databases/{database}/backupSchedules/{schedule}. + */ + public static class Builder { + private String project; + private String instance; + private String database; + private String schedule; + + protected Builder() {} + + public String getProject() { + return project; + } + + public String getInstance() { + return instance; + } + + public String getDatabase() { + return database; + } + + public String getSchedule() { + return schedule; + } + + public Builder setProject(String project) { + this.project = project; + return this; + } + + public Builder setInstance(String instance) { + this.instance = instance; + return this; + } + + public Builder setDatabase(String database) { + this.database = database; + return this; + } + + public Builder setSchedule(String schedule) { + this.schedule = schedule; + return this; + } + + private Builder(BackupScheduleName backupScheduleName) { + this.project = backupScheduleName.project; + this.instance = backupScheduleName.instance; + this.database = backupScheduleName.database; + this.schedule = backupScheduleName.schedule; + } + + public BackupScheduleName build() { + return new BackupScheduleName(this); + } + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleOrBuilder.java new file mode 100644 index 00000000000..128bc441f78 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleOrBuilder.java @@ -0,0 +1,326 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface BackupScheduleOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.BackupSchedule) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Identifier. Output only for the
+   * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
+   * Required for the
+   * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
+   * operation. A globally unique identifier for the backup schedule which
+   * cannot be changed. Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
+   * The final segment of the name must be between 2 and 60 characters in
+   * length.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Identifier. Output only for the
+   * [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation.
+   * Required for the
+   * [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]
+   * operation. A globally unique identifier for the backup schedule which
+   * cannot be changed. Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]`
+   * The final segment of the name must be between 2 and 60 characters in
+   * length.
+   * 
+ * + * string name = 1 [(.google.api.field_behavior) = IDENTIFIER]; + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); + + /** + * + * + *
+   * Optional. The schedule specification based on which the backup creations
+   * are triggered.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the spec field is set. + */ + boolean hasSpec(); + /** + * + * + *
+   * Optional. The schedule specification based on which the backup creations
+   * are triggered.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The spec. + */ + com.google.spanner.admin.database.v1.BackupScheduleSpec getSpec(); + /** + * + * + *
+   * Optional. The schedule specification based on which the backup creations
+   * are triggered.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupScheduleSpec spec = 6 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.spanner.admin.database.v1.BackupScheduleSpecOrBuilder getSpecOrBuilder(); + + /** + * + * + *
+   * Optional. The retention duration of a backup that must be at least 6 hours
+   * and at most 366 days. The backup is eligible to be automatically deleted
+   * once the retention period has elapsed.
+   * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the retentionDuration field is set. + */ + boolean hasRetentionDuration(); + /** + * + * + *
+   * Optional. The retention duration of a backup that must be at least 6 hours
+   * and at most 366 days. The backup is eligible to be automatically deleted
+   * once the retention period has elapsed.
+   * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The retentionDuration. + */ + com.google.protobuf.Duration getRetentionDuration(); + /** + * + * + *
+   * Optional. The retention duration of a backup that must be at least 6 hours
+   * and at most 366 days. The backup is eligible to be automatically deleted
+   * once the retention period has elapsed.
+   * 
+ * + * + * .google.protobuf.Duration retention_duration = 3 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.protobuf.DurationOrBuilder getRetentionDurationOrBuilder(); + + /** + * + * + *
+   * Optional. The encryption configuration that will be used to encrypt the
+   * backup. If this field is not specified, the backup will use the same
+   * encryption configuration as the database.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return Whether the encryptionConfig field is set. + */ + boolean hasEncryptionConfig(); + /** + * + * + *
+   * Optional. The encryption configuration that will be used to encrypt the
+   * backup. If this field is not specified, the backup will use the same
+   * encryption configuration as the database.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * + * @return The encryptionConfig. + */ + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfig getEncryptionConfig(); + /** + * + * + *
+   * Optional. The encryption configuration that will be used to encrypt the
+   * backup. If this field is not specified, the backup will use the same
+   * encryption configuration as the database.
+   * 
+ * + * + * .google.spanner.admin.database.v1.CreateBackupEncryptionConfig encryption_config = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + */ + com.google.spanner.admin.database.v1.CreateBackupEncryptionConfigOrBuilder + getEncryptionConfigOrBuilder(); + + /** + * + * + *
+   * The schedule creates only full backups.
+   * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + * + * @return Whether the fullBackupSpec field is set. + */ + boolean hasFullBackupSpec(); + /** + * + * + *
+   * The schedule creates only full backups.
+   * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + * + * @return The fullBackupSpec. + */ + com.google.spanner.admin.database.v1.FullBackupSpec getFullBackupSpec(); + /** + * + * + *
+   * The schedule creates only full backups.
+   * 
+ * + * .google.spanner.admin.database.v1.FullBackupSpec full_backup_spec = 7; + */ + com.google.spanner.admin.database.v1.FullBackupSpecOrBuilder getFullBackupSpecOrBuilder(); + + /** + * + * + *
+   * The schedule creates incremental backup chains.
+   * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + * + * @return Whether the incrementalBackupSpec field is set. + */ + boolean hasIncrementalBackupSpec(); + /** + * + * + *
+   * The schedule creates incremental backup chains.
+   * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + * + * @return The incrementalBackupSpec. + */ + com.google.spanner.admin.database.v1.IncrementalBackupSpec getIncrementalBackupSpec(); + /** + * + * + *
+   * The schedule creates incremental backup chains.
+   * 
+ * + * .google.spanner.admin.database.v1.IncrementalBackupSpec incremental_backup_spec = 8; + * + */ + com.google.spanner.admin.database.v1.IncrementalBackupSpecOrBuilder + getIncrementalBackupSpecOrBuilder(); + + /** + * + * + *
+   * Output only. The timestamp at which the schedule was last updated.
+   * If the schedule has never been updated, this field contains the timestamp
+   * when the schedule was first created.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the updateTime field is set. + */ + boolean hasUpdateTime(); + /** + * + * + *
+   * Output only. The timestamp at which the schedule was last updated.
+   * If the schedule has never been updated, this field contains the timestamp
+   * when the schedule was first created.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The updateTime. + */ + com.google.protobuf.Timestamp getUpdateTime(); + /** + * + * + *
+   * Output only. The timestamp at which the schedule was last updated.
+   * If the schedule has never been updated, this field contains the timestamp
+   * when the schedule was first created.
+   * 
+ * + * .google.protobuf.Timestamp update_time = 9 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.TimestampOrBuilder getUpdateTimeOrBuilder(); + + com.google.spanner.admin.database.v1.BackupSchedule.BackupTypeSpecCase getBackupTypeSpecCase(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleProto.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleProto.java new file mode 100644 index 00000000000..9f018585afd --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleProto.java @@ -0,0 +1,241 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public final class BackupScheduleProto { + private BackupScheduleProto() {} + + 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_spanner_admin_database_v1_BackupScheduleSpec_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_BackupScheduleSpec_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_BackupSchedule_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_BackupSchedule_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_CrontabSpec_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_CrontabSpec_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_CreateBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_CreateBackupScheduleRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_GetBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_GetBackupScheduleRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_DeleteBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_DeleteBackupScheduleRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_ListBackupSchedulesRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_ListBackupSchedulesRequest_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_ListBackupSchedulesResponse_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_ListBackupSchedulesResponse_fieldAccessorTable; + static final com.google.protobuf.Descriptors.Descriptor + internal_static_google_spanner_admin_database_v1_UpdateBackupScheduleRequest_descriptor; + static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internal_static_google_spanner_admin_database_v1_UpdateBackupScheduleRequest_fieldAccessorTable; + + public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + return descriptor; + } + + private static com.google.protobuf.Descriptors.FileDescriptor descriptor; + + static { + java.lang.String[] descriptorData = { + "\n6google/spanner/admin/database/v1/backu" + + "p_schedule.proto\022 google.spanner.admin.d" + + "atabase.v1\032\037google/api/field_behavior.pr" + + "oto\032\031google/api/resource.proto\032\036google/p" + + "rotobuf/duration.proto\032 google/protobuf/" + + "field_mask.proto\032\037google/protobuf/timest" + + "amp.proto\032-google/spanner/admin/database" + + "/v1/backup.proto\"i\n\022BackupScheduleSpec\022B" + + "\n\tcron_spec\030\001 \001(\0132-.google.spanner.admin" + + ".database.v1.CrontabSpecH\000B\017\n\rschedule_s" + + "pec\"\244\005\n\016BackupSchedule\022\021\n\004name\030\001 \001(\tB\003\340A" + + "\010\022G\n\004spec\030\006 \001(\01324.google.spanner.admin.d" + + "atabase.v1.BackupScheduleSpecB\003\340A\001\022:\n\022re" + + "tention_duration\030\003 \001(\0132\031.google.protobuf" + + ".DurationB\003\340A\001\022^\n\021encryption_config\030\004 \001(" + + "\0132>.google.spanner.admin.database.v1.Cre" + + "ateBackupEncryptionConfigB\003\340A\001\022L\n\020full_b" + + "ackup_spec\030\007 \001(\01320.google.spanner.admin." + + "database.v1.FullBackupSpecH\000\022Z\n\027incremen" + + "tal_backup_spec\030\010 \001(\01327.google.spanner.a" + + "dmin.database.v1.IncrementalBackupSpecH\000" + + "\0224\n\013update_time\030\t \001(\0132\032.google.protobuf." + + "TimestampB\003\340A\003:\245\001\352A\241\001\n%spanner.googleapi" + + "s.com/BackupSchedule\022Wprojects/{project}" + + "/instances/{instance}/databases/{databas" + + "e}/backupSchedules/{schedule}*\017backupSch" + + "edules2\016backupScheduleB\022\n\020backup_type_sp" + + "ec\"q\n\013CrontabSpec\022\021\n\004text\030\001 \001(\tB\003\340A\002\022\026\n\t" + + "time_zone\030\002 \001(\tB\003\340A\003\0227\n\017creation_window\030" + + "\003 \001(\0132\031.google.protobuf.DurationB\003\340A\003\"\307\001" + + "\n\033CreateBackupScheduleRequest\0227\n\006parent\030" + + "\001 \001(\tB\'\340A\002\372A!\n\037spanner.googleapis.com/Da" + + "tabase\022\037\n\022backup_schedule_id\030\002 \001(\tB\003\340A\002\022" + + "N\n\017backup_schedule\030\003 \001(\01320.google.spanne" + + "r.admin.database.v1.BackupScheduleB\003\340A\002\"" + + "W\n\030GetBackupScheduleRequest\022;\n\004name\030\001 \001(" + + "\tB-\340A\002\372A\'\n%spanner.googleapis.com/Backup" + + "Schedule\"Z\n\033DeleteBackupScheduleRequest\022" + + ";\n\004name\030\001 \001(\tB-\340A\002\372A\'\n%spanner.googleapi" + + "s.com/BackupSchedule\"\206\001\n\032ListBackupSched" + + "ulesRequest\0227\n\006parent\030\001 \001(\tB\'\340A\002\372A!\n\037spa" + + "nner.googleapis.com/Database\022\026\n\tpage_siz" + + "e\030\002 \001(\005B\003\340A\001\022\027\n\npage_token\030\004 \001(\tB\003\340A\001\"\202\001" + + "\n\033ListBackupSchedulesResponse\022J\n\020backup_" + + "schedules\030\001 \003(\01320.google.spanner.admin.d" + + "atabase.v1.BackupSchedule\022\027\n\017next_page_t" + + "oken\030\002 \001(\t\"\243\001\n\033UpdateBackupScheduleReque" + + "st\022N\n\017backup_schedule\030\001 \001(\01320.google.spa" + + "nner.admin.database.v1.BackupScheduleB\003\340" + + "A\002\0224\n\013update_mask\030\002 \001(\0132\032.google.protobu" + + "f.FieldMaskB\003\340A\002B\205\002\n$com.google.spanner." + + "admin.database.v1B\023BackupScheduleProtoP\001" + + "ZFcloud.google.com/go/spanner/admin/data" + + "base/apiv1/databasepb;databasepb\252\002&Googl" + + "e.Cloud.Spanner.Admin.Database.V1\312\002&Goog" + + "le\\Cloud\\Spanner\\Admin\\Database\\V1\352\002+Goo" + + "gle::Cloud::Spanner::Admin::Database::V1" + + "b\006proto3" + }; + descriptor = + com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( + descriptorData, + new com.google.protobuf.Descriptors.FileDescriptor[] { + com.google.api.FieldBehaviorProto.getDescriptor(), + com.google.api.ResourceProto.getDescriptor(), + com.google.protobuf.DurationProto.getDescriptor(), + com.google.protobuf.FieldMaskProto.getDescriptor(), + com.google.protobuf.TimestampProto.getDescriptor(), + com.google.spanner.admin.database.v1.BackupProto.getDescriptor(), + }); + internal_static_google_spanner_admin_database_v1_BackupScheduleSpec_descriptor = + getDescriptor().getMessageTypes().get(0); + internal_static_google_spanner_admin_database_v1_BackupScheduleSpec_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_BackupScheduleSpec_descriptor, + new java.lang.String[] { + "CronSpec", "ScheduleSpec", + }); + internal_static_google_spanner_admin_database_v1_BackupSchedule_descriptor = + getDescriptor().getMessageTypes().get(1); + internal_static_google_spanner_admin_database_v1_BackupSchedule_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_BackupSchedule_descriptor, + new java.lang.String[] { + "Name", + "Spec", + "RetentionDuration", + "EncryptionConfig", + "FullBackupSpec", + "IncrementalBackupSpec", + "UpdateTime", + "BackupTypeSpec", + }); + internal_static_google_spanner_admin_database_v1_CrontabSpec_descriptor = + getDescriptor().getMessageTypes().get(2); + internal_static_google_spanner_admin_database_v1_CrontabSpec_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_CrontabSpec_descriptor, + new java.lang.String[] { + "Text", "TimeZone", "CreationWindow", + }); + internal_static_google_spanner_admin_database_v1_CreateBackupScheduleRequest_descriptor = + getDescriptor().getMessageTypes().get(3); + internal_static_google_spanner_admin_database_v1_CreateBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_CreateBackupScheduleRequest_descriptor, + new java.lang.String[] { + "Parent", "BackupScheduleId", "BackupSchedule", + }); + internal_static_google_spanner_admin_database_v1_GetBackupScheduleRequest_descriptor = + getDescriptor().getMessageTypes().get(4); + internal_static_google_spanner_admin_database_v1_GetBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_GetBackupScheduleRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_spanner_admin_database_v1_DeleteBackupScheduleRequest_descriptor = + getDescriptor().getMessageTypes().get(5); + internal_static_google_spanner_admin_database_v1_DeleteBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_DeleteBackupScheduleRequest_descriptor, + new java.lang.String[] { + "Name", + }); + internal_static_google_spanner_admin_database_v1_ListBackupSchedulesRequest_descriptor = + getDescriptor().getMessageTypes().get(6); + internal_static_google_spanner_admin_database_v1_ListBackupSchedulesRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_ListBackupSchedulesRequest_descriptor, + new java.lang.String[] { + "Parent", "PageSize", "PageToken", + }); + internal_static_google_spanner_admin_database_v1_ListBackupSchedulesResponse_descriptor = + getDescriptor().getMessageTypes().get(7); + internal_static_google_spanner_admin_database_v1_ListBackupSchedulesResponse_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_ListBackupSchedulesResponse_descriptor, + new java.lang.String[] { + "BackupSchedules", "NextPageToken", + }); + internal_static_google_spanner_admin_database_v1_UpdateBackupScheduleRequest_descriptor = + getDescriptor().getMessageTypes().get(8); + internal_static_google_spanner_admin_database_v1_UpdateBackupScheduleRequest_fieldAccessorTable = + new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( + internal_static_google_spanner_admin_database_v1_UpdateBackupScheduleRequest_descriptor, + new java.lang.String[] { + "BackupSchedule", "UpdateMask", + }); + com.google.protobuf.ExtensionRegistry registry = + com.google.protobuf.ExtensionRegistry.newInstance(); + registry.add(com.google.api.FieldBehaviorProto.fieldBehavior); + registry.add(com.google.api.ResourceProto.resource); + registry.add(com.google.api.ResourceProto.resourceReference); + com.google.protobuf.Descriptors.FileDescriptor.internalUpdateFileDescriptor( + descriptor, registry); + com.google.api.FieldBehaviorProto.getDescriptor(); + com.google.api.ResourceProto.getDescriptor(); + com.google.protobuf.DurationProto.getDescriptor(); + com.google.protobuf.FieldMaskProto.getDescriptor(); + com.google.protobuf.TimestampProto.getDescriptor(); + com.google.spanner.admin.database.v1.BackupProto.getDescriptor(); + } + + // @@protoc_insertion_point(outer_class_scope) +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleSpec.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleSpec.java new file mode 100644 index 00000000000..d5f0ad3ed70 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleSpec.java @@ -0,0 +1,820 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * Defines specifications of the backup schedule.
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.BackupScheduleSpec} + */ +public final class BackupScheduleSpec extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.BackupScheduleSpec) + BackupScheduleSpecOrBuilder { + private static final long serialVersionUID = 0L; + // Use BackupScheduleSpec.newBuilder() to construct. + private BackupScheduleSpec(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private BackupScheduleSpec() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new BackupScheduleSpec(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_BackupScheduleSpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_BackupScheduleSpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.BackupScheduleSpec.class, + com.google.spanner.admin.database.v1.BackupScheduleSpec.Builder.class); + } + + private int scheduleSpecCase_ = 0; + + @SuppressWarnings("serial") + private java.lang.Object scheduleSpec_; + + public enum ScheduleSpecCase + implements + com.google.protobuf.Internal.EnumLite, + com.google.protobuf.AbstractMessage.InternalOneOfEnum { + CRON_SPEC(1), + SCHEDULESPEC_NOT_SET(0); + private final int value; + + private ScheduleSpecCase(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 ScheduleSpecCase valueOf(int value) { + return forNumber(value); + } + + public static ScheduleSpecCase forNumber(int value) { + switch (value) { + case 1: + return CRON_SPEC; + case 0: + return SCHEDULESPEC_NOT_SET; + default: + return null; + } + } + + public int getNumber() { + return this.value; + } + }; + + public ScheduleSpecCase getScheduleSpecCase() { + return ScheduleSpecCase.forNumber(scheduleSpecCase_); + } + + public static final int CRON_SPEC_FIELD_NUMBER = 1; + /** + * + * + *
+   * Cron style schedule specification.
+   * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + * + * @return Whether the cronSpec field is set. + */ + @java.lang.Override + public boolean hasCronSpec() { + return scheduleSpecCase_ == 1; + } + /** + * + * + *
+   * Cron style schedule specification.
+   * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + * + * @return The cronSpec. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.CrontabSpec getCronSpec() { + if (scheduleSpecCase_ == 1) { + return (com.google.spanner.admin.database.v1.CrontabSpec) scheduleSpec_; + } + return com.google.spanner.admin.database.v1.CrontabSpec.getDefaultInstance(); + } + /** + * + * + *
+   * Cron style schedule specification.
+   * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.CrontabSpecOrBuilder getCronSpecOrBuilder() { + if (scheduleSpecCase_ == 1) { + return (com.google.spanner.admin.database.v1.CrontabSpec) scheduleSpec_; + } + return com.google.spanner.admin.database.v1.CrontabSpec.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 (scheduleSpecCase_ == 1) { + output.writeMessage(1, (com.google.spanner.admin.database.v1.CrontabSpec) scheduleSpec_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (scheduleSpecCase_ == 1) { + size += + com.google.protobuf.CodedOutputStream.computeMessageSize( + 1, (com.google.spanner.admin.database.v1.CrontabSpec) scheduleSpec_); + } + 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.spanner.admin.database.v1.BackupScheduleSpec)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.BackupScheduleSpec other = + (com.google.spanner.admin.database.v1.BackupScheduleSpec) obj; + + if (!getScheduleSpecCase().equals(other.getScheduleSpecCase())) return false; + switch (scheduleSpecCase_) { + case 1: + if (!getCronSpec().equals(other.getCronSpec())) 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 (scheduleSpecCase_) { + case 1: + hash = (37 * hash) + CRON_SPEC_FIELD_NUMBER; + hash = (53 * hash) + getCronSpec().hashCode(); + break; + case 0: + default: + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.spanner.admin.database.v1.BackupScheduleSpec parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.BackupScheduleSpec parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.BackupScheduleSpec parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.BackupScheduleSpec 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.spanner.admin.database.v1.BackupScheduleSpec parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.BackupScheduleSpec parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.BackupScheduleSpec parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.BackupScheduleSpec 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.spanner.admin.database.v1.BackupScheduleSpec parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.BackupScheduleSpec 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.spanner.admin.database.v1.BackupScheduleSpec parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.BackupScheduleSpec 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.spanner.admin.database.v1.BackupScheduleSpec 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 specifications of the backup schedule.
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.BackupScheduleSpec} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.BackupScheduleSpec) + com.google.spanner.admin.database.v1.BackupScheduleSpecOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_BackupScheduleSpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_BackupScheduleSpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.BackupScheduleSpec.class, + com.google.spanner.admin.database.v1.BackupScheduleSpec.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.BackupScheduleSpec.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (cronSpecBuilder_ != null) { + cronSpecBuilder_.clear(); + } + scheduleSpecCase_ = 0; + scheduleSpec_ = null; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_BackupScheduleSpec_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupScheduleSpec getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.BackupScheduleSpec.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupScheduleSpec build() { + com.google.spanner.admin.database.v1.BackupScheduleSpec result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupScheduleSpec buildPartial() { + com.google.spanner.admin.database.v1.BackupScheduleSpec result = + new com.google.spanner.admin.database.v1.BackupScheduleSpec(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + buildPartialOneofs(result); + onBuilt(); + return result; + } + + private void buildPartial0(com.google.spanner.admin.database.v1.BackupScheduleSpec result) { + int from_bitField0_ = bitField0_; + } + + private void buildPartialOneofs( + com.google.spanner.admin.database.v1.BackupScheduleSpec result) { + result.scheduleSpecCase_ = scheduleSpecCase_; + result.scheduleSpec_ = this.scheduleSpec_; + if (scheduleSpecCase_ == 1 && cronSpecBuilder_ != null) { + result.scheduleSpec_ = cronSpecBuilder_.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.spanner.admin.database.v1.BackupScheduleSpec) { + return mergeFrom((com.google.spanner.admin.database.v1.BackupScheduleSpec) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.spanner.admin.database.v1.BackupScheduleSpec other) { + if (other == com.google.spanner.admin.database.v1.BackupScheduleSpec.getDefaultInstance()) + return this; + switch (other.getScheduleSpecCase()) { + case CRON_SPEC: + { + mergeCronSpec(other.getCronSpec()); + break; + } + case SCHEDULESPEC_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(getCronSpecFieldBuilder().getBuilder(), extensionRegistry); + scheduleSpecCase_ = 1; + 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 scheduleSpecCase_ = 0; + private java.lang.Object scheduleSpec_; + + public ScheduleSpecCase getScheduleSpecCase() { + return ScheduleSpecCase.forNumber(scheduleSpecCase_); + } + + public Builder clearScheduleSpec() { + scheduleSpecCase_ = 0; + scheduleSpec_ = null; + onChanged(); + return this; + } + + private int bitField0_; + + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.CrontabSpec, + com.google.spanner.admin.database.v1.CrontabSpec.Builder, + com.google.spanner.admin.database.v1.CrontabSpecOrBuilder> + cronSpecBuilder_; + /** + * + * + *
+     * Cron style schedule specification.
+     * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + * + * @return Whether the cronSpec field is set. + */ + @java.lang.Override + public boolean hasCronSpec() { + return scheduleSpecCase_ == 1; + } + /** + * + * + *
+     * Cron style schedule specification.
+     * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + * + * @return The cronSpec. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.CrontabSpec getCronSpec() { + if (cronSpecBuilder_ == null) { + if (scheduleSpecCase_ == 1) { + return (com.google.spanner.admin.database.v1.CrontabSpec) scheduleSpec_; + } + return com.google.spanner.admin.database.v1.CrontabSpec.getDefaultInstance(); + } else { + if (scheduleSpecCase_ == 1) { + return cronSpecBuilder_.getMessage(); + } + return com.google.spanner.admin.database.v1.CrontabSpec.getDefaultInstance(); + } + } + /** + * + * + *
+     * Cron style schedule specification.
+     * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + */ + public Builder setCronSpec(com.google.spanner.admin.database.v1.CrontabSpec value) { + if (cronSpecBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + scheduleSpec_ = value; + onChanged(); + } else { + cronSpecBuilder_.setMessage(value); + } + scheduleSpecCase_ = 1; + return this; + } + /** + * + * + *
+     * Cron style schedule specification.
+     * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + */ + public Builder setCronSpec( + com.google.spanner.admin.database.v1.CrontabSpec.Builder builderForValue) { + if (cronSpecBuilder_ == null) { + scheduleSpec_ = builderForValue.build(); + onChanged(); + } else { + cronSpecBuilder_.setMessage(builderForValue.build()); + } + scheduleSpecCase_ = 1; + return this; + } + /** + * + * + *
+     * Cron style schedule specification.
+     * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + */ + public Builder mergeCronSpec(com.google.spanner.admin.database.v1.CrontabSpec value) { + if (cronSpecBuilder_ == null) { + if (scheduleSpecCase_ == 1 + && scheduleSpec_ + != com.google.spanner.admin.database.v1.CrontabSpec.getDefaultInstance()) { + scheduleSpec_ = + com.google.spanner.admin.database.v1.CrontabSpec.newBuilder( + (com.google.spanner.admin.database.v1.CrontabSpec) scheduleSpec_) + .mergeFrom(value) + .buildPartial(); + } else { + scheduleSpec_ = value; + } + onChanged(); + } else { + if (scheduleSpecCase_ == 1) { + cronSpecBuilder_.mergeFrom(value); + } else { + cronSpecBuilder_.setMessage(value); + } + } + scheduleSpecCase_ = 1; + return this; + } + /** + * + * + *
+     * Cron style schedule specification.
+     * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + */ + public Builder clearCronSpec() { + if (cronSpecBuilder_ == null) { + if (scheduleSpecCase_ == 1) { + scheduleSpecCase_ = 0; + scheduleSpec_ = null; + onChanged(); + } + } else { + if (scheduleSpecCase_ == 1) { + scheduleSpecCase_ = 0; + scheduleSpec_ = null; + } + cronSpecBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * Cron style schedule specification.
+     * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + */ + public com.google.spanner.admin.database.v1.CrontabSpec.Builder getCronSpecBuilder() { + return getCronSpecFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Cron style schedule specification.
+     * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.CrontabSpecOrBuilder getCronSpecOrBuilder() { + if ((scheduleSpecCase_ == 1) && (cronSpecBuilder_ != null)) { + return cronSpecBuilder_.getMessageOrBuilder(); + } else { + if (scheduleSpecCase_ == 1) { + return (com.google.spanner.admin.database.v1.CrontabSpec) scheduleSpec_; + } + return com.google.spanner.admin.database.v1.CrontabSpec.getDefaultInstance(); + } + } + /** + * + * + *
+     * Cron style schedule specification.
+     * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.CrontabSpec, + com.google.spanner.admin.database.v1.CrontabSpec.Builder, + com.google.spanner.admin.database.v1.CrontabSpecOrBuilder> + getCronSpecFieldBuilder() { + if (cronSpecBuilder_ == null) { + if (!(scheduleSpecCase_ == 1)) { + scheduleSpec_ = com.google.spanner.admin.database.v1.CrontabSpec.getDefaultInstance(); + } + cronSpecBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.CrontabSpec, + com.google.spanner.admin.database.v1.CrontabSpec.Builder, + com.google.spanner.admin.database.v1.CrontabSpecOrBuilder>( + (com.google.spanner.admin.database.v1.CrontabSpec) scheduleSpec_, + getParentForChildren(), + isClean()); + scheduleSpec_ = null; + } + scheduleSpecCase_ = 1; + onChanged(); + return cronSpecBuilder_; + } + + @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.spanner.admin.database.v1.BackupScheduleSpec) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.BackupScheduleSpec) + private static final com.google.spanner.admin.database.v1.BackupScheduleSpec DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.BackupScheduleSpec(); + } + + public static com.google.spanner.admin.database.v1.BackupScheduleSpec getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public BackupScheduleSpec 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.spanner.admin.database.v1.BackupScheduleSpec getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleSpecOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleSpecOrBuilder.java new file mode 100644 index 00000000000..df8f8268965 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/BackupScheduleSpecOrBuilder.java @@ -0,0 +1,63 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface BackupScheduleSpecOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.BackupScheduleSpec) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Cron style schedule specification.
+   * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + * + * @return Whether the cronSpec field is set. + */ + boolean hasCronSpec(); + /** + * + * + *
+   * Cron style schedule specification.
+   * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + * + * @return The cronSpec. + */ + com.google.spanner.admin.database.v1.CrontabSpec getCronSpec(); + /** + * + * + *
+   * Cron style schedule specification.
+   * 
+ * + * .google.spanner.admin.database.v1.CrontabSpec cron_spec = 1; + */ + com.google.spanner.admin.database.v1.CrontabSpecOrBuilder getCronSpecOrBuilder(); + + com.google.spanner.admin.database.v1.BackupScheduleSpec.ScheduleSpecCase getScheduleSpecCase(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateBackupScheduleRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateBackupScheduleRequest.java new file mode 100644 index 00000000000..f16ded8cbb7 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateBackupScheduleRequest.java @@ -0,0 +1,1152 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * The request for
+ * [CreateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackupSchedule].
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.CreateBackupScheduleRequest} + */ +public final class CreateBackupScheduleRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.CreateBackupScheduleRequest) + CreateBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use CreateBackupScheduleRequest.newBuilder() to construct. + private CreateBackupScheduleRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CreateBackupScheduleRequest() { + parent_ = ""; + backupScheduleId_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CreateBackupScheduleRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_CreateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_CreateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest.class, + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest.Builder.class); + } + + private int bitField0_; + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + /** + * + * + *
+   * Required. The name of the database that this backup schedule applies to.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The name of the database that this backup schedule applies to.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BACKUP_SCHEDULE_ID_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object backupScheduleId_ = ""; + /** + * + * + *
+   * Required. The Id to use for the backup schedule. The `backup_schedule_id`
+   * appended to `parent` forms the full backup schedule name of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The backupScheduleId. + */ + @java.lang.Override + public java.lang.String getBackupScheduleId() { + java.lang.Object ref = backupScheduleId_; + 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(); + backupScheduleId_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The Id to use for the backup schedule. The `backup_schedule_id`
+   * appended to `parent` forms the full backup schedule name of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for backupScheduleId. + */ + @java.lang.Override + public com.google.protobuf.ByteString getBackupScheduleIdBytes() { + java.lang.Object ref = backupScheduleId_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backupScheduleId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int BACKUP_SCHEDULE_FIELD_NUMBER = 3; + private com.google.spanner.admin.database.v1.BackupSchedule backupSchedule_; + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + @java.lang.Override + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupSchedule getBackupSchedule() { + return backupSchedule_ == null + ? com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder() { + return backupSchedule_ == null + ? com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(backupScheduleId_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, backupScheduleId_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getBackupSchedule()); + } + 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(parent_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(backupScheduleId_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, backupScheduleId_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getBackupSchedule()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.spanner.admin.database.v1.CreateBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest other = + (com.google.spanner.admin.database.v1.CreateBackupScheduleRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (!getBackupScheduleId().equals(other.getBackupScheduleId())) return false; + if (hasBackupSchedule() != other.hasBackupSchedule()) return false; + if (hasBackupSchedule()) { + if (!getBackupSchedule().equals(other.getBackupSchedule())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + BACKUP_SCHEDULE_ID_FIELD_NUMBER; + hash = (53 * hash) + getBackupScheduleId().hashCode(); + if (hasBackupSchedule()) { + hash = (37 * hash) + BACKUP_SCHEDULE_FIELD_NUMBER; + hash = (53 * hash) + getBackupSchedule().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest 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.spanner.admin.database.v1.CreateBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest 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.spanner.admin.database.v1.CreateBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest 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.spanner.admin.database.v1.CreateBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [CreateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackupSchedule].
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.CreateBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.CreateBackupScheduleRequest) + com.google.spanner.admin.database.v1.CreateBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_CreateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_CreateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest.class, + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.CreateBackupScheduleRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getBackupScheduleFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + backupScheduleId_ = ""; + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_CreateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CreateBackupScheduleRequest + getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.CreateBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CreateBackupScheduleRequest build() { + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CreateBackupScheduleRequest buildPartial() { + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest result = + new com.google.spanner.admin.database.v1.CreateBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.backupScheduleId_ = backupScheduleId_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.backupSchedule_ = + backupScheduleBuilder_ == null ? backupSchedule_ : backupScheduleBuilder_.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.spanner.admin.database.v1.CreateBackupScheduleRequest) { + return mergeFrom((com.google.spanner.admin.database.v1.CreateBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.spanner.admin.database.v1.CreateBackupScheduleRequest other) { + if (other + == com.google.spanner.admin.database.v1.CreateBackupScheduleRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getBackupScheduleId().isEmpty()) { + backupScheduleId_ = other.backupScheduleId_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.hasBackupSchedule()) { + mergeBackupSchedule(other.getBackupSchedule()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + backupScheduleId_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(getBackupScheduleFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object parent_ = ""; + /** + * + * + *
+     * Required. The name of the database that this backup schedule applies to.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The name of the database that this backup schedule applies to.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The name of the database that this backup schedule applies to.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the database that this backup schedule applies to.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the database that this backup schedule applies to.
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object backupScheduleId_ = ""; + /** + * + * + *
+     * Required. The Id to use for the backup schedule. The `backup_schedule_id`
+     * appended to `parent` forms the full backup schedule name of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The backupScheduleId. + */ + public java.lang.String getBackupScheduleId() { + java.lang.Object ref = backupScheduleId_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + backupScheduleId_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The Id to use for the backup schedule. The `backup_schedule_id`
+     * appended to `parent` forms the full backup schedule name of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for backupScheduleId. + */ + public com.google.protobuf.ByteString getBackupScheduleIdBytes() { + java.lang.Object ref = backupScheduleId_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + backupScheduleId_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The Id to use for the backup schedule. The `backup_schedule_id`
+     * appended to `parent` forms the full backup schedule name of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The backupScheduleId to set. + * @return This builder for chaining. + */ + public Builder setBackupScheduleId(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + backupScheduleId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Id to use for the backup schedule. The `backup_schedule_id`
+     * appended to `parent` forms the full backup schedule name of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearBackupScheduleId() { + backupScheduleId_ = getDefaultInstance().getBackupScheduleId(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The Id to use for the backup schedule. The `backup_schedule_id`
+     * appended to `parent` forms the full backup schedule name of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for backupScheduleId to set. + * @return This builder for chaining. + */ + public Builder setBackupScheduleIdBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + backupScheduleId_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private com.google.spanner.admin.database.v1.BackupSchedule backupSchedule_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupSchedule, + com.google.spanner.admin.database.v1.BackupSchedule.Builder, + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder> + backupScheduleBuilder_; + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + public com.google.spanner.admin.database.v1.BackupSchedule getBackupSchedule() { + if (backupScheduleBuilder_ == null) { + return backupSchedule_ == null + ? com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } else { + return backupScheduleBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule(com.google.spanner.admin.database.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + backupSchedule_ = value; + } else { + backupScheduleBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule( + com.google.spanner.admin.database.v1.BackupSchedule.Builder builderForValue) { + if (backupScheduleBuilder_ == null) { + backupSchedule_ = builderForValue.build(); + } else { + backupScheduleBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeBackupSchedule(com.google.spanner.admin.database.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && backupSchedule_ != null + && backupSchedule_ + != com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance()) { + getBackupScheduleBuilder().mergeFrom(value); + } else { + backupSchedule_ = value; + } + } else { + backupScheduleBuilder_.mergeFrom(value); + } + if (backupSchedule_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearBackupSchedule() { + bitField0_ = (bitField0_ & ~0x00000004); + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.spanner.admin.database.v1.BackupSchedule.Builder getBackupScheduleBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getBackupScheduleFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.spanner.admin.database.v1.BackupScheduleOrBuilder + getBackupScheduleOrBuilder() { + if (backupScheduleBuilder_ != null) { + return backupScheduleBuilder_.getMessageOrBuilder(); + } else { + return backupSchedule_ == null + ? com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + } + /** + * + * + *
+     * Required. The backup schedule to create.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupSchedule, + com.google.spanner.admin.database.v1.BackupSchedule.Builder, + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder> + getBackupScheduleFieldBuilder() { + if (backupScheduleBuilder_ == null) { + backupScheduleBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupSchedule, + com.google.spanner.admin.database.v1.BackupSchedule.Builder, + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder>( + getBackupSchedule(), getParentForChildren(), isClean()); + backupSchedule_ = null; + } + return backupScheduleBuilder_; + } + + @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.spanner.admin.database.v1.CreateBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CreateBackupScheduleRequest) + private static final com.google.spanner.admin.database.v1.CreateBackupScheduleRequest + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.CreateBackupScheduleRequest(); + } + + public static com.google.spanner.admin.database.v1.CreateBackupScheduleRequest + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CreateBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CreateBackupScheduleRequest + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateBackupScheduleRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateBackupScheduleRequestOrBuilder.java new file mode 100644 index 00000000000..4882326d5a1 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CreateBackupScheduleRequestOrBuilder.java @@ -0,0 +1,125 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface CreateBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.CreateBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the database that this backup schedule applies to.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. The name of the database that this backup schedule applies to.
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Required. The Id to use for the backup schedule. The `backup_schedule_id`
+   * appended to `parent` forms the full backup schedule name of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The backupScheduleId. + */ + java.lang.String getBackupScheduleId(); + /** + * + * + *
+   * Required. The Id to use for the backup schedule. The `backup_schedule_id`
+   * appended to `parent` forms the full backup schedule name of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * string backup_schedule_id = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for backupScheduleId. + */ + com.google.protobuf.ByteString getBackupScheduleIdBytes(); + + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + boolean hasBackupSchedule(); + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + com.google.spanner.admin.database.v1.BackupSchedule getBackupSchedule(); + /** + * + * + *
+   * Required. The backup schedule to create.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 3 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CrontabSpec.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CrontabSpec.java new file mode 100644 index 00000000000..17b2126c51c --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CrontabSpec.java @@ -0,0 +1,1269 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * CrontabSpec can be used to specify the version time and frequency at
+ * which the backup should be created.
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.CrontabSpec} + */ +public final class CrontabSpec extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.CrontabSpec) + CrontabSpecOrBuilder { + private static final long serialVersionUID = 0L; + // Use CrontabSpec.newBuilder() to construct. + private CrontabSpec(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private CrontabSpec() { + text_ = ""; + timeZone_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new CrontabSpec(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_CrontabSpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_CrontabSpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.CrontabSpec.class, + com.google.spanner.admin.database.v1.CrontabSpec.Builder.class); + } + + private int bitField0_; + public static final int TEXT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object text_ = ""; + /** + * + * + *
+   * Required. Textual representation of the crontab. User can customize the
+   * backup frequency and the backup version time using the cron
+   * expression. The version time must be in UTC timzeone.
+   *
+   * The backup will contain an externally consistent copy of the
+   * database at the version time. Allowed frequencies are 12 hour, 1 day,
+   * 1 week and 1 month. Examples of valid cron specifications:
+   *   * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
+   *   * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
+   *   * `0 2 * * * `    : once a day at 2 past midnight in UTC.
+   *   * `0 2 * * 0 `    : once a week every Sunday at 2 past midnight in UTC.
+   *   * `0 2 8 * * `    : once a month on 8th day at 2 past midnight in UTC.
+   * 
+ * + * string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The text. + */ + @java.lang.Override + public java.lang.String getText() { + java.lang.Object ref = text_; + 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(); + text_ = s; + return s; + } + } + /** + * + * + *
+   * Required. Textual representation of the crontab. User can customize the
+   * backup frequency and the backup version time using the cron
+   * expression. The version time must be in UTC timzeone.
+   *
+   * The backup will contain an externally consistent copy of the
+   * database at the version time. Allowed frequencies are 12 hour, 1 day,
+   * 1 week and 1 month. Examples of valid cron specifications:
+   *   * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
+   *   * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
+   *   * `0 2 * * * `    : once a day at 2 past midnight in UTC.
+   *   * `0 2 * * 0 `    : once a week every Sunday at 2 past midnight in UTC.
+   *   * `0 2 8 * * `    : once a month on 8th day at 2 past midnight in UTC.
+   * 
+ * + * string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for text. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTextBytes() { + java.lang.Object ref = text_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + text_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int TIME_ZONE_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object timeZone_ = ""; + /** + * + * + *
+   * Output only. The time zone of the times in `CrontabSpec.text`. Currently
+   * only UTC is supported.
+   * 
+ * + * string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The timeZone. + */ + @java.lang.Override + public java.lang.String getTimeZone() { + java.lang.Object ref = timeZone_; + 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(); + timeZone_ = s; + return s; + } + } + /** + * + * + *
+   * Output only. The time zone of the times in `CrontabSpec.text`. Currently
+   * only UTC is supported.
+   * 
+ * + * string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for timeZone. + */ + @java.lang.Override + public com.google.protobuf.ByteString getTimeZoneBytes() { + java.lang.Object ref = timeZone_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + timeZone_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int CREATION_WINDOW_FIELD_NUMBER = 3; + private com.google.protobuf.Duration creationWindow_; + /** + * + * + *
+   * Output only. Schedule backups will contain an externally consistent copy
+   * of the database at the version time specified in
+   * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+   * of the scheduled backups at that version time. Spanner will initiate
+   * the creation of scheduled backups within the time window bounded by the
+   * version_time specified in `schedule_spec.cron_spec` and version_time +
+   * `creation_window`.
+   * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the creationWindow field is set. + */ + @java.lang.Override + public boolean hasCreationWindow() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Output only. Schedule backups will contain an externally consistent copy
+   * of the database at the version time specified in
+   * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+   * of the scheduled backups at that version time. Spanner will initiate
+   * the creation of scheduled backups within the time window bounded by the
+   * version_time specified in `schedule_spec.cron_spec` and version_time +
+   * `creation_window`.
+   * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The creationWindow. + */ + @java.lang.Override + public com.google.protobuf.Duration getCreationWindow() { + return creationWindow_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : creationWindow_; + } + /** + * + * + *
+   * Output only. Schedule backups will contain an externally consistent copy
+   * of the database at the version time specified in
+   * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+   * of the scheduled backups at that version time. Spanner will initiate
+   * the creation of scheduled backups within the time window bounded by the
+   * version_time specified in `schedule_spec.cron_spec` and version_time +
+   * `creation_window`.
+   * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + @java.lang.Override + public com.google.protobuf.DurationOrBuilder getCreationWindowOrBuilder() { + return creationWindow_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : creationWindow_; + } + + 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(text_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, text_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(timeZone_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, timeZone_); + } + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(3, getCreationWindow()); + } + 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(text_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, text_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(timeZone_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, timeZone_); + } + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getCreationWindow()); + } + 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.spanner.admin.database.v1.CrontabSpec)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.CrontabSpec other = + (com.google.spanner.admin.database.v1.CrontabSpec) obj; + + if (!getText().equals(other.getText())) return false; + if (!getTimeZone().equals(other.getTimeZone())) return false; + if (hasCreationWindow() != other.hasCreationWindow()) return false; + if (hasCreationWindow()) { + if (!getCreationWindow().equals(other.getCreationWindow())) 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) + TEXT_FIELD_NUMBER; + hash = (53 * hash) + getText().hashCode(); + hash = (37 * hash) + TIME_ZONE_FIELD_NUMBER; + hash = (53 * hash) + getTimeZone().hashCode(); + if (hasCreationWindow()) { + hash = (37 * hash) + CREATION_WINDOW_FIELD_NUMBER; + hash = (53 * hash) + getCreationWindow().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.spanner.admin.database.v1.CrontabSpec parseFrom(java.nio.ByteBuffer data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CrontabSpec parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CrontabSpec parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CrontabSpec 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.spanner.admin.database.v1.CrontabSpec parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.CrontabSpec parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.CrontabSpec parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CrontabSpec 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.spanner.admin.database.v1.CrontabSpec parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CrontabSpec 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.spanner.admin.database.v1.CrontabSpec parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.CrontabSpec 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.spanner.admin.database.v1.CrontabSpec 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; + } + /** + * + * + *
+   * CrontabSpec can be used to specify the version time and frequency at
+   * which the backup should be created.
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.CrontabSpec} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.CrontabSpec) + com.google.spanner.admin.database.v1.CrontabSpecOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_CrontabSpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_CrontabSpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.CrontabSpec.class, + com.google.spanner.admin.database.v1.CrontabSpec.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.CrontabSpec.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getCreationWindowFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + text_ = ""; + timeZone_ = ""; + creationWindow_ = null; + if (creationWindowBuilder_ != null) { + creationWindowBuilder_.dispose(); + creationWindowBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_CrontabSpec_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CrontabSpec getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.CrontabSpec.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CrontabSpec build() { + com.google.spanner.admin.database.v1.CrontabSpec result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.CrontabSpec buildPartial() { + com.google.spanner.admin.database.v1.CrontabSpec result = + new com.google.spanner.admin.database.v1.CrontabSpec(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(com.google.spanner.admin.database.v1.CrontabSpec result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.text_ = text_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.timeZone_ = timeZone_; + } + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000004) != 0)) { + result.creationWindow_ = + creationWindowBuilder_ == null ? creationWindow_ : creationWindowBuilder_.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.spanner.admin.database.v1.CrontabSpec) { + return mergeFrom((com.google.spanner.admin.database.v1.CrontabSpec) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.spanner.admin.database.v1.CrontabSpec other) { + if (other == com.google.spanner.admin.database.v1.CrontabSpec.getDefaultInstance()) + return this; + if (!other.getText().isEmpty()) { + text_ = other.text_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (!other.getTimeZone().isEmpty()) { + timeZone_ = other.timeZone_; + bitField0_ |= 0x00000002; + onChanged(); + } + if (other.hasCreationWindow()) { + mergeCreationWindow(other.getCreationWindow()); + } + 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: + { + text_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + timeZone_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } // case 18 + case 26: + { + input.readMessage(getCreationWindowFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000004; + break; + } // case 26 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object text_ = ""; + /** + * + * + *
+     * Required. Textual representation of the crontab. User can customize the
+     * backup frequency and the backup version time using the cron
+     * expression. The version time must be in UTC timzeone.
+     *
+     * The backup will contain an externally consistent copy of the
+     * database at the version time. Allowed frequencies are 12 hour, 1 day,
+     * 1 week and 1 month. Examples of valid cron specifications:
+     *   * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
+     *   * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
+     *   * `0 2 * * * `    : once a day at 2 past midnight in UTC.
+     *   * `0 2 * * 0 `    : once a week every Sunday at 2 past midnight in UTC.
+     *   * `0 2 8 * * `    : once a month on 8th day at 2 past midnight in UTC.
+     * 
+ * + * string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The text. + */ + public java.lang.String getText() { + java.lang.Object ref = text_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + text_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. Textual representation of the crontab. User can customize the
+     * backup frequency and the backup version time using the cron
+     * expression. The version time must be in UTC timzeone.
+     *
+     * The backup will contain an externally consistent copy of the
+     * database at the version time. Allowed frequencies are 12 hour, 1 day,
+     * 1 week and 1 month. Examples of valid cron specifications:
+     *   * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
+     *   * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
+     *   * `0 2 * * * `    : once a day at 2 past midnight in UTC.
+     *   * `0 2 * * 0 `    : once a week every Sunday at 2 past midnight in UTC.
+     *   * `0 2 8 * * `    : once a month on 8th day at 2 past midnight in UTC.
+     * 
+ * + * string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for text. + */ + public com.google.protobuf.ByteString getTextBytes() { + java.lang.Object ref = text_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + text_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. Textual representation of the crontab. User can customize the
+     * backup frequency and the backup version time using the cron
+     * expression. The version time must be in UTC timzeone.
+     *
+     * The backup will contain an externally consistent copy of the
+     * database at the version time. Allowed frequencies are 12 hour, 1 day,
+     * 1 week and 1 month. Examples of valid cron specifications:
+     *   * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
+     *   * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
+     *   * `0 2 * * * `    : once a day at 2 past midnight in UTC.
+     *   * `0 2 * * 0 `    : once a week every Sunday at 2 past midnight in UTC.
+     *   * `0 2 8 * * `    : once a month on 8th day at 2 past midnight in UTC.
+     * 
+ * + * string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The text to set. + * @return This builder for chaining. + */ + public Builder setText(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + text_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Textual representation of the crontab. User can customize the
+     * backup frequency and the backup version time using the cron
+     * expression. The version time must be in UTC timzeone.
+     *
+     * The backup will contain an externally consistent copy of the
+     * database at the version time. Allowed frequencies are 12 hour, 1 day,
+     * 1 week and 1 month. Examples of valid cron specifications:
+     *   * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
+     *   * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
+     *   * `0 2 * * * `    : once a day at 2 past midnight in UTC.
+     *   * `0 2 * * 0 `    : once a week every Sunday at 2 past midnight in UTC.
+     *   * `0 2 8 * * `    : once a month on 8th day at 2 past midnight in UTC.
+     * 
+ * + * string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return This builder for chaining. + */ + public Builder clearText() { + text_ = getDefaultInstance().getText(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Textual representation of the crontab. User can customize the
+     * backup frequency and the backup version time using the cron
+     * expression. The version time must be in UTC timzeone.
+     *
+     * The backup will contain an externally consistent copy of the
+     * database at the version time. Allowed frequencies are 12 hour, 1 day,
+     * 1 week and 1 month. Examples of valid cron specifications:
+     *   * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
+     *   * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
+     *   * `0 2 * * * `    : once a day at 2 past midnight in UTC.
+     *   * `0 2 * * 0 `    : once a week every Sunday at 2 past midnight in UTC.
+     *   * `0 2 8 * * `    : once a month on 8th day at 2 past midnight in UTC.
+     * 
+ * + * string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @param value The bytes for text to set. + * @return This builder for chaining. + */ + public Builder setTextBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + text_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private java.lang.Object timeZone_ = ""; + /** + * + * + *
+     * Output only. The time zone of the times in `CrontabSpec.text`. Currently
+     * only UTC is supported.
+     * 
+ * + * string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The timeZone. + */ + public java.lang.String getTimeZone() { + java.lang.Object ref = timeZone_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + timeZone_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Output only. The time zone of the times in `CrontabSpec.text`. Currently
+     * only UTC is supported.
+     * 
+ * + * string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for timeZone. + */ + public com.google.protobuf.ByteString getTimeZoneBytes() { + java.lang.Object ref = timeZone_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + timeZone_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Output only. The time zone of the times in `CrontabSpec.text`. Currently
+     * only UTC is supported.
+     * 
+ * + * string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The timeZone to set. + * @return This builder for chaining. + */ + public Builder setTimeZone(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + timeZone_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time zone of the times in `CrontabSpec.text`. Currently
+     * only UTC is supported.
+     * 
+ * + * string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return This builder for chaining. + */ + public Builder clearTimeZone() { + timeZone_ = getDefaultInstance().getTimeZone(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. The time zone of the times in `CrontabSpec.text`. Currently
+     * only UTC is supported.
+     * 
+ * + * string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @param value The bytes for timeZone to set. + * @return This builder for chaining. + */ + public Builder setTimeZoneBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + timeZone_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + private com.google.protobuf.Duration creationWindow_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + creationWindowBuilder_; + /** + * + * + *
+     * Output only. Schedule backups will contain an externally consistent copy
+     * of the database at the version time specified in
+     * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+     * of the scheduled backups at that version time. Spanner will initiate
+     * the creation of scheduled backups within the time window bounded by the
+     * version_time specified in `schedule_spec.cron_spec` and version_time +
+     * `creation_window`.
+     * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the creationWindow field is set. + */ + public boolean hasCreationWindow() { + return ((bitField0_ & 0x00000004) != 0); + } + /** + * + * + *
+     * Output only. Schedule backups will contain an externally consistent copy
+     * of the database at the version time specified in
+     * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+     * of the scheduled backups at that version time. Spanner will initiate
+     * the creation of scheduled backups within the time window bounded by the
+     * version_time specified in `schedule_spec.cron_spec` and version_time +
+     * `creation_window`.
+     * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The creationWindow. + */ + public com.google.protobuf.Duration getCreationWindow() { + if (creationWindowBuilder_ == null) { + return creationWindow_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : creationWindow_; + } else { + return creationWindowBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Output only. Schedule backups will contain an externally consistent copy
+     * of the database at the version time specified in
+     * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+     * of the scheduled backups at that version time. Spanner will initiate
+     * the creation of scheduled backups within the time window bounded by the
+     * version_time specified in `schedule_spec.cron_spec` and version_time +
+     * `creation_window`.
+     * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreationWindow(com.google.protobuf.Duration value) { + if (creationWindowBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + creationWindow_ = value; + } else { + creationWindowBuilder_.setMessage(value); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Schedule backups will contain an externally consistent copy
+     * of the database at the version time specified in
+     * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+     * of the scheduled backups at that version time. Spanner will initiate
+     * the creation of scheduled backups within the time window bounded by the
+     * version_time specified in `schedule_spec.cron_spec` and version_time +
+     * `creation_window`.
+     * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder setCreationWindow(com.google.protobuf.Duration.Builder builderForValue) { + if (creationWindowBuilder_ == null) { + creationWindow_ = builderForValue.build(); + } else { + creationWindowBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Schedule backups will contain an externally consistent copy
+     * of the database at the version time specified in
+     * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+     * of the scheduled backups at that version time. Spanner will initiate
+     * the creation of scheduled backups within the time window bounded by the
+     * version_time specified in `schedule_spec.cron_spec` and version_time +
+     * `creation_window`.
+     * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder mergeCreationWindow(com.google.protobuf.Duration value) { + if (creationWindowBuilder_ == null) { + if (((bitField0_ & 0x00000004) != 0) + && creationWindow_ != null + && creationWindow_ != com.google.protobuf.Duration.getDefaultInstance()) { + getCreationWindowBuilder().mergeFrom(value); + } else { + creationWindow_ = value; + } + } else { + creationWindowBuilder_.mergeFrom(value); + } + if (creationWindow_ != null) { + bitField0_ |= 0x00000004; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Output only. Schedule backups will contain an externally consistent copy
+     * of the database at the version time specified in
+     * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+     * of the scheduled backups at that version time. Spanner will initiate
+     * the creation of scheduled backups within the time window bounded by the
+     * version_time specified in `schedule_spec.cron_spec` and version_time +
+     * `creation_window`.
+     * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public Builder clearCreationWindow() { + bitField0_ = (bitField0_ & ~0x00000004); + creationWindow_ = null; + if (creationWindowBuilder_ != null) { + creationWindowBuilder_.dispose(); + creationWindowBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Output only. Schedule backups will contain an externally consistent copy
+     * of the database at the version time specified in
+     * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+     * of the scheduled backups at that version time. Spanner will initiate
+     * the creation of scheduled backups within the time window bounded by the
+     * version_time specified in `schedule_spec.cron_spec` and version_time +
+     * `creation_window`.
+     * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.Duration.Builder getCreationWindowBuilder() { + bitField0_ |= 0x00000004; + onChanged(); + return getCreationWindowFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Output only. Schedule backups will contain an externally consistent copy
+     * of the database at the version time specified in
+     * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+     * of the scheduled backups at that version time. Spanner will initiate
+     * the creation of scheduled backups within the time window bounded by the
+     * version_time specified in `schedule_spec.cron_spec` and version_time +
+     * `creation_window`.
+     * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + public com.google.protobuf.DurationOrBuilder getCreationWindowOrBuilder() { + if (creationWindowBuilder_ != null) { + return creationWindowBuilder_.getMessageOrBuilder(); + } else { + return creationWindow_ == null + ? com.google.protobuf.Duration.getDefaultInstance() + : creationWindow_; + } + } + /** + * + * + *
+     * Output only. Schedule backups will contain an externally consistent copy
+     * of the database at the version time specified in
+     * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+     * of the scheduled backups at that version time. Spanner will initiate
+     * the creation of scheduled backups within the time window bounded by the
+     * version_time specified in `schedule_spec.cron_spec` and version_time +
+     * `creation_window`.
+     * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder> + getCreationWindowFieldBuilder() { + if (creationWindowBuilder_ == null) { + creationWindowBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.Duration, + com.google.protobuf.Duration.Builder, + com.google.protobuf.DurationOrBuilder>( + getCreationWindow(), getParentForChildren(), isClean()); + creationWindow_ = null; + } + return creationWindowBuilder_; + } + + @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.spanner.admin.database.v1.CrontabSpec) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CrontabSpec) + private static final com.google.spanner.admin.database.v1.CrontabSpec DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.CrontabSpec(); + } + + public static com.google.spanner.admin.database.v1.CrontabSpec getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public CrontabSpec 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.spanner.admin.database.v1.CrontabSpec getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CrontabSpecOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CrontabSpecOrBuilder.java new file mode 100644 index 00000000000..6fdc1185acb --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/CrontabSpecOrBuilder.java @@ -0,0 +1,159 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface CrontabSpecOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.CrontabSpec) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Textual representation of the crontab. User can customize the
+   * backup frequency and the backup version time using the cron
+   * expression. The version time must be in UTC timzeone.
+   *
+   * The backup will contain an externally consistent copy of the
+   * database at the version time. Allowed frequencies are 12 hour, 1 day,
+   * 1 week and 1 month. Examples of valid cron specifications:
+   *   * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
+   *   * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
+   *   * `0 2 * * * `    : once a day at 2 past midnight in UTC.
+   *   * `0 2 * * 0 `    : once a week every Sunday at 2 past midnight in UTC.
+   *   * `0 2 8 * * `    : once a month on 8th day at 2 past midnight in UTC.
+   * 
+ * + * string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The text. + */ + java.lang.String getText(); + /** + * + * + *
+   * Required. Textual representation of the crontab. User can customize the
+   * backup frequency and the backup version time using the cron
+   * expression. The version time must be in UTC timzeone.
+   *
+   * The backup will contain an externally consistent copy of the
+   * database at the version time. Allowed frequencies are 12 hour, 1 day,
+   * 1 week and 1 month. Examples of valid cron specifications:
+   *   * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC.
+   *   * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC.
+   *   * `0 2 * * * `    : once a day at 2 past midnight in UTC.
+   *   * `0 2 * * 0 `    : once a week every Sunday at 2 past midnight in UTC.
+   *   * `0 2 8 * * `    : once a month on 8th day at 2 past midnight in UTC.
+   * 
+ * + * string text = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * @return The bytes for text. + */ + com.google.protobuf.ByteString getTextBytes(); + + /** + * + * + *
+   * Output only. The time zone of the times in `CrontabSpec.text`. Currently
+   * only UTC is supported.
+   * 
+ * + * string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The timeZone. + */ + java.lang.String getTimeZone(); + /** + * + * + *
+   * Output only. The time zone of the times in `CrontabSpec.text`. Currently
+   * only UTC is supported.
+   * 
+ * + * string time_zone = 2 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * @return The bytes for timeZone. + */ + com.google.protobuf.ByteString getTimeZoneBytes(); + + /** + * + * + *
+   * Output only. Schedule backups will contain an externally consistent copy
+   * of the database at the version time specified in
+   * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+   * of the scheduled backups at that version time. Spanner will initiate
+   * the creation of scheduled backups within the time window bounded by the
+   * version_time specified in `schedule_spec.cron_spec` and version_time +
+   * `creation_window`.
+   * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return Whether the creationWindow field is set. + */ + boolean hasCreationWindow(); + /** + * + * + *
+   * Output only. Schedule backups will contain an externally consistent copy
+   * of the database at the version time specified in
+   * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+   * of the scheduled backups at that version time. Spanner will initiate
+   * the creation of scheduled backups within the time window bounded by the
+   * version_time specified in `schedule_spec.cron_spec` and version_time +
+   * `creation_window`.
+   * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + * + * @return The creationWindow. + */ + com.google.protobuf.Duration getCreationWindow(); + /** + * + * + *
+   * Output only. Schedule backups will contain an externally consistent copy
+   * of the database at the version time specified in
+   * `schedule_spec.cron_spec`. However, Spanner may not initiate the creation
+   * of the scheduled backups at that version time. Spanner will initiate
+   * the creation of scheduled backups within the time window bounded by the
+   * version_time specified in `schedule_spec.cron_spec` and version_time +
+   * `creation_window`.
+   * 
+ * + * + * .google.protobuf.Duration creation_window = 3 [(.google.api.field_behavior) = OUTPUT_ONLY]; + * + */ + com.google.protobuf.DurationOrBuilder getCreationWindowOrBuilder(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DeleteBackupScheduleRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DeleteBackupScheduleRequest.java new file mode 100644 index 00000000000..f015c243bf2 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DeleteBackupScheduleRequest.java @@ -0,0 +1,663 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * The request for
+ * [DeleteBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackupSchedule].
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.DeleteBackupScheduleRequest} + */ +public final class DeleteBackupScheduleRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.DeleteBackupScheduleRequest) + DeleteBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use DeleteBackupScheduleRequest.newBuilder() to construct. + private DeleteBackupScheduleRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private DeleteBackupScheduleRequest() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new DeleteBackupScheduleRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_DeleteBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_DeleteBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest.class, + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Required. The name of the schedule to delete.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The name of the schedule to delete.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.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.spanner.admin.database.v1.DeleteBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest other = + (com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest 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.spanner.admin.database.v1.DeleteBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest 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.spanner.admin.database.v1.DeleteBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest 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.spanner.admin.database.v1.DeleteBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [DeleteBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackupSchedule].
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.DeleteBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.DeleteBackupScheduleRequest) + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_DeleteBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_DeleteBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest.class, + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest.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.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_DeleteBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest + getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest build() { + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest buildPartial() { + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest result = + new com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest 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.spanner.admin.database.v1.DeleteBackupScheduleRequest) { + return mergeFrom((com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest other) { + if (other + == com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Required. The name of the schedule to delete.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The name of the schedule to delete.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The name of the schedule to delete.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the schedule to delete.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the schedule to delete.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @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.spanner.admin.database.v1.DeleteBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.DeleteBackupScheduleRequest) + private static final com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest(); + } + + public static com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public DeleteBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.DeleteBackupScheduleRequest + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DeleteBackupScheduleRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DeleteBackupScheduleRequestOrBuilder.java new file mode 100644 index 00000000000..5cf1ecb4f55 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/DeleteBackupScheduleRequestOrBuilder.java @@ -0,0 +1,59 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface DeleteBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.DeleteBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the schedule to delete.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Required. The name of the schedule to delete.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/FullBackupSpec.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/FullBackupSpec.java new file mode 100644 index 00000000000..9a8af831031 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/FullBackupSpec.java @@ -0,0 +1,436 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * The specification for full backups.
+ * A full backup stores the entire contents of the database at a given
+ * version time.
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.FullBackupSpec} + */ +public final class FullBackupSpec extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.FullBackupSpec) + FullBackupSpecOrBuilder { + private static final long serialVersionUID = 0L; + // Use FullBackupSpec.newBuilder() to construct. + private FullBackupSpec(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private FullBackupSpec() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new FullBackupSpec(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_FullBackupSpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_FullBackupSpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.FullBackupSpec.class, + com.google.spanner.admin.database.v1.FullBackupSpec.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.spanner.admin.database.v1.FullBackupSpec)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.FullBackupSpec other = + (com.google.spanner.admin.database.v1.FullBackupSpec) 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.spanner.admin.database.v1.FullBackupSpec parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.FullBackupSpec parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.FullBackupSpec parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.FullBackupSpec 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.spanner.admin.database.v1.FullBackupSpec parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.FullBackupSpec parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.FullBackupSpec parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.FullBackupSpec 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.spanner.admin.database.v1.FullBackupSpec parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.FullBackupSpec 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.spanner.admin.database.v1.FullBackupSpec parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.FullBackupSpec 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.spanner.admin.database.v1.FullBackupSpec 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 specification for full backups.
+   * A full backup stores the entire contents of the database at a given
+   * version time.
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.FullBackupSpec} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.FullBackupSpec) + com.google.spanner.admin.database.v1.FullBackupSpecOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_FullBackupSpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_FullBackupSpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.FullBackupSpec.class, + com.google.spanner.admin.database.v1.FullBackupSpec.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.FullBackupSpec.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.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_FullBackupSpec_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.FullBackupSpec getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.FullBackupSpec.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.FullBackupSpec build() { + com.google.spanner.admin.database.v1.FullBackupSpec result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.FullBackupSpec buildPartial() { + com.google.spanner.admin.database.v1.FullBackupSpec result = + new com.google.spanner.admin.database.v1.FullBackupSpec(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.spanner.admin.database.v1.FullBackupSpec) { + return mergeFrom((com.google.spanner.admin.database.v1.FullBackupSpec) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.spanner.admin.database.v1.FullBackupSpec other) { + if (other == com.google.spanner.admin.database.v1.FullBackupSpec.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.spanner.admin.database.v1.FullBackupSpec) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.FullBackupSpec) + private static final com.google.spanner.admin.database.v1.FullBackupSpec DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.FullBackupSpec(); + } + + public static com.google.spanner.admin.database.v1.FullBackupSpec getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public FullBackupSpec 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.spanner.admin.database.v1.FullBackupSpec getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/FullBackupSpecOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/FullBackupSpecOrBuilder.java new file mode 100644 index 00000000000..d7e604faeac --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/FullBackupSpecOrBuilder.java @@ -0,0 +1,25 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface FullBackupSpecOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.FullBackupSpec) + com.google.protobuf.MessageOrBuilder {} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetBackupScheduleRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetBackupScheduleRequest.java new file mode 100644 index 00000000000..3f7b923b3f6 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetBackupScheduleRequest.java @@ -0,0 +1,660 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * The request for
+ * [GetBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.GetBackupSchedule].
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.GetBackupScheduleRequest} + */ +public final class GetBackupScheduleRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.GetBackupScheduleRequest) + GetBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use GetBackupScheduleRequest.newBuilder() to construct. + private GetBackupScheduleRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private GetBackupScheduleRequest() { + name_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new GetBackupScheduleRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_GetBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_GetBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.GetBackupScheduleRequest.class, + com.google.spanner.admin.database.v1.GetBackupScheduleRequest.Builder.class); + } + + public static final int NAME_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object name_ = ""; + /** + * + * + *
+   * Required. The name of the schedule to retrieve.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + @java.lang.Override + public java.lang.String getName() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } + } + /** + * + * + *
+   * Required. The name of the schedule to retrieve.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + @java.lang.Override + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (!com.google.protobuf.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.spanner.admin.database.v1.GetBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.GetBackupScheduleRequest other = + (com.google.spanner.admin.database.v1.GetBackupScheduleRequest) obj; + + if (!getName().equals(other.getName())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + NAME_FIELD_NUMBER; + hash = (53 * hash) + getName().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest 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.spanner.admin.database.v1.GetBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest 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.spanner.admin.database.v1.GetBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest 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.spanner.admin.database.v1.GetBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [GetBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.GetBackupSchedule].
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.GetBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.GetBackupScheduleRequest) + com.google.spanner.admin.database.v1.GetBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_GetBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_GetBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.GetBackupScheduleRequest.class, + com.google.spanner.admin.database.v1.GetBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.GetBackupScheduleRequest.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.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_GetBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.GetBackupScheduleRequest + getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.GetBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.GetBackupScheduleRequest build() { + com.google.spanner.admin.database.v1.GetBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.GetBackupScheduleRequest buildPartial() { + com.google.spanner.admin.database.v1.GetBackupScheduleRequest result = + new com.google.spanner.admin.database.v1.GetBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.spanner.admin.database.v1.GetBackupScheduleRequest 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.spanner.admin.database.v1.GetBackupScheduleRequest) { + return mergeFrom((com.google.spanner.admin.database.v1.GetBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.spanner.admin.database.v1.GetBackupScheduleRequest other) { + if (other + == com.google.spanner.admin.database.v1.GetBackupScheduleRequest.getDefaultInstance()) + return this; + if (!other.getName().isEmpty()) { + name_ = other.name_; + bitField0_ |= 0x00000001; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + name_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + done = true; // was an endgroup tag + } + break; + } // default: + } // switch (tag) + } // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } // finally + return this; + } + + private int bitField0_; + + private java.lang.Object name_ = ""; + /** + * + * + *
+     * Required. The name of the schedule to retrieve.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + public java.lang.String getName() { + java.lang.Object ref = name_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + name_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. The name of the schedule to retrieve.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + public com.google.protobuf.ByteString getNameBytes() { + java.lang.Object ref = name_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + name_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. The name of the schedule to retrieve.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The name to set. + * @return This builder for chaining. + */ + public Builder setName(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the schedule to retrieve.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearName() { + name_ = getDefaultInstance().getName(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The name of the schedule to retrieve.
+     * Values are of the form
+     * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+     * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for name to set. + * @return This builder for chaining. + */ + public Builder setNameBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + name_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + @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.spanner.admin.database.v1.GetBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.GetBackupScheduleRequest) + private static final com.google.spanner.admin.database.v1.GetBackupScheduleRequest + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.GetBackupScheduleRequest(); + } + + public static com.google.spanner.admin.database.v1.GetBackupScheduleRequest getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public GetBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.GetBackupScheduleRequest getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetBackupScheduleRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetBackupScheduleRequestOrBuilder.java new file mode 100644 index 00000000000..16539d3a894 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/GetBackupScheduleRequestOrBuilder.java @@ -0,0 +1,59 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface GetBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.GetBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The name of the schedule to retrieve.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The name. + */ + java.lang.String getName(); + /** + * + * + *
+   * Required. The name of the schedule to retrieve.
+   * Values are of the form
+   * `projects/<project>/instances/<instance>/databases/<database>/backupSchedules/<backup_schedule_id>`.
+   * 
+ * + * + * string name = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for name. + */ + com.google.protobuf.ByteString getNameBytes(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/IncrementalBackupSpec.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/IncrementalBackupSpec.java new file mode 100644 index 00000000000..36a605c8aad --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/IncrementalBackupSpec.java @@ -0,0 +1,443 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * The specification for incremental backup chains.
+ * An incremental backup stores the delta of changes between a previous
+ * backup and the database contents at a given version time. An
+ * incremental backup chain consists of a full backup and zero or more
+ * successive incremental backups. The first backup created for an
+ * incremental backup chain is always a full backup.
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.IncrementalBackupSpec} + */ +public final class IncrementalBackupSpec extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.IncrementalBackupSpec) + IncrementalBackupSpecOrBuilder { + private static final long serialVersionUID = 0L; + // Use IncrementalBackupSpec.newBuilder() to construct. + private IncrementalBackupSpec(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private IncrementalBackupSpec() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new IncrementalBackupSpec(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_IncrementalBackupSpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_IncrementalBackupSpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.IncrementalBackupSpec.class, + com.google.spanner.admin.database.v1.IncrementalBackupSpec.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.spanner.admin.database.v1.IncrementalBackupSpec)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.IncrementalBackupSpec other = + (com.google.spanner.admin.database.v1.IncrementalBackupSpec) 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.spanner.admin.database.v1.IncrementalBackupSpec parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.IncrementalBackupSpec parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.IncrementalBackupSpec parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.IncrementalBackupSpec 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.spanner.admin.database.v1.IncrementalBackupSpec parseFrom(byte[] data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.IncrementalBackupSpec parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.IncrementalBackupSpec parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.IncrementalBackupSpec 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.spanner.admin.database.v1.IncrementalBackupSpec parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.IncrementalBackupSpec 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.spanner.admin.database.v1.IncrementalBackupSpec parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.IncrementalBackupSpec 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.spanner.admin.database.v1.IncrementalBackupSpec 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 specification for incremental backup chains.
+   * An incremental backup stores the delta of changes between a previous
+   * backup and the database contents at a given version time. An
+   * incremental backup chain consists of a full backup and zero or more
+   * successive incremental backups. The first backup created for an
+   * incremental backup chain is always a full backup.
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.IncrementalBackupSpec} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.IncrementalBackupSpec) + com.google.spanner.admin.database.v1.IncrementalBackupSpecOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_IncrementalBackupSpec_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_IncrementalBackupSpec_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.IncrementalBackupSpec.class, + com.google.spanner.admin.database.v1.IncrementalBackupSpec.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.IncrementalBackupSpec.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.spanner.admin.database.v1.BackupProto + .internal_static_google_spanner_admin_database_v1_IncrementalBackupSpec_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.IncrementalBackupSpec getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.IncrementalBackupSpec.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.IncrementalBackupSpec build() { + com.google.spanner.admin.database.v1.IncrementalBackupSpec result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.IncrementalBackupSpec buildPartial() { + com.google.spanner.admin.database.v1.IncrementalBackupSpec result = + new com.google.spanner.admin.database.v1.IncrementalBackupSpec(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.spanner.admin.database.v1.IncrementalBackupSpec) { + return mergeFrom((com.google.spanner.admin.database.v1.IncrementalBackupSpec) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(com.google.spanner.admin.database.v1.IncrementalBackupSpec other) { + if (other == com.google.spanner.admin.database.v1.IncrementalBackupSpec.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.spanner.admin.database.v1.IncrementalBackupSpec) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.IncrementalBackupSpec) + private static final com.google.spanner.admin.database.v1.IncrementalBackupSpec DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.IncrementalBackupSpec(); + } + + public static com.google.spanner.admin.database.v1.IncrementalBackupSpec getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public IncrementalBackupSpec 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.spanner.admin.database.v1.IncrementalBackupSpec getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/IncrementalBackupSpecOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/IncrementalBackupSpecOrBuilder.java new file mode 100644 index 00000000000..fa0ee3f7e71 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/IncrementalBackupSpecOrBuilder.java @@ -0,0 +1,25 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface IncrementalBackupSpecOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.IncrementalBackupSpec) + com.google.protobuf.MessageOrBuilder {} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesRequest.java new file mode 100644 index 00000000000..01a82d606c7 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesRequest.java @@ -0,0 +1,970 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * The request for
+ * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules].
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.ListBackupSchedulesRequest} + */ +public final class ListBackupSchedulesRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.ListBackupSchedulesRequest) + ListBackupSchedulesRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListBackupSchedulesRequest.newBuilder() to construct. + private ListBackupSchedulesRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListBackupSchedulesRequest() { + parent_ = ""; + pageToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListBackupSchedulesRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_ListBackupSchedulesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_ListBackupSchedulesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest.class, + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest.Builder.class); + } + + public static final int PARENT_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private volatile java.lang.Object parent_ = ""; + /** + * + * + *
+   * Required. Database is the parent resource whose backup schedules should be
+   * listed. Values are of the form
+   * projects/<project>/instances/<instance>/databases/<database>
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + @java.lang.Override + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } + } + /** + * + * + *
+   * Required. Database is the parent resource whose backup schedules should be
+   * listed. Values are of the form
+   * projects/<project>/instances/<instance>/databases/<database>
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + @java.lang.Override + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + public static final int PAGE_SIZE_FIELD_NUMBER = 2; + private int pageSize_ = 0; + /** + * + * + *
+   * Optional. Number of backup schedules to be returned in the response. If 0
+   * or less, defaults to the server's maximum allowed page size.
+   * 
+ * + * int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + + public static final int PAGE_TOKEN_FIELD_NUMBER = 4; + + @SuppressWarnings("serial") + private volatile java.lang.Object pageToken_ = ""; + /** + * + * + *
+   * Optional. If non-empty, `page_token` should contain a
+   * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
+   * from a previous
+   * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
+   * to the same `parent`.
+   * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageToken. + */ + @java.lang.Override + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } + } + /** + * + * + *
+   * Optional. If non-empty, `page_token` should contain a
+   * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
+   * from a previous
+   * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
+   * to the same `parent`.
+   * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for pageToken. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + 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(parent_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 1, parent_); + } + if (pageSize_ != 0) { + output.writeInt32(2, pageSize_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 4, pageToken_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(parent_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(1, parent_); + } + if (pageSize_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeInt32Size(2, pageSize_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(pageToken_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(4, pageToken_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.spanner.admin.database.v1.ListBackupSchedulesRequest)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest other = + (com.google.spanner.admin.database.v1.ListBackupSchedulesRequest) obj; + + if (!getParent().equals(other.getParent())) return false; + if (getPageSize() != other.getPageSize()) return false; + if (!getPageToken().equals(other.getPageToken())) return false; + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + PARENT_FIELD_NUMBER; + hash = (53 * hash) + getParent().hashCode(); + hash = (37 * hash) + 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.spanner.admin.database.v1.ListBackupSchedulesRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesRequest parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesRequest 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.spanner.admin.database.v1.ListBackupSchedulesRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesRequest 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.spanner.admin.database.v1.ListBackupSchedulesRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesRequest 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.spanner.admin.database.v1.ListBackupSchedulesRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules].
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.ListBackupSchedulesRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.ListBackupSchedulesRequest) + com.google.spanner.admin.database.v1.ListBackupSchedulesRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_ListBackupSchedulesRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_ListBackupSchedulesRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest.class, + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.ListBackupSchedulesRequest.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + parent_ = ""; + pageSize_ = 0; + pageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_ListBackupSchedulesRequest_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.ListBackupSchedulesRequest + getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.ListBackupSchedulesRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.ListBackupSchedulesRequest build() { + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.ListBackupSchedulesRequest buildPartial() { + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest result = + new com.google.spanner.admin.database.v1.ListBackupSchedulesRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.parent_ = parent_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.pageSize_ = pageSize_; + } + if (((from_bitField0_ & 0x00000004) != 0)) { + result.pageToken_ = pageToken_; + } + } + + @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.spanner.admin.database.v1.ListBackupSchedulesRequest) { + return mergeFrom((com.google.spanner.admin.database.v1.ListBackupSchedulesRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.spanner.admin.database.v1.ListBackupSchedulesRequest other) { + if (other + == com.google.spanner.admin.database.v1.ListBackupSchedulesRequest.getDefaultInstance()) + return this; + if (!other.getParent().isEmpty()) { + parent_ = other.parent_; + bitField0_ |= 0x00000001; + onChanged(); + } + if (other.getPageSize() != 0) { + setPageSize(other.getPageSize()); + } + if (!other.getPageToken().isEmpty()) { + pageToken_ = other.pageToken_; + bitField0_ |= 0x00000004; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + parent_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 16: + { + pageSize_ = input.readInt32(); + bitField0_ |= 0x00000002; + break; + } // case 16 + case 34: + { + pageToken_ = 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 parent_ = ""; + /** + * + * + *
+     * Required. Database is the parent resource whose backup schedules should be
+     * listed. Values are of the form
+     * projects/<project>/instances/<instance>/databases/<database>
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + public java.lang.String getParent() { + java.lang.Object ref = parent_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + parent_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Required. Database is the parent resource whose backup schedules should be
+     * listed. Values are of the form
+     * projects/<project>/instances/<instance>/databases/<database>
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + public com.google.protobuf.ByteString getParentBytes() { + java.lang.Object ref = parent_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + parent_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Required. Database is the parent resource whose backup schedules should be
+     * listed. Values are of the form
+     * projects/<project>/instances/<instance>/databases/<database>
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The parent to set. + * @return This builder for chaining. + */ + public Builder setParent(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Database is the parent resource whose backup schedules should be
+     * listed. Values are of the form
+     * projects/<project>/instances/<instance>/databases/<database>
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return This builder for chaining. + */ + public Builder clearParent() { + parent_ = getDefaultInstance().getParent(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * Required. Database is the parent resource whose backup schedules should be
+     * listed. Values are of the form
+     * projects/<project>/instances/<instance>/databases/<database>
+     * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @param value The bytes for parent to set. + * @return This builder for chaining. + */ + public Builder setParentBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + parent_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + private int pageSize_; + /** + * + * + *
+     * Optional. Number of backup schedules to be returned in the response. If 0
+     * or less, defaults to the server's maximum allowed page size.
+     * 
+ * + * int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageSize. + */ + @java.lang.Override + public int getPageSize() { + return pageSize_; + } + /** + * + * + *
+     * Optional. Number of backup schedules to be returned in the response. If 0
+     * or less, defaults to the server's maximum allowed page size.
+     * 
+ * + * int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The pageSize to set. + * @return This builder for chaining. + */ + public Builder setPageSize(int value) { + + pageSize_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. Number of backup schedules to be returned in the response. If 0
+     * or less, defaults to the server's maximum allowed page size.
+     * 
+ * + * int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearPageSize() { + bitField0_ = (bitField0_ & ~0x00000002); + pageSize_ = 0; + onChanged(); + return this; + } + + private java.lang.Object pageToken_ = ""; + /** + * + * + *
+     * Optional. If non-empty, `page_token` should contain a
+     * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
+     * from a previous
+     * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
+     * to the same `parent`.
+     * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageToken. + */ + public java.lang.String getPageToken() { + java.lang.Object ref = pageToken_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + pageToken_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + /** + * + * + *
+     * Optional. If non-empty, `page_token` should contain a
+     * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
+     * from a previous
+     * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
+     * to the same `parent`.
+     * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for pageToken. + */ + public com.google.protobuf.ByteString getPageTokenBytes() { + java.lang.Object ref = pageToken_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = + com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + pageToken_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + /** + * + * + *
+     * Optional. If non-empty, `page_token` should contain a
+     * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
+     * from a previous
+     * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
+     * to the same `parent`.
+     * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageToken(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + pageToken_ = value; + bitField0_ |= 0x00000004; + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. If non-empty, `page_token` should contain a
+     * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
+     * from a previous
+     * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
+     * to the same `parent`.
+     * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return This builder for chaining. + */ + public Builder clearPageToken() { + pageToken_ = getDefaultInstance().getPageToken(); + bitField0_ = (bitField0_ & ~0x00000004); + onChanged(); + return this; + } + /** + * + * + *
+     * Optional. If non-empty, `page_token` should contain a
+     * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
+     * from a previous
+     * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
+     * to the same `parent`.
+     * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @param value The bytes for pageToken to set. + * @return This builder for chaining. + */ + public Builder setPageTokenBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + pageToken_ = value; + bitField0_ |= 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.spanner.admin.database.v1.ListBackupSchedulesRequest) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListBackupSchedulesRequest) + private static final com.google.spanner.admin.database.v1.ListBackupSchedulesRequest + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.ListBackupSchedulesRequest(); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesRequest + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListBackupSchedulesRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.ListBackupSchedulesRequest + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesRequestOrBuilder.java new file mode 100644 index 00000000000..84d6c2fcfcf --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesRequestOrBuilder.java @@ -0,0 +1,106 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 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/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface ListBackupSchedulesRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.ListBackupSchedulesRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. Database is the parent resource whose backup schedules should be
+   * listed. Values are of the form
+   * projects/<project>/instances/<instance>/databases/<database>
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The parent. + */ + java.lang.String getParent(); + /** + * + * + *
+   * Required. Database is the parent resource whose backup schedules should be
+   * listed. Values are of the form
+   * projects/<project>/instances/<instance>/databases/<database>
+   * 
+ * + * + * string parent = 1 [(.google.api.field_behavior) = REQUIRED, (.google.api.resource_reference) = { ... } + * + * + * @return The bytes for parent. + */ + com.google.protobuf.ByteString getParentBytes(); + + /** + * + * + *
+   * Optional. Number of backup schedules to be returned in the response. If 0
+   * or less, defaults to the server's maximum allowed page size.
+   * 
+ * + * int32 page_size = 2 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageSize. + */ + int getPageSize(); + + /** + * + * + *
+   * Optional. If non-empty, `page_token` should contain a
+   * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
+   * from a previous
+   * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
+   * to the same `parent`.
+   * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The pageToken. + */ + java.lang.String getPageToken(); + /** + * + * + *
+   * Optional. If non-empty, `page_token` should contain a
+   * [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token]
+   * from a previous
+   * [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse]
+   * to the same `parent`.
+   * 
+ * + * string page_token = 4 [(.google.api.field_behavior) = OPTIONAL]; + * + * @return The bytes for pageToken. + */ + com.google.protobuf.ByteString getPageTokenBytes(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesResponse.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesResponse.java new file mode 100644 index 00000000000..14db767e7bf --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesResponse.java @@ -0,0 +1,1158 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * The response for
+ * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules].
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.ListBackupSchedulesResponse} + */ +public final class ListBackupSchedulesResponse extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.ListBackupSchedulesResponse) + ListBackupSchedulesResponseOrBuilder { + private static final long serialVersionUID = 0L; + // Use ListBackupSchedulesResponse.newBuilder() to construct. + private ListBackupSchedulesResponse(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private ListBackupSchedulesResponse() { + backupSchedules_ = java.util.Collections.emptyList(); + nextPageToken_ = ""; + } + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new ListBackupSchedulesResponse(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_ListBackupSchedulesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_ListBackupSchedulesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse.class, + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse.Builder.class); + } + + public static final int BACKUP_SCHEDULES_FIELD_NUMBER = 1; + + @SuppressWarnings("serial") + private java.util.List backupSchedules_; + /** + * + * + *
+   * The list of backup schedules for a database.
+   * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public java.util.List + getBackupSchedulesList() { + return backupSchedules_; + } + /** + * + * + *
+   * The list of backup schedules for a database.
+   * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public java.util.List + getBackupSchedulesOrBuilderList() { + return backupSchedules_; + } + /** + * + * + *
+   * The list of backup schedules for a database.
+   * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public int getBackupSchedulesCount() { + return backupSchedules_.size(); + } + /** + * + * + *
+   * The list of backup schedules for a database.
+   * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupSchedule getBackupSchedules(int index) { + return backupSchedules_.get(index); + } + /** + * + * + *
+   * The list of backup schedules for a database.
+   * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupScheduleOrBuilder getBackupSchedulesOrBuilder( + int index) { + return backupSchedules_.get(index); + } + + public static final int NEXT_PAGE_TOKEN_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object nextPageToken_ = ""; + /** + * + * + *
+   * `next_page_token` can be sent in a subsequent
+   * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
+   * call to fetch more of the schedules.
+   * 
+ * + * 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; + } + } + /** + * + * + *
+   * `next_page_token` can be sent in a subsequent
+   * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
+   * call to fetch more of the schedules.
+   * 
+ * + * 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 < backupSchedules_.size(); i++) { + output.writeMessage(1, backupSchedules_.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 < backupSchedules_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, backupSchedules_.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.spanner.admin.database.v1.ListBackupSchedulesResponse)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse other = + (com.google.spanner.admin.database.v1.ListBackupSchedulesResponse) obj; + + if (!getBackupSchedulesList().equals(other.getBackupSchedulesList())) 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 (getBackupSchedulesCount() > 0) { + hash = (37 * hash) + BACKUP_SCHEDULES_FIELD_NUMBER; + hash = (53 * hash) + getBackupSchedulesList().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.spanner.admin.database.v1.ListBackupSchedulesResponse parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesResponse parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesResponse parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesResponse parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesResponse parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesResponse 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.spanner.admin.database.v1.ListBackupSchedulesResponse parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesResponse 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.spanner.admin.database.v1.ListBackupSchedulesResponse parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesResponse 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.spanner.admin.database.v1.ListBackupSchedulesResponse prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The response for
+   * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules].
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.ListBackupSchedulesResponse} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.ListBackupSchedulesResponse) + com.google.spanner.admin.database.v1.ListBackupSchedulesResponseOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_ListBackupSchedulesResponse_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_ListBackupSchedulesResponse_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse.class, + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.ListBackupSchedulesResponse.newBuilder() + private Builder() {} + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + if (backupSchedulesBuilder_ == null) { + backupSchedules_ = java.util.Collections.emptyList(); + } else { + backupSchedules_ = null; + backupSchedulesBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000001); + nextPageToken_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_ListBackupSchedulesResponse_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.ListBackupSchedulesResponse + getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.ListBackupSchedulesResponse.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.ListBackupSchedulesResponse build() { + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.ListBackupSchedulesResponse buildPartial() { + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse result = + new com.google.spanner.admin.database.v1.ListBackupSchedulesResponse(this); + buildPartialRepeatedFields(result); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartialRepeatedFields( + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse result) { + if (backupSchedulesBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0)) { + backupSchedules_ = java.util.Collections.unmodifiableList(backupSchedules_); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.backupSchedules_ = backupSchedules_; + } else { + result.backupSchedules_ = backupSchedulesBuilder_.build(); + } + } + + private void buildPartial0( + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse 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.spanner.admin.database.v1.ListBackupSchedulesResponse) { + return mergeFrom((com.google.spanner.admin.database.v1.ListBackupSchedulesResponse) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.spanner.admin.database.v1.ListBackupSchedulesResponse other) { + if (other + == com.google.spanner.admin.database.v1.ListBackupSchedulesResponse.getDefaultInstance()) + return this; + if (backupSchedulesBuilder_ == null) { + if (!other.backupSchedules_.isEmpty()) { + if (backupSchedules_.isEmpty()) { + backupSchedules_ = other.backupSchedules_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureBackupSchedulesIsMutable(); + backupSchedules_.addAll(other.backupSchedules_); + } + onChanged(); + } + } else { + if (!other.backupSchedules_.isEmpty()) { + if (backupSchedulesBuilder_.isEmpty()) { + backupSchedulesBuilder_.dispose(); + backupSchedulesBuilder_ = null; + backupSchedules_ = other.backupSchedules_; + bitField0_ = (bitField0_ & ~0x00000001); + backupSchedulesBuilder_ = + com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders + ? getBackupSchedulesFieldBuilder() + : null; + } else { + backupSchedulesBuilder_.addAllMessages(other.backupSchedules_); + } + } + } + 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.spanner.admin.database.v1.BackupSchedule m = + input.readMessage( + com.google.spanner.admin.database.v1.BackupSchedule.parser(), + extensionRegistry); + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(m); + } else { + backupSchedulesBuilder_.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 backupSchedules_ = + java.util.Collections.emptyList(); + + private void ensureBackupSchedulesIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + backupSchedules_ = + new java.util.ArrayList( + backupSchedules_); + bitField0_ |= 0x00000001; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupSchedule, + com.google.spanner.admin.database.v1.BackupSchedule.Builder, + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder> + backupSchedulesBuilder_; + + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public java.util.List + getBackupSchedulesList() { + if (backupSchedulesBuilder_ == null) { + return java.util.Collections.unmodifiableList(backupSchedules_); + } else { + return backupSchedulesBuilder_.getMessageList(); + } + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public int getBackupSchedulesCount() { + if (backupSchedulesBuilder_ == null) { + return backupSchedules_.size(); + } else { + return backupSchedulesBuilder_.getCount(); + } + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.spanner.admin.database.v1.BackupSchedule getBackupSchedules(int index) { + if (backupSchedulesBuilder_ == null) { + return backupSchedules_.get(index); + } else { + return backupSchedulesBuilder_.getMessage(index); + } + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public Builder setBackupSchedules( + int index, com.google.spanner.admin.database.v1.BackupSchedule value) { + if (backupSchedulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.set(index, value); + onChanged(); + } else { + backupSchedulesBuilder_.setMessage(index, value); + } + return this; + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public Builder setBackupSchedules( + int index, com.google.spanner.admin.database.v1.BackupSchedule.Builder builderForValue) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.set(index, builderForValue.build()); + onChanged(); + } else { + backupSchedulesBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules(com.google.spanner.admin.database.v1.BackupSchedule value) { + if (backupSchedulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(value); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(value); + } + return this; + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules( + int index, com.google.spanner.admin.database.v1.BackupSchedule value) { + if (backupSchedulesBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(index, value); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(index, value); + } + return this; + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules( + com.google.spanner.admin.database.v1.BackupSchedule.Builder builderForValue) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(builderForValue.build()); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addBackupSchedules( + int index, com.google.spanner.admin.database.v1.BackupSchedule.Builder builderForValue) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.add(index, builderForValue.build()); + onChanged(); + } else { + backupSchedulesBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public Builder addAllBackupSchedules( + java.lang.Iterable values) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, backupSchedules_); + onChanged(); + } else { + backupSchedulesBuilder_.addAllMessages(values); + } + return this; + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public Builder clearBackupSchedules() { + if (backupSchedulesBuilder_ == null) { + backupSchedules_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + } else { + backupSchedulesBuilder_.clear(); + } + return this; + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public Builder removeBackupSchedules(int index) { + if (backupSchedulesBuilder_ == null) { + ensureBackupSchedulesIsMutable(); + backupSchedules_.remove(index); + onChanged(); + } else { + backupSchedulesBuilder_.remove(index); + } + return this; + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.spanner.admin.database.v1.BackupSchedule.Builder getBackupSchedulesBuilder( + int index) { + return getBackupSchedulesFieldBuilder().getBuilder(index); + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.spanner.admin.database.v1.BackupScheduleOrBuilder getBackupSchedulesOrBuilder( + int index) { + if (backupSchedulesBuilder_ == null) { + return backupSchedules_.get(index); + } else { + return backupSchedulesBuilder_.getMessageOrBuilder(index); + } + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public java.util.List + getBackupSchedulesOrBuilderList() { + if (backupSchedulesBuilder_ != null) { + return backupSchedulesBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(backupSchedules_); + } + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.spanner.admin.database.v1.BackupSchedule.Builder addBackupSchedulesBuilder() { + return getBackupSchedulesFieldBuilder() + .addBuilder(com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance()); + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public com.google.spanner.admin.database.v1.BackupSchedule.Builder addBackupSchedulesBuilder( + int index) { + return getBackupSchedulesFieldBuilder() + .addBuilder( + index, com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance()); + } + /** + * + * + *
+     * The list of backup schedules for a database.
+     * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + public java.util.List + getBackupSchedulesBuilderList() { + return getBackupSchedulesFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupSchedule, + com.google.spanner.admin.database.v1.BackupSchedule.Builder, + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder> + getBackupSchedulesFieldBuilder() { + if (backupSchedulesBuilder_ == null) { + backupSchedulesBuilder_ = + new com.google.protobuf.RepeatedFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupSchedule, + com.google.spanner.admin.database.v1.BackupSchedule.Builder, + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder>( + backupSchedules_, + ((bitField0_ & 0x00000001) != 0), + getParentForChildren(), + isClean()); + backupSchedules_ = null; + } + return backupSchedulesBuilder_; + } + + private java.lang.Object nextPageToken_ = ""; + /** + * + * + *
+     * `next_page_token` can be sent in a subsequent
+     * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
+     * call to fetch more of the schedules.
+     * 
+ * + * 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; + } + } + /** + * + * + *
+     * `next_page_token` can be sent in a subsequent
+     * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
+     * call to fetch more of the schedules.
+     * 
+ * + * 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; + } + } + /** + * + * + *
+     * `next_page_token` can be sent in a subsequent
+     * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
+     * call to fetch more of the schedules.
+     * 
+ * + * 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; + } + /** + * + * + *
+     * `next_page_token` can be sent in a subsequent
+     * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
+     * call to fetch more of the schedules.
+     * 
+ * + * string next_page_token = 2; + * + * @return This builder for chaining. + */ + public Builder clearNextPageToken() { + nextPageToken_ = getDefaultInstance().getNextPageToken(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + /** + * + * + *
+     * `next_page_token` can be sent in a subsequent
+     * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
+     * call to fetch more of the schedules.
+     * 
+ * + * 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.spanner.admin.database.v1.ListBackupSchedulesResponse) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListBackupSchedulesResponse) + private static final com.google.spanner.admin.database.v1.ListBackupSchedulesResponse + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.ListBackupSchedulesResponse(); + } + + public static com.google.spanner.admin.database.v1.ListBackupSchedulesResponse + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public ListBackupSchedulesResponse parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.ListBackupSchedulesResponse + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesResponseOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesResponseOrBuilder.java new file mode 100644 index 00000000000..c835805ec85 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/ListBackupSchedulesResponseOrBuilder.java @@ -0,0 +1,108 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface ListBackupSchedulesResponseOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.ListBackupSchedulesResponse) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * The list of backup schedules for a database.
+   * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + java.util.List getBackupSchedulesList(); + /** + * + * + *
+   * The list of backup schedules for a database.
+   * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + com.google.spanner.admin.database.v1.BackupSchedule getBackupSchedules(int index); + /** + * + * + *
+   * The list of backup schedules for a database.
+   * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + int getBackupSchedulesCount(); + /** + * + * + *
+   * The list of backup schedules for a database.
+   * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + java.util.List + getBackupSchedulesOrBuilderList(); + /** + * + * + *
+   * The list of backup schedules for a database.
+   * 
+ * + * repeated .google.spanner.admin.database.v1.BackupSchedule backup_schedules = 1; + */ + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder getBackupSchedulesOrBuilder( + int index); + + /** + * + * + *
+   * `next_page_token` can be sent in a subsequent
+   * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
+   * call to fetch more of the schedules.
+   * 
+ * + * string next_page_token = 2; + * + * @return The nextPageToken. + */ + java.lang.String getNextPageToken(); + /** + * + * + *
+   * `next_page_token` can be sent in a subsequent
+   * [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]
+   * call to fetch more of the schedules.
+   * 
+ * + * string next_page_token = 2; + * + * @return The bytes for nextPageToken. + */ + com.google.protobuf.ByteString getNextPageTokenBytes(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java index 8b78748dbe2..ab98cc3e295 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/SpannerDatabaseAdminProto.java @@ -144,262 +144,299 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "otobuf/empty.proto\032 google/protobuf/fiel" + "d_mask.proto\032\037google/protobuf/timestamp." + "proto\032-google/spanner/admin/database/v1/" - + "backup.proto\032-google/spanner/admin/datab" - + "ase/v1/common.proto\"\253\001\n\013RestoreInfo\022H\n\013s" - + "ource_type\030\001 \001(\01623.google.spanner.admin." - + "database.v1.RestoreSourceType\022C\n\013backup_" - + "info\030\002 \001(\0132,.google.spanner.admin.databa" - + "se.v1.BackupInfoH\000B\r\n\013source_info\"\312\006\n\010Da" - + "tabase\022\021\n\004name\030\001 \001(\tB\003\340A\002\022D\n\005state\030\002 \001(\016" - + "20.google.spanner.admin.database.v1.Data" - + "base.StateB\003\340A\003\0224\n\013create_time\030\003 \001(\0132\032.g" - + "oogle.protobuf.TimestampB\003\340A\003\022H\n\014restore" - + "_info\030\004 \001(\0132-.google.spanner.admin.datab" - + "ase.v1.RestoreInfoB\003\340A\003\022R\n\021encryption_co" - + "nfig\030\005 \001(\01322.google.spanner.admin.databa" - + "se.v1.EncryptionConfigB\003\340A\003\022N\n\017encryptio" - + "n_info\030\010 \003(\01320.google.spanner.admin.data" - + "base.v1.EncryptionInfoB\003\340A\003\022%\n\030version_r" - + "etention_period\030\006 \001(\tB\003\340A\003\022>\n\025earliest_v" - + "ersion_time\030\007 \001(\0132\032.google.protobuf.Time" - + "stampB\003\340A\003\022\033\n\016default_leader\030\t \001(\tB\003\340A\003\022" - + "P\n\020database_dialect\030\n \001(\01621.google.spann" - + "er.admin.database.v1.DatabaseDialectB\003\340A" - + "\003\022\036\n\026enable_drop_protection\030\013 \001(\010\022\030\n\013rec" - + "onciling\030\014 \001(\010B\003\340A\003\"M\n\005State\022\025\n\021STATE_UN" - + "SPECIFIED\020\000\022\014\n\010CREATING\020\001\022\t\n\005READY\020\002\022\024\n\020" - + "READY_OPTIMIZING\020\003:b\352A_\n\037spanner.googlea" - + "pis.com/Database\022\n\025earliest_version_time\030\007 \001(\0132\032.goog" + + "le.protobuf.TimestampB\003\340A\003\022\033\n\016default_le" + + "ader\030\t \001(\tB\003\340A\003\022P\n\020database_dialect\030\n \001(" + + "\01621.google.spanner.admin.database.v1.Dat" + + "abaseDialectB\003\340A\003\022\036\n\026enable_drop_protect" + + "ion\030\013 \001(\010\022\030\n\013reconciling\030\014 \001(\010B\003\340A\003\"M\n\005S" + + "tate\022\025\n\021STATE_UNSPECIFIED\020\000\022\014\n\010CREATING\020" + + "\001\022\t\n\005READY\020\002\022\024\n\020READY_OPTIMIZING\020\003:b\352A_\n" + + "\037spanner.googleapis.com/Database\022\332A\006parent\202\323" - + "\344\223\002/\022-/v1/{parent=projects/*/instances/*" - + "}/databases\022\244\002\n\016CreateDatabase\0227.google." - + "spanner.admin.database.v1.CreateDatabase" - + "Request\032\035.google.longrunning.Operation\"\271" - + "\001\312Ad\n)google.spanner.admin.database.v1.D" - + "atabase\0227google.spanner.admin.database.v" - + "1.CreateDatabaseMetadata\332A\027parent,create" - + "_statement\202\323\344\223\0022\"-/v1/{parent=projects/*" - + "/instances/*}/databases:\001*\022\255\001\n\013GetDataba" - + "se\0224.google.spanner.admin.database.v1.Ge" - + "tDatabaseRequest\032*.google.spanner.admin." - + "database.v1.Database\"<\332A\004name\202\323\344\223\002/\022-/v1" - + "/{name=projects/*/instances/*/databases/" - + "*}\022\357\001\n\016UpdateDatabase\0227.google.spanner.a" - + "dmin.database.v1.UpdateDatabaseRequest\032\035" - + ".google.longrunning.Operation\"\204\001\312A\"\n\010Dat" - + "abase\022\026UpdateDatabaseMetadata\332A\024database" - + ",update_mask\202\323\344\223\002B26/v1/{database.name=p" - + "rojects/*/instances/*/databases/*}:\010data" - + "base\022\235\002\n\021UpdateDatabaseDdl\022:.google.span" - + "ner.admin.database.v1.UpdateDatabaseDdlR" - + "equest\032\035.google.longrunning.Operation\"\254\001" - + "\312AS\n\025google.protobuf.Empty\022:google.spann" - + "er.admin.database.v1.UpdateDatabaseDdlMe" - + "tadata\332A\023database,statements\202\323\344\223\002:25/v1/" - + "{database=projects/*/instances/*/databas" - + "es/*}/ddl:\001*\022\243\001\n\014DropDatabase\0225.google.s" - + "panner.admin.database.v1.DropDatabaseReq" - + "uest\032\026.google.protobuf.Empty\"D\332A\010databas" - + "e\202\323\344\223\0023*1/v1/{database=projects/*/instan" - + "ces/*/databases/*}\022\315\001\n\016GetDatabaseDdl\0227." - + "google.spanner.admin.database.v1.GetData" - + "baseDdlRequest\0328.google.spanner.admin.da" - + "tabase.v1.GetDatabaseDdlResponse\"H\332A\010dat" - + "abase\202\323\344\223\0027\0225/v1/{database=projects/*/in" - + "stances/*/databases/*}/ddl\022\353\001\n\014SetIamPol" - + "icy\022\".google.iam.v1.SetIamPolicyRequest\032" - + "\025.google.iam.v1.Policy\"\237\001\332A\017resource,pol" - + "icy\202\323\344\223\002\206\001\">/v1/{resource=projects/*/ins" - + "tances/*/databases/*}:setIamPolicy:\001*ZA\"" - + "/v1/{resource=projects/*/instances/*/" - + "databases/*}:getIamPolicy:\001*ZA\".google.spanner.admin.database." - + "v1.ListBackupOperationsResponse\"E\332A\006pare" - + "nt\202\323\344\223\0026\0224/v1/{parent=projects/*/instanc" - + "es/*}/backupOperations\022\334\001\n\021ListDatabaseR" - + "oles\022:.google.spanner.admin.database.v1." - + "ListDatabaseRolesRequest\032;.google.spanne" - + "r.admin.database.v1.ListDatabaseRolesRes" - + "ponse\"N\332A\006parent\202\323\344\223\002?\022=/v1/{parent=proj" - + "ects/*/instances/*/databases/*}/database" - + "Roles\032x\312A\026spanner.googleapis.com\322A\\https" - + "://www.googleapis.com/auth/cloud-platfor" - + "m,https://www.googleapis.com/auth/spanne" - + "r.adminB\330\002\n$com.google.spanner.admin.dat" - + "abase.v1B\031SpannerDatabaseAdminProtoP\001ZFc" - + "loud.google.com/go/spanner/admin/databas" - + "e/apiv1/databasepb;databasepb\252\002&Google.C" - + "loud.Spanner.Admin.Database.V1\312\002&Google\\" - + "Cloud\\Spanner\\Admin\\Database\\V1\352\002+Google" - + "::Cloud::Spanner::Admin::Database::V1\352AJ" - + "\n\037spanner.googleapis.com/Instance\022\'proje" - + "cts/{project}/instances/{instance}b\006prot" - + "o3" + + "\030\n\013database_id\030\002 \001(\tB\003\340A\002\0224\n\006backup\030\003 \001(" + + "\tB\"\372A\037\n\035spanner.googleapis.com/BackupH\000\022" + + "a\n\021encryption_config\030\004 \001(\0132A.google.span" + + "ner.admin.database.v1.RestoreDatabaseEnc" + + "ryptionConfigB\003\340A\001B\010\n\006source\"\265\003\n\037Restore" + + "DatabaseEncryptionConfig\022n\n\017encryption_t" + + "ype\030\001 \001(\0162P.google.spanner.admin.databas" + + "e.v1.RestoreDatabaseEncryptionConfig.Enc" + + "ryptionTypeB\003\340A\002\022?\n\014kms_key_name\030\002 \001(\tB)" + + "\340A\001\372A#\n!cloudkms.googleapis.com/CryptoKe" + + "y\022@\n\rkms_key_names\030\003 \003(\tB)\340A\001\372A#\n!cloudk" + + "ms.googleapis.com/CryptoKey\"\236\001\n\016Encrypti" + + "onType\022\037\n\033ENCRYPTION_TYPE_UNSPECIFIED\020\000\022" + + "+\n\'USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTI" + + "ON\020\001\022\035\n\031GOOGLE_DEFAULT_ENCRYPTION\020\002\022\037\n\033C" + + "USTOMER_MANAGED_ENCRYPTION\020\003\"\215\003\n\027Restore" + + "DatabaseMetadata\0222\n\004name\030\001 \001(\tB$\372A!\n\037spa" + + "nner.googleapis.com/Database\022H\n\013source_t" + + "ype\030\002 \001(\01623.google.spanner.admin.databas" + + "e.v1.RestoreSourceType\022C\n\013backup_info\030\003 " + + "\001(\0132,.google.spanner.admin.database.v1.B" + + "ackupInfoH\000\022E\n\010progress\030\004 \001(\01323.google.s" + + "panner.admin.database.v1.OperationProgre" + + "ss\022/\n\013cancel_time\030\005 \001(\0132\032.google.protobu" + + "f.Timestamp\022(\n optimize_database_operati" + + "on_name\030\006 \001(\tB\r\n\013source_info\"\235\001\n Optimiz" + + "eRestoredDatabaseMetadata\0222\n\004name\030\001 \001(\tB" + + "$\372A!\n\037spanner.googleapis.com/Database\022E\n" + + "\010progress\030\002 \001(\01323.google.spanner.admin.d" + + "atabase.v1.OperationProgress\"\236\001\n\014Databas" + + "eRole\022\021\n\004name\030\001 \001(\tB\003\340A\002:{\352Ax\n#spanner.g" + + "oogleapis.com/DatabaseRole\022Qprojects/{pr" + + "oject}/instances/{instance}/databases/{d" + + "atabase}/databaseRoles/{role}\"z\n\030ListDat" + + "abaseRolesRequest\0227\n\006parent\030\001 \001(\tB\'\340A\002\372A" + + "!\n\037spanner.googleapis.com/Database\022\021\n\tpa" + + "ge_size\030\002 \001(\005\022\022\n\npage_token\030\003 \001(\t\"|\n\031Lis" + + "tDatabaseRolesResponse\022F\n\016database_roles" + + "\030\001 \003(\0132..google.spanner.admin.database.v" + + "1.DatabaseRole\022\027\n\017next_page_token\030\002 \001(\t*" + + "5\n\021RestoreSourceType\022\024\n\020TYPE_UNSPECIFIED" + + "\020\000\022\n\n\006BACKUP\020\0012\2301\n\rDatabaseAdmin\022\300\001\n\rLis" + + "tDatabases\0226.google.spanner.admin.databa" + + "se.v1.ListDatabasesRequest\0327.google.span" + + "ner.admin.database.v1.ListDatabasesRespo" + + "nse\">\332A\006parent\202\323\344\223\002/\022-/v1/{parent=projec" + + "ts/*/instances/*}/databases\022\244\002\n\016CreateDa" + + "tabase\0227.google.spanner.admin.database.v" + + "1.CreateDatabaseRequest\032\035.google.longrun" + + "ning.Operation\"\271\001\312Ad\n)google.spanner.adm" + + "in.database.v1.Database\0227google.spanner." + + "admin.database.v1.CreateDatabaseMetadata" + + "\332A\027parent,create_statement\202\323\344\223\0022\"-/v1/{p" + + "arent=projects/*/instances/*}/databases:" + + "\001*\022\255\001\n\013GetDatabase\0224.google.spanner.admi" + + "n.database.v1.GetDatabaseRequest\032*.googl" + + "e.spanner.admin.database.v1.Database\"<\332A" + + "\004name\202\323\344\223\002/\022-/v1/{name=projects/*/instan" + + "ces/*/databases/*}\022\357\001\n\016UpdateDatabase\0227." + + "google.spanner.admin.database.v1.UpdateD" + + "atabaseRequest\032\035.google.longrunning.Oper" + + "ation\"\204\001\312A\"\n\010Database\022\026UpdateDatabaseMet" + + "adata\332A\024database,update_mask\202\323\344\223\002B26/v1/" + + "{database.name=projects/*/instances/*/da" + + "tabases/*}:\010database\022\235\002\n\021UpdateDatabaseD" + + "dl\022:.google.spanner.admin.database.v1.Up" + + "dateDatabaseDdlRequest\032\035.google.longrunn" + + "ing.Operation\"\254\001\312AS\n\025google.protobuf.Emp" + + "ty\022:google.spanner.admin.database.v1.Upd" + + "ateDatabaseDdlMetadata\332A\023database,statem" + + "ents\202\323\344\223\002:25/v1/{database=projects/*/ins" + + "tances/*/databases/*}/ddl:\001*\022\243\001\n\014DropDat" + + "abase\0225.google.spanner.admin.database.v1" + + ".DropDatabaseRequest\032\026.google.protobuf.E" + + "mpty\"D\332A\010database\202\323\344\223\0023*1/v1/{database=p" + + "rojects/*/instances/*/databases/*}\022\315\001\n\016G" + + "etDatabaseDdl\0227.google.spanner.admin.dat" + + "abase.v1.GetDatabaseDdlRequest\0328.google." + + "spanner.admin.database.v1.GetDatabaseDdl" + + "Response\"H\332A\010database\202\323\344\223\0027\0225/v1/{databa" + + "se=projects/*/instances/*/databases/*}/d" + + "dl\022\302\002\n\014SetIamPolicy\022\".google.iam.v1.SetI" + + "amPolicyRequest\032\025.google.iam.v1.Policy\"\366" + + "\001\332A\017resource,policy\202\323\344\223\002\335\001\">/v1/{resourc" + + "e=projects/*/instances/*/databases/*}:se" + + "tIamPolicy:\001*ZA\"/v1/{resource=" + + "projects/*/instances/*/databases/*}:getI" + + "amPolicy:\001*ZA\".google.spanner.admin.databa" + + "se.v1.ListBackupOperationsResponse\"E\332A\006p" + + "arent\202\323\344\223\0026\0224/v1/{parent=projects/*/inst" + + "ances/*}/backupOperations\022\334\001\n\021ListDataba" + + "seRoles\022:.google.spanner.admin.database." + + "v1.ListDatabaseRolesRequest\032;.google.spa" + + "nner.admin.database.v1.ListDatabaseRoles" + + "Response\"N\332A\006parent\202\323\344\223\002?\022=/v1/{parent=p" + + "rojects/*/instances/*/databases/*}/datab" + + "aseRoles\022\216\002\n\024CreateBackupSchedule\022=.goog" + + "le.spanner.admin.database.v1.CreateBacku" + + "pScheduleRequest\0320.google.spanner.admin." + + "database.v1.BackupSchedule\"\204\001\332A)parent,b" + + "ackup_schedule,backup_schedule_id\202\323\344\223\002R\"" + + "?/v1/{parent=projects/*/instances/*/data" + + "bases/*}/backupSchedules:\017backup_schedul" + + "e\022\321\001\n\021GetBackupSchedule\022:.google.spanner" + + ".admin.database.v1.GetBackupScheduleRequ" + + "est\0320.google.spanner.admin.database.v1.B" + + "ackupSchedule\"N\332A\004name\202\323\344\223\002A\022?/v1/{name=" + + "projects/*/instances/*/databases/*/backu" + + "pSchedules/*}\022\220\002\n\024UpdateBackupSchedule\022=" + + ".google.spanner.admin.database.v1.Update" + + "BackupScheduleRequest\0320.google.spanner.a" + + "dmin.database.v1.BackupSchedule\"\206\001\332A\033bac" + + "kup_schedule,update_mask\202\323\344\223\002b2O/v1/{bac" + + "kup_schedule.name=projects/*/instances/*" + + "/databases/*/backupSchedules/*}:\017backup_" + + "schedule\022\275\001\n\024DeleteBackupSchedule\022=.goog" + + "le.spanner.admin.database.v1.DeleteBacku" + + "pScheduleRequest\032\026.google.protobuf.Empty" + + "\"N\332A\004name\202\323\344\223\002A*?/v1/{name=projects/*/in" + + "stances/*/databases/*/backupSchedules/*}" + + "\022\344\001\n\023ListBackupSchedules\022<.google.spanne" + + "r.admin.database.v1.ListBackupSchedulesR" + + "equest\032=.google.spanner.admin.database.v" + + "1.ListBackupSchedulesResponse\"P\332A\006parent" + + "\202\323\344\223\002A\022?/v1/{parent=projects/*/instances" + + "/*/databases/*}/backupSchedules\032x\312A\026span" + + "ner.googleapis.com\322A\\https://www.googlea" + + "pis.com/auth/cloud-platform,https://www." + + "googleapis.com/auth/spanner.adminB\330\002\n$co" + + "m.google.spanner.admin.database.v1B\031Span" + + "nerDatabaseAdminProtoP\001ZFcloud.google.co" + + "m/go/spanner/admin/database/apiv1/databa" + + "sepb;databasepb\252\002&Google.Cloud.Spanner.A" + + "dmin.Database.V1\312\002&Google\\Cloud\\Spanner\\" + + "Admin\\Database\\V1\352\002+Google::Cloud::Spann" + + "er::Admin::Database::V1\352AJ\n\037spanner.goog" + + "leapis.com/Instance\022\'projects/{project}/" + + "instances/{instance}b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -416,6 +453,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.protobuf.FieldMaskProto.getDescriptor(), com.google.protobuf.TimestampProto.getDescriptor(), com.google.spanner.admin.database.v1.BackupProto.getDescriptor(), + com.google.spanner.admin.database.v1.BackupScheduleProto.getDescriptor(), com.google.spanner.admin.database.v1.CommonProto.getDescriptor(), }); internal_static_google_spanner_admin_database_v1_RestoreInfo_descriptor = @@ -656,6 +694,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { com.google.protobuf.FieldMaskProto.getDescriptor(); com.google.protobuf.TimestampProto.getDescriptor(); com.google.spanner.admin.database.v1.BackupProto.getDescriptor(); + com.google.spanner.admin.database.v1.BackupScheduleProto.getDescriptor(); com.google.spanner.admin.database.v1.CommonProto.getDescriptor(); } diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateBackupScheduleRequest.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateBackupScheduleRequest.java new file mode 100644 index 00000000000..92c58484868 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateBackupScheduleRequest.java @@ -0,0 +1,1107 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +/** + * + * + *
+ * The request for
+ * [UpdateBackupScheduleRequest][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule].
+ * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.UpdateBackupScheduleRequest} + */ +public final class UpdateBackupScheduleRequest extends com.google.protobuf.GeneratedMessageV3 + implements + // @@protoc_insertion_point(message_implements:google.spanner.admin.database.v1.UpdateBackupScheduleRequest) + UpdateBackupScheduleRequestOrBuilder { + private static final long serialVersionUID = 0L; + // Use UpdateBackupScheduleRequest.newBuilder() to construct. + private UpdateBackupScheduleRequest(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private UpdateBackupScheduleRequest() {} + + @java.lang.Override + @SuppressWarnings({"unused"}) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new UpdateBackupScheduleRequest(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_UpdateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_UpdateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest.class, + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest.Builder.class); + } + + private int bitField0_; + public static final int BACKUP_SCHEDULE_FIELD_NUMBER = 1; + private com.google.spanner.admin.database.v1.BackupSchedule backupSchedule_; + /** + * + * + *
+   * Required. The backup schedule to update. `backup_schedule.name`, and the
+   * fields to be updated as specified by `update_mask` are required. Other
+   * fields are ignored.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + @java.lang.Override + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+   * Required. The backup schedule to update. `backup_schedule.name`, and the
+   * fields to be updated as specified by `update_mask` are required. Other
+   * fields are ignored.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupSchedule getBackupSchedule() { + return backupSchedule_ == null + ? com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + /** + * + * + *
+   * Required. The backup schedule to update. `backup_schedule.name`, and the
+   * fields to be updated as specified by `update_mask` are required. Other
+   * fields are ignored.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.spanner.admin.database.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder() { + return backupSchedule_ == null + ? com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + + public static final int UPDATE_MASK_FIELD_NUMBER = 2; + private com.google.protobuf.FieldMask updateMask_; + /** + * + * + *
+   * Required. A mask specifying which fields in the BackupSchedule resource
+   * should be updated. This mask is relative to the BackupSchedule resource,
+   * not to the request message. The field mask must always be
+   * specified; this prevents any future fields from being erased
+   * accidentally.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the updateMask field is set. + */ + @java.lang.Override + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+   * Required. A mask specifying which fields in the BackupSchedule resource
+   * should be updated. This mask is relative to the BackupSchedule resource,
+   * not to the request message. The field mask must always be
+   * specified; this prevents any future fields from being erased
+   * accidentally.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The updateMask. + */ + @java.lang.Override + public com.google.protobuf.FieldMask getUpdateMask() { + return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; + } + /** + * + * + *
+   * Required. A mask specifying which fields in the BackupSchedule resource
+   * should be updated. This mask is relative to the BackupSchedule resource,
+   * not to the request message. The field mask must always be
+   * specified; this prevents any future fields from being erased
+   * accidentally.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + @java.lang.Override + public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { + return updateMask_ == null ? com.google.protobuf.FieldMask.getDefaultInstance() : updateMask_; + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) return true; + if (isInitialized == 0) return false; + + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (((bitField0_ & 0x00000001) != 0)) { + output.writeMessage(1, getBackupSchedule()); + } + if (((bitField0_ & 0x00000002) != 0)) { + output.writeMessage(2, getUpdateMask()); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) return size; + + size = 0; + if (((bitField0_ & 0x00000001) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getBackupSchedule()); + } + if (((bitField0_ & 0x00000002) != 0)) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getUpdateMask()); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest)) { + return super.equals(obj); + } + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest other = + (com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest) obj; + + if (hasBackupSchedule() != other.hasBackupSchedule()) return false; + if (hasBackupSchedule()) { + if (!getBackupSchedule().equals(other.getBackupSchedule())) return false; + } + if (hasUpdateMask() != other.hasUpdateMask()) return false; + if (hasUpdateMask()) { + if (!getUpdateMask().equals(other.getUpdateMask())) return false; + } + if (!getUnknownFields().equals(other.getUnknownFields())) return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + if (hasBackupSchedule()) { + hash = (37 * hash) + BACKUP_SCHEDULE_FIELD_NUMBER; + hash = (53 * hash) + getBackupSchedule().hashCode(); + } + if (hasUpdateMask()) { + hash = (37 * hash) + UPDATE_MASK_FIELD_NUMBER; + hash = (53 * hash) + getUpdateMask().hashCode(); + } + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest parseFrom( + java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.ByteString data, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest parseFrom( + byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest parseFrom( + byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest parseFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest 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.spanner.admin.database.v1.UpdateBackupScheduleRequest parseDelimitedFrom( + java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest 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.spanner.admin.database.v1.UpdateBackupScheduleRequest parseFrom( + com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest 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.spanner.admin.database.v1.UpdateBackupScheduleRequest prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + /** + * + * + *
+   * The request for
+   * [UpdateBackupScheduleRequest][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule].
+   * 
+ * + * Protobuf type {@code google.spanner.admin.database.v1.UpdateBackupScheduleRequest} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder + implements + // @@protoc_insertion_point(builder_implements:google.spanner.admin.database.v1.UpdateBackupScheduleRequest) + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequestOrBuilder { + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_UpdateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable + internalGetFieldAccessorTable() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_UpdateBackupScheduleRequest_fieldAccessorTable + .ensureFieldAccessorsInitialized( + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest.class, + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest.Builder.class); + } + + // Construct using com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest.newBuilder() + private Builder() { + maybeForceBuilderInitialization(); + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + maybeForceBuilderInitialization(); + } + + private void maybeForceBuilderInitialization() { + if (com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders) { + getBackupScheduleFieldBuilder(); + getUpdateMaskFieldBuilder(); + } + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return com.google.spanner.admin.database.v1.BackupScheduleProto + .internal_static_google_spanner_admin_database_v1_UpdateBackupScheduleRequest_descriptor; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest + getDefaultInstanceForType() { + return com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest.getDefaultInstance(); + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest build() { + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest buildPartial() { + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest result = + new com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0( + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest result) { + int from_bitField0_ = bitField0_; + int to_bitField0_ = 0; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.backupSchedule_ = + backupScheduleBuilder_ == null ? backupSchedule_ : backupScheduleBuilder_.build(); + to_bitField0_ |= 0x00000001; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.updateMask_ = updateMaskBuilder_ == null ? updateMask_ : updateMaskBuilder_.build(); + to_bitField0_ |= 0x00000002; + } + result.bitField0_ |= to_bitField0_; + } + + @java.lang.Override + public Builder 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.spanner.admin.database.v1.UpdateBackupScheduleRequest) { + return mergeFrom((com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom( + com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest other) { + if (other + == com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest.getDefaultInstance()) + return this; + if (other.hasBackupSchedule()) { + mergeBackupSchedule(other.getBackupSchedule()); + } + if (other.hasUpdateMask()) { + mergeUpdateMask(other.getUpdateMask()); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch (tag) { + case 0: + done = true; + break; + case 10: + { + input.readMessage(getBackupScheduleFieldBuilder().getBuilder(), extensionRegistry); + bitField0_ |= 0x00000001; + break; + } // case 10 + case 18: + { + input.readMessage(getUpdateMaskFieldBuilder().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.spanner.admin.database.v1.BackupSchedule backupSchedule_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupSchedule, + com.google.spanner.admin.database.v1.BackupSchedule.Builder, + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder> + backupScheduleBuilder_; + /** + * + * + *
+     * Required. The backup schedule to update. `backup_schedule.name`, and the
+     * fields to be updated as specified by `update_mask` are required. Other
+     * fields are ignored.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + public boolean hasBackupSchedule() { + return ((bitField0_ & 0x00000001) != 0); + } + /** + * + * + *
+     * Required. The backup schedule to update. `backup_schedule.name`, and the
+     * fields to be updated as specified by `update_mask` are required. Other
+     * fields are ignored.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + public com.google.spanner.admin.database.v1.BackupSchedule getBackupSchedule() { + if (backupScheduleBuilder_ == null) { + return backupSchedule_ == null + ? com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } else { + return backupScheduleBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. The backup schedule to update. `backup_schedule.name`, and the
+     * fields to be updated as specified by `update_mask` are required. Other
+     * fields are ignored.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule(com.google.spanner.admin.database.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + backupSchedule_ = value; + } else { + backupScheduleBuilder_.setMessage(value); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to update. `backup_schedule.name`, and the
+     * fields to be updated as specified by `update_mask` are required. Other
+     * fields are ignored.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setBackupSchedule( + com.google.spanner.admin.database.v1.BackupSchedule.Builder builderForValue) { + if (backupScheduleBuilder_ == null) { + backupSchedule_ = builderForValue.build(); + } else { + backupScheduleBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to update. `backup_schedule.name`, and the
+     * fields to be updated as specified by `update_mask` are required. Other
+     * fields are ignored.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeBackupSchedule(com.google.spanner.admin.database.v1.BackupSchedule value) { + if (backupScheduleBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) + && backupSchedule_ != null + && backupSchedule_ + != com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance()) { + getBackupScheduleBuilder().mergeFrom(value); + } else { + backupSchedule_ = value; + } + } else { + backupScheduleBuilder_.mergeFrom(value); + } + if (backupSchedule_ != null) { + bitField0_ |= 0x00000001; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Required. The backup schedule to update. `backup_schedule.name`, and the
+     * fields to be updated as specified by `update_mask` are required. Other
+     * fields are ignored.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearBackupSchedule() { + bitField0_ = (bitField0_ & ~0x00000001); + backupSchedule_ = null; + if (backupScheduleBuilder_ != null) { + backupScheduleBuilder_.dispose(); + backupScheduleBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. The backup schedule to update. `backup_schedule.name`, and the
+     * fields to be updated as specified by `update_mask` are required. Other
+     * fields are ignored.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.spanner.admin.database.v1.BackupSchedule.Builder getBackupScheduleBuilder() { + bitField0_ |= 0x00000001; + onChanged(); + return getBackupScheduleFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. The backup schedule to update. `backup_schedule.name`, and the
+     * fields to be updated as specified by `update_mask` are required. Other
+     * fields are ignored.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.spanner.admin.database.v1.BackupScheduleOrBuilder + getBackupScheduleOrBuilder() { + if (backupScheduleBuilder_ != null) { + return backupScheduleBuilder_.getMessageOrBuilder(); + } else { + return backupSchedule_ == null + ? com.google.spanner.admin.database.v1.BackupSchedule.getDefaultInstance() + : backupSchedule_; + } + } + /** + * + * + *
+     * Required. The backup schedule to update. `backup_schedule.name`, and the
+     * fields to be updated as specified by `update_mask` are required. Other
+     * fields are ignored.
+     * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupSchedule, + com.google.spanner.admin.database.v1.BackupSchedule.Builder, + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder> + getBackupScheduleFieldBuilder() { + if (backupScheduleBuilder_ == null) { + backupScheduleBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.spanner.admin.database.v1.BackupSchedule, + com.google.spanner.admin.database.v1.BackupSchedule.Builder, + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder>( + getBackupSchedule(), getParentForChildren(), isClean()); + backupSchedule_ = null; + } + return backupScheduleBuilder_; + } + + private com.google.protobuf.FieldMask updateMask_; + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder> + updateMaskBuilder_; + /** + * + * + *
+     * Required. A mask specifying which fields in the BackupSchedule resource
+     * should be updated. This mask is relative to the BackupSchedule resource,
+     * not to the request message. The field mask must always be
+     * specified; this prevents any future fields from being erased
+     * accidentally.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the updateMask field is set. + */ + public boolean hasUpdateMask() { + return ((bitField0_ & 0x00000002) != 0); + } + /** + * + * + *
+     * Required. A mask specifying which fields in the BackupSchedule resource
+     * should be updated. This mask is relative to the BackupSchedule resource,
+     * not to the request message. The field mask must always be
+     * specified; this prevents any future fields from being erased
+     * accidentally.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The updateMask. + */ + public com.google.protobuf.FieldMask getUpdateMask() { + if (updateMaskBuilder_ == null) { + return updateMask_ == null + ? com.google.protobuf.FieldMask.getDefaultInstance() + : updateMask_; + } else { + return updateMaskBuilder_.getMessage(); + } + } + /** + * + * + *
+     * Required. A mask specifying which fields in the BackupSchedule resource
+     * should be updated. This mask is relative to the BackupSchedule resource,
+     * not to the request message. The field mask must always be
+     * specified; this prevents any future fields from being erased
+     * accidentally.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setUpdateMask(com.google.protobuf.FieldMask value) { + if (updateMaskBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + updateMask_ = value; + } else { + updateMaskBuilder_.setMessage(value); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. A mask specifying which fields in the BackupSchedule resource
+     * should be updated. This mask is relative to the BackupSchedule resource,
+     * not to the request message. The field mask must always be
+     * specified; this prevents any future fields from being erased
+     * accidentally.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder setUpdateMask(com.google.protobuf.FieldMask.Builder builderForValue) { + if (updateMaskBuilder_ == null) { + updateMask_ = builderForValue.build(); + } else { + updateMaskBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + /** + * + * + *
+     * Required. A mask specifying which fields in the BackupSchedule resource
+     * should be updated. This mask is relative to the BackupSchedule resource,
+     * not to the request message. The field mask must always be
+     * specified; this prevents any future fields from being erased
+     * accidentally.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder mergeUpdateMask(com.google.protobuf.FieldMask value) { + if (updateMaskBuilder_ == null) { + if (((bitField0_ & 0x00000002) != 0) + && updateMask_ != null + && updateMask_ != com.google.protobuf.FieldMask.getDefaultInstance()) { + getUpdateMaskBuilder().mergeFrom(value); + } else { + updateMask_ = value; + } + } else { + updateMaskBuilder_.mergeFrom(value); + } + if (updateMask_ != null) { + bitField0_ |= 0x00000002; + onChanged(); + } + return this; + } + /** + * + * + *
+     * Required. A mask specifying which fields in the BackupSchedule resource
+     * should be updated. This mask is relative to the BackupSchedule resource,
+     * not to the request message. The field mask must always be
+     * specified; this prevents any future fields from being erased
+     * accidentally.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public Builder clearUpdateMask() { + bitField0_ = (bitField0_ & ~0x00000002); + updateMask_ = null; + if (updateMaskBuilder_ != null) { + updateMaskBuilder_.dispose(); + updateMaskBuilder_ = null; + } + onChanged(); + return this; + } + /** + * + * + *
+     * Required. A mask specifying which fields in the BackupSchedule resource
+     * should be updated. This mask is relative to the BackupSchedule resource,
+     * not to the request message. The field mask must always be
+     * specified; this prevents any future fields from being erased
+     * accidentally.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.protobuf.FieldMask.Builder getUpdateMaskBuilder() { + bitField0_ |= 0x00000002; + onChanged(); + return getUpdateMaskFieldBuilder().getBuilder(); + } + /** + * + * + *
+     * Required. A mask specifying which fields in the BackupSchedule resource
+     * should be updated. This mask is relative to the BackupSchedule resource,
+     * not to the request message. The field mask must always be
+     * specified; this prevents any future fields from being erased
+     * accidentally.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + public com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder() { + if (updateMaskBuilder_ != null) { + return updateMaskBuilder_.getMessageOrBuilder(); + } else { + return updateMask_ == null + ? com.google.protobuf.FieldMask.getDefaultInstance() + : updateMask_; + } + } + /** + * + * + *
+     * Required. A mask specifying which fields in the BackupSchedule resource
+     * should be updated. This mask is relative to the BackupSchedule resource,
+     * not to the request message. The field mask must always be
+     * specified; this prevents any future fields from being erased
+     * accidentally.
+     * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + private com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder> + getUpdateMaskFieldBuilder() { + if (updateMaskBuilder_ == null) { + updateMaskBuilder_ = + new com.google.protobuf.SingleFieldBuilderV3< + com.google.protobuf.FieldMask, + com.google.protobuf.FieldMask.Builder, + com.google.protobuf.FieldMaskOrBuilder>( + getUpdateMask(), getParentForChildren(), isClean()); + updateMask_ = null; + } + return updateMaskBuilder_; + } + + @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.spanner.admin.database.v1.UpdateBackupScheduleRequest) + } + + // @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.UpdateBackupScheduleRequest) + private static final com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest + DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest(); + } + + public static com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest + getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = + new com.google.protobuf.AbstractParser() { + @java.lang.Override + public UpdateBackupScheduleRequest parsePartialFrom( + com.google.protobuf.CodedInputStream input, + com.google.protobuf.ExtensionRegistryLite extensionRegistry) + throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e) + .setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public com.google.spanner.admin.database.v1.UpdateBackupScheduleRequest + getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateBackupScheduleRequestOrBuilder.java b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateBackupScheduleRequestOrBuilder.java new file mode 100644 index 00000000000..100874a6098 --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/java/com/google/spanner/admin/database/v1/UpdateBackupScheduleRequestOrBuilder.java @@ -0,0 +1,123 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: google/spanner/admin/database/v1/backup_schedule.proto + +// Protobuf Java Version: 3.25.3 +package com.google.spanner.admin.database.v1; + +public interface UpdateBackupScheduleRequestOrBuilder + extends + // @@protoc_insertion_point(interface_extends:google.spanner.admin.database.v1.UpdateBackupScheduleRequest) + com.google.protobuf.MessageOrBuilder { + + /** + * + * + *
+   * Required. The backup schedule to update. `backup_schedule.name`, and the
+   * fields to be updated as specified by `update_mask` are required. Other
+   * fields are ignored.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the backupSchedule field is set. + */ + boolean hasBackupSchedule(); + /** + * + * + *
+   * Required. The backup schedule to update. `backup_schedule.name`, and the
+   * fields to be updated as specified by `update_mask` are required. Other
+   * fields are ignored.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The backupSchedule. + */ + com.google.spanner.admin.database.v1.BackupSchedule getBackupSchedule(); + /** + * + * + *
+   * Required. The backup schedule to update. `backup_schedule.name`, and the
+   * fields to be updated as specified by `update_mask` are required. Other
+   * fields are ignored.
+   * 
+ * + * + * .google.spanner.admin.database.v1.BackupSchedule backup_schedule = 1 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.spanner.admin.database.v1.BackupScheduleOrBuilder getBackupScheduleOrBuilder(); + + /** + * + * + *
+   * Required. A mask specifying which fields in the BackupSchedule resource
+   * should be updated. This mask is relative to the BackupSchedule resource,
+   * not to the request message. The field mask must always be
+   * specified; this prevents any future fields from being erased
+   * accidentally.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return Whether the updateMask field is set. + */ + boolean hasUpdateMask(); + /** + * + * + *
+   * Required. A mask specifying which fields in the BackupSchedule resource
+   * should be updated. This mask is relative to the BackupSchedule resource,
+   * not to the request message. The field mask must always be
+   * specified; this prevents any future fields from being erased
+   * accidentally.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + * + * @return The updateMask. + */ + com.google.protobuf.FieldMask getUpdateMask(); + /** + * + * + *
+   * Required. A mask specifying which fields in the BackupSchedule resource
+   * should be updated. This mask is relative to the BackupSchedule resource,
+   * not to the request message. The field mask must always be
+   * specified; this prevents any future fields from being erased
+   * accidentally.
+   * 
+ * + * .google.protobuf.FieldMask update_mask = 2 [(.google.api.field_behavior) = REQUIRED]; + * + */ + com.google.protobuf.FieldMaskOrBuilder getUpdateMaskOrBuilder(); +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup.proto b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup.proto index bb8ef4d55e8..842ab0ff1e8 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup.proto +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup.proto @@ -103,6 +103,24 @@ message Backup { // Output only. Size of the backup in bytes. int64 size_bytes = 5 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Output only. The number of bytes that will be freed by deleting this + // backup. This value will be zero if, for example, this backup is part of an + // incremental backup chain and younger backups in the chain require that we + // keep its data. For backups not in an incremental backup chain, this is + // always the size of the backup. This value may change if backups on the same + // chain get created, deleted or expired. + int64 freeable_size_bytes = 15 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. For a backup in an incremental backup chain, this is the + // storage space needed to keep the data that has changed since the previous + // backup. For all other backups, this is always the size of the backup. This + // value may change if backups on the same chain get deleted or expired. + // + // This field can be used to calculate the total storage space used by a set + // of backups. For example, the total space used by all backups of a database + // can be computed by summing up this field. + int64 exclusive_size_bytes = 16 [(google.api.field_behavior) = OUTPUT_ONLY]; + // Output only. The current state of the backup. State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY]; @@ -156,6 +174,35 @@ message Backup { // less than `Backup.max_expire_time`. google.protobuf.Timestamp max_expire_time = 12 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. List of backup schedule URIs that are associated with + // creating this backup. This is only applicable for scheduled backups, and + // is empty for on-demand backups. + // + // To optimize for storage, whenever possible, multiple schedules are + // collapsed together to create one backup. In such cases, this field captures + // the list of all backup schedule URIs that are associated with creating + // this backup. If collapsing is not done, then this field captures the + // single backup schedule URI associated with creating this backup. + repeated string backup_schedules = 14 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Populated only for backups in an incremental backup chain. + // Backups share the same chain id if and only if they belong to the same + // incremental backup chain. Use this field to determine which backups are + // part of the same incremental backup chain. The ordering of backups in the + // chain can be determined by ordering the backup `version_time`. + string incremental_backup_chain_id = 17 + [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Data deleted at a time older than this is guaranteed not to be + // retained in order to support this backup. For a backup in an incremental + // backup chain, this is the version time of the oldest backup that exists or + // ever existed in the chain. For all other backups, this is the version time + // of the backup. This field can be used to understand what data is being + // retained by the backup system. + google.protobuf.Timestamp oldest_version_time = 18 + [(google.api.field_behavior) = OUTPUT_ONLY]; } // The request for @@ -688,3 +735,16 @@ message CopyBackupEncryptionConfig { } ]; } + +// The specification for full backups. +// A full backup stores the entire contents of the database at a given +// version time. +message FullBackupSpec {} + +// The specification for incremental backup chains. +// An incremental backup stores the delta of changes between a previous +// backup and the database contents at a given version time. An +// incremental backup chain consists of a full backup and zero or more +// successive incremental backups. The first backup created for an +// incremental backup chain is always a full backup. +message IncrementalBackupSpec {} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup_schedule.proto b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup_schedule.proto new file mode 100644 index 00000000000..c9b5e7e3f4b --- /dev/null +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/backup_schedule.proto @@ -0,0 +1,230 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package google.spanner.admin.database.v1; + +import "google/api/field_behavior.proto"; +import "google/api/resource.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/field_mask.proto"; +import "google/protobuf/timestamp.proto"; +import "google/spanner/admin/database/v1/backup.proto"; + +option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; +option go_package = "cloud.google.com/go/spanner/admin/database/apiv1/databasepb;databasepb"; +option java_multiple_files = true; +option java_outer_classname = "BackupScheduleProto"; +option java_package = "com.google.spanner.admin.database.v1"; +option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1"; +option ruby_package = "Google::Cloud::Spanner::Admin::Database::V1"; + +// Defines specifications of the backup schedule. +message BackupScheduleSpec { + // Required. + oneof schedule_spec { + // Cron style schedule specification. + CrontabSpec cron_spec = 1; + } +} + +// BackupSchedule expresses the automated backup creation specification for a +// Spanner database. +// Next ID: 10 +message BackupSchedule { + option (google.api.resource) = { + type: "spanner.googleapis.com/BackupSchedule" + pattern: "projects/{project}/instances/{instance}/databases/{database}/backupSchedules/{schedule}" + plural: "backupSchedules" + singular: "backupSchedule" + }; + + // Identifier. Output only for the + // [CreateBackupSchedule][DatabaseAdmin.CreateBackupSchededule] operation. + // Required for the + // [UpdateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule] + // operation. A globally unique identifier for the backup schedule which + // cannot be changed. Values are of the form + // `projects//instances//databases//backupSchedules/[a-z][a-z0-9_\-]*[a-z0-9]` + // The final segment of the name must be between 2 and 60 characters in + // length. + string name = 1 [(google.api.field_behavior) = IDENTIFIER]; + + // Optional. The schedule specification based on which the backup creations + // are triggered. + BackupScheduleSpec spec = 6 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The retention duration of a backup that must be at least 6 hours + // and at most 366 days. The backup is eligible to be automatically deleted + // once the retention period has elapsed. + google.protobuf.Duration retention_duration = 3 + [(google.api.field_behavior) = OPTIONAL]; + + // Optional. The encryption configuration that will be used to encrypt the + // backup. If this field is not specified, the backup will use the same + // encryption configuration as the database. + CreateBackupEncryptionConfig encryption_config = 4 + [(google.api.field_behavior) = OPTIONAL]; + + // Required. Backup type spec determines the type of backup that is created by + // the backup schedule. Currently, only full backups are supported. + oneof backup_type_spec { + // The schedule creates only full backups. + FullBackupSpec full_backup_spec = 7; + + // The schedule creates incremental backup chains. + IncrementalBackupSpec incremental_backup_spec = 8; + } + + // Output only. The timestamp at which the schedule was last updated. + // If the schedule has never been updated, this field contains the timestamp + // when the schedule was first created. + google.protobuf.Timestamp update_time = 9 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// CrontabSpec can be used to specify the version time and frequency at +// which the backup should be created. +message CrontabSpec { + // Required. Textual representation of the crontab. User can customize the + // backup frequency and the backup version time using the cron + // expression. The version time must be in UTC timzeone. + // + // The backup will contain an externally consistent copy of the + // database at the version time. Allowed frequencies are 12 hour, 1 day, + // 1 week and 1 month. Examples of valid cron specifications: + // * `0 2/12 * * * ` : every 12 hours at (2, 14) hours past midnight in UTC. + // * `0 2,14 * * * ` : every 12 hours at (2,14) hours past midnight in UTC. + // * `0 2 * * * ` : once a day at 2 past midnight in UTC. + // * `0 2 * * 0 ` : once a week every Sunday at 2 past midnight in UTC. + // * `0 2 8 * * ` : once a month on 8th day at 2 past midnight in UTC. + string text = 1 [(google.api.field_behavior) = REQUIRED]; + + // Output only. The time zone of the times in `CrontabSpec.text`. Currently + // only UTC is supported. + string time_zone = 2 [(google.api.field_behavior) = OUTPUT_ONLY]; + + // Output only. Schedule backups will contain an externally consistent copy + // of the database at the version time specified in + // `schedule_spec.cron_spec`. However, Spanner may not initiate the creation + // of the scheduled backups at that version time. Spanner will initiate + // the creation of scheduled backups within the time window bounded by the + // version_time specified in `schedule_spec.cron_spec` and version_time + + // `creation_window`. + google.protobuf.Duration creation_window = 3 + [(google.api.field_behavior) = OUTPUT_ONLY]; +} + +// The request for +// [CreateBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackupSchedule]. +message CreateBackupScheduleRequest { + // Required. The name of the database that this backup schedule applies to. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; + + // Required. The Id to use for the backup schedule. The `backup_schedule_id` + // appended to `parent` forms the full backup schedule name of the form + // `projects//instances//databases//backupSchedules/`. + string backup_schedule_id = 2 [(google.api.field_behavior) = REQUIRED]; + + // Required. The backup schedule to create. + BackupSchedule backup_schedule = 3 [(google.api.field_behavior) = REQUIRED]; +} + +// The request for +// [GetBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.GetBackupSchedule]. +message GetBackupScheduleRequest { + // Required. The name of the schedule to retrieve. + // Values are of the form + // `projects//instances//databases//backupSchedules/`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/BackupSchedule" + } + ]; +} + +// The request for +// [DeleteBackupSchedule][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackupSchedule]. +message DeleteBackupScheduleRequest { + // Required. The name of the schedule to delete. + // Values are of the form + // `projects//instances//databases//backupSchedules/`. + string name = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/BackupSchedule" + } + ]; +} + +// The request for +// [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]. +message ListBackupSchedulesRequest { + // Required. Database is the parent resource whose backup schedules should be + // listed. Values are of the form + // projects//instances//databases/ + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + type: "spanner.googleapis.com/Database" + } + ]; + + // Optional. Number of backup schedules to be returned in the response. If 0 + // or less, defaults to the server's maximum allowed page size. + int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL]; + + // Optional. If non-empty, `page_token` should contain a + // [next_page_token][google.spanner.admin.database.v1.ListBackupSchedulesResponse.next_page_token] + // from a previous + // [ListBackupSchedulesResponse][google.spanner.admin.database.v1.ListBackupSchedulesResponse] + // to the same `parent`. + string page_token = 4 [(google.api.field_behavior) = OPTIONAL]; +} + +// The response for +// [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules]. +message ListBackupSchedulesResponse { + // The list of backup schedules for a database. + repeated BackupSchedule backup_schedules = 1; + + // `next_page_token` can be sent in a subsequent + // [ListBackupSchedules][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupSchedules] + // call to fetch more of the schedules. + string next_page_token = 2; +} + +// The request for +// [UpdateBackupScheduleRequest][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackupSchedule]. +message UpdateBackupScheduleRequest { + // Required. The backup schedule to update. `backup_schedule.name`, and the + // fields to be updated as specified by `update_mask` are required. Other + // fields are ignored. + BackupSchedule backup_schedule = 1 [(google.api.field_behavior) = REQUIRED]; + + // Required. A mask specifying which fields in the BackupSchedule resource + // should be updated. This mask is relative to the BackupSchedule resource, + // not to the request message. The field mask must always be + // specified; this prevents any future fields from being erased + // accidentally. + google.protobuf.FieldMask update_mask = 2 + [(google.api.field_behavior) = REQUIRED]; +} diff --git a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/spanner_database_admin.proto b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/spanner_database_admin.proto index 0d4e261709c..5df142403e6 100644 --- a/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/spanner_database_admin.proto +++ b/proto-google-cloud-spanner-admin-database-v1/src/main/proto/google/spanner/admin/database/v1/spanner_database_admin.proto @@ -27,6 +27,7 @@ import "google/protobuf/empty.proto"; import "google/protobuf/field_mask.proto"; import "google/protobuf/timestamp.proto"; import "google/spanner/admin/database/v1/backup.proto"; +import "google/spanner/admin/database/v1/backup_schedule.proto"; import "google/spanner/admin/database/v1/common.proto"; option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1"; @@ -199,6 +200,10 @@ service DatabaseAdmin { post: "/v1/{resource=projects/*/instances/*/backups/*}:setIamPolicy" body: "*" } + additional_bindings { + post: "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:setIamPolicy" + body: "*" + } }; option (google.api.method_signature) = "resource,policy"; } @@ -220,6 +225,10 @@ service DatabaseAdmin { post: "/v1/{resource=projects/*/instances/*/backups/*}:getIamPolicy" body: "*" } + additional_bindings { + post: "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:getIamPolicy" + body: "*" + } }; option (google.api.method_signature) = "resource"; } @@ -243,6 +252,10 @@ service DatabaseAdmin { post: "/v1/{resource=projects/*/instances/*/backups/*}:testIamPermissions" body: "*" } + additional_bindings { + post: "/v1/{resource=projects/*/instances/*/databases/*/backupSchedules/*}:testIamPermissions" + body: "*" + } additional_bindings { post: "/v1/{resource=projects/*/instances/*/databases/*/databaseRoles/*}:testIamPermissions" body: "*" @@ -411,6 +424,53 @@ service DatabaseAdmin { }; option (google.api.method_signature) = "parent"; } + + // Creates a new backup schedule. + rpc CreateBackupSchedule(CreateBackupScheduleRequest) + returns (BackupSchedule) { + option (google.api.http) = { + post: "/v1/{parent=projects/*/instances/*/databases/*}/backupSchedules" + body: "backup_schedule" + }; + option (google.api.method_signature) = + "parent,backup_schedule,backup_schedule_id"; + } + + // Gets backup schedule for the input schedule name. + rpc GetBackupSchedule(GetBackupScheduleRequest) returns (BackupSchedule) { + option (google.api.http) = { + get: "/v1/{name=projects/*/instances/*/databases/*/backupSchedules/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Updates a backup schedule. + rpc UpdateBackupSchedule(UpdateBackupScheduleRequest) + returns (BackupSchedule) { + option (google.api.http) = { + patch: "/v1/{backup_schedule.name=projects/*/instances/*/databases/*/backupSchedules/*}" + body: "backup_schedule" + }; + option (google.api.method_signature) = "backup_schedule,update_mask"; + } + + // Deletes a backup schedule. + rpc DeleteBackupSchedule(DeleteBackupScheduleRequest) + returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v1/{name=projects/*/instances/*/databases/*/backupSchedules/*}" + }; + option (google.api.method_signature) = "name"; + } + + // Lists all the backup schedules for the database. + rpc ListBackupSchedules(ListBackupSchedulesRequest) + returns (ListBackupSchedulesResponse) { + option (google.api.http) = { + get: "/v1/{parent=projects/*/instances/*/databases/*}/backupSchedules" + }; + option (google.api.method_signature) = "parent"; + } } // Information about the database restore. diff --git a/proto-google-cloud-spanner-admin-instance-v1/pom.xml b/proto-google-cloud-spanner-admin-instance-v1/pom.xml index 9f8f0642e78..a7d13f01a46 100644 --- a/proto-google-cloud-spanner-admin-instance-v1/pom.xml +++ b/proto-google-cloud-spanner-admin-instance-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-spanner-admin-instance-v1 - 6.71.0 + 6.72.0 proto-google-cloud-spanner-admin-instance-v1 PROTO library for proto-google-cloud-spanner-admin-instance-v1 com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 diff --git a/proto-google-cloud-spanner-executor-v1/pom.xml b/proto-google-cloud-spanner-executor-v1/pom.xml index 201a72217c1..fe38be68ce6 100644 --- a/proto-google-cloud-spanner-executor-v1/pom.xml +++ b/proto-google-cloud-spanner-executor-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-spanner-executor-v1 - 6.71.0 + 6.72.0 proto-google-cloud-spanner-executor-v1 Proto library for google-cloud-spanner com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 diff --git a/proto-google-cloud-spanner-v1/pom.xml b/proto-google-cloud-spanner-v1/pom.xml index 12b4bc94bec..fce72e60709 100644 --- a/proto-google-cloud-spanner-v1/pom.xml +++ b/proto-google-cloud-spanner-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-spanner-v1 - 6.71.0 + 6.72.0 proto-google-cloud-spanner-v1 PROTO library for proto-google-cloud-spanner-v1 com.google.cloud google-cloud-spanner-parent - 6.71.0 + 6.72.0 diff --git a/renovate.json b/renovate.json index 33c03a11c6a..26169743fc5 100644 --- a/renovate.json +++ b/renovate.json @@ -20,7 +20,7 @@ "customManagers": [ { "customType": "regex", - "fileMatch": [ + "fileMatch": [ "^.kokoro/presubmit/graalvm-native.*.cfg$" ], "matchStrings": ["value: \"gcr.io/cloud-devrel-public-resources/graalvm.*:(?.*?)\""], @@ -30,7 +30,7 @@ { "customType": "regex", "fileMatch": [ - "^.github/workflows/unmanaged_dependency_check.yaml$" + "^.github/workflows/unmanaged_dependency_check.yaml$" ], "matchStrings": ["uses: googleapis/sdk-platform-java/java-shared-dependencies/unmanaged-dependency-check@google-cloud-shared-dependencies/v(?.+?)\\n"], "depNameTemplate": "com.google.cloud:sdk-platform-java-config", diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 79d9c665884..56b1c708c8c 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -23,8 +23,8 @@ 1.8 UTF-8 0.31.1 - 2.41.0 - 3.44.0 + 2.47.0 + 3.48.0
@@ -33,7 +33,7 @@ com.google.cloud google-cloud-spanner - 6.67.0 + 6.71.0 @@ -100,7 +100,7 @@ com.google.truth truth - 1.4.2 + 1.4.4 test @@ -116,7 +116,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.5.0 + 3.6.0 add-snippets-source @@ -145,7 +145,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.3.0 + 3.3.1 java-client-integration-tests diff --git a/samples/native-image/pom.xml b/samples/native-image/pom.xml index 45003271793..b34fc048486 100644 --- a/samples/native-image/pom.xml +++ b/samples/native-image/pom.xml @@ -29,7 +29,7 @@ com.google.cloud libraries-bom - 26.39.0 + 26.43.0 pom import @@ -51,7 +51,7 @@ com.google.truth truth - 1.4.2 + 1.4.4 test @@ -62,7 +62,7 @@ org.apache.maven.plugins maven-jar-plugin - 3.4.1 + 3.4.2 @@ -104,7 +104,7 @@ org.junit.vintage junit-vintage-engine - 5.10.2 + 5.10.3 test @@ -121,7 +121,7 @@ org.apache.maven.plugins maven-surefire-plugin - 3.2.5 + 3.3.1 **/*IT diff --git a/samples/native-image/src/main/java/com/example/spanner/InstanceOperations.java b/samples/native-image/src/main/java/com/example/spanner/InstanceOperations.java index 75efd6b45b1..cbda19236c0 100644 --- a/samples/native-image/src/main/java/com/example/spanner/InstanceOperations.java +++ b/samples/native-image/src/main/java/com/example/spanner/InstanceOperations.java @@ -35,7 +35,7 @@ static void createTestInstance( InstanceInfo instanceInfo = InstanceInfo.newBuilder(InstanceId.of(projectId, instanceId)) - .setInstanceConfigId(InstanceConfigId.of(projectId, "regional-us-central1")) + .setInstanceConfigId(InstanceConfigId.of(projectId, "regional-us-east4")) .setNodeCount(1) .setDisplayName(instanceId) .build(); diff --git a/samples/pom.xml b/samples/pom.xml index e99ce19e6b0..07c91c62ad0 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -48,7 +48,7 @@ org.sonatype.plugins nexus-staging-maven-plugin - 1.6.13 + 1.7.0 true diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 0730871b890..86832f71b9d 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -23,8 +23,8 @@ 1.8 UTF-8 0.31.1 - 2.41.0 - 3.44.0 + 2.47.0 + 3.48.0
@@ -32,7 +32,7 @@ com.google.cloud google-cloud-spanner - 6.71.0 + 6.72.0 @@ -99,7 +99,7 @@ com.google.truth truth - 1.4.2 + 1.4.4 test @@ -115,7 +115,7 @@ org.codehaus.mojo build-helper-maven-plugin - 3.5.0 + 3.6.0 add-snippets-source @@ -144,7 +144,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.3.0 + 3.3.1 java-client-integration-tests diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index ced7df0a375..c96c572d509 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -34,7 +34,7 @@ com.google.cloud libraries-bom - 26.39.0 + 26.43.0 pom import @@ -111,7 +111,7 @@ com.google.truth truth - 1.4.2 + 1.4.4 test @@ -175,7 +175,7 @@ org.apache.maven.plugins maven-failsafe-plugin - 3.3.0 + 3.3.1 java-client-integration-tests @@ -192,7 +192,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.3.1 + 3.4.0 **/SingerProto.java diff --git a/samples/snippets/src/main/java/com/example/spanner/CreateInstanceExample.java b/samples/snippets/src/main/java/com/example/spanner/CreateInstanceExample.java index b53727ba6d5..0bfb3a54c82 100644 --- a/samples/snippets/src/main/java/com/example/spanner/CreateInstanceExample.java +++ b/samples/snippets/src/main/java/com/example/spanner/CreateInstanceExample.java @@ -47,9 +47,9 @@ static void createInstance(String projectId, String instanceId) { .setDisplayName(displayName) .setNodeCount(nodeCount) .setConfig( - InstanceConfigName.of(projectId, "regional-us-central1").toString()) + InstanceConfigName.of(projectId, "regional-us-east4").toString()) .build(); - + try (Spanner spanner = SpannerOptions.newBuilder() .setProjectId(projectId) @@ -74,4 +74,4 @@ static void createInstance(String projectId, String instanceId) { } } } -//[END spanner_create_instance] \ No newline at end of file +//[END spanner_create_instance] diff --git a/samples/snippets/src/main/java/com/example/spanner/CreateInstancePartitionSample.java b/samples/snippets/src/main/java/com/example/spanner/CreateInstancePartitionSample.java new file mode 100644 index 00000000000..0e547bdaf7e --- /dev/null +++ b/samples/snippets/src/main/java/com/example/spanner/CreateInstancePartitionSample.java @@ -0,0 +1,80 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner; + +// [START spanner_create_instance_partition] + +import com.google.cloud.spanner.Spanner; +import com.google.cloud.spanner.SpannerOptions; +import com.google.cloud.spanner.admin.instance.v1.InstanceAdminClient; +import com.google.spanner.admin.instance.v1.CreateInstancePartitionRequest; +import com.google.spanner.admin.instance.v1.InstanceConfigName; +import com.google.spanner.admin.instance.v1.InstanceName; +import com.google.spanner.admin.instance.v1.InstancePartition; +import java.util.concurrent.ExecutionException; + +class CreateInstancePartitionSample { + + static void createInstancePartition() { + // TODO(developer): Replace these variables before running the sample. + String projectId = "my-project"; + String instanceId = "my-instance"; + String instancePartitionId = "my-instance-partition"; + createInstancePartition(projectId, instanceId, instancePartitionId); + } + + static void createInstancePartition( + String projectId, String instanceId, String instancePartitionId) { + // Set instance partition configuration. + int nodeCount = 1; + String displayName = "Descriptive name"; + + // Create an InstancePartition object that will be used to create the instance partition. + InstancePartition instancePartition = + InstancePartition.newBuilder() + .setDisplayName(displayName) + .setNodeCount(nodeCount) + .setConfig(InstanceConfigName.of(projectId, "nam3").toString()) + .build(); + + try (Spanner spanner = + SpannerOptions.newBuilder().setProjectId(projectId).build().getService(); + InstanceAdminClient instanceAdminClient = spanner.createInstanceAdminClient()) { + + // Wait for the createInstancePartition operation to finish. + InstancePartition createdInstancePartition = + instanceAdminClient + .createInstancePartitionAsync( + CreateInstancePartitionRequest.newBuilder() + .setParent(InstanceName.of(projectId, instanceId).toString()) + .setInstancePartitionId(instancePartitionId) + .setInstancePartition(instancePartition) + .build()) + .get(); + System.out.printf( + "Instance partition %s was successfully created%n", createdInstancePartition.getName()); + } catch (ExecutionException e) { + System.out.printf( + "Error: Creating instance partition %s failed with error message %s%n", + instancePartition.getName(), e.getMessage()); + } catch (InterruptedException e) { + System.out.println( + "Error: Waiting for createInstancePartition operation to finish was interrupted"); + } + } +} +// [END spanner_create_instance_partition] diff --git a/samples/snippets/src/main/java/com/example/spanner/CreateInstanceWithAutoscalingConfigExample.java b/samples/snippets/src/main/java/com/example/spanner/CreateInstanceWithAutoscalingConfigExample.java index dc62dd7a684..0a6e21ea620 100644 --- a/samples/snippets/src/main/java/com/example/spanner/CreateInstanceWithAutoscalingConfigExample.java +++ b/samples/snippets/src/main/java/com/example/spanner/CreateInstanceWithAutoscalingConfigExample.java @@ -45,7 +45,7 @@ static void createInstance(String projectId, String instanceId) { .getService(); InstanceAdminClient instanceAdminClient = spanner.createInstanceAdminClient()) { // Set Instance configuration. - String configId = "regional-us-central1"; + String configId = "regional-us-east4"; String displayName = "Descriptive name"; // Create an autoscaling config. diff --git a/samples/snippets/src/main/java/com/example/spanner/CreateInstanceWithProcessingUnitsExample.java b/samples/snippets/src/main/java/com/example/spanner/CreateInstanceWithProcessingUnitsExample.java index 293c10249c5..51133194744 100644 --- a/samples/snippets/src/main/java/com/example/spanner/CreateInstanceWithProcessingUnitsExample.java +++ b/samples/snippets/src/main/java/com/example/spanner/CreateInstanceWithProcessingUnitsExample.java @@ -44,7 +44,7 @@ static void createInstance(String projectId, String instanceId) { InstanceAdminClient instanceAdminClient = spanner.createInstanceAdminClient()) { // Set Instance configuration. - String configId = "regional-us-central1"; + String configId = "regional-us-east4"; // This will create an instance with the processing power of 0.2 nodes. int processingUnits = 500; String displayName = "Descriptive name"; diff --git a/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceExample.java b/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceExample.java index 15b33ae8927..a17784d874b 100644 --- a/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceExample.java +++ b/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceExample.java @@ -42,7 +42,7 @@ static void createInstance(String projectId, String instanceId) { InstanceAdminClient instanceAdminClient = spanner.getInstanceAdminClient(); // Set Instance configuration. - String configId = "regional-us-central1"; + String configId = "regional-us-east4"; int nodeCount = 2; String displayName = "Descriptive name"; diff --git a/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceWithAutoscalingConfigExample.java b/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceWithAutoscalingConfigExample.java index 3fe60c554bb..f8a683865ac 100644 --- a/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceWithAutoscalingConfigExample.java +++ b/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceWithAutoscalingConfigExample.java @@ -44,7 +44,7 @@ static void createInstance(String projectId, String instanceId) { InstanceAdminClient instanceAdminClient = spanner.getInstanceAdminClient(); // Set Instance configuration. - String configId = "regional-us-central1"; + String configId = "regional-us-east4"; // Create an autoscaling config. AutoscalingConfig autoscalingConfig = AutoscalingConfig.newBuilder() diff --git a/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceWithProcessingUnitsExample.java b/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceWithProcessingUnitsExample.java index f688b4cdbf9..95d4f1b6737 100644 --- a/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceWithProcessingUnitsExample.java +++ b/samples/snippets/src/main/java/com/example/spanner/admin/archived/CreateInstanceWithProcessingUnitsExample.java @@ -42,7 +42,7 @@ static void createInstance(String projectId, String instanceId) { InstanceAdminClient instanceAdminClient = spanner.getInstanceAdminClient(); // Set Instance configuration. - String configId = "regional-us-central1"; + String configId = "regional-us-east4"; // This will create an instance with the processing power of 0.2 nodes. int processingUnits = 500; String displayName = "Descriptive name"; diff --git a/samples/snippets/src/test/java/com/example/spanner/CreateInstancePartitionSampleIT.java b/samples/snippets/src/test/java/com/example/spanner/CreateInstancePartitionSampleIT.java new file mode 100644 index 00000000000..3038d29750d --- /dev/null +++ b/samples/snippets/src/test/java/com/example/spanner/CreateInstancePartitionSampleIT.java @@ -0,0 +1,55 @@ +/* + * Copyright 2024 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.example.spanner; + +import static com.google.common.truth.Truth.assertThat; + +import com.google.cloud.spanner.InstanceAdminClient; +import com.google.cloud.spanner.InstanceConfigId; +import com.google.cloud.spanner.InstanceId; +import com.google.cloud.spanner.InstanceInfo; +import com.google.spanner.admin.instance.v1.InstancePartitionName; +import org.junit.Test; + +public class CreateInstancePartitionSampleIT extends SampleTestBaseV2 { + + @Test + public void testCreateInstancePartition() throws Exception { + String instanceId = idGenerator.generateInstanceId(); + InstanceAdminClient instanceAdminClient = spanner.getInstanceAdminClient(); + instanceAdminClient + .createInstance( + InstanceInfo.newBuilder(InstanceId.of(projectId, instanceId)) + .setDisplayName("Geo-partitioning test instance") + .setInstanceConfigId(InstanceConfigId.of(projectId, "regional-us-central1")) + .setNodeCount(1) + .build()) + .get(); + + String instancePartitionId = "my-instance-partition"; + String out = + SampleRunner.runSample( + () -> + CreateInstancePartitionSample.createInstancePartition( + projectId, instanceId, instancePartitionId)); + assertThat(out) + .contains( + String.format( + "Instance partition %s", + InstancePartitionName.of(projectId, instanceId, instancePartitionId).toString())); + } +} diff --git a/versions.txt b/versions.txt index 52b39f63231..6cf9f7b626e 100644 --- a/versions.txt +++ b/versions.txt @@ -1,13 +1,13 @@ # Format: # module:released-version:current-version -proto-google-cloud-spanner-admin-instance-v1:6.71.0:6.71.0 -proto-google-cloud-spanner-v1:6.71.0:6.71.0 -proto-google-cloud-spanner-admin-database-v1:6.71.0:6.71.0 -grpc-google-cloud-spanner-v1:6.71.0:6.71.0 -grpc-google-cloud-spanner-admin-instance-v1:6.71.0:6.71.0 -grpc-google-cloud-spanner-admin-database-v1:6.71.0:6.71.0 -google-cloud-spanner:6.71.0:6.71.0 -google-cloud-spanner-executor:6.71.0:6.71.0 -proto-google-cloud-spanner-executor-v1:6.71.0:6.71.0 -grpc-google-cloud-spanner-executor-v1:6.71.0:6.71.0 +proto-google-cloud-spanner-admin-instance-v1:6.72.0:6.72.0 +proto-google-cloud-spanner-v1:6.72.0:6.72.0 +proto-google-cloud-spanner-admin-database-v1:6.72.0:6.72.0 +grpc-google-cloud-spanner-v1:6.72.0:6.72.0 +grpc-google-cloud-spanner-admin-instance-v1:6.72.0:6.72.0 +grpc-google-cloud-spanner-admin-database-v1:6.72.0:6.72.0 +google-cloud-spanner:6.72.0:6.72.0 +google-cloud-spanner-executor:6.72.0:6.72.0 +proto-google-cloud-spanner-executor-v1:6.72.0:6.72.0 +grpc-google-cloud-spanner-executor-v1:6.72.0:6.72.0