diff --git a/google/cloud/spanner_admin_database_v1/gapic/__init__.py b/.github/snippet-bot.yml
similarity index 100%
rename from google/cloud/spanner_admin_database_v1/gapic/__init__.py
rename to .github/snippet-bot.yml
diff --git a/.github/workflows/integration-tests-against-emulator.yaml b/.github/workflows/integration-tests-against-emulator.yaml
index d957a96662..803064a38e 100644
--- a/.github/workflows/integration-tests-against-emulator.yaml
+++ b/.github/workflows/integration-tests-against-emulator.yaml
@@ -21,11 +21,11 @@ jobs:
- name: Setup Python
uses: actions/setup-python@v2
with:
- python-version: 3.7
+ python-version: 3.8
- name: Install nox
run: python -m pip install nox
- name: Run system tests
- run: nox -s system-3.7
+ run: nox -s system
env:
SPANNER_EMULATOR_HOST: localhost:9010
GOOGLE_CLOUD_PROJECT: emulator-test-project
diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile
index f4c0758ce0..412b0b56a9 100644
--- a/.kokoro/docker/docs/Dockerfile
+++ b/.kokoro/docker/docs/Dockerfile
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from ubuntu:20.10
+from ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
diff --git a/.kokoro/docs/common.cfg b/.kokoro/docs/common.cfg
index ddb827fc6a..e58f8f473e 100644
--- a/.kokoro/docs/common.cfg
+++ b/.kokoro/docs/common.cfg
@@ -30,7 +30,7 @@ env_vars: {
env_vars: {
key: "V2_STAGING_BUCKET"
- value: "docs-staging-v2-staging"
+ value: "docs-staging-v2"
}
# It will upload the docker image after successful builds.
diff --git a/.kokoro/populate-secrets.sh b/.kokoro/populate-secrets.sh
new file mode 100755
index 0000000000..f52514257e
--- /dev/null
+++ b/.kokoro/populate-secrets.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+# Copyright 2020 Google LLC.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set -eo pipefail
+
+function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;}
+function msg { println "$*" >&2 ;}
+function println { printf '%s\n' "$(now) $*" ;}
+
+
+# Populates requested secrets set in SECRET_MANAGER_KEYS from service account:
+# kokoro-trampoline@cloud-devrel-kokoro-resources.iam.gserviceaccount.com
+SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager"
+msg "Creating folder on disk for secrets: ${SECRET_LOCATION}"
+mkdir -p ${SECRET_LOCATION}
+for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g")
+do
+ msg "Retrieving secret ${key}"
+ docker run --entrypoint=gcloud \
+ --volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR} \
+ gcr.io/google.com/cloudsdktool/cloud-sdk \
+ secrets versions access latest \
+ --project cloud-devrel-kokoro-resources \
+ --secret ${key} > \
+ "${SECRET_LOCATION}/${key}"
+ if [[ $? == 0 ]]; then
+ msg "Secret written to ${SECRET_LOCATION}/${key}"
+ else
+ msg "Error retrieving secret ${key}"
+ fi
+done
diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg
index 05c943b0c6..47b6a1fba3 100644
--- a/.kokoro/release/common.cfg
+++ b/.kokoro/release/common.cfg
@@ -23,42 +23,18 @@ env_vars: {
value: "github/python-spanner/.kokoro/release.sh"
}
-# Fetch the token needed for reporting release status to GitHub
-before_action {
- fetch_keystore {
- keystore_resource {
- keystore_config_id: 73713
- keyname: "yoshi-automation-github-key"
- }
- }
-}
-
-# Fetch PyPI password
-before_action {
- fetch_keystore {
- keystore_resource {
- keystore_config_id: 73713
- keyname: "google_cloud_pypi_password"
- }
- }
-}
-
-# Fetch magictoken to use with Magic Github Proxy
-before_action {
- fetch_keystore {
- keystore_resource {
- keystore_config_id: 73713
- keyname: "releasetool-magictoken"
- }
- }
+# Fetch PyPI password
+before_action {
+ fetch_keystore {
+ keystore_resource {
+ keystore_config_id: 73713
+ keyname: "google_cloud_pypi_password"
+ }
+ }
}
-# Fetch api key to use with Magic Github Proxy
-before_action {
- fetch_keystore {
- keystore_resource {
- keystore_config_id: 73713
- keyname: "magic-github-proxy-api-key"
- }
- }
-}
+# Tokens needed to report release status back to GitHub
+env_vars: {
+ key: "SECRET_MANAGER_KEYS"
+ value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.6/common.cfg b/.kokoro/samples/python3.6/common.cfg
index 093647288c..58b15c2849 100644
--- a/.kokoro/samples/python3.6/common.cfg
+++ b/.kokoro/samples/python3.6/common.cfg
@@ -13,6 +13,12 @@ env_vars: {
value: "py-3.6"
}
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-py36"
+}
+
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-spanner/.kokoro/test-samples.sh"
diff --git a/.kokoro/samples/python3.7/common.cfg b/.kokoro/samples/python3.7/common.cfg
index cc54c52285..07195c4c5e 100644
--- a/.kokoro/samples/python3.7/common.cfg
+++ b/.kokoro/samples/python3.7/common.cfg
@@ -13,6 +13,12 @@ env_vars: {
value: "py-3.7"
}
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-py37"
+}
+
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-spanner/.kokoro/test-samples.sh"
diff --git a/.kokoro/samples/python3.8/common.cfg b/.kokoro/samples/python3.8/common.cfg
index 04da5ee7ef..58713430dd 100644
--- a/.kokoro/samples/python3.8/common.cfg
+++ b/.kokoro/samples/python3.8/common.cfg
@@ -13,6 +13,12 @@ env_vars: {
value: "py-3.8"
}
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-py38"
+}
+
env_vars: {
key: "TRAMPOLINE_BUILD_FILE"
value: "github/python-spanner/.kokoro/test-samples.sh"
diff --git a/.kokoro/test-samples.sh b/.kokoro/test-samples.sh
index 77a94bb6d7..469771e159 100755
--- a/.kokoro/test-samples.sh
+++ b/.kokoro/test-samples.sh
@@ -28,6 +28,12 @@ if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"periodic"* ]]; then
git checkout $LATEST_RELEASE
fi
+# Exit early if samples directory doesn't exist
+if [ ! -d "./samples" ]; then
+ echo "No tests run. `./samples` not found"
+ exit 0
+fi
+
# Disable buffering, so that the logs stream through.
export PYTHONUNBUFFERED=1
@@ -101,4 +107,4 @@ cd "$ROOT"
# Workaround for Kokoro permissions issue: delete secrets
rm testing/{test-env.sh,client-secrets.json,service-account.json}
-exit "$RTN"
\ No newline at end of file
+exit "$RTN"
diff --git a/.kokoro/trampoline.sh b/.kokoro/trampoline.sh
index e8c4251f3e..f39236e943 100755
--- a/.kokoro/trampoline.sh
+++ b/.kokoro/trampoline.sh
@@ -15,9 +15,14 @@
set -eo pipefail
-python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" || ret_code=$?
+# Always run the cleanup script, regardless of the success of bouncing into
+# the container.
+function cleanup() {
+ chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
+ ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
+ echo "cleanup";
+}
+trap cleanup EXIT
-chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh
-${KOKORO_GFILE_DIR}/trampoline_cleanup.sh || true
-
-exit ${ret_code}
+$(dirname $0)/populate-secrets.sh # Secret Manager secrets.
+python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py"
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9e95a1ccc6..90c2aac158 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,18 @@
[1]: https://pypi.org/project/google-cloud-spanner/#history
+## [2.0.0](https://www.github.com/googleapis/python-spanner/compare/v1.19.1...v2.0.0) (2020-11-11)
+
+
+### ⚠ BREAKING CHANGES
+
+* migrate to v2.0.0 (#147)
+
+### Features
+
+* DB-API driver + unit tests ([#160](https://www.github.com/googleapis/python-spanner/issues/160)) ([2493fa1](https://www.github.com/googleapis/python-spanner/commit/2493fa1725d2d613f6c064637a4e215ee66255e3))
+* migrate to v2.0.0 ([#147](https://www.github.com/googleapis/python-spanner/issues/147)) ([bf4b278](https://www.github.com/googleapis/python-spanner/commit/bf4b27827494e3dc33b1e4333dfe147a36a486b3))
+
### [1.19.1](https://www.github.com/googleapis/python-spanner/compare/v1.19.0...v1.19.1) (2020-10-13)
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index b3d1f60298..039f436812 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -1,44 +1,95 @@
-# Contributor Code of Conduct
+# Code of Conduct
-As contributors and maintainers of this project,
-and in the interest of fostering an open and welcoming community,
-we pledge to respect all people who contribute through reporting issues,
-posting feature requests, updating documentation,
-submitting pull requests or patches, and other activities.
+## Our Pledge
-We are committed to making participation in this project
-a harassment-free experience for everyone,
-regardless of level of experience, gender, gender identity and expression,
-sexual orientation, disability, personal appearance,
-body size, race, ethnicity, age, religion, or nationality.
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, gender identity and expression, level of
+experience, education, socio-economic status, nationality, personal appearance,
+race, religion, or sexual identity and orientation.
+
+## Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
-* The use of sexualized language or imagery
-* Personal attacks
-* Trolling or insulting/derogatory comments
-* Public or private harassment
-* Publishing other's private information,
-such as physical or electronic
-addresses, without explicit permission
-* Other unethical or unprofessional conduct.
+* The use of sexualized language or imagery and unwelcome sexual attention or
+ advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject
-comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct.
-By adopting this Code of Conduct,
-project maintainers commit themselves to fairly and consistently
-applying these principles to every aspect of managing this project.
-Project maintainers who do not follow or enforce the Code of Conduct
-may be permanently removed from the project team.
-
-This code of conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community.
-
-Instances of abusive, harassing, or otherwise unacceptable behavior
-may be reported by opening an issue
-or contacting one or more of the project maintainers.
-
-This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.2.0,
-available at [http://contributor-covenant.org/version/1/2/0/](http://contributor-covenant.org/version/1/2/0/)
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, or to ban temporarily or permanently any
+contributor for other behaviors that they deem inappropriate, threatening,
+offensive, or harmful.
+
+## Scope
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an appointed
+representative at an online or offline event. Representation of a project may be
+further defined and clarified by project maintainers.
+
+This Code of Conduct also applies outside the project spaces when the Project
+Steward has a reasonable belief that an individual's behavior may have a
+negative impact on the project or its community.
+
+## Conflict Resolution
+
+We do not believe that all conflict is bad; healthy debate and disagreement
+often yield positive results. However, it is never okay to be disrespectful or
+to engage in behavior that violates the project’s code of conduct.
+
+If you see someone violating the code of conduct, you are encouraged to address
+the behavior directly with those involved. Many issues can be resolved quickly
+and easily, and this gives people more control over the outcome of their
+dispute. If you are unable to resolve the matter for any reason, or if the
+behavior is threatening or harassing, report it. We are dedicated to providing
+an environment where participants feel welcome and safe.
+
+
+Reports should be directed to *googleapis-stewards@google.com*, the
+Project Steward(s) for *Google Cloud Client Libraries*. It is the Project Steward’s duty to
+receive and address reported violations of the code of conduct. They will then
+work with a committee consisting of representatives from the Open Source
+Programs Office and the Google Open Source Strategy team. If for any reason you
+are uncomfortable reaching out to the Project Steward, please email
+opensource@google.com.
+
+We will investigate every complaint, but you may not receive a direct response.
+We will use our discretion in determining when and how to follow up on reported
+incidents, which may range from not taking action to permanent expulsion from
+the project and project-sponsored spaces. We will notify the accused of the
+report and provide them an opportunity to discuss it before any action is taken.
+The identity of the reporter will be omitted from the details of the report
+supplied to the accused. In potentially harmful situations, such as ongoing
+harassment or threats to anyone's safety, we may take action without notice.
+
+## Attribution
+
+This Code of Conduct is adapted from the Contributor Covenant, version 1.4,
+available at
+https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
\ No newline at end of file
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index e3b0e9d158..11e26783be 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -80,25 +80,6 @@ We use `nox `__ to instrument our tests.
.. nox: https://pypi.org/project/nox/
-Note on Editable Installs / Develop Mode
-========================================
-
-- As mentioned previously, using ``setuptools`` in `develop mode`_
- or a ``pip`` `editable install`_ is not possible with this
- library. This is because this library uses `namespace packages`_.
- For context see `Issue #2316`_ and the relevant `PyPA issue`_.
-
- Since ``editable`` / ``develop`` mode can't be used, packages
- need to be installed directly. Hence your changes to the source
- tree don't get incorporated into the **already installed**
- package.
-
-.. _namespace packages: https://www.python.org/dev/peps/pep-0420/
-.. _Issue #2316: https://github.com/GoogleCloudPlatform/google-cloud-python/issues/2316
-.. _PyPA issue: https://github.com/pypa/packaging-problems/issues/12
-.. _develop mode: https://setuptools.readthedocs.io/en/latest/setuptools.html#development-mode
-.. _editable install: https://pip.pypa.io/en/stable/reference/pip_install/#editable-installs
-
*****************************************
I'm getting weird errors... Can you help?
*****************************************
diff --git a/MANIFEST.in b/MANIFEST.in
index 42e5750549..e9e29d1203 100644
--- a/MANIFEST.in
+++ b/MANIFEST.in
@@ -16,7 +16,6 @@
# Generated by synthtool. DO NOT EDIT!
include README.rst LICENSE
-include google/cloud/spanner_v1/gapic/transports/spanner.grpc.config
recursive-include google *.json *.proto
recursive-include tests *
global-exclude *.py[co]
diff --git a/UPGRADING.md b/UPGRADING.md
new file mode 100644
index 0000000000..e90f2141bf
--- /dev/null
+++ b/UPGRADING.md
@@ -0,0 +1,318 @@
+
+
+
+# 2.0.0 Migration Guide
+
+The 2.0 release of the `google-cloud-spanner` client is a significant update based on a
+[next-gen code generator](https://github.com/googleapis/gapic-generator-python).
+It drops support for Python versions below 3.6.
+
+The handwritten client surfaces have minor changes which may require minimal updates to existing user code.
+
+The generated client surfaces have substantial interface changes. Existing user code which uses these surfaces directly
+will require significant updates to use this version.
+
+This document describes the changes that have been made, and what you need to do to update your usage.
+
+If you experience issues or have questions, please file an
+[issue](https://github.com/googleapis/python-spanner/issues).
+
+
+## Supported Python Versions
+
+> **WARNING**: Breaking change
+
+The 2.0.0 release requires Python 3.6+.
+
+## Handwritten Surface Changes
+
+### Resource List Methods
+
+> **WARNING**: Breaking change
+
+The list methods will now return the resource protos rather than the handwritten interfaces.
+
+Accessing properties will remain unchanged. However, calling methods will require creating the handwritten interface
+from the proto.
+
+**Before:**
+```py
+for instance in client.list_instances():
+ if "test" in instance.name:
+ instance.delete()
+```
+```py
+for backup in instance.list_backups():
+ if "test" in backup.name:
+ backup.delete()
+```
+```py
+for database in instance.list_databases():
+ if "test" in database.name:
+ database.delete()
+```
+
+**After:**
+```py
+for instance_pb in client.list_instances():
+ if "test" in instance_pb.name:
+ instance = Instance.from_pb(instance_pb, client)
+ instance.delete()
+```
+```py
+for backup_pb in instance.list_backups():
+ if "test" in backup_pb.name:
+ backup = Backup.from_pb(backup_pb, instance)
+ backup.delete()
+```
+```py
+for database_pb in instance.list_databases():
+ if "test" in database_pb.name:
+ database = Database.from_pb(database_pb, instance)
+ database.delete()
+```
+
+
+### Resource List Pagination
+
+> **WARNING**: Breaking change
+
+The library now handles pages for the user. Previously, the library would return a page generator which required a user
+to then iterate over each page to get the resource. Now, the library handles iterating over the pages and only returns
+the resource protos.
+
+**Before:**
+```py
+for page in client.list_instances(page_size=5):
+ for instance in page:
+ ...
+```
+```py
+for page in instance.list_backups(page_size=5):
+ for backup in page:
+ ...
+```
+```py
+for page in instance.list_databases(page_size=5):
+ for database in page:
+ ...
+```
+
+**After:**
+```py
+for instance_pb in client.list_instances(page_size=5):
+ ...
+```
+```py
+for backup_pb in instance.list_backups(page_size=5):
+ ...
+```
+```py
+for database_pb in instance.list_databases(page_size=5):
+ ...
+```
+
+### Deprecated Method Arguments
+
+> **WARNING**: Breaking change
+
+Deprecated arguments have been removed.
+If you use these arguments, they have no effect and can be removed without consequence.
+`user_agent` can be specified using `client_info` instead.
+Users should not be using `page_token` directly as the library handles pagination under the hood.
+
+**Before:**
+```py
+client = Client(user_agent=user_agent)
+```
+```py
+for instance in list_instances(page_token=page_token):
+ ...
+```
+```py
+for config in list_instance_configs(page_token=page_token):
+ ...
+```
+```py
+for database in list_databases(page_token=page_token):
+ ...
+```
+
+**After:**
+```py
+client = Client()
+```
+```py
+for instance_pb in client.list_instances():
+ ...
+```
+```py
+for instance_config_pb in client.list_instance_configs():
+ ...
+```
+```py
+for database_pb in instance.list_databases():
+ ...
+```
+
+
+## Generated Surface Changes
+
+
+### Method Calls
+
+> **WARNING**: Breaking change
+
+Methods expect request objects. We provide scripts that will convert most common use cases.
+
+* Install the library
+
+```py
+python3 -m pip install google-cloud-spanner
+```
+
+* The scripts `fixup_spanner_v1_keywords.py`, `fixup_spanner_admin_database_v1_keywords.py`, and
+`fixup_spanner_admin_instance_v1_keywords.py` are shipped with the library. They expect an input directory (with the
+code to convert) and an empty destination directory.
+
+```sh
+$ fixup_spanner_v1_keywords.py --input-directory .samples/ --output-directory samples/
+```
+
+>**WARNING**: These scripts will change any calls that match one of the methods. This may cause issues if you also use
+>the handwritten surfaces e.g. `client.list_instances()`
+
+#### More details
+
+ In `google-cloud-spanner<2.0.0`, parameters required by the API were positional parameters and optional parameters were
+ keyword parameters.
+
+ **Before:**
+ ```py
+def list_instances(
+ self,
+ parent,
+ page_size=None,
+ filter_=None,
+ retry=google.api_core.gapic_v1.method.DEFAULT,
+ timeout=google.api_core.gapic_v1.method.DEFAULT,
+ metadata=None,
+ ):
+ ```
+
+ In the 2.0.0 release, all methods have a single positional parameter `request`. Method docstrings indicate whether a
+ parameter is required or optional.
+
+ Some methods have additional keyword only parameters. The available parameters depend on the
+ [`google.api.method_signature` annotation](https://github.com/googleapis/googleapis/blob/master/google/spanner/admin/instance/v1/spanner_instance_admin.proto#L86) specified by the API producer.
+
+
+ **After:**
+ ```py
+def list_instances(
+ self,
+ request: spanner_instance_admin.ListInstancesRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListInstancesPager:
+ ```
+
+ > **NOTE:** The `request` parameter and flattened keyword parameters for the API are mutually exclusive.
+ > Passing both will result in an error.
+
+
+ Both of these calls are valid:
+
+ ```py
+ response = client.list_instances(
+ request={
+ "parent": project_name,
+ }
+ )
+ ```
+
+ ```py
+ response = client.execute_sql(
+ parent=project_name,
+ )
+ ```
+
+ This call is invalid because it mixes `request` with a keyword argument `parent`. Executing this code
+ will result in an error.
+
+ ```py
+ response = client.execute_sql(
+ request={},
+ parent=project_name,
+ )
+ ```
+
+### Enum and protos
+
+> **WARNING**: Breaking change
+
+Generated GAPIC protos have been moved under `types`. Import paths need to be adjusted.
+
+**Before:**
+```py
+from google.cloud.spanner_v1.proto import type_pb2
+
+param_types = {
+ "start_title": type_pb2.Type(code=type_pb2.STRING),
+ "end_title": type_pb2.Type(code=type_pb2.STRING),
+}
+```
+**After:**
+```py
+from google.cloud.spanner_v1 import Type
+from google.cloud.spanner_v1 import TypeCode
+
+param_types = {
+ "start_title": Type(code=TypeCode.STRING),
+ "end_title": Type(code=TypeCode.STRING),
+}
+```
+**Preferred:**
+```py
+from google.cloud import spanner
+
+param_types = {
+ "start_title": spanner.param_types.STRING,
+ "end_title": spanner.param_types.STRING,
+}
+```
+
+Generated GAPIC enum types have also been moved under `types`. Import paths need to be adjusted.
+
+**Before:**
+```py
+from google.cloud.spanner_admin_database_v1.gapic import enums
+
+state = enums.Backup.State.READY
+```
+**After:**
+```py
+from google.cloud.spanner_admin_database_v1 import types
+
+state = types.Backup.State.READY
+```
+**Preferred:**
+```py
+from google.cloud.spanner_admin_database_v1 import Backup
+
+state = Backup.State.READY
+```
diff --git a/docs/advanced-session-pool-topics.rst b/docs/advanced-session-pool-topics.rst
index 1b21fdcc9b..ea64c98a10 100644
--- a/docs/advanced-session-pool-topics.rst
+++ b/docs/advanced-session-pool-topics.rst
@@ -6,7 +6,7 @@ Custom Session Pool Implementations
You can supply your own pool implementation, which must satisfy the
contract laid out in
-:class:`~google.cloud.spanner.pool.AbstractSessionPool`:
+:class:`~google.cloud.spanner_v1.pool.AbstractSessionPool`:
.. code-block:: python
@@ -35,11 +35,11 @@ Lowering latency for read / query operations
Some applications may need to minimize latency for read operations, including
particularly the overhead of making an API request to create or refresh a
-session. :class:`~google.cloud.spanner.pool.PingingPool` is designed for such
+session. :class:`~google.cloud.spanner_v1.pool.PingingPool` is designed for such
applications, which need to configure a background thread to do the work of
keeping the sessions fresh.
-Create an instance of :class:`~google.cloud.spanner.pool.PingingPool`:
+Create an instance of :class:`~google.cloud.spanner_v1.pool.PingingPool`:
.. code-block:: python
@@ -74,12 +74,12 @@ Lowering latency for mixed read-write operations
Some applications may need to minimize latency for read write operations,
including particularly the overhead of making an API request to create or
refresh a session or to begin a session's transaction.
-:class:`~google.cloud.spanner.pool.TransactionPingingPool` is designed for
+:class:`~google.cloud.spanner_v1.pool.TransactionPingingPool` is designed for
such applications, which need to configure a background thread to do the work
of keeping the sessions fresh and starting their transactions after use.
Create an instance of
-:class:`~google.cloud.spanner.pool.TransactionPingingPool`:
+:class:`~google.cloud.spanner_v1.pool.TransactionPingingPool`:
.. code-block:: python
diff --git a/docs/api-reference.rst b/docs/api-reference.rst
index c767b23afa..30f67cd300 100644
--- a/docs/api-reference.rst
+++ b/docs/api-reference.rst
@@ -25,9 +25,9 @@ and some advanced use cases may wish to interact with these directly:
.. toctree::
:maxdepth: 1
- gapic/v1/api
- gapic/v1/types
- gapic/v1/admin_database_api
- gapic/v1/admin_database_types
- gapic/v1/admin_instance_api
- gapic/v1/admin_instance_types
+ spanner_v1/services
+ spanner_v1/types
+ spanner_admin_database_v1/services
+ spanner_admin_database_v1/types
+ spanner_admin_instance_v1/services
+ spanner_admin_instance_v1/types
diff --git a/docs/conf.py b/docs/conf.py
index 9eee0015d1..7d53976561 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -29,7 +29,7 @@
# -- General configuration ------------------------------------------------
# If your documentation needs a minimal Sphinx version, state it here.
-needs_sphinx = "1.6.3"
+needs_sphinx = "1.5.5"
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
@@ -39,6 +39,7 @@
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
+ "sphinx.ext.doctest",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
@@ -346,7 +347,7 @@
intersphinx_mapping = {
"python": ("http://python.readthedocs.org/en/latest/", None),
"google-auth": ("https://google-auth.readthedocs.io/en/stable", None),
- "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None),
+ "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,),
"grpc": ("https://grpc.io/grpc/python/", None),
}
diff --git a/docs/gapic/v1/admin_database_api.rst b/docs/gapic/v1/admin_database_api.rst
deleted file mode 100644
index c63f242e85..0000000000
--- a/docs/gapic/v1/admin_database_api.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-Spanner Admin Database Client API
-=================================
-
-.. automodule:: google.cloud.spanner_admin_database_v1
- :members:
- :inherited-members:
diff --git a/docs/gapic/v1/admin_database_types.rst b/docs/gapic/v1/admin_database_types.rst
deleted file mode 100644
index fa9aaa73b1..0000000000
--- a/docs/gapic/v1/admin_database_types.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-Spanner Admin Database Client Types
-===================================
-
-.. automodule:: google.cloud.spanner_admin_database_v1.types
- :members:
- :noindex:
diff --git a/docs/gapic/v1/admin_instance_api.rst b/docs/gapic/v1/admin_instance_api.rst
deleted file mode 100644
index c8c320a6cf..0000000000
--- a/docs/gapic/v1/admin_instance_api.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-Spanner Admin Instance Client API
-=================================
-
-.. automodule:: google.cloud.spanner_admin_instance_v1
- :members:
- :inherited-members:
diff --git a/docs/gapic/v1/admin_instance_types.rst b/docs/gapic/v1/admin_instance_types.rst
deleted file mode 100644
index f8f3afa5ff..0000000000
--- a/docs/gapic/v1/admin_instance_types.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-Spanner Admin Instance Client Types
-===================================
-
-.. automodule:: google.cloud.spanner_admin_instance_v1.types
- :members:
- :noindex:
diff --git a/docs/gapic/v1/api.rst b/docs/gapic/v1/api.rst
deleted file mode 100644
index 79e4835f22..0000000000
--- a/docs/gapic/v1/api.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-Spanner Client API
-==================
-
-.. automodule:: google.cloud.spanner_v1
- :members:
- :inherited-members:
diff --git a/docs/gapic/v1/transactions.rst b/docs/gapic/v1/transactions.rst
deleted file mode 100644
index d34af43b4a..0000000000
--- a/docs/gapic/v1/transactions.rst
+++ /dev/null
@@ -1,241 +0,0 @@
-..
- This page is pulled from the TransactionOption type, where this entire
- kaboodle is auto-generated. Sphinx does not particularly appreciate
- entire narrative documentation, complete with headers, in an arbitrary
- class docstring, and complains about this, so I (lukesneeringer@)
- manually copied it over here.
-
- This should probably be updated when the Spanner code is re-generated.
- This will be easy to remember because the source that needs to be copied
- will be dropped in transaction_pb2.py and Sphinx will complain loudly
- about it.
-
- Internal Google ticket: b/65243734
-
-:orphan:
-
-.. _spanner-txn:
-
-Transactions
-============
-
-Each session can have at most one active transaction at a time. After
-the active transaction is completed, the session can immediately be
-re-used for the next transaction. It is not necessary to create a new
-session for each transaction.
-
-Transaction Modes
-=================
-
-Cloud Spanner supports two transaction modes:
-
-1. Locking read-write. This type of transaction is the only way to write
- data into Cloud Spanner. These transactions rely on pessimistic
- locking and, if necessary, two-phase commit. Locking read-write
- transactions may abort, requiring the application to retry.
-
-2. Snapshot read-only. This transaction type provides guaranteed
- consistency across several reads, but does not allow writes. Snapshot
- read-only transactions can be configured to read at timestamps in the
- past. Snapshot read-only transactions do not need to be committed.
-
-For transactions that only read, snapshot read-only transactions provide
-simpler semantics and are almost always faster. In particular, read-only
-transactions do not take locks, so they do not conflict with read-write
-transactions. As a consequence of not taking locks, they also do not
-abort, so retry loops are not needed.
-
-Transactions may only read/write data in a single database. They may,
-however, read/write data in different tables within that database.
-
-Locking Read-Write Transactions
--------------------------------
-
-Locking transactions may be used to atomically read-modify-write data
-anywhere in a database. This type of transaction is externally
-consistent.
-
-Clients should attempt to minimize the amount of time a transaction is
-active. Faster transactions commit with higher probability and cause
-less contention. Cloud Spanner attempts to keep read locks active as
-long as the transaction continues to do reads, and the transaction has
-not been terminated by [Commit][google.spanner.v1.Spanner.Commit] or
-[Rollback][google.spanner.v1.Spanner.Rollback]. Long periods of
-inactivity at the client may cause Cloud Spanner to release a
-transaction's locks and abort it.
-
-Reads performed within a transaction acquire locks on the data being
-read. Writes can only be done at commit time, after all reads have been
-completed. Conceptually, a read-write transaction consists of zero or
-more reads or SQL queries followed by
-[Commit][google.spanner.v1.Spanner.Commit]. At any time before
-[Commit][google.spanner.v1.Spanner.Commit], the client can send a
-[Rollback][google.spanner.v1.Spanner.Rollback] request to abort the
-transaction.
-
-Semantics
-~~~~~~~~~
-
-Cloud Spanner can commit the transaction if all read locks it acquired
-are still valid at commit time, and it is able to acquire write locks
-for all writes. Cloud Spanner can abort the transaction for any reason.
-If a commit attempt returns ``ABORTED``, Cloud Spanner guarantees that
-the transaction has not modified any user data in Cloud Spanner.
-
-Unless the transaction commits, Cloud Spanner makes no guarantees about
-how long the transaction's locks were held for. It is an error to use
-Cloud Spanner locks for any sort of mutual exclusion other than between
-Cloud Spanner transactions themselves.
-
-Retrying Aborted Transactions
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-When a transaction aborts, the application can choose to retry the whole
-transaction again. To maximize the chances of successfully committing
-the retry, the client should execute the retry in the same session as
-the original attempt. The original session's lock priority increases
-with each consecutive abort, meaning that each attempt has a slightly
-better chance of success than the previous.
-
-Under some circumstances (e.g., many transactions attempting to modify
-the same row(s)), a transaction can abort many times in a short period
-before successfully committing. Thus, it is not a good idea to cap the
-number of retries a transaction can attempt; instead, it is better to
-limit the total amount of wall time spent retrying.
-
-Idle Transactions
-~~~~~~~~~~~~~~~~~
-
-A transaction is considered idle if it has no outstanding reads or SQL
-queries and has not started a read or SQL query within the last 10
-seconds. Idle transactions can be aborted by Cloud Spanner so that they
-don't hold on to locks indefinitely. In that case, the commit will fail
-with error ``ABORTED``.
-
-If this behavior is undesirable, periodically executing a simple SQL
-query in the transaction (e.g., ``SELECT 1``) prevents the transaction
-from becoming idle.
-
-Snapshot Read-Only Transactions
--------------------------------
-
-Snapshot read-only transactions provides a simpler method than locking
-read-write transactions for doing several consistent reads. However,
-this type of transaction does not support writes.
-
-Snapshot transactions do not take locks. Instead, they work by choosing
-a Cloud Spanner timestamp, then executing all reads at that timestamp.
-Since they do not acquire locks, they do not block concurrent read-write
-transactions.
-
-Unlike locking read-write transactions, snapshot read-only transactions
-never abort. They can fail if the chosen read timestamp is garbage
-collected; however, the default garbage collection policy is generous
-enough that most applications do not need to worry about this in
-practice.
-
-Snapshot read-only transactions do not need to call
-[Commit][google.spanner.v1.Spanner.Commit] or
-[Rollback][google.spanner.v1.Spanner.Rollback] (and in fact are not
-permitted to do so).
-
-To execute a snapshot transaction, the client specifies a timestamp
-bound, which tells Cloud Spanner how to choose a read timestamp.
-
-The types of timestamp bound are:
-
-- Strong (the default).
-- Bounded staleness.
-- Exact staleness.
-
-If the Cloud Spanner database to be read is geographically distributed,
-stale read-only transactions can execute more quickly than strong or
-read-write transaction, because they are able to execute far from the
-leader replica.
-
-Each type of timestamp bound is discussed in detail below.
-
-Strong
-~~~~~~
-
-Strong reads are guaranteed to see the effects of all transactions that
-have committed before the start of the read. Furthermore, all rows
-yielded by a single read are consistent with each other -- if any part
-of the read observes a transaction, all parts of the read see the
-transaction.
-
-Strong reads are not repeatable: two consecutive strong read-only
-transactions might return inconsistent results if there are concurrent
-writes. If consistency across reads is required, the reads should be
-executed within a transaction or at an exact read timestamp.
-
-See
-[TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong].
-
-Exact Staleness
-~~~~~~~~~~~~~~~
-
-These timestamp bounds execute reads at a user-specified timestamp.
-Reads at a timestamp are guaranteed to see a consistent prefix of the
-global transaction history: they observe modifications done by all
-transactions with a commit timestamp <= the read timestamp, and observe
-none of the modifications done by transactions with a larger commit
-timestamp. They will block until all conflicting transactions that may
-be assigned commit timestamps <= the read timestamp have finished.
-
-The timestamp can either be expressed as an absolute Cloud Spanner
-commit timestamp or a staleness relative to the current time.
-
-These modes do not require a "negotiation phase" to pick a timestamp. As
-a result, they execute slightly faster than the equivalent boundedly
-stale concurrency modes. On the other hand, boundedly stale reads
-usually return fresher results.
-
-See
-[TransactionOptions.ReadOnly.read\_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read\_timestamp]
-and
-[TransactionOptions.ReadOnly.exact\_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact\_staleness].
-
-Bounded Staleness
-~~~~~~~~~~~~~~~~~
-
-Bounded staleness modes allow Cloud Spanner to pick the read timestamp,
-subject to a user-provided staleness bound. Cloud Spanner chooses the
-newest timestamp within the staleness bound that allows execution of the
-reads at the closest available replica without blocking.
-
-All rows yielded are consistent with each other -- if any part of the
-read observes a transaction, all parts of the read see the transaction.
-Boundedly stale reads are not repeatable: two stale reads, even if they
-use the same staleness bound, can execute at different timestamps and
-thus return inconsistent results.
-
-Boundedly stale reads execute in two phases: the first phase negotiates
-a timestamp among all replicas needed to serve the read. In the second
-phase, reads are executed at the negotiated timestamp.
-
-As a result of the two phase execution, bounded staleness reads are
-usually a little slower than comparable exact staleness reads. However,
-they are typically able to return fresher results, and are more likely
-to execute at the closest replica.
-
-Because the timestamp negotiation requires up-front knowledge of which
-rows will be read, it can only be used with single-use read-only
-transactions.
-
-See
-[TransactionOptions.ReadOnly.max\_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max\_staleness]
-and
-[TransactionOptions.ReadOnly.min\_read\_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min\_read\_timestamp].
-
-Old Read Timestamps and Garbage Collection
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
-Cloud Spanner continuously garbage collects deleted and overwritten data
-in the background to reclaim storage space. This process is known as
-"version GC". By default, version GC reclaims versions after they are
-one hour old. Because of this, Cloud Spanner cannot perform reads at
-read timestamps more than one hour in the past. This restriction also
-applies to in-progress reads and/or SQL queries whose timestamp become
-too old while executing. Reads and SQL queries with too-old read
-timestamps fail with the error ``FAILED_PRECONDITION``.
diff --git a/docs/gapic/v1/types.rst b/docs/gapic/v1/types.rst
deleted file mode 100644
index 54424febf3..0000000000
--- a/docs/gapic/v1/types.rst
+++ /dev/null
@@ -1,6 +0,0 @@
-Spanner Client Types
-===================================
-
-.. automodule:: google.cloud.spanner_v1.types
- :members:
- :noindex:
diff --git a/docs/instance-usage.rst b/docs/instance-usage.rst
index 909e36b93f..55042c2df3 100644
--- a/docs/instance-usage.rst
+++ b/docs/instance-usage.rst
@@ -1,7 +1,7 @@
Instance Admin
==============
-After creating a :class:`~google.cloud.spanner.client.Client`, you can
+After creating a :class:`~google.cloud.spanner_v1.client.Client`, you can
interact with individual instances for a project.
Instance Configurations
@@ -12,7 +12,7 @@ specifying the location and other parameters for a set of instances. These
configurations are defined by the server, and cannot be changed.
To iterate over all instance configurations available to your project, use the
-:meth:`~google.cloud.spanner.client.Client.list_instance_configs`
+:meth:`~google.cloud.spanner_v1.client.Client.list_instance_configs`
method of the client:
.. code:: python
@@ -22,7 +22,7 @@ method of the client:
To fetch a single instance configuration, use the
-:meth:`~google.cloud.spanner.client.Client.get_instance_configuration`
+:meth:`~google.cloud.spanner_v1.client.Client.get_instance_configuration`
method of the client:
.. code:: python
@@ -37,7 +37,7 @@ List Instances
--------------
If you want a comprehensive list of all existing instances, iterate over the
-:meth:`~google.cloud.spanner.client.Client.list_instances` method of
+:meth:`~google.cloud.spanner_v1.client.Client.list_instances` method of
the client:
.. code:: python
@@ -52,7 +52,7 @@ objects.
Instance Factory
----------------
-To create a :class:`~google.cloud.spanner.instance.Instance` object:
+To create a :class:`~google.cloud.spanner_v1.instance.Instance` object:
.. code:: python
@@ -65,7 +65,7 @@ To create a :class:`~google.cloud.spanner.instance.Instance` object:
- ``configuration_name`` is the name of the instance configuration to which the
instance will be bound. It must be one of the names configured for your
project, discoverable via
- :meth:`~google.cloud.spanner.client.Client.list_instance_configs`.
+ :meth:`~google.cloud.spanner_v1.client.Client.list_instance_configs`.
- ``node_count`` is a postitive integral count of the number of nodes used
by the instance. More nodes allows for higher performance, but at a higher
@@ -87,7 +87,7 @@ Create a new Instance
---------------------
After creating the instance object, use its
-:meth:`~google.cloud.spanner.instance.Instance.create` method to
+:meth:`~google.cloud.spanner_v1.instance.Instance.create` method to
trigger its creation on the server:
.. code:: python
@@ -98,7 +98,7 @@ trigger its creation on the server:
.. note::
Creating an instance triggers a "long-running operation" and
- returns an :class:`google.cloud.spanner.instance.Operation`
+ returns an :class:`google.cloud.spanner_v1.instance.Operation`
object. See :ref:`check-on-current-instance-operation` for polling
to find out if the operation is completed.
@@ -107,7 +107,7 @@ Refresh metadata for an existing Instance
-----------------------------------------
After creating the instance object, reload its server-side configuration
-using its :meth:`~google.cloud.spanner.instance.Instance.reload` method:
+using its :meth:`~google.cloud.spanner_v1.instance.Instance.reload` method:
.. code:: python
@@ -121,7 +121,7 @@ Update an existing Instance
---------------------------
After creating the instance object, you can update its metadata via
-its :meth:`~google.cloud.spanner.instance.Instance.update` method:
+its :meth:`~google.cloud.spanner_v1.instance.Instance.update` method:
.. code:: python
@@ -131,7 +131,7 @@ its :meth:`~google.cloud.spanner.instance.Instance.update` method:
.. note::
Update an instance triggers a "long-running operation" and
- returns a :class:`google.cloud.spanner.instance.Operation`
+ returns a :class:`google.cloud.spanner_v1.instance.Operation`
object. See :ref:`check-on-current-instance-operation` for polling
to find out if the operation is completed.
@@ -140,7 +140,7 @@ Delete an existing Instance
---------------------------
Delete an instance using its
-:meth:`~google.cloud.spanner.instance.Instance.delete` method:
+:meth:`~google.cloud.spanner_v1.instance.Instance.delete` method:
.. code:: python
@@ -152,10 +152,10 @@ Delete an instance using its
Resolve Current Instance Operation
----------------------------------
-The :meth:`~google.cloud.spanner.instance.Instance.create` and
-:meth:`~google.cloud.spanner.instance.Instance.update` methods of instance
+The :meth:`~google.cloud.spanner_v1.instance.Instance.create` and
+:meth:`~google.cloud.spanner_v1.instance.Instance.update` methods of instance
object trigger long-running operations on the server, and return instances
-of the :class:`~google.cloud.spanner.instance.Operation` class.
+of the :class:`~google.cloud.spanner_v1.instance.Operation` class.
If you want to block on the completion of those operations, use the
``result`` method on the returned objects:
@@ -172,8 +172,8 @@ Next Step
---------
Now we go down the hierarchy from
-:class:`~google.cloud.spanner.instance.Instance` to a
-:class:`~google.cloud.spanner.database.Database`.
+:class:`~google.cloud.spanner_v1.instance.Instance` to a
+:class:`~google.cloud.spanner_v1.database.Database`.
Next, learn about the :doc:`database-usage`.
diff --git a/docs/spanner_admin_database_v1/services.rst b/docs/spanner_admin_database_v1/services.rst
new file mode 100644
index 0000000000..770ff1a8c2
--- /dev/null
+++ b/docs/spanner_admin_database_v1/services.rst
@@ -0,0 +1,6 @@
+Services for Google Cloud Spanner Admin Database v1 API
+=======================================================
+
+.. automodule:: google.cloud.spanner_admin_database_v1.services.database_admin
+ :members:
+ :inherited-members:
diff --git a/docs/spanner_admin_database_v1/types.rst b/docs/spanner_admin_database_v1/types.rst
new file mode 100644
index 0000000000..da44c33458
--- /dev/null
+++ b/docs/spanner_admin_database_v1/types.rst
@@ -0,0 +1,5 @@
+Types for Google Cloud Spanner Admin Database v1 API
+====================================================
+
+.. automodule:: google.cloud.spanner_admin_database_v1.types
+ :members:
diff --git a/docs/spanner_admin_instance_v1/services.rst b/docs/spanner_admin_instance_v1/services.rst
new file mode 100644
index 0000000000..44b02ecebb
--- /dev/null
+++ b/docs/spanner_admin_instance_v1/services.rst
@@ -0,0 +1,6 @@
+Services for Google Cloud Spanner Admin Instance v1 API
+=======================================================
+
+.. automodule:: google.cloud.spanner_admin_instance_v1.services.instance_admin
+ :members:
+ :inherited-members:
diff --git a/docs/spanner_admin_instance_v1/types.rst b/docs/spanner_admin_instance_v1/types.rst
new file mode 100644
index 0000000000..b496dfc681
--- /dev/null
+++ b/docs/spanner_admin_instance_v1/types.rst
@@ -0,0 +1,5 @@
+Types for Google Cloud Spanner Admin Instance v1 API
+====================================================
+
+.. automodule:: google.cloud.spanner_admin_instance_v1.types
+ :members:
diff --git a/docs/spanner_v1/services.rst b/docs/spanner_v1/services.rst
new file mode 100644
index 0000000000..9dbd2fe03e
--- /dev/null
+++ b/docs/spanner_v1/services.rst
@@ -0,0 +1,6 @@
+Services for Google Cloud Spanner v1 API
+========================================
+
+.. automodule:: google.cloud.spanner_v1.services.spanner
+ :members:
+ :inherited-members:
diff --git a/docs/spanner_v1/types.rst b/docs/spanner_v1/types.rst
new file mode 100644
index 0000000000..15b938d7f3
--- /dev/null
+++ b/docs/spanner_v1/types.rst
@@ -0,0 +1,5 @@
+Types for Google Cloud Spanner v1 API
+=====================================
+
+.. automodule:: google.cloud.spanner_v1.types
+ :members:
diff --git a/docs/transaction-usage.rst b/docs/transaction-usage.rst
index e475894939..4781cfa148 100644
--- a/docs/transaction-usage.rst
+++ b/docs/transaction-usage.rst
@@ -1,11 +1,11 @@
Read-write Transactions
#######################
-A :class:`~google.cloud.spanner.transaction.Transaction` represents a
+A :class:`~google.cloud.spanner_v1.transaction.Transaction` represents a
transaction: when the transaction commits, it will send any accumulated
mutations to the server.
-To understand more about how transactions work, visit :ref:`spanner-txn`.
+To understand more about how transactions work, visit [Transaction](https://cloud.google.com/spanner/docs/reference/rest/v1/Transaction).
To learn more about how to use them in the Python client, continue reading.
diff --git a/google/cloud/spanner.py b/google/cloud/spanner.py
index 0b1d3d949f..41a77cf7ce 100644
--- a/google/cloud/spanner.py
+++ b/google/cloud/spanner.py
@@ -1,4 +1,4 @@
-# Copyright 2016 Google LLC All rights reserved.
+# Copyright 2016, Google LLC All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -12,37 +12,36 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-"""Cloud Spanner API package."""
-
from __future__ import absolute_import
from google.cloud.spanner_v1 import __version__
-from google.cloud.spanner_v1 import AbstractSessionPool
-from google.cloud.spanner_v1 import BurstyPool
+from google.cloud.spanner_v1 import param_types
from google.cloud.spanner_v1 import Client
-from google.cloud.spanner_v1 import COMMIT_TIMESTAMP
-from google.cloud.spanner_v1 import enums
-from google.cloud.spanner_v1 import FixedSizePool
from google.cloud.spanner_v1 import KeyRange
from google.cloud.spanner_v1 import KeySet
-from google.cloud.spanner_v1 import param_types
+from google.cloud.spanner_v1 import AbstractSessionPool
+from google.cloud.spanner_v1 import BurstyPool
+from google.cloud.spanner_v1 import FixedSizePool
from google.cloud.spanner_v1 import PingingPool
from google.cloud.spanner_v1 import TransactionPingingPool
-from google.cloud.spanner_v1 import types
+from google.cloud.spanner_v1 import COMMIT_TIMESTAMP
__all__ = (
+ # google.cloud.spanner
"__version__",
- "AbstractSessionPool",
- "BurstyPool",
+ "param_types",
+ # google.cloud.spanner_v1.client
"Client",
- "COMMIT_TIMESTAMP",
- "enums",
- "FixedSizePool",
+ # google.cloud.spanner_v1.keyset
"KeyRange",
"KeySet",
- "param_types",
+ # google.cloud.spanner_v1.pool
+ "AbstractSessionPool",
+ "BurstyPool",
+ "FixedSizePool",
"PingingPool",
"TransactionPingingPool",
- "types",
+ # local
+ "COMMIT_TIMESTAMP",
)
diff --git a/google/cloud/spanner_admin_database_v1/__init__.py b/google/cloud/spanner_admin_database_v1/__init__.py
index 3a5b42403c..0f5bcd49b1 100644
--- a/google/cloud/spanner_admin_database_v1/__init__.py
+++ b/google/cloud/spanner_admin_database_v1/__init__.py
@@ -1,29 +1,83 @@
# -*- coding: utf-8 -*-
-#
-# Copyright 2018 Google LLC
+
+# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
-# https://www.apache.org/licenses/LICENSE-2.0
+# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
+#
-from __future__ import absolute_import
-
-from google.cloud.spanner_admin_database_v1 import types
-from google.cloud.spanner_admin_database_v1.gapic import database_admin_client
-from google.cloud.spanner_admin_database_v1.gapic import enums
-
-
-class DatabaseAdminClient(database_admin_client.DatabaseAdminClient):
- __doc__ = database_admin_client.DatabaseAdminClient.__doc__
- enums = enums
+from .services.database_admin import DatabaseAdminClient
+from .types.backup import Backup
+from .types.backup import BackupInfo
+from .types.backup import CreateBackupMetadata
+from .types.backup import CreateBackupRequest
+from .types.backup import DeleteBackupRequest
+from .types.backup import GetBackupRequest
+from .types.backup import ListBackupOperationsRequest
+from .types.backup import ListBackupOperationsResponse
+from .types.backup import ListBackupsRequest
+from .types.backup import ListBackupsResponse
+from .types.backup import UpdateBackupRequest
+from .types.common import OperationProgress
+from .types.spanner_database_admin import CreateDatabaseMetadata
+from .types.spanner_database_admin import CreateDatabaseRequest
+from .types.spanner_database_admin import Database
+from .types.spanner_database_admin import DropDatabaseRequest
+from .types.spanner_database_admin import GetDatabaseDdlRequest
+from .types.spanner_database_admin import GetDatabaseDdlResponse
+from .types.spanner_database_admin import GetDatabaseRequest
+from .types.spanner_database_admin import ListDatabaseOperationsRequest
+from .types.spanner_database_admin import ListDatabaseOperationsResponse
+from .types.spanner_database_admin import ListDatabasesRequest
+from .types.spanner_database_admin import ListDatabasesResponse
+from .types.spanner_database_admin import OptimizeRestoredDatabaseMetadata
+from .types.spanner_database_admin import RestoreDatabaseMetadata
+from .types.spanner_database_admin import RestoreDatabaseRequest
+from .types.spanner_database_admin import RestoreInfo
+from .types.spanner_database_admin import RestoreSourceType
+from .types.spanner_database_admin import UpdateDatabaseDdlMetadata
+from .types.spanner_database_admin import UpdateDatabaseDdlRequest
-__all__ = ("enums", "types", "DatabaseAdminClient")
+__all__ = (
+ "Backup",
+ "BackupInfo",
+ "CreateBackupMetadata",
+ "CreateBackupRequest",
+ "CreateDatabaseMetadata",
+ "CreateDatabaseRequest",
+ "Database",
+ "DeleteBackupRequest",
+ "DropDatabaseRequest",
+ "GetBackupRequest",
+ "GetDatabaseDdlRequest",
+ "GetDatabaseDdlResponse",
+ "GetDatabaseRequest",
+ "ListBackupOperationsRequest",
+ "ListBackupOperationsResponse",
+ "ListBackupsRequest",
+ "ListBackupsResponse",
+ "ListDatabaseOperationsRequest",
+ "ListDatabaseOperationsResponse",
+ "ListDatabasesRequest",
+ "ListDatabasesResponse",
+ "OperationProgress",
+ "OptimizeRestoredDatabaseMetadata",
+ "RestoreDatabaseMetadata",
+ "RestoreDatabaseRequest",
+ "RestoreInfo",
+ "RestoreSourceType",
+ "UpdateBackupRequest",
+ "UpdateDatabaseDdlMetadata",
+ "UpdateDatabaseDdlRequest",
+ "DatabaseAdminClient",
+)
diff --git a/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py b/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py
deleted file mode 100644
index dc11cb0283..0000000000
--- a/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py
+++ /dev/null
@@ -1,1923 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Accesses the google.spanner.admin.database.v1 DatabaseAdmin API."""
-
-import functools
-import pkg_resources
-import warnings
-
-from google.oauth2 import service_account
-import google.api_core.client_options
-import google.api_core.gapic_v1.client_info
-import google.api_core.gapic_v1.config
-import google.api_core.gapic_v1.method
-import google.api_core.gapic_v1.routing_header
-import google.api_core.grpc_helpers
-import google.api_core.operation
-import google.api_core.operations_v1
-import google.api_core.page_iterator
-import google.api_core.path_template
-import google.api_core.protobuf_helpers
-import grpc
-
-from google.cloud.spanner_admin_database_v1.gapic import database_admin_client_config
-from google.cloud.spanner_admin_database_v1.gapic import enums
-from google.cloud.spanner_admin_database_v1.gapic.transports import (
- database_admin_grpc_transport,
-)
-from google.cloud.spanner_admin_database_v1.proto import backup_pb2
-from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2
-from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2_grpc
-from google.iam.v1 import iam_policy_pb2
-from google.iam.v1 import options_pb2
-from google.iam.v1 import policy_pb2
-from google.longrunning import operations_pb2
-from google.protobuf import empty_pb2
-from google.protobuf import field_mask_pb2
-
-
-_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-spanner").version
-
-
-class DatabaseAdminClient(object):
- """
- Cloud Spanner Database Admin API
-
- The Cloud Spanner Database Admin API can be used to create, drop, and
- list databases. It also enables updating the schema of pre-existing
- databases. It can be also used to create, delete and list backups for a
- database and to restore from an existing backup.
- """
-
- SERVICE_ADDRESS = "spanner.googleapis.com:443"
- """The default address of the service."""
-
- # The name of the interface for this client. This is the key used to
- # find the method configuration in the client_config dictionary.
- _INTERFACE_NAME = "google.spanner.admin.database.v1.DatabaseAdmin"
-
- @classmethod
- def from_service_account_file(cls, filename, *args, **kwargs):
- """Creates an instance of this client using the provided credentials
- file.
-
- Args:
- filename (str): The path to the service account private key json
- file.
- args: Additional arguments to pass to the constructor.
- kwargs: Additional arguments to pass to the constructor.
-
- Returns:
- DatabaseAdminClient: The constructed client.
- """
- credentials = service_account.Credentials.from_service_account_file(filename)
- kwargs["credentials"] = credentials
- return cls(*args, **kwargs)
-
- from_service_account_json = from_service_account_file
-
- @classmethod
- def backup_path(cls, project, instance, backup):
- """Return a fully-qualified backup string."""
- return google.api_core.path_template.expand(
- "projects/{project}/instances/{instance}/backups/{backup}",
- project=project,
- instance=instance,
- backup=backup,
- )
-
- @classmethod
- def database_path(cls, project, instance, database):
- """Return a fully-qualified database string."""
- return google.api_core.path_template.expand(
- "projects/{project}/instances/{instance}/databases/{database}",
- project=project,
- instance=instance,
- database=database,
- )
-
- @classmethod
- def instance_path(cls, project, instance):
- """Return a fully-qualified instance string."""
- return google.api_core.path_template.expand(
- "projects/{project}/instances/{instance}",
- project=project,
- instance=instance,
- )
-
- def __init__(
- self,
- transport=None,
- channel=None,
- credentials=None,
- client_config=None,
- client_info=None,
- client_options=None,
- ):
- """Constructor.
-
- Args:
- transport (Union[~.DatabaseAdminGrpcTransport,
- Callable[[~.Credentials, type], ~.DatabaseAdminGrpcTransport]): A transport
- instance, responsible for actually making the API calls.
- The default transport uses the gRPC protocol.
- This argument may also be a callable which returns a
- transport instance. Callables will be sent the credentials
- as the first argument and the default transport class as
- the second argument.
- channel (grpc.Channel): DEPRECATED. A ``Channel`` instance
- through which to make calls. This argument is mutually exclusive
- with ``credentials``; providing both will raise an exception.
- credentials (google.auth.credentials.Credentials): The
- authorization credentials to attach to requests. These
- credentials identify this application to the service. If none
- are specified, the client will attempt to ascertain the
- credentials from the environment.
- This argument is mutually exclusive with providing a
- transport instance to ``transport``; doing so will raise
- an exception.
- client_config (dict): DEPRECATED. A dictionary of call options for
- each method. If not specified, the default configuration is used.
- client_info (google.api_core.gapic_v1.client_info.ClientInfo):
- The client info used to send a user-agent string along with
- API requests. If ``None``, then default info will be used.
- Generally, you only need to set this if you're developing
- your own client library.
- client_options (Union[dict, google.api_core.client_options.ClientOptions]):
- Client options used to set user options on the client. API Endpoint
- should be set through client_options.
- """
- # Raise deprecation warnings for things we want to go away.
- if client_config is not None:
- warnings.warn(
- "The `client_config` argument is deprecated.",
- PendingDeprecationWarning,
- stacklevel=2,
- )
- else:
- client_config = database_admin_client_config.config
-
- if channel:
- warnings.warn(
- "The `channel` argument is deprecated; use " "`transport` instead.",
- PendingDeprecationWarning,
- stacklevel=2,
- )
-
- api_endpoint = self.SERVICE_ADDRESS
- if client_options:
- if type(client_options) == dict:
- client_options = google.api_core.client_options.from_dict(
- client_options
- )
- if client_options.api_endpoint:
- api_endpoint = client_options.api_endpoint
-
- # Instantiate the transport.
- # The transport is responsible for handling serialization and
- # deserialization and actually sending data to the service.
- if transport:
- if callable(transport):
- self.transport = transport(
- credentials=credentials,
- default_class=database_admin_grpc_transport.DatabaseAdminGrpcTransport,
- address=api_endpoint,
- )
- else:
- if credentials:
- raise ValueError(
- "Received both a transport instance and "
- "credentials; these are mutually exclusive."
- )
- self.transport = transport
- else:
- self.transport = database_admin_grpc_transport.DatabaseAdminGrpcTransport(
- address=api_endpoint, channel=channel, credentials=credentials
- )
-
- if client_info is None:
- client_info = google.api_core.gapic_v1.client_info.ClientInfo(
- gapic_version=_GAPIC_LIBRARY_VERSION
- )
- else:
- client_info.gapic_version = _GAPIC_LIBRARY_VERSION
- self._client_info = client_info
-
- # Parse out the default settings for retry and timeout for each RPC
- # from the client configuration.
- # (Ordinarily, these are the defaults specified in the `*_config.py`
- # file next to this one.)
- self._method_configs = google.api_core.gapic_v1.config.parse_method_configs(
- client_config["interfaces"][self._INTERFACE_NAME]
- )
-
- # Save a dictionary of cached API call functions.
- # These are the actual callables which invoke the proper
- # transport methods, wrapped with `wrap_method` to add retry,
- # timeout, and the like.
- self._inner_api_calls = {}
-
- # Service calls
- def create_database(
- self,
- parent,
- create_statement,
- extra_statements=None,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Creates a new Cloud Spanner database and starts to prepare it for
- serving. The returned ``long-running operation`` will have a name of the
- format ``/operations/`` and can be used to
- track preparation of the database. The ``metadata`` field type is
- ``CreateDatabaseMetadata``. The ``response`` field type is ``Database``,
- if successful.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
- >>>
- >>> # TODO: Initialize `create_statement`:
- >>> create_statement = ''
- >>>
- >>> response = client.create_database(parent, create_statement)
- >>>
- >>> def callback(operation_future):
- ... # Handle result.
- ... result = operation_future.result()
- >>>
- >>> response.add_done_callback(callback)
- >>>
- >>> # Handle metadata.
- >>> metadata = response.metadata()
-
- Args:
- parent (str): Required. The name of the instance that will serve the new database.
- Values are of the form ``projects//instances/``.
- create_statement (str): Required. A ``CREATE DATABASE`` statement, which specifies the ID of
- the new database. The database ID must conform to the regular expression
- ``[a-z][a-z0-9_\-]*[a-z0-9]`` and be between 2 and 30 characters in
- length. If the database ID is a reserved word or if it contains a
- hyphen, the database ID must be enclosed in backticks (:literal:`\``).
- extra_statements (list[str]): Optional. A list of DDL statements to run inside the newly created
- database. Statements can create tables, indexes, etc. These
- statements execute atomically with the creation of the database:
- if there is an error in any statement, the database is not created.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.api_core.operation.Operation` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "create_database" not in self._inner_api_calls:
- self._inner_api_calls[
- "create_database"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.create_database,
- default_retry=self._method_configs["CreateDatabase"].retry,
- default_timeout=self._method_configs["CreateDatabase"].timeout,
- client_info=self._client_info,
- )
-
- request = spanner_database_admin_pb2.CreateDatabaseRequest(
- parent=parent,
- create_statement=create_statement,
- extra_statements=extra_statements,
- )
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("parent", parent)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- operation = self._inner_api_calls["create_database"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
- return google.api_core.operation.from_gapic(
- operation,
- self.transport._operations_client,
- spanner_database_admin_pb2.Database,
- metadata_type=spanner_database_admin_pb2.CreateDatabaseMetadata,
- )
-
- def update_database_ddl(
- self,
- database,
- statements,
- operation_id=None,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Updates the schema of a Cloud Spanner database by
- creating/altering/dropping tables, columns, indexes, etc. The returned
- ``long-running operation`` will have a name of the format
- ``/operations/`` and can be used to track
- execution of the schema change(s). The ``metadata`` field type is
- ``UpdateDatabaseDdlMetadata``. The operation has no response.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> database = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]')
- >>>
- >>> # TODO: Initialize `statements`:
- >>> statements = []
- >>>
- >>> response = client.update_database_ddl(database, statements)
- >>>
- >>> def callback(operation_future):
- ... # Handle result.
- ... result = operation_future.result()
- >>>
- >>> response.add_done_callback(callback)
- >>>
- >>> # Handle metadata.
- >>> metadata = response.metadata()
-
- Args:
- database (str): Required. The database to update.
- statements (list[str]): Required. DDL statements to be applied to the database.
- operation_id (str): If empty, the new update request is assigned an
- automatically-generated operation ID. Otherwise, ``operation_id`` is
- used to construct the name of the resulting ``Operation``.
-
- Specifying an explicit operation ID simplifies determining whether the
- statements were executed in the event that the ``UpdateDatabaseDdl``
- call is replayed, or the return value is otherwise lost: the
- ``database`` and ``operation_id`` fields can be combined to form the
- ``name`` of the resulting ``longrunning.Operation``:
- ``/operations/``.
-
- ``operation_id`` should be unique within the database, and must be a
- valid identifier: ``[a-z][a-z0-9_]*``. Note that automatically-generated
- operation IDs always begin with an underscore. If the named operation
- already exists, ``UpdateDatabaseDdl`` returns ``ALREADY_EXISTS``.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.api_core.operation.Operation` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "update_database_ddl" not in self._inner_api_calls:
- self._inner_api_calls[
- "update_database_ddl"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.update_database_ddl,
- default_retry=self._method_configs["UpdateDatabaseDdl"].retry,
- default_timeout=self._method_configs["UpdateDatabaseDdl"].timeout,
- client_info=self._client_info,
- )
-
- request = spanner_database_admin_pb2.UpdateDatabaseDdlRequest(
- database=database, statements=statements, operation_id=operation_id
- )
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("database", database)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- operation = self._inner_api_calls["update_database_ddl"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
- return google.api_core.operation.from_gapic(
- operation,
- self.transport._operations_client,
- empty_pb2.Empty,
- metadata_type=spanner_database_admin_pb2.UpdateDatabaseDdlMetadata,
- )
-
- def create_backup(
- self,
- parent,
- backup_id,
- backup,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Starts creating a new Cloud Spanner Backup. The returned backup
- ``long-running operation`` will have a name of the format
- ``projects//instances//backups//operations/``
- and can be used to track creation of the backup. The ``metadata`` field
- type is ``CreateBackupMetadata``. The ``response`` field type is
- ``Backup``, if successful. Cancelling the returned operation will stop
- the creation and delete the backup. There can be only one pending backup
- creation per database. Backup creation of different databases can run
- concurrently.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
- >>>
- >>> # TODO: Initialize `backup_id`:
- >>> backup_id = ''
- >>>
- >>> # TODO: Initialize `backup`:
- >>> backup = {}
- >>>
- >>> response = client.create_backup(parent, backup_id, backup)
- >>>
- >>> def callback(operation_future):
- ... # Handle result.
- ... result = operation_future.result()
- >>>
- >>> response.add_done_callback(callback)
- >>>
- >>> # Handle metadata.
- >>> metadata = response.metadata()
-
- Args:
- parent (str): Required. The name of the instance in which the backup will be
- created. This must be the same instance that contains the database the
- backup will be created from. The backup will be stored in the
- location(s) specified in the instance configuration of this instance.
- Values are of the form ``projects//instances/``.
- backup_id (str): Required. The id of the backup to be created. The ``backup_id``
- appended to ``parent`` forms the full backup name of the form
- ``projects//instances//backups/``.
- backup (Union[dict, ~google.cloud.spanner_admin_database_v1.types.Backup]): Required. The backup to create.
-
- If a dict is provided, it must be of the same form as the protobuf
- message :class:`~google.cloud.spanner_admin_database_v1.types.Backup`
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.api_core.operation.Operation` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "create_backup" not in self._inner_api_calls:
- self._inner_api_calls[
- "create_backup"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.create_backup,
- default_retry=self._method_configs["CreateBackup"].retry,
- default_timeout=self._method_configs["CreateBackup"].timeout,
- client_info=self._client_info,
- )
-
- request = backup_pb2.CreateBackupRequest(
- parent=parent, backup_id=backup_id, backup=backup
- )
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("parent", parent)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- operation = self._inner_api_calls["create_backup"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
- return google.api_core.operation.from_gapic(
- operation,
- self.transport._operations_client,
- backup_pb2.Backup,
- metadata_type=backup_pb2.CreateBackupMetadata,
- )
-
- def restore_database(
- self,
- parent,
- database_id,
- backup=None,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Create a new database by restoring from a completed backup. The new
- database must be in the same project and in an instance with the same
- instance configuration as the instance containing the backup. The
- returned database ``long-running operation`` has a name of the format
- ``projects//instances//databases//operations/``,
- and can be used to track the progress of the operation, and to cancel
- it. The ``metadata`` field type is ``RestoreDatabaseMetadata``. The
- ``response`` type is ``Database``, if successful. Cancelling the
- returned operation will stop the restore and delete the database. There
- can be only one database being restored into an instance at a time. Once
- the restore operation completes, a new restore operation can be
- initiated, without waiting for the optimize operation associated with
- the first restore to complete.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
- >>>
- >>> # TODO: Initialize `database_id`:
- >>> database_id = ''
- >>>
- >>> response = client.restore_database(parent, database_id)
- >>>
- >>> def callback(operation_future):
- ... # Handle result.
- ... result = operation_future.result()
- >>>
- >>> response.add_done_callback(callback)
- >>>
- >>> # Handle metadata.
- >>> metadata = response.metadata()
-
- Args:
- parent (str): Required. The name of the instance in which to create the restored
- database. This instance must be in the same project and have the same
- instance configuration as the instance containing the source backup.
- Values are of the form ``projects//instances/``.
- database_id (str): Required. The id of the database to create and restore to. This
- database must not already exist. The ``database_id`` appended to
- ``parent`` forms the full database name of the form
- ``projects//instances//databases/``.
- backup (str): Name of the backup from which to restore. Values are of the form
- ``projects//instances//backups/``.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.api_core.operation.Operation` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "restore_database" not in self._inner_api_calls:
- self._inner_api_calls[
- "restore_database"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.restore_database,
- default_retry=self._method_configs["RestoreDatabase"].retry,
- default_timeout=self._method_configs["RestoreDatabase"].timeout,
- client_info=self._client_info,
- )
-
- # Sanity check: We have some fields which are mutually exclusive;
- # raise ValueError if more than one is sent.
- google.api_core.protobuf_helpers.check_oneof(backup=backup)
-
- request = spanner_database_admin_pb2.RestoreDatabaseRequest(
- parent=parent, database_id=database_id, backup=backup
- )
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("parent", parent)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- operation = self._inner_api_calls["restore_database"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
- return google.api_core.operation.from_gapic(
- operation,
- self.transport._operations_client,
- spanner_database_admin_pb2.Database,
- metadata_type=spanner_database_admin_pb2.RestoreDatabaseMetadata,
- )
-
- def list_databases(
- self,
- parent,
- page_size=None,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Lists Cloud Spanner databases.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
- >>>
- >>> # Iterate over all results
- >>> for element in client.list_databases(parent):
- ... # process element
- ... pass
- >>>
- >>>
- >>> # Alternatively:
- >>>
- >>> # Iterate over results one page at a time
- >>> for page in client.list_databases(parent).pages:
- ... for element in page:
- ... # process element
- ... pass
-
- Args:
- parent (str): Required. The instance whose databases should be listed. Values are
- of the form ``projects//instances/``.
- page_size (int): The maximum number of resources contained in the
- underlying API response. If page streaming is performed per-
- resource, this parameter does not affect the return value. If page
- streaming is performed per-page, this determines the maximum number
- of resources in a page.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.api_core.page_iterator.PageIterator` instance.
- An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Database` instances.
- You can also iterate over the pages of the response
- using its `pages` property.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "list_databases" not in self._inner_api_calls:
- self._inner_api_calls[
- "list_databases"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.list_databases,
- default_retry=self._method_configs["ListDatabases"].retry,
- default_timeout=self._method_configs["ListDatabases"].timeout,
- client_info=self._client_info,
- )
-
- request = spanner_database_admin_pb2.ListDatabasesRequest(
- parent=parent, page_size=page_size
- )
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("parent", parent)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- iterator = google.api_core.page_iterator.GRPCIterator(
- client=None,
- method=functools.partial(
- self._inner_api_calls["list_databases"],
- retry=retry,
- timeout=timeout,
- metadata=metadata,
- ),
- request=request,
- items_field="databases",
- request_token_field="page_token",
- response_token_field="next_page_token",
- )
- return iterator
-
- def get_database(
- self,
- name,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Gets the state of a Cloud Spanner database.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> name = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]')
- >>>
- >>> response = client.get_database(name)
-
- Args:
- name (str): Required. The name of the requested database. Values are of the form
- ``projects//instances//databases/``.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.cloud.spanner_admin_database_v1.types.Database` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "get_database" not in self._inner_api_calls:
- self._inner_api_calls[
- "get_database"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.get_database,
- default_retry=self._method_configs["GetDatabase"].retry,
- default_timeout=self._method_configs["GetDatabase"].timeout,
- client_info=self._client_info,
- )
-
- request = spanner_database_admin_pb2.GetDatabaseRequest(name=name)
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("name", name)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- return self._inner_api_calls["get_database"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
-
- def drop_database(
- self,
- database,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Drops (aka deletes) a Cloud Spanner database. Completed backups for
- the database will be retained according to their ``expire_time``.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> database = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]')
- >>>
- >>> client.drop_database(database)
-
- Args:
- database (str): Required. The database to be dropped.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "drop_database" not in self._inner_api_calls:
- self._inner_api_calls[
- "drop_database"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.drop_database,
- default_retry=self._method_configs["DropDatabase"].retry,
- default_timeout=self._method_configs["DropDatabase"].timeout,
- client_info=self._client_info,
- )
-
- request = spanner_database_admin_pb2.DropDatabaseRequest(database=database)
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("database", database)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- self._inner_api_calls["drop_database"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
-
- def get_database_ddl(
- self,
- database,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Returns the schema of a Cloud Spanner database as a list of
- formatted DDL statements. This method does not show pending schema
- updates, those may be queried using the ``Operations`` API.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> database = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]')
- >>>
- >>> response = client.get_database_ddl(database)
-
- Args:
- database (str): Required. The database whose schema we wish to get.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlResponse` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "get_database_ddl" not in self._inner_api_calls:
- self._inner_api_calls[
- "get_database_ddl"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.get_database_ddl,
- default_retry=self._method_configs["GetDatabaseDdl"].retry,
- default_timeout=self._method_configs["GetDatabaseDdl"].timeout,
- client_info=self._client_info,
- )
-
- request = spanner_database_admin_pb2.GetDatabaseDdlRequest(database=database)
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("database", database)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- return self._inner_api_calls["get_database_ddl"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
-
- def set_iam_policy(
- self,
- resource,
- policy,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Sets the access control policy on a database or backup resource.
- Replaces any existing policy.
-
- Authorization requires ``spanner.databases.setIamPolicy`` permission on
- ``resource``. For backups, authorization requires
- ``spanner.backups.setIamPolicy`` permission on ``resource``.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> # TODO: Initialize `resource`:
- >>> resource = ''
- >>>
- >>> # TODO: Initialize `policy`:
- >>> policy = {}
- >>>
- >>> response = client.set_iam_policy(resource, policy)
-
- Args:
- resource (str): REQUIRED: The resource for which the policy is being specified.
- See the operation documentation for the appropriate value for this field.
- policy (Union[dict, ~google.cloud.spanner_admin_database_v1.types.Policy]): REQUIRED: The complete policy to be applied to the ``resource``. The
- size of the policy is limited to a few 10s of KB. An empty policy is a
- valid policy but certain Cloud Platform services (such as Projects)
- might reject them.
-
- If a dict is provided, it must be of the same form as the protobuf
- message :class:`~google.cloud.spanner_admin_database_v1.types.Policy`
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.cloud.spanner_admin_database_v1.types.Policy` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "set_iam_policy" not in self._inner_api_calls:
- self._inner_api_calls[
- "set_iam_policy"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.set_iam_policy,
- default_retry=self._method_configs["SetIamPolicy"].retry,
- default_timeout=self._method_configs["SetIamPolicy"].timeout,
- client_info=self._client_info,
- )
-
- request = iam_policy_pb2.SetIamPolicyRequest(resource=resource, policy=policy)
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("resource", resource)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- return self._inner_api_calls["set_iam_policy"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
-
- def get_iam_policy(
- self,
- resource,
- options_=None,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Gets the access control policy for a database or backup resource.
- Returns an empty policy if a database or backup exists but does not have
- a policy set.
-
- Authorization requires ``spanner.databases.getIamPolicy`` permission on
- ``resource``. For backups, authorization requires
- ``spanner.backups.getIamPolicy`` permission on ``resource``.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> # TODO: Initialize `resource`:
- >>> resource = ''
- >>>
- >>> response = client.get_iam_policy(resource)
-
- Args:
- resource (str): REQUIRED: The resource for which the policy is being requested.
- See the operation documentation for the appropriate value for this field.
- options_ (Union[dict, ~google.cloud.spanner_admin_database_v1.types.GetPolicyOptions]): OPTIONAL: A ``GetPolicyOptions`` object for specifying options to
- ``GetIamPolicy``. This field is only used by Cloud IAM.
-
- If a dict is provided, it must be of the same form as the protobuf
- message :class:`~google.cloud.spanner_admin_database_v1.types.GetPolicyOptions`
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.cloud.spanner_admin_database_v1.types.Policy` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "get_iam_policy" not in self._inner_api_calls:
- self._inner_api_calls[
- "get_iam_policy"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.get_iam_policy,
- default_retry=self._method_configs["GetIamPolicy"].retry,
- default_timeout=self._method_configs["GetIamPolicy"].timeout,
- client_info=self._client_info,
- )
-
- request = iam_policy_pb2.GetIamPolicyRequest(
- resource=resource, options=options_
- )
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("resource", resource)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- return self._inner_api_calls["get_iam_policy"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
-
- def test_iam_permissions(
- self,
- resource,
- permissions,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Returns permissions that the caller has on the specified database or
- backup resource.
-
- Attempting this RPC on a non-existent Cloud Spanner database will result
- in a NOT_FOUND error if the user has ``spanner.databases.list``
- permission on the containing Cloud Spanner instance. Otherwise returns
- an empty set of permissions. Calling this method on a backup that does
- not exist will result in a NOT_FOUND error if the user has
- ``spanner.backups.list`` permission on the containing instance.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> # TODO: Initialize `resource`:
- >>> resource = ''
- >>>
- >>> # TODO: Initialize `permissions`:
- >>> permissions = []
- >>>
- >>> response = client.test_iam_permissions(resource, permissions)
-
- Args:
- resource (str): REQUIRED: The resource for which the policy detail is being requested.
- See the operation documentation for the appropriate value for this field.
- permissions (list[str]): The set of permissions to check for the ``resource``. Permissions
- with wildcards (such as '*' or 'storage.*') are not allowed. For more
- information see `IAM
- Overview `__.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.cloud.spanner_admin_database_v1.types.TestIamPermissionsResponse` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "test_iam_permissions" not in self._inner_api_calls:
- self._inner_api_calls[
- "test_iam_permissions"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.test_iam_permissions,
- default_retry=self._method_configs["TestIamPermissions"].retry,
- default_timeout=self._method_configs["TestIamPermissions"].timeout,
- client_info=self._client_info,
- )
-
- request = iam_policy_pb2.TestIamPermissionsRequest(
- resource=resource, permissions=permissions
- )
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("resource", resource)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- return self._inner_api_calls["test_iam_permissions"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
-
- def get_backup(
- self,
- name,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Gets metadata on a pending or completed ``Backup``.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> name = client.backup_path('[PROJECT]', '[INSTANCE]', '[BACKUP]')
- >>>
- >>> response = client.get_backup(name)
-
- Args:
- name (str): Required. Name of the backup. Values are of the form
- ``projects//instances//backups/``.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.cloud.spanner_admin_database_v1.types.Backup` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "get_backup" not in self._inner_api_calls:
- self._inner_api_calls[
- "get_backup"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.get_backup,
- default_retry=self._method_configs["GetBackup"].retry,
- default_timeout=self._method_configs["GetBackup"].timeout,
- client_info=self._client_info,
- )
-
- request = backup_pb2.GetBackupRequest(name=name)
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("name", name)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- return self._inner_api_calls["get_backup"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
-
- def update_backup(
- self,
- backup,
- update_mask,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Updates a pending or completed ``Backup``.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> # TODO: Initialize `backup`:
- >>> backup = {}
- >>>
- >>> # TODO: Initialize `update_mask`:
- >>> update_mask = {}
- >>>
- >>> response = client.update_backup(backup, update_mask)
-
- Args:
- backup (Union[dict, ~google.cloud.spanner_admin_database_v1.types.Backup]): Required. The backup to update. ``backup.name``, and the fields to
- be updated as specified by ``update_mask`` are required. Other fields
- are ignored. Update is only supported for the following fields:
-
- - ``backup.expire_time``.
-
- If a dict is provided, it must be of the same form as the protobuf
- message :class:`~google.cloud.spanner_admin_database_v1.types.Backup`
- update_mask (Union[dict, ~google.cloud.spanner_admin_database_v1.types.FieldMask]): Required. A mask specifying which fields (e.g. ``expire_time``) in
- the Backup resource should be updated. This mask is relative to the
- Backup resource, not to the request message. The field mask must always
- be specified; this prevents any future fields from being erased
- accidentally by clients that do not know about them.
-
- If a dict is provided, it must be of the same form as the protobuf
- message :class:`~google.cloud.spanner_admin_database_v1.types.FieldMask`
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.cloud.spanner_admin_database_v1.types.Backup` instance.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "update_backup" not in self._inner_api_calls:
- self._inner_api_calls[
- "update_backup"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.update_backup,
- default_retry=self._method_configs["UpdateBackup"].retry,
- default_timeout=self._method_configs["UpdateBackup"].timeout,
- client_info=self._client_info,
- )
-
- request = backup_pb2.UpdateBackupRequest(backup=backup, update_mask=update_mask)
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("backup.name", backup.name)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- return self._inner_api_calls["update_backup"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
-
- def delete_backup(
- self,
- name,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Deletes a pending or completed ``Backup``.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> name = client.backup_path('[PROJECT]', '[INSTANCE]', '[BACKUP]')
- >>>
- >>> client.delete_backup(name)
-
- Args:
- name (str): Required. Name of the backup to delete. Values are of the form
- ``projects//instances//backups/``.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "delete_backup" not in self._inner_api_calls:
- self._inner_api_calls[
- "delete_backup"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.delete_backup,
- default_retry=self._method_configs["DeleteBackup"].retry,
- default_timeout=self._method_configs["DeleteBackup"].timeout,
- client_info=self._client_info,
- )
-
- request = backup_pb2.DeleteBackupRequest(name=name)
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("name", name)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- self._inner_api_calls["delete_backup"](
- request, retry=retry, timeout=timeout, metadata=metadata
- )
-
- def list_backups(
- self,
- parent,
- filter_=None,
- page_size=None,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Lists completed and pending backups. Backups returned are ordered by
- ``create_time`` in descending order, starting from the most recent
- ``create_time``.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
- >>>
- >>> # Iterate over all results
- >>> for element in client.list_backups(parent):
- ... # process element
- ... pass
- >>>
- >>>
- >>> # Alternatively:
- >>>
- >>> # Iterate over results one page at a time
- >>> for page in client.list_backups(parent).pages:
- ... for element in page:
- ... # process element
- ... pass
-
- Args:
- parent (str): Required. The instance to list backups from. Values are of the form
- ``projects//instances/``.
- filter_ (str): An expression that filters the list of returned backups.
-
- A filter expression consists of a field name, a comparison operator, and
- a value for filtering. The value must be a string, a number, or a
- boolean. The comparison operator must be one of: ``<``, ``>``, ``<=``,
- ``>=``, ``!=``, ``=``, or ``:``. Colon ``:`` is the contains operator.
- Filter rules are not case sensitive.
-
- The following fields in the ``Backup`` are eligible for filtering:
-
- - ``name``
- - ``database``
- - ``state``
- - ``create_time`` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
- - ``expire_time`` (and values are of the format YYYY-MM-DDTHH:MM:SSZ)
- - ``size_bytes``
-
- You can combine multiple expressions by enclosing each expression in
- parentheses. By default, expressions are combined with AND logic, but
- you can specify AND, OR, and NOT logic explicitly.
-
- Here are a few examples:
-
- - ``name:Howl`` - The backup's name contains the string "howl".
- - ``database:prod`` - The database's name contains the string "prod".
- - ``state:CREATING`` - The backup is pending creation.
- - ``state:READY`` - The backup is fully created and ready for use.
- - ``(name:howl) AND (create_time < \"2018-03-28T14:50:00Z\")`` - The
- backup name contains the string "howl" and ``create_time`` of the
- backup is before 2018-03-28T14:50:00Z.
- - ``expire_time < \"2018-03-28T14:50:00Z\"`` - The backup
- ``expire_time`` is before 2018-03-28T14:50:00Z.
- - ``size_bytes > 10000000000`` - The backup's size is greater than 10GB
- page_size (int): The maximum number of resources contained in the
- underlying API response. If page streaming is performed per-
- resource, this parameter does not affect the return value. If page
- streaming is performed per-page, this determines the maximum number
- of resources in a page.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.api_core.page_iterator.PageIterator` instance.
- An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Backup` instances.
- You can also iterate over the pages of the response
- using its `pages` property.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "list_backups" not in self._inner_api_calls:
- self._inner_api_calls[
- "list_backups"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.list_backups,
- default_retry=self._method_configs["ListBackups"].retry,
- default_timeout=self._method_configs["ListBackups"].timeout,
- client_info=self._client_info,
- )
-
- request = backup_pb2.ListBackupsRequest(
- parent=parent, filter=filter_, page_size=page_size
- )
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("parent", parent)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- iterator = google.api_core.page_iterator.GRPCIterator(
- client=None,
- method=functools.partial(
- self._inner_api_calls["list_backups"],
- retry=retry,
- timeout=timeout,
- metadata=metadata,
- ),
- request=request,
- items_field="backups",
- request_token_field="page_token",
- response_token_field="next_page_token",
- )
- return iterator
-
- def list_database_operations(
- self,
- parent,
- filter_=None,
- page_size=None,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Lists database ``longrunning-operations``. A database operation has
- a name of the form
- ``projects//instances//databases//operations/``.
- The long-running operation ``metadata`` field type ``metadata.type_url``
- describes the type of the metadata. Operations returned include those
- that have completed/failed/canceled within the last 7 days, and pending
- operations.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
- >>>
- >>> # Iterate over all results
- >>> for element in client.list_database_operations(parent):
- ... # process element
- ... pass
- >>>
- >>>
- >>> # Alternatively:
- >>>
- >>> # Iterate over results one page at a time
- >>> for page in client.list_database_operations(parent).pages:
- ... for element in page:
- ... # process element
- ... pass
-
- Args:
- parent (str): Required. The instance of the database operations. Values are of the
- form ``projects//instances/``.
- filter_ (str): An expression that filters the list of returned operations.
-
- A filter expression consists of a field name, a comparison operator, and
- a value for filtering. The value must be a string, a number, or a
- boolean. The comparison operator must be one of: ``<``, ``>``, ``<=``,
- ``>=``, ``!=``, ``=``, or ``:``. Colon ``:`` is the contains operator.
- Filter rules are not case sensitive.
-
- The following fields in the ``Operation`` are eligible for filtering:
-
- - ``name`` - The name of the long-running operation
- - ``done`` - False if the operation is in progress, else true.
- - ``metadata.@type`` - the type of metadata. For example, the type
- string for ``RestoreDatabaseMetadata`` is
- ``type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata``.
- - ``metadata.`` - any field in metadata.value.
- - ``error`` - Error associated with the long-running operation.
- - ``response.@type`` - the type of response.
- - ``response.`` - any field in response.value.
-
- You can combine multiple expressions by enclosing each expression in
- parentheses. By default, expressions are combined with AND logic.
- However, you can specify AND, OR, and NOT logic explicitly.
-
- Here are a few examples:
-
- - ``done:true`` - The operation is complete.
- - ``(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.RestoreDatabaseMetadata) AND``
- ``(metadata.source_type:BACKUP) AND``
- ``(metadata.backup_info.backup:backup_howl) AND``
- ``(metadata.name:restored_howl) AND``
- ``(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND``
- ``(error:*)`` - Return operations where:
-
- - The operation's metadata type is ``RestoreDatabaseMetadata``.
- - The database is restored from a backup.
- - The backup name contains "backup_howl".
- - The restored database's name contains "restored_howl".
- - The operation started before 2018-03-28T14:50:00Z.
- - The operation resulted in an error.
- page_size (int): The maximum number of resources contained in the
- underlying API response. If page streaming is performed per-
- resource, this parameter does not affect the return value. If page
- streaming is performed per-page, this determines the maximum number
- of resources in a page.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.api_core.page_iterator.PageIterator` instance.
- An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Operation` instances.
- You can also iterate over the pages of the response
- using its `pages` property.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "list_database_operations" not in self._inner_api_calls:
- self._inner_api_calls[
- "list_database_operations"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.list_database_operations,
- default_retry=self._method_configs["ListDatabaseOperations"].retry,
- default_timeout=self._method_configs["ListDatabaseOperations"].timeout,
- client_info=self._client_info,
- )
-
- request = spanner_database_admin_pb2.ListDatabaseOperationsRequest(
- parent=parent, filter=filter_, page_size=page_size
- )
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("parent", parent)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- iterator = google.api_core.page_iterator.GRPCIterator(
- client=None,
- method=functools.partial(
- self._inner_api_calls["list_database_operations"],
- retry=retry,
- timeout=timeout,
- metadata=metadata,
- ),
- request=request,
- items_field="operations",
- request_token_field="page_token",
- response_token_field="next_page_token",
- )
- return iterator
-
- def list_backup_operations(
- self,
- parent,
- filter_=None,
- page_size=None,
- retry=google.api_core.gapic_v1.method.DEFAULT,
- timeout=google.api_core.gapic_v1.method.DEFAULT,
- metadata=None,
- ):
- """
- Lists the backup ``long-running operations`` in the given instance.
- A backup operation has a name of the form
- ``projects//instances//backups//operations/``.
- The long-running operation ``metadata`` field type ``metadata.type_url``
- describes the type of the metadata. Operations returned include those
- that have completed/failed/canceled within the last 7 days, and pending
- operations. Operations returned are ordered by
- ``operation.metadata.value.progress.start_time`` in descending order
- starting from the most recently started operation.
-
- Example:
- >>> from google.cloud import spanner_admin_database_v1
- >>>
- >>> client = spanner_admin_database_v1.DatabaseAdminClient()
- >>>
- >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
- >>>
- >>> # Iterate over all results
- >>> for element in client.list_backup_operations(parent):
- ... # process element
- ... pass
- >>>
- >>>
- >>> # Alternatively:
- >>>
- >>> # Iterate over results one page at a time
- >>> for page in client.list_backup_operations(parent).pages:
- ... for element in page:
- ... # process element
- ... pass
-
- Args:
- parent (str): Required. The instance of the backup operations. Values are of the
- form ``projects//instances/``.
- filter_ (str): An expression that filters the list of returned backup operations.
-
- A filter expression consists of a field name, a comparison operator, and
- a value for filtering. The value must be a string, a number, or a
- boolean. The comparison operator must be one of: ``<``, ``>``, ``<=``,
- ``>=``, ``!=``, ``=``, or ``:``. Colon ``:`` is the contains operator.
- Filter rules are not case sensitive.
-
- The following fields in the ``operation`` are eligible for filtering:
-
- - ``name`` - The name of the long-running operation
- - ``done`` - False if the operation is in progress, else true.
- - ``metadata.@type`` - the type of metadata. For example, the type
- string for ``CreateBackupMetadata`` is
- ``type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata``.
- - ``metadata.`` - any field in metadata.value.
- - ``error`` - Error associated with the long-running operation.
- - ``response.@type`` - the type of response.
- - ``response.`` - any field in response.value.
-
- You can combine multiple expressions by enclosing each expression in
- parentheses. By default, expressions are combined with AND logic, but
- you can specify AND, OR, and NOT logic explicitly.
-
- Here are a few examples:
-
- - ``done:true`` - The operation is complete.
- - ``metadata.database:prod`` - The database the backup was taken from
- has a name containing the string "prod".
- - ``(metadata.@type=type.googleapis.com/google.spanner.admin.database.v1.CreateBackupMetadata) AND``
- ``(metadata.name:howl) AND``
- ``(metadata.progress.start_time < \"2018-03-28T14:50:00Z\") AND``
- ``(error:*)`` - Returns operations where:
-
- - The operation's metadata type is ``CreateBackupMetadata``.
- - The backup name contains the string "howl".
- - The operation started before 2018-03-28T14:50:00Z.
- - The operation resulted in an error.
- page_size (int): The maximum number of resources contained in the
- underlying API response. If page streaming is performed per-
- resource, this parameter does not affect the return value. If page
- streaming is performed per-page, this determines the maximum number
- of resources in a page.
- retry (Optional[google.api_core.retry.Retry]): A retry object used
- to retry requests. If ``None`` is specified, requests will
- be retried using a default configuration.
- timeout (Optional[float]): The amount of time, in seconds, to wait
- for the request to complete. Note that if ``retry`` is
- specified, the timeout applies to each individual attempt.
- metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
- that is provided to the method.
-
- Returns:
- A :class:`~google.api_core.page_iterator.PageIterator` instance.
- An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Operation` instances.
- You can also iterate over the pages of the response
- using its `pages` property.
-
- Raises:
- google.api_core.exceptions.GoogleAPICallError: If the request
- failed for any reason.
- google.api_core.exceptions.RetryError: If the request failed due
- to a retryable error and retry attempts failed.
- ValueError: If the parameters are invalid.
- """
- # Wrap the transport method to add retry and timeout logic.
- if "list_backup_operations" not in self._inner_api_calls:
- self._inner_api_calls[
- "list_backup_operations"
- ] = google.api_core.gapic_v1.method.wrap_method(
- self.transport.list_backup_operations,
- default_retry=self._method_configs["ListBackupOperations"].retry,
- default_timeout=self._method_configs["ListBackupOperations"].timeout,
- client_info=self._client_info,
- )
-
- request = backup_pb2.ListBackupOperationsRequest(
- parent=parent, filter=filter_, page_size=page_size
- )
- if metadata is None:
- metadata = []
- metadata = list(metadata)
- try:
- routing_header = [("parent", parent)]
- except AttributeError:
- pass
- else:
- routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
- routing_header
- )
- metadata.append(routing_metadata)
-
- iterator = google.api_core.page_iterator.GRPCIterator(
- client=None,
- method=functools.partial(
- self._inner_api_calls["list_backup_operations"],
- retry=retry,
- timeout=timeout,
- metadata=metadata,
- ),
- request=request,
- items_field="operations",
- request_token_field="page_token",
- response_token_field="next_page_token",
- )
- return iterator
diff --git a/google/cloud/spanner_admin_database_v1/gapic/database_admin_client_config.py b/google/cloud/spanner_admin_database_v1/gapic/database_admin_client_config.py
deleted file mode 100644
index 936fa54ef9..0000000000
--- a/google/cloud/spanner_admin_database_v1/gapic/database_admin_client_config.py
+++ /dev/null
@@ -1,147 +0,0 @@
-config = {
- "interfaces": {
- "google.spanner.admin.database.v1.DatabaseAdmin": {
- "retry_codes": {
- "retry_policy_1_codes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"],
- "no_retry_2_codes": [],
- "no_retry_codes": [],
- "retry_policy_2_codes": ["UNAVAILABLE", "DEADLINE_EXCEEDED"],
- "no_retry_1_codes": [],
- },
- "retry_params": {
- "retry_policy_1_params": {
- "initial_retry_delay_millis": 1000,
- "retry_delay_multiplier": 1.3,
- "max_retry_delay_millis": 32000,
- "initial_rpc_timeout_millis": 3600000,
- "rpc_timeout_multiplier": 1.0,
- "max_rpc_timeout_millis": 3600000,
- "total_timeout_millis": 3600000,
- },
- "retry_policy_2_params": {
- "initial_retry_delay_millis": 1000,
- "retry_delay_multiplier": 1.3,
- "max_retry_delay_millis": 32000,
- "initial_rpc_timeout_millis": 30000,
- "rpc_timeout_multiplier": 1.0,
- "max_rpc_timeout_millis": 30000,
- "total_timeout_millis": 30000,
- },
- "no_retry_params": {
- "initial_retry_delay_millis": 0,
- "retry_delay_multiplier": 0.0,
- "max_retry_delay_millis": 0,
- "initial_rpc_timeout_millis": 0,
- "rpc_timeout_multiplier": 1.0,
- "max_rpc_timeout_millis": 0,
- "total_timeout_millis": 0,
- },
- "no_retry_1_params": {
- "initial_retry_delay_millis": 0,
- "retry_delay_multiplier": 0.0,
- "max_retry_delay_millis": 0,
- "initial_rpc_timeout_millis": 3600000,
- "rpc_timeout_multiplier": 1.0,
- "max_rpc_timeout_millis": 3600000,
- "total_timeout_millis": 3600000,
- },
- "no_retry_2_params": {
- "initial_retry_delay_millis": 0,
- "retry_delay_multiplier": 0.0,
- "max_retry_delay_millis": 0,
- "initial_rpc_timeout_millis": 30000,
- "rpc_timeout_multiplier": 1.0,
- "max_rpc_timeout_millis": 30000,
- "total_timeout_millis": 30000,
- },
- },
- "methods": {
- "CreateDatabase": {
- "timeout_millis": 3600000,
- "retry_codes_name": "no_retry_1_codes",
- "retry_params_name": "no_retry_1_params",
- },
- "UpdateDatabaseDdl": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- "CreateBackup": {
- "timeout_millis": 3600000,
- "retry_codes_name": "no_retry_1_codes",
- "retry_params_name": "no_retry_1_params",
- },
- "RestoreDatabase": {
- "timeout_millis": 3600000,
- "retry_codes_name": "no_retry_1_codes",
- "retry_params_name": "no_retry_1_params",
- },
- "ListDatabases": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- "GetDatabase": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- "DropDatabase": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- "GetDatabaseDdl": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- "SetIamPolicy": {
- "timeout_millis": 30000,
- "retry_codes_name": "no_retry_2_codes",
- "retry_params_name": "no_retry_2_params",
- },
- "GetIamPolicy": {
- "timeout_millis": 30000,
- "retry_codes_name": "retry_policy_2_codes",
- "retry_params_name": "retry_policy_2_params",
- },
- "TestIamPermissions": {
- "timeout_millis": 30000,
- "retry_codes_name": "no_retry_2_codes",
- "retry_params_name": "no_retry_2_params",
- },
- "GetBackup": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- "UpdateBackup": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- "DeleteBackup": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- "ListBackups": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- "ListDatabaseOperations": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- "ListBackupOperations": {
- "timeout_millis": 3600000,
- "retry_codes_name": "retry_policy_1_codes",
- "retry_params_name": "retry_policy_1_params",
- },
- },
- }
- }
-}
diff --git a/google/cloud/spanner_admin_database_v1/gapic/enums.py b/google/cloud/spanner_admin_database_v1/gapic/enums.py
deleted file mode 100644
index 575cb3a8f7..0000000000
--- a/google/cloud/spanner_admin_database_v1/gapic/enums.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Wrappers for protocol buffer enum types."""
-
-import enum
-
-
-class RestoreSourceType(enum.IntEnum):
- """
- Indicates the type of the restore source.
-
- Attributes:
- TYPE_UNSPECIFIED (int): No restore associated.
- BACKUP (int): A backup was used as the source of the restore.
- """
-
- TYPE_UNSPECIFIED = 0
- BACKUP = 1
-
-
-class Backup(object):
- class State(enum.IntEnum):
- """
- Indicates the current state of the backup.
-
- Attributes:
- STATE_UNSPECIFIED (int): Not specified.
- CREATING (int): The pending backup is still being created. Operations on the backup
- may fail with ``FAILED_PRECONDITION`` in this state.
- READY (int): The backup is complete and ready for use.
- """
-
- STATE_UNSPECIFIED = 0
- CREATING = 1
- READY = 2
-
-
-class Database(object):
- class State(enum.IntEnum):
- """
- Indicates the current state of the database.
-
- Attributes:
- STATE_UNSPECIFIED (int): Not specified.
- CREATING (int): The database is still being created. Operations on the database may
- fail with ``FAILED_PRECONDITION`` in this state.
- READY (int): The database is fully created and ready for use.
- READY_OPTIMIZING (int): The database is fully created and ready for use, but is still being
- optimized for performance and cannot handle full load.
-
- In this state, the database still references the backup it was restore
- from, preventing the backup from being deleted. When optimizations are
- complete, the full performance of the database will be restored, and the
- database will transition to ``READY`` state.
- """
-
- STATE_UNSPECIFIED = 0
- CREATING = 1
- READY = 2
- READY_OPTIMIZING = 3
diff --git a/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py b/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py
deleted file mode 100644
index f2fb755668..0000000000
--- a/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py
+++ /dev/null
@@ -1,410 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright 2020 Google LLC
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# https://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-
-import google.api_core.grpc_helpers
-import google.api_core.operations_v1
-
-from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2_grpc
-
-
-class DatabaseAdminGrpcTransport(object):
- """gRPC transport class providing stubs for
- google.spanner.admin.database.v1 DatabaseAdmin API.
-
- The transport provides access to the raw gRPC stubs,
- which can be used to take advantage of advanced
- features of gRPC.
- """
-
- # The scopes needed to make gRPC calls to all of the methods defined
- # in this service.
- _OAUTH_SCOPES = (
- "https://www.googleapis.com/auth/cloud-platform",
- "https://www.googleapis.com/auth/spanner.admin",
- )
-
- def __init__(
- self, channel=None, credentials=None, address="spanner.googleapis.com:443"
- ):
- """Instantiate the transport class.
-
- Args:
- channel (grpc.Channel): A ``Channel`` instance through
- which to make calls. This argument is mutually exclusive
- with ``credentials``; providing both will raise an exception.
- credentials (google.auth.credentials.Credentials): The
- authorization credentials to attach to requests. These
- credentials identify this application to the service. If none
- are specified, the client will attempt to ascertain the
- credentials from the environment.
- address (str): The address where the service is hosted.
- """
- # If both `channel` and `credentials` are specified, raise an
- # exception (channels come with credentials baked in already).
- if channel is not None and credentials is not None:
- raise ValueError(
- "The `channel` and `credentials` arguments are mutually " "exclusive."
- )
-
- # Create the channel.
- if channel is None:
- channel = self.create_channel(
- address=address,
- credentials=credentials,
- options={
- "grpc.max_send_message_length": -1,
- "grpc.max_receive_message_length": -1,
- }.items(),
- )
-
- self._channel = channel
-
- # gRPC uses objects called "stubs" that are bound to the
- # channel and provide a basic method for each RPC.
- self._stubs = {
- "database_admin_stub": spanner_database_admin_pb2_grpc.DatabaseAdminStub(
- channel
- )
- }
-
- # Because this API includes a method that returns a
- # long-running operation (proto: google.longrunning.Operation),
- # instantiate an LRO client.
- self._operations_client = google.api_core.operations_v1.OperationsClient(
- channel
- )
-
- @classmethod
- def create_channel(
- cls, address="spanner.googleapis.com:443", credentials=None, **kwargs
- ):
- """Create and return a gRPC channel object.
-
- Args:
- address (str): The host for the channel to use.
- credentials (~.Credentials): The
- authorization credentials to attach to requests. These
- credentials identify this application to the service. If
- none are specified, the client will attempt to ascertain
- the credentials from the environment.
- kwargs (dict): Keyword arguments, which are passed to the
- channel creation.
-
- Returns:
- grpc.Channel: A gRPC channel object.
- """
- return google.api_core.grpc_helpers.create_channel(
- address, credentials=credentials, scopes=cls._OAUTH_SCOPES, **kwargs
- )
-
- @property
- def channel(self):
- """The gRPC channel used by the transport.
-
- Returns:
- grpc.Channel: A gRPC channel object.
- """
- return self._channel
-
- @property
- def create_database(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.create_database`.
-
- Creates a new Cloud Spanner database and starts to prepare it for
- serving. The returned ``long-running operation`` will have a name of the
- format ``/operations/`` and can be used to
- track preparation of the database. The ``metadata`` field type is
- ``CreateDatabaseMetadata``. The ``response`` field type is ``Database``,
- if successful.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].CreateDatabase
-
- @property
- def update_database_ddl(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.update_database_ddl`.
-
- Updates the schema of a Cloud Spanner database by
- creating/altering/dropping tables, columns, indexes, etc. The returned
- ``long-running operation`` will have a name of the format
- ``/operations/`` and can be used to track
- execution of the schema change(s). The ``metadata`` field type is
- ``UpdateDatabaseDdlMetadata``. The operation has no response.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].UpdateDatabaseDdl
-
- @property
- def create_backup(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.create_backup`.
-
- Starts creating a new Cloud Spanner Backup. The returned backup
- ``long-running operation`` will have a name of the format
- ``projects//instances//backups//operations/``
- and can be used to track creation of the backup. The ``metadata`` field
- type is ``CreateBackupMetadata``. The ``response`` field type is
- ``Backup``, if successful. Cancelling the returned operation will stop
- the creation and delete the backup. There can be only one pending backup
- creation per database. Backup creation of different databases can run
- concurrently.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].CreateBackup
-
- @property
- def restore_database(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.restore_database`.
-
- Create a new database by restoring from a completed backup. The new
- database must be in the same project and in an instance with the same
- instance configuration as the instance containing the backup. The
- returned database ``long-running operation`` has a name of the format
- ``projects//instances//databases//operations/``,
- and can be used to track the progress of the operation, and to cancel
- it. The ``metadata`` field type is ``RestoreDatabaseMetadata``. The
- ``response`` type is ``Database``, if successful. Cancelling the
- returned operation will stop the restore and delete the database. There
- can be only one database being restored into an instance at a time. Once
- the restore operation completes, a new restore operation can be
- initiated, without waiting for the optimize operation associated with
- the first restore to complete.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].RestoreDatabase
-
- @property
- def list_databases(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.list_databases`.
-
- Lists Cloud Spanner databases.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].ListDatabases
-
- @property
- def get_database(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.get_database`.
-
- Gets the state of a Cloud Spanner database.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].GetDatabase
-
- @property
- def drop_database(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.drop_database`.
-
- Drops (aka deletes) a Cloud Spanner database. Completed backups for
- the database will be retained according to their ``expire_time``.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].DropDatabase
-
- @property
- def get_database_ddl(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.get_database_ddl`.
-
- Returns the schema of a Cloud Spanner database as a list of
- formatted DDL statements. This method does not show pending schema
- updates, those may be queried using the ``Operations`` API.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].GetDatabaseDdl
-
- @property
- def set_iam_policy(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.set_iam_policy`.
-
- Sets the access control policy on a database or backup resource.
- Replaces any existing policy.
-
- Authorization requires ``spanner.databases.setIamPolicy`` permission on
- ``resource``. For backups, authorization requires
- ``spanner.backups.setIamPolicy`` permission on ``resource``.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].SetIamPolicy
-
- @property
- def get_iam_policy(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.get_iam_policy`.
-
- Gets the access control policy for a database or backup resource.
- Returns an empty policy if a database or backup exists but does not have
- a policy set.
-
- Authorization requires ``spanner.databases.getIamPolicy`` permission on
- ``resource``. For backups, authorization requires
- ``spanner.backups.getIamPolicy`` permission on ``resource``.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].GetIamPolicy
-
- @property
- def test_iam_permissions(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.test_iam_permissions`.
-
- Returns permissions that the caller has on the specified database or
- backup resource.
-
- Attempting this RPC on a non-existent Cloud Spanner database will result
- in a NOT_FOUND error if the user has ``spanner.databases.list``
- permission on the containing Cloud Spanner instance. Otherwise returns
- an empty set of permissions. Calling this method on a backup that does
- not exist will result in a NOT_FOUND error if the user has
- ``spanner.backups.list`` permission on the containing instance.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].TestIamPermissions
-
- @property
- def get_backup(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.get_backup`.
-
- Gets metadata on a pending or completed ``Backup``.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].GetBackup
-
- @property
- def update_backup(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.update_backup`.
-
- Updates a pending or completed ``Backup``.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].UpdateBackup
-
- @property
- def delete_backup(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.delete_backup`.
-
- Deletes a pending or completed ``Backup``.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].DeleteBackup
-
- @property
- def list_backups(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.list_backups`.
-
- Lists completed and pending backups. Backups returned are ordered by
- ``create_time`` in descending order, starting from the most recent
- ``create_time``.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].ListBackups
-
- @property
- def list_database_operations(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.list_database_operations`.
-
- Lists database ``longrunning-operations``. A database operation has
- a name of the form
- ``projects//instances//databases//operations/``.
- The long-running operation ``metadata`` field type ``metadata.type_url``
- describes the type of the metadata. Operations returned include those
- that have completed/failed/canceled within the last 7 days, and pending
- operations.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].ListDatabaseOperations
-
- @property
- def list_backup_operations(self):
- """Return the gRPC stub for :meth:`DatabaseAdminClient.list_backup_operations`.
-
- Lists the backup ``long-running operations`` in the given instance.
- A backup operation has a name of the form
- ``projects//instances//backups//operations/``.
- The long-running operation ``metadata`` field type ``metadata.type_url``
- describes the type of the metadata. Operations returned include those
- that have completed/failed/canceled within the last 7 days, and pending
- operations. Operations returned are ordered by
- ``operation.metadata.value.progress.start_time`` in descending order
- starting from the most recently started operation.
-
- Returns:
- Callable: A callable which accepts the appropriate
- deserialized request object and returns a
- deserialized response object.
- """
- return self._stubs["database_admin_stub"].ListBackupOperations
diff --git a/google/cloud/spanner_admin_database_v1/proto/__init__.py b/google/cloud/spanner_admin_database_v1/proto/__init__.py
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/google/cloud/spanner_admin_database_v1/proto/backup_pb2.py b/google/cloud/spanner_admin_database_v1/proto/backup_pb2.py
deleted file mode 100644
index 707412b7da..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/backup_pb2.py
+++ /dev/null
@@ -1,1407 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: google/cloud/spanner_admin_database_v1/proto/backup.proto
-
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2
-from google.api import resource_pb2 as google_dot_api_dot_resource__pb2
-from google.longrunning import (
- operations_pb2 as google_dot_longrunning_dot_operations__pb2,
-)
-from google.protobuf import field_mask_pb2 as google_dot_protobuf_dot_field__mask__pb2
-from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
-from google.cloud.spanner_admin_database_v1.proto import (
- common_pb2 as google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_common__pb2,
-)
-from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name="google/cloud/spanner_admin_database_v1/proto/backup.proto",
- package="google.spanner.admin.database.v1",
- syntax="proto3",
- serialized_options=b"\n$com.google.spanner.admin.database.v1B\013BackupProtoP\001ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\252\002&Google.Cloud.Spanner.Admin.Database.V1\312\002&Google\\Cloud\\Spanner\\Admin\\Database\\V1\352\002+Google::Cloud::Spanner::Admin::Database::V1",
- create_key=_descriptor._internal_create_key,
- serialized_pb=b'\n9google/cloud/spanner_admin_database_v1/proto/backup.proto\x12 google.spanner.admin.database.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a#google/longrunning/operations.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x39google/cloud/spanner_admin_database_v1/proto/common.proto\x1a\x1cgoogle/api/annotations.proto"\xcd\x03\n\x06\x42\x61\x63kup\x12\x36\n\x08\x64\x61tabase\x18\x02 \x01(\tB$\xfa\x41!\n\x1fspanner.googleapis.com/Database\x12/\n\x0b\x65xpire_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x34\n\x0b\x63reate_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12\x17\n\nsize_bytes\x18\x05 \x01(\x03\x42\x03\xe0\x41\x03\x12\x42\n\x05state\x18\x06 \x01(\x0e\x32..google.spanner.admin.database.v1.Backup.StateB\x03\xe0\x41\x03\x12"\n\x15referencing_databases\x18\x07 \x03(\tB\x03\xe0\x41\x03"7\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x43REATING\x10\x01\x12\t\n\x05READY\x10\x02:\\\xea\x41Y\n\x1dspanner.googleapis.com/Backup\x12\x38projects/{project}/instances/{instance}/backups/{backup}"\xa5\x01\n\x13\x43reateBackupRequest\x12\x37\n\x06parent\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\n\x1fspanner.googleapis.com/Instance\x12\x16\n\tbackup_id\x18\x02 \x01(\tB\x03\xe0\x41\x02\x12=\n\x06\x62\x61\x63kup\x18\x03 \x01(\x0b\x32(.google.spanner.admin.database.v1.BackupB\x03\xe0\x41\x02"\xae\x01\n\x14\x43reateBackupMetadata\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x10\n\x08\x64\x61tabase\x18\x02 \x01(\t\x12\x45\n\x08progress\x18\x03 \x01(\x0b\x32\x33.google.spanner.admin.database.v1.OperationProgress\x12/\n\x0b\x63\x61ncel_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"\x8a\x01\n\x13UpdateBackupRequest\x12=\n\x06\x62\x61\x63kup\x18\x01 \x01(\x0b\x32(.google.spanner.admin.database.v1.BackupB\x03\xe0\x41\x02\x12\x34\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMaskB\x03\xe0\x41\x02"G\n\x10GetBackupRequest\x12\x33\n\x04name\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\n\x1dspanner.googleapis.com/Backup"J\n\x13\x44\x65leteBackupRequest\x12\x33\n\x04name\x18\x01 \x01(\tB%\xe0\x41\x02\xfa\x41\x1f\n\x1dspanner.googleapis.com/Backup"\x84\x01\n\x12ListBackupsRequest\x12\x37\n\x06parent\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\n\x1fspanner.googleapis.com/Instance\x12\x0e\n\x06\x66ilter\x18\x02 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t"i\n\x13ListBackupsResponse\x12\x39\n\x07\x62\x61\x63kups\x18\x01 \x03(\x0b\x32(.google.spanner.admin.database.v1.Backup\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"\x8d\x01\n\x1bListBackupOperationsRequest\x12\x37\n\x06parent\x18\x01 \x01(\tB\'\xe0\x41\x02\xfa\x41!\n\x1fspanner.googleapis.com/Instance\x12\x0e\n\x06\x66ilter\x18\x02 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t"j\n\x1cListBackupOperationsResponse\x12\x31\n\noperations\x18\x01 \x03(\x0b\x32\x1d.google.longrunning.Operation\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"f\n\nBackupInfo\x12\x0e\n\x06\x62\x61\x63kup\x18\x01 \x01(\t\x12/\n\x0b\x63reate_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x17\n\x0fsource_database\x18\x03 \x01(\tB\xff\x01\n$com.google.spanner.admin.database.v1B\x0b\x42\x61\x63kupProtoP\x01ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\xaa\x02&Google.Cloud.Spanner.Admin.Database.V1\xca\x02&Google\\Cloud\\Spanner\\Admin\\Database\\V1\xea\x02+Google::Cloud::Spanner::Admin::Database::V1b\x06proto3',
- dependencies=[
- google_dot_api_dot_field__behavior__pb2.DESCRIPTOR,
- google_dot_api_dot_resource__pb2.DESCRIPTOR,
- google_dot_longrunning_dot_operations__pb2.DESCRIPTOR,
- google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR,
- google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_common__pb2.DESCRIPTOR,
- google_dot_api_dot_annotations__pb2.DESCRIPTOR,
- ],
-)
-
-
-_BACKUP_STATE = _descriptor.EnumDescriptor(
- name="State",
- full_name="google.spanner.admin.database.v1.Backup.State",
- filename=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- values=[
- _descriptor.EnumValueDescriptor(
- name="STATE_UNSPECIFIED",
- index=0,
- number=0,
- serialized_options=None,
- type=None,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.EnumValueDescriptor(
- name="CREATING",
- index=1,
- number=1,
- serialized_options=None,
- type=None,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.EnumValueDescriptor(
- name="READY",
- index=2,
- number=2,
- serialized_options=None,
- type=None,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=661,
- serialized_end=716,
-)
-_sym_db.RegisterEnumDescriptor(_BACKUP_STATE)
-
-
-_BACKUP = _descriptor.Descriptor(
- name="Backup",
- full_name="google.spanner.admin.database.v1.Backup",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="database",
- full_name="google.spanner.admin.database.v1.Backup.database",
- index=0,
- number=2,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\372A!\n\037spanner.googleapis.com/Database",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="expire_time",
- full_name="google.spanner.admin.database.v1.Backup.expire_time",
- index=1,
- number=3,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="name",
- full_name="google.spanner.admin.database.v1.Backup.name",
- index=2,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="create_time",
- full_name="google.spanner.admin.database.v1.Backup.create_time",
- index=3,
- number=4,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\003",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="size_bytes",
- full_name="google.spanner.admin.database.v1.Backup.size_bytes",
- index=4,
- number=5,
- type=3,
- cpp_type=2,
- label=1,
- has_default_value=False,
- default_value=0,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\003",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="state",
- full_name="google.spanner.admin.database.v1.Backup.state",
- index=5,
- number=6,
- type=14,
- cpp_type=8,
- label=1,
- has_default_value=False,
- default_value=0,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\003",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="referencing_databases",
- full_name="google.spanner.admin.database.v1.Backup.referencing_databases",
- index=6,
- number=7,
- type=9,
- cpp_type=9,
- label=3,
- has_default_value=False,
- default_value=[],
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\003",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[_BACKUP_STATE],
- serialized_options=b"\352AY\n\035spanner.googleapis.com/Backup\0228projects/{project}/instances/{instance}/backups/{backup}",
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=349,
- serialized_end=810,
-)
-
-
-_CREATEBACKUPREQUEST = _descriptor.Descriptor(
- name="CreateBackupRequest",
- full_name="google.spanner.admin.database.v1.CreateBackupRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="parent",
- full_name="google.spanner.admin.database.v1.CreateBackupRequest.parent",
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\002\372A!\n\037spanner.googleapis.com/Instance",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="backup_id",
- full_name="google.spanner.admin.database.v1.CreateBackupRequest.backup_id",
- index=1,
- number=2,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\002",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="backup",
- full_name="google.spanner.admin.database.v1.CreateBackupRequest.backup",
- index=2,
- number=3,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\002",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=813,
- serialized_end=978,
-)
-
-
-_CREATEBACKUPMETADATA = _descriptor.Descriptor(
- name="CreateBackupMetadata",
- full_name="google.spanner.admin.database.v1.CreateBackupMetadata",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="name",
- full_name="google.spanner.admin.database.v1.CreateBackupMetadata.name",
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="database",
- full_name="google.spanner.admin.database.v1.CreateBackupMetadata.database",
- index=1,
- number=2,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="progress",
- full_name="google.spanner.admin.database.v1.CreateBackupMetadata.progress",
- index=2,
- number=3,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="cancel_time",
- full_name="google.spanner.admin.database.v1.CreateBackupMetadata.cancel_time",
- index=3,
- number=4,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=981,
- serialized_end=1155,
-)
-
-
-_UPDATEBACKUPREQUEST = _descriptor.Descriptor(
- name="UpdateBackupRequest",
- full_name="google.spanner.admin.database.v1.UpdateBackupRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="backup",
- full_name="google.spanner.admin.database.v1.UpdateBackupRequest.backup",
- index=0,
- number=1,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\002",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="update_mask",
- full_name="google.spanner.admin.database.v1.UpdateBackupRequest.update_mask",
- index=1,
- number=2,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\002",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1158,
- serialized_end=1296,
-)
-
-
-_GETBACKUPREQUEST = _descriptor.Descriptor(
- name="GetBackupRequest",
- full_name="google.spanner.admin.database.v1.GetBackupRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="name",
- full_name="google.spanner.admin.database.v1.GetBackupRequest.name",
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\002\372A\037\n\035spanner.googleapis.com/Backup",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- )
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1298,
- serialized_end=1369,
-)
-
-
-_DELETEBACKUPREQUEST = _descriptor.Descriptor(
- name="DeleteBackupRequest",
- full_name="google.spanner.admin.database.v1.DeleteBackupRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="name",
- full_name="google.spanner.admin.database.v1.DeleteBackupRequest.name",
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\002\372A\037\n\035spanner.googleapis.com/Backup",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- )
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1371,
- serialized_end=1445,
-)
-
-
-_LISTBACKUPSREQUEST = _descriptor.Descriptor(
- name="ListBackupsRequest",
- full_name="google.spanner.admin.database.v1.ListBackupsRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="parent",
- full_name="google.spanner.admin.database.v1.ListBackupsRequest.parent",
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\002\372A!\n\037spanner.googleapis.com/Instance",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="filter",
- full_name="google.spanner.admin.database.v1.ListBackupsRequest.filter",
- index=1,
- number=2,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="page_size",
- full_name="google.spanner.admin.database.v1.ListBackupsRequest.page_size",
- index=2,
- number=3,
- type=5,
- cpp_type=1,
- label=1,
- has_default_value=False,
- default_value=0,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="page_token",
- full_name="google.spanner.admin.database.v1.ListBackupsRequest.page_token",
- index=3,
- number=4,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1448,
- serialized_end=1580,
-)
-
-
-_LISTBACKUPSRESPONSE = _descriptor.Descriptor(
- name="ListBackupsResponse",
- full_name="google.spanner.admin.database.v1.ListBackupsResponse",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="backups",
- full_name="google.spanner.admin.database.v1.ListBackupsResponse.backups",
- index=0,
- number=1,
- type=11,
- cpp_type=10,
- label=3,
- has_default_value=False,
- default_value=[],
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="next_page_token",
- full_name="google.spanner.admin.database.v1.ListBackupsResponse.next_page_token",
- index=1,
- number=2,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1582,
- serialized_end=1687,
-)
-
-
-_LISTBACKUPOPERATIONSREQUEST = _descriptor.Descriptor(
- name="ListBackupOperationsRequest",
- full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="parent",
- full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest.parent",
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\002\372A!\n\037spanner.googleapis.com/Instance",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="filter",
- full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest.filter",
- index=1,
- number=2,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="page_size",
- full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest.page_size",
- index=2,
- number=3,
- type=5,
- cpp_type=1,
- label=1,
- has_default_value=False,
- default_value=0,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="page_token",
- full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest.page_token",
- index=3,
- number=4,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1690,
- serialized_end=1831,
-)
-
-
-_LISTBACKUPOPERATIONSRESPONSE = _descriptor.Descriptor(
- name="ListBackupOperationsResponse",
- full_name="google.spanner.admin.database.v1.ListBackupOperationsResponse",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="operations",
- full_name="google.spanner.admin.database.v1.ListBackupOperationsResponse.operations",
- index=0,
- number=1,
- type=11,
- cpp_type=10,
- label=3,
- has_default_value=False,
- default_value=[],
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="next_page_token",
- full_name="google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token",
- index=1,
- number=2,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1833,
- serialized_end=1939,
-)
-
-
-_BACKUPINFO = _descriptor.Descriptor(
- name="BackupInfo",
- full_name="google.spanner.admin.database.v1.BackupInfo",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="backup",
- full_name="google.spanner.admin.database.v1.BackupInfo.backup",
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="create_time",
- full_name="google.spanner.admin.database.v1.BackupInfo.create_time",
- index=1,
- number=2,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="source_database",
- full_name="google.spanner.admin.database.v1.BackupInfo.source_database",
- index=2,
- number=3,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1941,
- serialized_end=2043,
-)
-
-_BACKUP.fields_by_name[
- "expire_time"
-].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP
-_BACKUP.fields_by_name[
- "create_time"
-].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP
-_BACKUP.fields_by_name["state"].enum_type = _BACKUP_STATE
-_BACKUP_STATE.containing_type = _BACKUP
-_CREATEBACKUPREQUEST.fields_by_name["backup"].message_type = _BACKUP
-_CREATEBACKUPMETADATA.fields_by_name[
- "progress"
-].message_type = (
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_common__pb2._OPERATIONPROGRESS
-)
-_CREATEBACKUPMETADATA.fields_by_name[
- "cancel_time"
-].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP
-_UPDATEBACKUPREQUEST.fields_by_name["backup"].message_type = _BACKUP
-_UPDATEBACKUPREQUEST.fields_by_name[
- "update_mask"
-].message_type = google_dot_protobuf_dot_field__mask__pb2._FIELDMASK
-_LISTBACKUPSRESPONSE.fields_by_name["backups"].message_type = _BACKUP
-_LISTBACKUPOPERATIONSRESPONSE.fields_by_name[
- "operations"
-].message_type = google_dot_longrunning_dot_operations__pb2._OPERATION
-_BACKUPINFO.fields_by_name[
- "create_time"
-].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP
-DESCRIPTOR.message_types_by_name["Backup"] = _BACKUP
-DESCRIPTOR.message_types_by_name["CreateBackupRequest"] = _CREATEBACKUPREQUEST
-DESCRIPTOR.message_types_by_name["CreateBackupMetadata"] = _CREATEBACKUPMETADATA
-DESCRIPTOR.message_types_by_name["UpdateBackupRequest"] = _UPDATEBACKUPREQUEST
-DESCRIPTOR.message_types_by_name["GetBackupRequest"] = _GETBACKUPREQUEST
-DESCRIPTOR.message_types_by_name["DeleteBackupRequest"] = _DELETEBACKUPREQUEST
-DESCRIPTOR.message_types_by_name["ListBackupsRequest"] = _LISTBACKUPSREQUEST
-DESCRIPTOR.message_types_by_name["ListBackupsResponse"] = _LISTBACKUPSRESPONSE
-DESCRIPTOR.message_types_by_name[
- "ListBackupOperationsRequest"
-] = _LISTBACKUPOPERATIONSREQUEST
-DESCRIPTOR.message_types_by_name[
- "ListBackupOperationsResponse"
-] = _LISTBACKUPOPERATIONSRESPONSE
-DESCRIPTOR.message_types_by_name["BackupInfo"] = _BACKUPINFO
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-Backup = _reflection.GeneratedProtocolMessageType(
- "Backup",
- (_message.Message,),
- {
- "DESCRIPTOR": _BACKUP,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """A backup of a Cloud Spanner database.
-
- Attributes:
- database:
- Required for the [CreateBackup][google.spanner.admin.database.
- v1.DatabaseAdmin.CreateBackup] operation. Name of the database
- from which this backup was created. This needs to be in the
- same instance as the backup. Values are of the form ``projects
- //instances//databases/``.
- expire_time:
- Required for the [CreateBackup][google.spanner.admin.database.
- v1.DatabaseAdmin.CreateBackup] operation. The expiration time
- of the backup, with microseconds granularity that must be at
- least 6 hours and at most 366 days from the time the
- CreateBackup request is processed. Once the ``expire_time``
- has passed, the backup is eligible to be automatically deleted
- by Cloud Spanner to free the resources used by the backup.
- name:
- Output only for the [CreateBackup][google.spanner.admin.databa
- se.v1.DatabaseAdmin.CreateBackup] operation. Required for the
- [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.
- UpdateBackup] operation. A globally unique identifier for the
- backup which cannot be changed. Values are of the form ``proje
- cts//instances//backups/[a-z][a-z0-9_\-]*[a
- -z0-9]`` The final segment of the name must be between 2 and
- 60 characters in length. The backup is stored in the
- location(s) specified in the instance configuration of the
- instance containing the backup, identified by the prefix of
- the backup name of the form
- ``projects//instances/``.
- create_time:
- Output only. The backup will contain an externally consistent
- copy of the database at the timestamp specified by
- ``create_time``. ``create_time`` is approximately the time the
- [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.
- CreateBackup] request is received.
- size_bytes:
- Output only. Size of the backup in bytes.
- state:
- Output only. The current state of the backup.
- referencing_databases:
- Output only. The names of the restored databases that
- reference the backup. The database names are of the form ``pro
- jects//instances//databases/``.
- Referencing databases may exist in different instances. The
- existence of any referencing database prevents the backup from
- being deleted. When a restored database from the backup enters
- the ``READY`` state, the reference to the backup is removed.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.Backup)
- },
-)
-_sym_db.RegisterMessage(Backup)
-
-CreateBackupRequest = _reflection.GeneratedProtocolMessageType(
- "CreateBackupRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _CREATEBACKUPREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """The request for [CreateBackup][google.spanner.admin.database.v1.Databa
- seAdmin.CreateBackup].
-
- Attributes:
- parent:
- Required. The name of the instance in which the backup will be
- created. This must be the same instance that contains the
- database the backup will be created from. The backup will be
- stored in the location(s) specified in the instance
- configuration of this instance. Values are of the form
- ``projects//instances/``.
- backup_id:
- Required. The id of the backup to be created. The
- ``backup_id`` appended to ``parent`` forms the full backup
- name of the form ``projects//instances//bac
- kups/``.
- backup:
- Required. The backup to create.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CreateBackupRequest)
- },
-)
-_sym_db.RegisterMessage(CreateBackupRequest)
-
-CreateBackupMetadata = _reflection.GeneratedProtocolMessageType(
- "CreateBackupMetadata",
- (_message.Message,),
- {
- "DESCRIPTOR": _CREATEBACKUPMETADATA,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """Metadata type for the operation returned by [CreateBackup][google.span
- ner.admin.database.v1.DatabaseAdmin.CreateBackup].
-
- Attributes:
- name:
- The name of the backup being created.
- database:
- The name of the database the backup is created from.
- progress:
- The progress of the [CreateBackup][google.spanner.admin.databa
- se.v1.DatabaseAdmin.CreateBackup] operation.
- cancel_time:
- The time at which cancellation of this operation was received.
- [Operations.CancelOperation][google.longrunning.Operations.Can
- celOperation] starts asynchronous cancellation on a long-
- running operation. The server makes a best effort to cancel
- the operation, but success is not guaranteed. Clients can use
- [Operations.GetOperation][google.longrunning.Operations.GetOpe
- ration] or other methods to check whether the cancellation
- succeeded or whether the operation completed despite
- cancellation. On successful cancellation, the operation is not
- deleted; instead, it becomes an operation with an
- [Operation.error][] value with a
- [google.rpc.Status.code][google.rpc.Status.code] of 1,
- corresponding to ``Code.CANCELLED``.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CreateBackupMetadata)
- },
-)
-_sym_db.RegisterMessage(CreateBackupMetadata)
-
-UpdateBackupRequest = _reflection.GeneratedProtocolMessageType(
- "UpdateBackupRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _UPDATEBACKUPREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """The request for [UpdateBackup][google.spanner.admin.database.v1.Databa
- seAdmin.UpdateBackup].
-
- Attributes:
- backup:
- Required. The backup to update. ``backup.name``, and the
- fields to be updated as specified by ``update_mask`` are
- required. Other fields are ignored. Update is only supported
- for the following fields: \* ``backup.expire_time``.
- update_mask:
- Required. A mask specifying which fields (e.g.
- ``expire_time``) in the Backup resource should be updated.
- This mask is relative to the Backup resource, not to the
- request message. The field mask must always be specified; this
- prevents any future fields from being erased accidentally by
- clients that do not know about them.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.UpdateBackupRequest)
- },
-)
-_sym_db.RegisterMessage(UpdateBackupRequest)
-
-GetBackupRequest = _reflection.GeneratedProtocolMessageType(
- "GetBackupRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _GETBACKUPREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """The request for
- [GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup].
-
- Attributes:
- name:
- Required. Name of the backup. Values are of the form
- ``projects//instances//backups/``.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.GetBackupRequest)
- },
-)
-_sym_db.RegisterMessage(GetBackupRequest)
-
-DeleteBackupRequest = _reflection.GeneratedProtocolMessageType(
- "DeleteBackupRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _DELETEBACKUPREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """The request for [DeleteBackup][google.spanner.admin.database.v1.Databa
- seAdmin.DeleteBackup].
-
- Attributes:
- name:
- Required. Name of the backup to delete. Values are of the form
- ``projects//instances//backups/``.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.DeleteBackupRequest)
- },
-)
-_sym_db.RegisterMessage(DeleteBackupRequest)
-
-ListBackupsRequest = _reflection.GeneratedProtocolMessageType(
- "ListBackupsRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _LISTBACKUPSREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """The request for [ListBackups][google.spanner.admin.database.v1.Databas
- eAdmin.ListBackups].
-
- Attributes:
- parent:
- Required. The instance to list backups from. Values are of the
- form ``projects//instances/``.
- filter:
- An expression that filters the list of returned backups. A
- filter expression consists of a field name, a comparison
- operator, and a value for filtering. The value must be a
- string, a number, or a boolean. The comparison operator must
- be one of: ``<``, ``>``, ``<=``, ``>=``, ``!=``, ``=``, or
- ``:``. Colon ``:`` is the contains operator. Filter rules are
- not case sensitive. The following fields in the
- [Backup][google.spanner.admin.database.v1.Backup] are eligible
- for filtering: - ``name`` - ``database`` - ``state`` -
- ``create_time`` (and values are of the format YYYY-MM-
- DDTHH:MM:SSZ) - ``expire_time`` (and values are of the format
- YYYY-MM-DDTHH:MM:SSZ) - ``size_bytes`` You can combine
- multiple expressions by enclosing each expression in
- parentheses. By default, expressions are combined with AND
- logic, but you can specify AND, OR, and NOT logic explicitly.
- Here are a few examples: - ``name:Howl`` - The backup’s name
- contains the string “howl”. - ``database:prod`` - The
- database’s name contains the string “prod”. -
- ``state:CREATING`` - The backup is pending creation. -
- ``state:READY`` - The backup is fully created and ready for
- use. - ``(name:howl) AND (create_time <
- \"2018-03-28T14:50:00Z\")`` - The backup name contains the
- string “howl” and ``create_time`` of the backup is before
- 2018-03-28T14:50:00Z. - ``expire_time <
- \"2018-03-28T14:50:00Z\"`` - The backup ``expire_time`` is
- before 2018-03-28T14:50:00Z. - ``size_bytes > 10000000000`` -
- The backup’s size is greater than 10GB
- page_size:
- Number of backups to be returned in the response. If 0 or
- less, defaults to the server’s maximum allowed page size.
- page_token:
- If non-empty, ``page_token`` should contain a [next_page_token
- ][google.spanner.admin.database.v1.ListBackupsResponse.next_pa
- ge_token] from a previous [ListBackupsResponse][google.spanner
- .admin.database.v1.ListBackupsResponse] to the same ``parent``
- and with the same ``filter``.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListBackupsRequest)
- },
-)
-_sym_db.RegisterMessage(ListBackupsRequest)
-
-ListBackupsResponse = _reflection.GeneratedProtocolMessageType(
- "ListBackupsResponse",
- (_message.Message,),
- {
- "DESCRIPTOR": _LISTBACKUPSRESPONSE,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """The response for [ListBackups][google.spanner.admin.database.v1.Databa
- seAdmin.ListBackups].
-
- Attributes:
- backups:
- The list of matching backups. Backups returned are ordered by
- ``create_time`` in descending order, starting from the most
- recent ``create_time``.
- next_page_token:
- \ ``next_page_token`` can be sent in a subsequent [ListBackups
- ][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups]
- call to fetch more of the matching backups.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListBackupsResponse)
- },
-)
-_sym_db.RegisterMessage(ListBackupsResponse)
-
-ListBackupOperationsRequest = _reflection.GeneratedProtocolMessageType(
- "ListBackupOperationsRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _LISTBACKUPOPERATIONSREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """The request for [ListBackupOperations][google.spanner.admin.database.v
- 1.DatabaseAdmin.ListBackupOperations].
-
- Attributes:
- parent:
- Required. The instance of the backup operations. Values are of
- the form ``projects//instances/``.
- filter:
- An expression that filters the list of returned backup
- operations. A filter expression consists of a field name, a
- comparison operator, and a value for filtering. The value must
- be a string, a number, or a boolean. The comparison operator
- must be one of: ``<``, ``>``, ``<=``, ``>=``, ``!=``, ``=``,
- or ``:``. Colon ``:`` is the contains operator. Filter rules
- are not case sensitive. The following fields in the
- [operation][google.longrunning.Operation] are eligible for
- filtering: - ``name`` - The name of the long-running
- operation - ``done`` - False if the operation is in progress,
- else true. - ``metadata.@type`` - the type of metadata. For
- example, the type string for [CreateBackupMetadata][goog
- le.spanner.admin.database.v1.CreateBackupMetadata] is ``
- type.googleapis.com/google.spanner.admin.database.v1.CreateBac
- kupMetadata``. - ``metadata.`` - any field in
- metadata.value. - ``error`` - Error associated with the long-
- running operation. - ``response.@type`` - the type of
- response. - ``response.`` - any field in
- response.value. You can combine multiple expressions by
- enclosing each expression in parentheses. By default,
- expressions are combined with AND logic, but you can specify
- AND, OR, and NOT logic explicitly. Here are a few examples:
- - ``done:true`` - The operation is complete. -
- ``metadata.database:prod`` - The database the backup was taken
- from has a name containing the string “prod”. - ``(metadat
- a.@type=type.googleapis.com/google.spanner.admin.database.v1.C
- reateBackupMetadata) AND`` ``(metadata.name:howl) AND``
- ``(metadata.progress.start_time < \"2018-03-28T14:50:00Z\")
- AND`` ``(error:*)`` - Returns operations where: - The
- operation’s metadata type is [CreateBackupMetadata][goog
- le.spanner.admin.database.v1.CreateBackupMetadata]. - The
- backup name contains the string “howl”. - The operation
- started before 2018-03-28T14:50:00Z. - The operation
- resulted in an error.
- page_size:
- Number of operations to be returned in the response. If 0 or
- less, defaults to the server’s maximum allowed page size.
- page_token:
- If non-empty, ``page_token`` should contain a [next_page_token
- ][google.spanner.admin.database.v1.ListBackupOperationsRespons
- e.next_page_token] from a previous [ListBackupOperationsRespon
- se][google.spanner.admin.database.v1.ListBackupOperationsRespo
- nse] to the same ``parent`` and with the same ``filter``.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListBackupOperationsRequest)
- },
-)
-_sym_db.RegisterMessage(ListBackupOperationsRequest)
-
-ListBackupOperationsResponse = _reflection.GeneratedProtocolMessageType(
- "ListBackupOperationsResponse",
- (_message.Message,),
- {
- "DESCRIPTOR": _LISTBACKUPOPERATIONSRESPONSE,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """The response for [ListBackupOperations][google.spanner.admin.database.
- v1.DatabaseAdmin.ListBackupOperations].
-
- Attributes:
- operations:
- The list of matching backup [long-running
- operations][google.longrunning.Operation]. Each operation’s
- name will be prefixed by the backup’s name and the operation’s
- [metadata][google.longrunning.Operation.metadata] will be of
- type [CreateBackupMetadata][google.spanner.admin.database.v1.C
- reateBackupMetadata]. Operations returned include those that
- are pending or have completed/failed/canceled within the last
- 7 days. Operations returned are ordered by
- ``operation.metadata.value.progress.start_time`` in descending
- order starting from the most recently started operation.
- next_page_token:
- \ ``next_page_token`` can be sent in a subsequent [ListBackupO
- perations][google.spanner.admin.database.v1.DatabaseAdmin.List
- BackupOperations] call to fetch more of the matching metadata.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListBackupOperationsResponse)
- },
-)
-_sym_db.RegisterMessage(ListBackupOperationsResponse)
-
-BackupInfo = _reflection.GeneratedProtocolMessageType(
- "BackupInfo",
- (_message.Message,),
- {
- "DESCRIPTOR": _BACKUPINFO,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.backup_pb2",
- "__doc__": """Information about a backup.
-
- Attributes:
- backup:
- Name of the backup.
- create_time:
- The backup contains an externally consistent copy of
- ``source_database`` at the timestamp specified by
- ``create_time``.
- source_database:
- Name of the database the backup was created from.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.BackupInfo)
- },
-)
-_sym_db.RegisterMessage(BackupInfo)
-
-
-DESCRIPTOR._options = None
-_BACKUP.fields_by_name["database"]._options = None
-_BACKUP.fields_by_name["create_time"]._options = None
-_BACKUP.fields_by_name["size_bytes"]._options = None
-_BACKUP.fields_by_name["state"]._options = None
-_BACKUP.fields_by_name["referencing_databases"]._options = None
-_BACKUP._options = None
-_CREATEBACKUPREQUEST.fields_by_name["parent"]._options = None
-_CREATEBACKUPREQUEST.fields_by_name["backup_id"]._options = None
-_CREATEBACKUPREQUEST.fields_by_name["backup"]._options = None
-_UPDATEBACKUPREQUEST.fields_by_name["backup"]._options = None
-_UPDATEBACKUPREQUEST.fields_by_name["update_mask"]._options = None
-_GETBACKUPREQUEST.fields_by_name["name"]._options = None
-_DELETEBACKUPREQUEST.fields_by_name["name"]._options = None
-_LISTBACKUPSREQUEST.fields_by_name["parent"]._options = None
-_LISTBACKUPOPERATIONSREQUEST.fields_by_name["parent"]._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/google/cloud/spanner_admin_database_v1/proto/backup_pb2_grpc.py b/google/cloud/spanner_admin_database_v1/proto/backup_pb2_grpc.py
deleted file mode 100644
index 8a9393943b..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/backup_pb2_grpc.py
+++ /dev/null
@@ -1,3 +0,0 @@
-# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
-"""Client and server classes corresponding to protobuf-defined services."""
-import grpc
diff --git a/google/cloud/spanner_admin_database_v1/proto/common_pb2.py b/google/cloud/spanner_admin_database_v1/proto/common_pb2.py
deleted file mode 100644
index b4e89476eb..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/common_pb2.py
+++ /dev/null
@@ -1,148 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: google/cloud/spanner_admin_database_v1/proto/common.proto
-
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2
-from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
-from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name="google/cloud/spanner_admin_database_v1/proto/common.proto",
- package="google.spanner.admin.database.v1",
- syntax="proto3",
- serialized_options=b"\n$com.google.spanner.admin.database.v1B\013CommonProtoP\001ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\252\002&Google.Cloud.Spanner.Admin.Database.V1\312\002&Google\\Cloud\\Spanner\\Admin\\Database\\V1\352\002+Google::Cloud::Spanner::Admin::Database::V1",
- create_key=_descriptor._internal_create_key,
- serialized_pb=b'\n9google/cloud/spanner_admin_database_v1/proto/common.proto\x12 google.spanner.admin.database.v1\x1a\x1fgoogle/api/field_behavior.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x1cgoogle/api/annotations.proto"\x8b\x01\n\x11OperationProgress\x12\x18\n\x10progress_percent\x18\x01 \x01(\x05\x12.\n\nstart_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\xff\x01\n$com.google.spanner.admin.database.v1B\x0b\x43ommonProtoP\x01ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\xaa\x02&Google.Cloud.Spanner.Admin.Database.V1\xca\x02&Google\\Cloud\\Spanner\\Admin\\Database\\V1\xea\x02+Google::Cloud::Spanner::Admin::Database::V1b\x06proto3',
- dependencies=[
- google_dot_api_dot_field__behavior__pb2.DESCRIPTOR,
- google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,
- google_dot_api_dot_annotations__pb2.DESCRIPTOR,
- ],
-)
-
-
-_OPERATIONPROGRESS = _descriptor.Descriptor(
- name="OperationProgress",
- full_name="google.spanner.admin.database.v1.OperationProgress",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="progress_percent",
- full_name="google.spanner.admin.database.v1.OperationProgress.progress_percent",
- index=0,
- number=1,
- type=5,
- cpp_type=1,
- label=1,
- has_default_value=False,
- default_value=0,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="start_time",
- full_name="google.spanner.admin.database.v1.OperationProgress.start_time",
- index=1,
- number=2,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="end_time",
- full_name="google.spanner.admin.database.v1.OperationProgress.end_time",
- index=2,
- number=3,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=192,
- serialized_end=331,
-)
-
-_OPERATIONPROGRESS.fields_by_name[
- "start_time"
-].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP
-_OPERATIONPROGRESS.fields_by_name[
- "end_time"
-].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP
-DESCRIPTOR.message_types_by_name["OperationProgress"] = _OPERATIONPROGRESS
-_sym_db.RegisterFileDescriptor(DESCRIPTOR)
-
-OperationProgress = _reflection.GeneratedProtocolMessageType(
- "OperationProgress",
- (_message.Message,),
- {
- "DESCRIPTOR": _OPERATIONPROGRESS,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.common_pb2",
- "__doc__": """Encapsulates progress related information for a Cloud Spanner long
- running operation.
-
- Attributes:
- progress_percent:
- Percent completion of the operation. Values are between 0 and
- 100 inclusive.
- start_time:
- Time the request was received.
- end_time:
- If set, the time at which this operation failed or was
- completed successfully.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.OperationProgress)
- },
-)
-_sym_db.RegisterMessage(OperationProgress)
-
-
-DESCRIPTOR._options = None
-# @@protoc_insertion_point(module_scope)
diff --git a/google/cloud/spanner_admin_database_v1/proto/common_pb2_grpc.py b/google/cloud/spanner_admin_database_v1/proto/common_pb2_grpc.py
deleted file mode 100644
index 8a9393943b..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/common_pb2_grpc.py
+++ /dev/null
@@ -1,3 +0,0 @@
-# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
-"""Client and server classes corresponding to protobuf-defined services."""
-import grpc
diff --git a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py b/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py
deleted file mode 100644
index f0accdbecd..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py
+++ /dev/null
@@ -1,2145 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: google/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto
-
-from google.protobuf.internal import enum_type_wrapper
-from google.protobuf import descriptor as _descriptor
-from google.protobuf import message as _message
-from google.protobuf import reflection as _reflection
-from google.protobuf import symbol_database as _symbol_database
-
-# @@protoc_insertion_point(imports)
-
-_sym_db = _symbol_database.Default()
-
-
-from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2
-from google.api import client_pb2 as google_dot_api_dot_client__pb2
-from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2
-from google.api import resource_pb2 as google_dot_api_dot_resource__pb2
-from google.iam.v1 import iam_policy_pb2 as google_dot_iam_dot_v1_dot_iam__policy__pb2
-from google.iam.v1 import policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2
-from google.longrunning import (
- operations_pb2 as google_dot_longrunning_dot_operations__pb2,
-)
-from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2
-from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2
-from google.cloud.spanner_admin_database_v1.proto import (
- backup_pb2 as google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2,
-)
-from google.cloud.spanner_admin_database_v1.proto import (
- common_pb2 as google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_common__pb2,
-)
-
-
-DESCRIPTOR = _descriptor.FileDescriptor(
- name="google/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto",
- package="google.spanner.admin.database.v1",
- syntax="proto3",
- serialized_options=b"\n$com.google.spanner.admin.database.v1B\031SpannerDatabaseAdminProtoP\001ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\252\002&Google.Cloud.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'projects/{project}/instances/{instance}",
- create_key=_descriptor._internal_create_key,
- serialized_pb=b'\nIgoogle/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto\x12 google.spanner.admin.database.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a\x19google/api/resource.proto\x1a\x1egoogle/iam/v1/iam_policy.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a#google/longrunning/operations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x39google/cloud/spanner_admin_database_v1/proto/backup.proto\x1a\x39google/cloud/spanner_admin_database_v1/proto/common.proto"\xab\x01\n\x0bRestoreInfo\x12H\n\x0bsource_type\x18\x01 \x01(\x0e\x32\x33.google.spanner.admin.database.v1.RestoreSourceType\x12\x43\n\x0b\x62\x61\x63kup_info\x18\x02 \x01(\x0b\x32,.google.spanner.admin.database.v1.BackupInfoH\x00\x42\r\n\x0bsource_info"\x96\x03\n\x08\x44\x61tabase\x12\x11\n\x04name\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12\x44\n\x05state\x18\x02 \x01(\x0e\x32\x30.google.spanner.admin.database.v1.Database.StateB\x03\xe0\x41\x03\x12\x34\n\x0b\x63reate_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.TimestampB\x03\xe0\x41\x03\x12H\n\x0crestore_info\x18\x04 \x01(\x0b\x32-.google.spanner.admin.database.v1.RestoreInfoB\x03\xe0\x41\x03"M\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x43REATING\x10\x01\x12\t\n\x05READY\x10\x02\x12\x14\n\x10READY_OPTIMIZING\x10\x03:b\xea\x41_\n\x1fspanner.googleapis.com/Database\x12\x82\xd3\xe4\x93\x02/\x12-/v1/{parent=projects/*/instances/*}/databases\xda\x41\x06parent\x12\xa4\x02\n\x0e\x43reateDatabase\x12\x37.google.spanner.admin.database.v1.CreateDatabaseRequest\x1a\x1d.google.longrunning.Operation"\xb9\x01\x82\xd3\xe4\x93\x02\x32"-/v1/{parent=projects/*/instances/*}/databases:\x01*\xda\x41\x17parent,create_statement\xca\x41\x64\n)google.spanner.admin.database.v1.Database\x12\x37google.spanner.admin.database.v1.CreateDatabaseMetadata\x12\xad\x01\n\x0bGetDatabase\x12\x34.google.spanner.admin.database.v1.GetDatabaseRequest\x1a*.google.spanner.admin.database.v1.Database"<\x82\xd3\xe4\x93\x02/\x12-/v1/{name=projects/*/instances/*/databases/*}\xda\x41\x04name\x12\x9d\x02\n\x11UpdateDatabaseDdl\x12:.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\x1a\x1d.google.longrunning.Operation"\xac\x01\x82\xd3\xe4\x93\x02:25/v1/{database=projects/*/instances/*/databases/*}/ddl:\x01*\xda\x41\x13\x64\x61tabase,statements\xca\x41S\n\x15google.protobuf.Empty\x12:google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata\x12\xa3\x01\n\x0c\x44ropDatabase\x12\x35.google.spanner.admin.database.v1.DropDatabaseRequest\x1a\x16.google.protobuf.Empty"D\x82\xd3\xe4\x93\x02\x33*1/v1/{database=projects/*/instances/*/databases/*}\xda\x41\x08\x64\x61tabase\x12\xcd\x01\n\x0eGetDatabaseDdl\x12\x37.google.spanner.admin.database.v1.GetDatabaseDdlRequest\x1a\x38.google.spanner.admin.database.v1.GetDatabaseDdlResponse"H\x82\xd3\xe4\x93\x02\x37\x12\x35/v1/{database=projects/*/instances/*/databases/*}/ddl\xda\x41\x08\x64\x61tabase\x12\xeb\x01\n\x0cSetIamPolicy\x12".google.iam.v1.SetIamPolicyRequest\x1a\x15.google.iam.v1.Policy"\x9f\x01\x82\xd3\xe4\x93\x02\x86\x01">/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy:\x01*ZA"/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy:\x01*ZA".google.spanner.admin.database.v1.ListBackupOperationsResponse"E\x82\xd3\xe4\x93\x02\x36\x12\x34/v1/{parent=projects/*/instances/*}/backupOperations\xda\x41\x06parent\x1ax\xca\x41\x16spanner.googleapis.com\xd2\x41\\https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/spanner.adminB\xda\x02\n$com.google.spanner.admin.database.v1B\x19SpannerDatabaseAdminProtoP\x01ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\xaa\x02&Google.Cloud.Spanner.Admin.Database.V1\xca\x02&Google\\Cloud\\Spanner\\Admin\\Database\\V1\xea\x02+Google::Cloud::Spanner::Admin::Database::V1\xea\x41J\n\x1fspanner.googleapis.com/Instance\x12\'projects/{project}/instances/{instance}b\x06proto3',
- dependencies=[
- google_dot_api_dot_annotations__pb2.DESCRIPTOR,
- google_dot_api_dot_client__pb2.DESCRIPTOR,
- google_dot_api_dot_field__behavior__pb2.DESCRIPTOR,
- google_dot_api_dot_resource__pb2.DESCRIPTOR,
- google_dot_iam_dot_v1_dot_iam__policy__pb2.DESCRIPTOR,
- google_dot_iam_dot_v1_dot_policy__pb2.DESCRIPTOR,
- google_dot_longrunning_dot_operations__pb2.DESCRIPTOR,
- google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,
- google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.DESCRIPTOR,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_common__pb2.DESCRIPTOR,
- ],
-)
-
-_RESTORESOURCETYPE = _descriptor.EnumDescriptor(
- name="RestoreSourceType",
- full_name="google.spanner.admin.database.v1.RestoreSourceType",
- filename=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- values=[
- _descriptor.EnumValueDescriptor(
- name="TYPE_UNSPECIFIED",
- index=0,
- number=0,
- serialized_options=None,
- type=None,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.EnumValueDescriptor(
- name="BACKUP",
- index=1,
- number=1,
- serialized_options=None,
- type=None,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=3044,
- serialized_end=3097,
-)
-_sym_db.RegisterEnumDescriptor(_RESTORESOURCETYPE)
-
-RestoreSourceType = enum_type_wrapper.EnumTypeWrapper(_RESTORESOURCETYPE)
-TYPE_UNSPECIFIED = 0
-BACKUP = 1
-
-
-_DATABASE_STATE = _descriptor.EnumDescriptor(
- name="State",
- full_name="google.spanner.admin.database.v1.Database.State",
- filename=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- values=[
- _descriptor.EnumValueDescriptor(
- name="STATE_UNSPECIFIED",
- index=0,
- number=0,
- serialized_options=None,
- type=None,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.EnumValueDescriptor(
- name="CREATING",
- index=1,
- number=1,
- serialized_options=None,
- type=None,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.EnumValueDescriptor(
- name="READY",
- index=2,
- number=2,
- serialized_options=None,
- type=None,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.EnumValueDescriptor(
- name="READY_OPTIMIZING",
- index=3,
- number=3,
- serialized_options=None,
- type=None,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=907,
- serialized_end=984,
-)
-_sym_db.RegisterEnumDescriptor(_DATABASE_STATE)
-
-
-_RESTOREINFO = _descriptor.Descriptor(
- name="RestoreInfo",
- full_name="google.spanner.admin.database.v1.RestoreInfo",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="source_type",
- full_name="google.spanner.admin.database.v1.RestoreInfo.source_type",
- index=0,
- number=1,
- type=14,
- cpp_type=8,
- label=1,
- has_default_value=False,
- default_value=0,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="backup_info",
- full_name="google.spanner.admin.database.v1.RestoreInfo.backup_info",
- index=1,
- number=2,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=None,
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[
- _descriptor.OneofDescriptor(
- name="source_info",
- full_name="google.spanner.admin.database.v1.RestoreInfo.source_info",
- index=0,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[],
- )
- ],
- serialized_start=504,
- serialized_end=675,
-)
-
-
-_DATABASE = _descriptor.Descriptor(
- name="Database",
- full_name="google.spanner.admin.database.v1.Database",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- create_key=_descriptor._internal_create_key,
- fields=[
- _descriptor.FieldDescriptor(
- name="name",
- full_name="google.spanner.admin.database.v1.Database.name",
- index=0,
- number=1,
- type=9,
- cpp_type=9,
- label=1,
- has_default_value=False,
- default_value=b"".decode("utf-8"),
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\002",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="state",
- full_name="google.spanner.admin.database.v1.Database.state",
- index=1,
- number=2,
- type=14,
- cpp_type=8,
- label=1,
- has_default_value=False,
- default_value=0,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\003",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="create_time",
- full_name="google.spanner.admin.database.v1.Database.create_time",
- index=2,
- number=3,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\003",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.FieldDescriptor(
- name="restore_info",
- full_name="google.spanner.admin.database.v1.Database.restore_info",
- index=3,
- number=4,
- type=11,
- cpp_type=10,
- label=1,
- has_default_value=False,
- default_value=None,
- message_type=None,
- enum_type=None,
- containing_type=None,
- is_extension=False,
- extension_scope=None,
- serialized_options=b"\340A\003",
- file=DESCRIPTOR,
- create_key=_descriptor._internal_create_key,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[_DATABASE_STATE],
- serialized_options=b"\352A_\n\037spanner.googleapis.com/Database\022/instances//databases/``,
- where ```` is as specified in the ``CREATE
- DATABASE`` statement. This name can be passed to other API
- methods to identify the database.
- state:
- Output only. The current database state.
- create_time:
- Output only. If exists, the time at which the database
- creation started.
- restore_info:
- Output only. Applicable only for restored databases. Contains
- information about the restore source.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.Database)
- },
-)
-_sym_db.RegisterMessage(Database)
-
-ListDatabasesRequest = _reflection.GeneratedProtocolMessageType(
- "ListDatabasesRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _LISTDATABASESREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """The request for [ListDatabases][google.spanner.admin.database.v1.Datab
- aseAdmin.ListDatabases].
-
- Attributes:
- parent:
- Required. The instance whose databases should be listed.
- Values are of the form
- ``projects//instances/``.
- page_size:
- Number of databases to be returned in the response. If 0 or
- less, defaults to the server’s maximum allowed page size.
- page_token:
- If non-empty, ``page_token`` should contain a [next\_page\_tok
- en][google.spanner.admin.database.v1.ListDatabasesResponse.nex
- t\_page\_token] from a previous [ListDatabasesResponse][google
- .spanner.admin.database.v1.ListDatabasesResponse].
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListDatabasesRequest)
- },
-)
-_sym_db.RegisterMessage(ListDatabasesRequest)
-
-ListDatabasesResponse = _reflection.GeneratedProtocolMessageType(
- "ListDatabasesResponse",
- (_message.Message,),
- {
- "DESCRIPTOR": _LISTDATABASESRESPONSE,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """The response for [ListDatabases][google.spanner.admin.database.v1.Data
- baseAdmin.ListDatabases].
-
- Attributes:
- databases:
- Databases that matched the request.
- next_page_token:
- \ ``next_page_token`` can be sent in a subsequent [ListDatabas
- es][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabas
- es] call to fetch more of the matching databases.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListDatabasesResponse)
- },
-)
-_sym_db.RegisterMessage(ListDatabasesResponse)
-
-CreateDatabaseRequest = _reflection.GeneratedProtocolMessageType(
- "CreateDatabaseRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _CREATEDATABASEREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """The request for [CreateDatabase][google.spanner.admin.database.v1.Data
- baseAdmin.CreateDatabase].
-
- Attributes:
- parent:
- Required. The name of the instance that will serve the new
- database. Values are of the form
- ``projects//instances/``.
- create_statement:
- Required. A ``CREATE DATABASE`` statement, which specifies the
- ID of the new database. The database ID must conform to the
- regular expression ``[a-z][a-z0-9_\-]*[a-z0-9]`` and be
- between 2 and 30 characters in length. If the database ID is a
- reserved word or if it contains a hyphen, the database ID must
- be enclosed in backticks (:literal:`\``).
- extra_statements:
- Optional. A list of DDL statements to run inside the newly
- created database. Statements can create tables, indexes, etc.
- These statements execute atomically with the creation of the
- database: if there is an error in any statement, the database
- is not created.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CreateDatabaseRequest)
- },
-)
-_sym_db.RegisterMessage(CreateDatabaseRequest)
-
-CreateDatabaseMetadata = _reflection.GeneratedProtocolMessageType(
- "CreateDatabaseMetadata",
- (_message.Message,),
- {
- "DESCRIPTOR": _CREATEDATABASEMETADATA,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """Metadata type for the operation returned by [CreateDatabase][google.sp
- anner.admin.database.v1.DatabaseAdmin.CreateDatabase].
-
- Attributes:
- database:
- The database being created.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.CreateDatabaseMetadata)
- },
-)
-_sym_db.RegisterMessage(CreateDatabaseMetadata)
-
-GetDatabaseRequest = _reflection.GeneratedProtocolMessageType(
- "GetDatabaseRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _GETDATABASEREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """The request for [GetDatabase][google.spanner.admin.database.v1.Databas
- eAdmin.GetDatabase].
-
- Attributes:
- name:
- Required. The name of the requested database. Values are of
- the form ``projects//instances//databases/<
- database>``.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.GetDatabaseRequest)
- },
-)
-_sym_db.RegisterMessage(GetDatabaseRequest)
-
-UpdateDatabaseDdlRequest = _reflection.GeneratedProtocolMessageType(
- "UpdateDatabaseDdlRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _UPDATEDATABASEDDLREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """Enqueues the given DDL statements to be applied, in order but not
- necessarily all at once, to the database schema at some point (or
- points) in the future. The server checks that the statements are
- executable (syntactically valid, name tables that exist, etc.) before
- enqueueing them, but they may still fail upon later execution (e.g.,
- if a statement from another batch of statements is applied first and
- it conflicts in some way, or if there is some data-related problem
- like a ``NULL`` value in a column to which ``NOT NULL`` would be
- added). If a statement fails, all subsequent statements in the batch
- are automatically cancelled. Each batch of statements is assigned a
- name which can be used with the
- [Operations][google.longrunning.Operations] API to monitor progress.
- See the [operation_id][google.spanner.admin.database.v1.UpdateDatabase
- DdlRequest.operation_id] field for more details.
-
- Attributes:
- database:
- Required. The database to update.
- statements:
- Required. DDL statements to be applied to the database.
- operation_id:
- If empty, the new update request is assigned an automatically-
- generated operation ID. Otherwise, ``operation_id`` is used to
- construct the name of the resulting
- [Operation][google.longrunning.Operation]. Specifying an
- explicit operation ID simplifies determining whether the
- statements were executed in the event that the [UpdateDatabase
- Ddl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateData
- baseDdl] call is replayed, or the return value is otherwise
- lost: the [database][google.spanner.admin.database.v1.UpdateDa
- tabaseDdlRequest.database] and ``operation_id`` fields can be
- combined to form the [name][google.longrunning.Operation.name]
- of the resulting
- [longrunning.Operation][google.longrunning.Operation]:
- ``/operations/``. ``operation_id``
- should be unique within the database, and must be a valid
- identifier: ``[a-z][a-z0-9_]*``. Note that automatically-
- generated operation IDs always begin with an underscore. If
- the named operation already exists, [UpdateDatabaseDdl][google
- .spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]
- returns ``ALREADY_EXISTS``.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.UpdateDatabaseDdlRequest)
- },
-)
-_sym_db.RegisterMessage(UpdateDatabaseDdlRequest)
-
-UpdateDatabaseDdlMetadata = _reflection.GeneratedProtocolMessageType(
- "UpdateDatabaseDdlMetadata",
- (_message.Message,),
- {
- "DESCRIPTOR": _UPDATEDATABASEDDLMETADATA,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """Metadata type for the operation returned by [UpdateDatabaseDdl][google
- .spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl].
-
- Attributes:
- database:
- The database being modified.
- statements:
- For an update this list contains all the statements. For an
- individual statement, this list contains only that statement.
- commit_timestamps:
- Reports the commit timestamps of all statements that have
- succeeded so far, where ``commit_timestamps[i]`` is the commit
- timestamp for the statement ``statements[i]``.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata)
- },
-)
-_sym_db.RegisterMessage(UpdateDatabaseDdlMetadata)
-
-DropDatabaseRequest = _reflection.GeneratedProtocolMessageType(
- "DropDatabaseRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _DROPDATABASEREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """The request for [DropDatabase][google.spanner.admin.database.v1.Databa
- seAdmin.DropDatabase].
-
- Attributes:
- database:
- Required. The database to be dropped.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.DropDatabaseRequest)
- },
-)
-_sym_db.RegisterMessage(DropDatabaseRequest)
-
-GetDatabaseDdlRequest = _reflection.GeneratedProtocolMessageType(
- "GetDatabaseDdlRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _GETDATABASEDDLREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """The request for [GetDatabaseDdl][google.spanner.admin.database.v1.Data
- baseAdmin.GetDatabaseDdl].
-
- Attributes:
- database:
- Required. The database whose schema we wish to get.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.GetDatabaseDdlRequest)
- },
-)
-_sym_db.RegisterMessage(GetDatabaseDdlRequest)
-
-GetDatabaseDdlResponse = _reflection.GeneratedProtocolMessageType(
- "GetDatabaseDdlResponse",
- (_message.Message,),
- {
- "DESCRIPTOR": _GETDATABASEDDLRESPONSE,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """The response for [GetDatabaseDdl][google.spanner.admin.database.v1.Dat
- abaseAdmin.GetDatabaseDdl].
-
- Attributes:
- statements:
- A list of formatted DDL statements defining the schema of the
- database specified in the request.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.GetDatabaseDdlResponse)
- },
-)
-_sym_db.RegisterMessage(GetDatabaseDdlResponse)
-
-ListDatabaseOperationsRequest = _reflection.GeneratedProtocolMessageType(
- "ListDatabaseOperationsRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _LISTDATABASEOPERATIONSREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """The request for [ListDatabaseOperations][google.spanner.admin.database
- .v1.DatabaseAdmin.ListDatabaseOperations].
-
- Attributes:
- parent:
- Required. The instance of the database operations. Values are
- of the form ``projects//instances/``.
- filter:
- An expression that filters the list of returned operations. A
- filter expression consists of a field name, a comparison
- operator, and a value for filtering. The value must be a
- string, a number, or a boolean. The comparison operator must
- be one of: ``<``, ``>``, ``<=``, ``>=``, ``!=``, ``=``, or
- ``:``. Colon ``:`` is the contains operator. Filter rules are
- not case sensitive. The following fields in the
- [Operation][google.longrunning.Operation] are eligible for
- filtering: - ``name`` - The name of the long-running
- operation - ``done`` - False if the operation is in progress,
- else true. - ``metadata.@type`` - the type of metadata. For
- example, the type string for [RestoreDatabaseMetadata][g
- oogle.spanner.admin.database.v1.RestoreDatabaseMetadata] is
- ``type.googleapis.com/google.spanner.admin.database.v1.Restore
- DatabaseMetadata``. - ``metadata.`` - any field
- in metadata.value. - ``error`` - Error associated with the
- long-running operation. - ``response.@type`` - the type of
- response. - ``response.`` - any field in
- response.value. You can combine multiple expressions by
- enclosing each expression in parentheses. By default,
- expressions are combined with AND logic. However, you can
- specify AND, OR, and NOT logic explicitly. Here are a few
- examples: - ``done:true`` - The operation is complete. - ``
- (metadata.@type=type.googleapis.com/google.spanner.admin.datab
- ase.v1.RestoreDatabaseMetadata) AND``
- ``(metadata.source_type:BACKUP) AND``
- ``(metadata.backup_info.backup:backup_howl) AND``
- ``(metadata.name:restored_howl) AND``
- ``(metadata.progress.start_time < \"2018-03-28T14:50:00Z\")
- AND`` ``(error:*)`` - Return operations where: - The
- operation’s metadata type is [RestoreDatabaseMetadata][g
- oogle.spanner.admin.database.v1.RestoreDatabaseMetadata]. -
- The database is restored from a backup. - The backup name
- contains “backup_howl”. - The restored database’s name
- contains “restored_howl”. - The operation started before
- 2018-03-28T14:50:00Z. - The operation resulted in an
- error.
- page_size:
- Number of operations to be returned in the response. If 0 or
- less, defaults to the server’s maximum allowed page size.
- page_token:
- If non-empty, ``page_token`` should contain a [next\_page\_tok
- en][google.spanner.admin.database.v1.ListDatabaseOperationsRes
- ponse.next\_page\_token] from a previous [ListDatabaseOperatio
- nsResponse][google.spanner.admin.database.v1.ListDatabaseOpera
- tionsResponse] to the same ``parent`` and with the same
- ``filter``.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListDatabaseOperationsRequest)
- },
-)
-_sym_db.RegisterMessage(ListDatabaseOperationsRequest)
-
-ListDatabaseOperationsResponse = _reflection.GeneratedProtocolMessageType(
- "ListDatabaseOperationsResponse",
- (_message.Message,),
- {
- "DESCRIPTOR": _LISTDATABASEOPERATIONSRESPONSE,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """The response for [ListDatabaseOperations][google.spanner.admin.databas
- e.v1.DatabaseAdmin.ListDatabaseOperations].
-
- Attributes:
- operations:
- The list of matching database [long-running
- operations][google.longrunning.Operation]. Each operation’s
- name will be prefixed by the database’s name. The operation’s
- [metadata][google.longrunning.Operation.metadata] field type
- ``metadata.type_url`` describes the type of the metadata.
- next_page_token:
- \ ``next_page_token`` can be sent in a subsequent [ListDatabas
- eOperations][google.spanner.admin.database.v1.DatabaseAdmin.Li
- stDatabaseOperations] call to fetch more of the matching
- metadata.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.ListDatabaseOperationsResponse)
- },
-)
-_sym_db.RegisterMessage(ListDatabaseOperationsResponse)
-
-RestoreDatabaseRequest = _reflection.GeneratedProtocolMessageType(
- "RestoreDatabaseRequest",
- (_message.Message,),
- {
- "DESCRIPTOR": _RESTOREDATABASEREQUEST,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """The request for [RestoreDatabase][google.spanner.admin.database.v1.Dat
- abaseAdmin.RestoreDatabase].
-
- Attributes:
- parent:
- Required. The name of the instance in which to create the
- restored database. This instance must be in the same project
- and have the same instance configuration as the instance
- containing the source backup. Values are of the form
- ``projects//instances/``.
- database_id:
- Required. The id of the database to create and restore to.
- This database must not already exist. The ``database_id``
- appended to ``parent`` forms the full database name of the
- form ``projects//instances//databases/``.
- source:
- Required. The source from which to restore.
- backup:
- Name of the backup from which to restore. Values are of the
- form
- ``projects//instances//backups/``.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.RestoreDatabaseRequest)
- },
-)
-_sym_db.RegisterMessage(RestoreDatabaseRequest)
-
-RestoreDatabaseMetadata = _reflection.GeneratedProtocolMessageType(
- "RestoreDatabaseMetadata",
- (_message.Message,),
- {
- "DESCRIPTOR": _RESTOREDATABASEMETADATA,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """Metadata type for the long-running operation returned by [RestoreDatab
- ase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
-
- Attributes:
- name:
- Name of the database being created and restored to.
- source_type:
- The type of the restore source.
- source_info:
- Information about the source used to restore the database, as
- specified by ``source`` in [RestoreDatabaseRequest][google.spa
- nner.admin.database.v1.RestoreDatabaseRequest].
- backup_info:
- Information about the backup used to restore the database.
- progress:
- The progress of the [RestoreDatabase][google.spanner.admin.dat
- abase.v1.DatabaseAdmin.RestoreDatabase] operation.
- cancel_time:
- The time at which cancellation of this operation was received.
- [Operations.CancelOperation][google.longrunning.Operations.Can
- celOperation] starts asynchronous cancellation on a long-
- running operation. The server makes a best effort to cancel
- the operation, but success is not guaranteed. Clients can use
- [Operations.GetOperation][google.longrunning.Operations.GetOpe
- ration] or other methods to check whether the cancellation
- succeeded or whether the operation completed despite
- cancellation. On successful cancellation, the operation is not
- deleted; instead, it becomes an operation with an
- [Operation.error][google.longrunning.Operation.error] value
- with a [google.rpc.Status.code][google.rpc.Status.code] of 1,
- corresponding to ``Code.CANCELLED``.
- optimize_database_operation_name:
- If exists, the name of the long-running operation that will be
- used to track the post-restore optimization process to
- optimize the performance of the restored database, and remove
- the dependency on the restore source. The name is of the form
- ``projects//instances//databases/
- /operations/`` where the is the name of database
- being created and restored to. The metadata type of the long-
- running operation is [OptimizeRestoredDatabaseMetadata][google
- .spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata].
- This long-running operation will be automatically created by
- the system after the RestoreDatabase long-running operation
- completes successfully. This operation will not be created if
- the restore was not successful.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.RestoreDatabaseMetadata)
- },
-)
-_sym_db.RegisterMessage(RestoreDatabaseMetadata)
-
-OptimizeRestoredDatabaseMetadata = _reflection.GeneratedProtocolMessageType(
- "OptimizeRestoredDatabaseMetadata",
- (_message.Message,),
- {
- "DESCRIPTOR": _OPTIMIZERESTOREDDATABASEMETADATA,
- "__module__": "google.cloud.spanner_admin_database_v1.proto.spanner_database_admin_pb2",
- "__doc__": """Metadata type for the long-running operation used to track the
- progress of optimizations performed on a newly restored database. This
- long-running operation is automatically created by the system after
- the successful completion of a database restore, and cannot be
- cancelled.
-
- Attributes:
- name:
- Name of the restored database being optimized.
- progress:
- The progress of the post-restore optimizations.
- """,
- # @@protoc_insertion_point(class_scope:google.spanner.admin.database.v1.OptimizeRestoredDatabaseMetadata)
- },
-)
-_sym_db.RegisterMessage(OptimizeRestoredDatabaseMetadata)
-
-
-DESCRIPTOR._options = None
-_DATABASE.fields_by_name["name"]._options = None
-_DATABASE.fields_by_name["state"]._options = None
-_DATABASE.fields_by_name["create_time"]._options = None
-_DATABASE.fields_by_name["restore_info"]._options = None
-_DATABASE._options = None
-_LISTDATABASESREQUEST.fields_by_name["parent"]._options = None
-_CREATEDATABASEREQUEST.fields_by_name["parent"]._options = None
-_CREATEDATABASEREQUEST.fields_by_name["create_statement"]._options = None
-_CREATEDATABASEREQUEST.fields_by_name["extra_statements"]._options = None
-_CREATEDATABASEMETADATA.fields_by_name["database"]._options = None
-_GETDATABASEREQUEST.fields_by_name["name"]._options = None
-_UPDATEDATABASEDDLREQUEST.fields_by_name["database"]._options = None
-_UPDATEDATABASEDDLREQUEST.fields_by_name["statements"]._options = None
-_UPDATEDATABASEDDLMETADATA.fields_by_name["database"]._options = None
-_DROPDATABASEREQUEST.fields_by_name["database"]._options = None
-_GETDATABASEDDLREQUEST.fields_by_name["database"]._options = None
-_LISTDATABASEOPERATIONSREQUEST.fields_by_name["parent"]._options = None
-_RESTOREDATABASEREQUEST.fields_by_name["parent"]._options = None
-_RESTOREDATABASEREQUEST.fields_by_name["database_id"]._options = None
-_RESTOREDATABASEREQUEST.fields_by_name["backup"]._options = None
-
-_DATABASEADMIN = _descriptor.ServiceDescriptor(
- name="DatabaseAdmin",
- full_name="google.spanner.admin.database.v1.DatabaseAdmin",
- file=DESCRIPTOR,
- index=0,
- serialized_options=b"\312A\026spanner.googleapis.com\322A\\https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/spanner.admin",
- create_key=_descriptor._internal_create_key,
- serialized_start=3100,
- serialized_end=7087,
- methods=[
- _descriptor.MethodDescriptor(
- name="ListDatabases",
- full_name="google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases",
- index=0,
- containing_service=None,
- input_type=_LISTDATABASESREQUEST,
- output_type=_LISTDATABASESRESPONSE,
- serialized_options=b"\202\323\344\223\002/\022-/v1/{parent=projects/*/instances/*}/databases\332A\006parent",
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.MethodDescriptor(
- name="CreateDatabase",
- full_name="google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase",
- index=1,
- containing_service=None,
- input_type=_CREATEDATABASEREQUEST,
- output_type=google_dot_longrunning_dot_operations__pb2._OPERATION,
- serialized_options=b'\202\323\344\223\0022"-/v1/{parent=projects/*/instances/*}/databases:\001*\332A\027parent,create_statement\312Ad\n)google.spanner.admin.database.v1.Database\0227google.spanner.admin.database.v1.CreateDatabaseMetadata',
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.MethodDescriptor(
- name="GetDatabase",
- full_name="google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase",
- index=2,
- containing_service=None,
- input_type=_GETDATABASEREQUEST,
- output_type=_DATABASE,
- serialized_options=b"\202\323\344\223\002/\022-/v1/{name=projects/*/instances/*/databases/*}\332A\004name",
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.MethodDescriptor(
- name="UpdateDatabaseDdl",
- full_name="google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl",
- index=3,
- containing_service=None,
- input_type=_UPDATEDATABASEDDLREQUEST,
- output_type=google_dot_longrunning_dot_operations__pb2._OPERATION,
- serialized_options=b"\202\323\344\223\002:25/v1/{database=projects/*/instances/*/databases/*}/ddl:\001*\332A\023database,statements\312AS\n\025google.protobuf.Empty\022:google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata",
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.MethodDescriptor(
- name="DropDatabase",
- full_name="google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase",
- index=4,
- containing_service=None,
- input_type=_DROPDATABASEREQUEST,
- output_type=google_dot_protobuf_dot_empty__pb2._EMPTY,
- serialized_options=b"\202\323\344\223\0023*1/v1/{database=projects/*/instances/*/databases/*}\332A\010database",
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.MethodDescriptor(
- name="GetDatabaseDdl",
- full_name="google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl",
- index=5,
- containing_service=None,
- input_type=_GETDATABASEDDLREQUEST,
- output_type=_GETDATABASEDDLRESPONSE,
- serialized_options=b"\202\323\344\223\0027\0225/v1/{database=projects/*/instances/*/databases/*}/ddl\332A\010database",
- create_key=_descriptor._internal_create_key,
- ),
- _descriptor.MethodDescriptor(
- name="SetIamPolicy",
- full_name="google.spanner.admin.database.v1.DatabaseAdmin.SetIamPolicy",
- index=6,
- containing_service=None,
- input_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._SETIAMPOLICYREQUEST,
- output_type=google_dot_iam_dot_v1_dot_policy__pb2._POLICY,
- serialized_options=b'\202\323\344\223\002\206\001">/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy:\001*ZA"/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy:\001*ZA"/operations/` and
- can be used to track preparation of the database. The
- [metadata][google.longrunning.Operation.metadata] field type is
- [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The
- [response][google.longrunning.Operation.response] field type is
- [Database][google.spanner.admin.database.v1.Database], if successful.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def GetDatabase(self, request, context):
- """Gets the state of a Cloud Spanner database.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def UpdateDatabaseDdl(self, request, context):
- """Updates the schema of a Cloud Spanner database by
- creating/altering/dropping tables, columns, indexes, etc. The returned
- [long-running operation][google.longrunning.Operation] will have a name of
- the format `/operations/` and can be used to
- track execution of the schema change(s). The
- [metadata][google.longrunning.Operation.metadata] field type is
- [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def DropDatabase(self, request, context):
- """Drops (aka deletes) a Cloud Spanner database.
- Completed backups for the database will be retained according to their
- `expire_time`.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def GetDatabaseDdl(self, request, context):
- """Returns the schema of a Cloud Spanner database as a list of formatted
- DDL statements. This method does not show pending schema updates, those may
- be queried using the [Operations][google.longrunning.Operations] API.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def SetIamPolicy(self, request, context):
- """Sets the access control policy on a database or backup resource.
- Replaces any existing policy.
-
- Authorization requires `spanner.databases.setIamPolicy`
- permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
- For backups, authorization requires `spanner.backups.setIamPolicy`
- permission on [resource][google.iam.v1.SetIamPolicyRequest.resource].
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def GetIamPolicy(self, request, context):
- """Gets the access control policy for a database or backup resource.
- Returns an empty policy if a database or backup exists but does not have a
- policy set.
-
- Authorization requires `spanner.databases.getIamPolicy` permission on
- [resource][google.iam.v1.GetIamPolicyRequest.resource].
- For backups, authorization requires `spanner.backups.getIamPolicy`
- permission on [resource][google.iam.v1.GetIamPolicyRequest.resource].
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def TestIamPermissions(self, request, context):
- """Returns permissions that the caller has on the specified database or backup
- resource.
-
- Attempting this RPC on a non-existent Cloud Spanner database will
- result in a NOT_FOUND error if the user has
- `spanner.databases.list` permission on the containing Cloud
- Spanner instance. Otherwise returns an empty set of permissions.
- Calling this method on a backup that does not exist will
- result in a NOT_FOUND error if the user has
- `spanner.backups.list` permission on the containing instance.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def CreateBackup(self, request, context):
- """Starts creating a new Cloud Spanner Backup.
- The returned backup [long-running operation][google.longrunning.Operation]
- will have a name of the format
- `projects//instances//backups//operations/`
- and can be used to track creation of the backup. The
- [metadata][google.longrunning.Operation.metadata] field type is
- [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata]. The
- [response][google.longrunning.Operation.response] field type is
- [Backup][google.spanner.admin.database.v1.Backup], if successful. Cancelling the returned operation will stop the
- creation and delete the backup.
- There can be only one pending backup creation per database. Backup creation
- of different databases can run concurrently.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def GetBackup(self, request, context):
- """Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def UpdateBackup(self, request, context):
- """Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def DeleteBackup(self, request, context):
- """Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def ListBackups(self, request, context):
- """Lists completed and pending backups.
- Backups returned are ordered by `create_time` in descending order,
- starting from the most recent `create_time`.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def RestoreDatabase(self, request, context):
- """Create a new database by restoring from a completed backup. The new
- database must be in the same project and in an instance with the same
- instance configuration as the instance containing
- the backup. The returned database [long-running
- operation][google.longrunning.Operation] has a name of the format
- `projects//instances//databases//operations/`,
- and can be used to track the progress of the operation, and to cancel it.
- The [metadata][google.longrunning.Operation.metadata] field type is
- [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
- The [response][google.longrunning.Operation.response] type
- is [Database][google.spanner.admin.database.v1.Database], if
- successful. Cancelling the returned operation will stop the restore and
- delete the database.
- There can be only one database being restored into an instance at a time.
- Once the restore operation completes, a new restore operation can be
- initiated, without waiting for the optimize operation associated with the
- first restore to complete.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def ListDatabaseOperations(self, request, context):
- """Lists database [longrunning-operations][google.longrunning.Operation].
- A database operation has a name of the form
- `projects//instances//databases//operations/`.
- The long-running operation
- [metadata][google.longrunning.Operation.metadata] field type
- `metadata.type_url` describes the type of the metadata. Operations returned
- include those that have completed/failed/canceled within the last 7 days,
- and pending operations.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
- def ListBackupOperations(self, request, context):
- """Lists the backup [long-running operations][google.longrunning.Operation] in
- the given instance. A backup operation has a name of the form
- `projects//instances//backups//operations/`.
- The long-running operation
- [metadata][google.longrunning.Operation.metadata] field type
- `metadata.type_url` describes the type of the metadata. Operations returned
- include those that have completed/failed/canceled within the last 7 days,
- and pending operations. Operations returned are ordered by
- `operation.metadata.value.progress.start_time` in descending order starting
- from the most recently started operation.
- """
- context.set_code(grpc.StatusCode.UNIMPLEMENTED)
- context.set_details("Method not implemented!")
- raise NotImplementedError("Method not implemented!")
-
-
-def add_DatabaseAdminServicer_to_server(servicer, server):
- rpc_method_handlers = {
- "ListDatabases": grpc.unary_unary_rpc_method_handler(
- servicer.ListDatabases,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabasesRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabasesResponse.SerializeToString,
- ),
- "CreateDatabase": grpc.unary_unary_rpc_method_handler(
- servicer.CreateDatabase,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.CreateDatabaseRequest.FromString,
- response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString,
- ),
- "GetDatabase": grpc.unary_unary_rpc_method_handler(
- servicer.GetDatabase,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.GetDatabaseRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.Database.SerializeToString,
- ),
- "UpdateDatabaseDdl": grpc.unary_unary_rpc_method_handler(
- servicer.UpdateDatabaseDdl,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.UpdateDatabaseDdlRequest.FromString,
- response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString,
- ),
- "DropDatabase": grpc.unary_unary_rpc_method_handler(
- servicer.DropDatabase,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.DropDatabaseRequest.FromString,
- response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
- ),
- "GetDatabaseDdl": grpc.unary_unary_rpc_method_handler(
- servicer.GetDatabaseDdl,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.GetDatabaseDdlRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.GetDatabaseDdlResponse.SerializeToString,
- ),
- "SetIamPolicy": grpc.unary_unary_rpc_method_handler(
- servicer.SetIamPolicy,
- request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.FromString,
- response_serializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString,
- ),
- "GetIamPolicy": grpc.unary_unary_rpc_method_handler(
- servicer.GetIamPolicy,
- request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.FromString,
- response_serializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString,
- ),
- "TestIamPermissions": grpc.unary_unary_rpc_method_handler(
- servicer.TestIamPermissions,
- request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.FromString,
- response_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.SerializeToString,
- ),
- "CreateBackup": grpc.unary_unary_rpc_method_handler(
- servicer.CreateBackup,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.CreateBackupRequest.FromString,
- response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString,
- ),
- "GetBackup": grpc.unary_unary_rpc_method_handler(
- servicer.GetBackup,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.GetBackupRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.Backup.SerializeToString,
- ),
- "UpdateBackup": grpc.unary_unary_rpc_method_handler(
- servicer.UpdateBackup,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.UpdateBackupRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.Backup.SerializeToString,
- ),
- "DeleteBackup": grpc.unary_unary_rpc_method_handler(
- servicer.DeleteBackup,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.DeleteBackupRequest.FromString,
- response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString,
- ),
- "ListBackups": grpc.unary_unary_rpc_method_handler(
- servicer.ListBackups,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.ListBackupsRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.ListBackupsResponse.SerializeToString,
- ),
- "RestoreDatabase": grpc.unary_unary_rpc_method_handler(
- servicer.RestoreDatabase,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.RestoreDatabaseRequest.FromString,
- response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString,
- ),
- "ListDatabaseOperations": grpc.unary_unary_rpc_method_handler(
- servicer.ListDatabaseOperations,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabaseOperationsRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabaseOperationsResponse.SerializeToString,
- ),
- "ListBackupOperations": grpc.unary_unary_rpc_method_handler(
- servicer.ListBackupOperations,
- request_deserializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.ListBackupOperationsRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.ListBackupOperationsResponse.SerializeToString,
- ),
- }
- generic_handler = grpc.method_handlers_generic_handler(
- "google.spanner.admin.database.v1.DatabaseAdmin", rpc_method_handlers
- )
- server.add_generic_rpc_handlers((generic_handler,))
-
-
-# This class is part of an EXPERIMENTAL API.
-class DatabaseAdmin(object):
- """Cloud Spanner Database Admin API
-
- The Cloud Spanner Database Admin API can be used to create, drop, and
- list databases. It also enables updating the schema of pre-existing
- databases. It can be also used to create, delete and list backups for a
- database and to restore from an existing backup.
- """
-
- @staticmethod
- def ListDatabases(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabases",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabasesRequest.SerializeToString,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabasesResponse.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def CreateDatabase(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/CreateDatabase",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.CreateDatabaseRequest.SerializeToString,
- google_dot_longrunning_dot_operations__pb2.Operation.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def GetDatabase(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/GetDatabase",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.GetDatabaseRequest.SerializeToString,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.Database.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def UpdateDatabaseDdl(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/UpdateDatabaseDdl",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.UpdateDatabaseDdlRequest.SerializeToString,
- google_dot_longrunning_dot_operations__pb2.Operation.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def DropDatabase(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/DropDatabase",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.DropDatabaseRequest.SerializeToString,
- google_dot_protobuf_dot_empty__pb2.Empty.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def GetDatabaseDdl(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/GetDatabaseDdl",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.GetDatabaseDdlRequest.SerializeToString,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.GetDatabaseDdlResponse.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def SetIamPolicy(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/SetIamPolicy",
- google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.SerializeToString,
- google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def GetIamPolicy(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/GetIamPolicy",
- google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.SerializeToString,
- google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def TestIamPermissions(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/TestIamPermissions",
- google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.SerializeToString,
- google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def CreateBackup(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/CreateBackup",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.CreateBackupRequest.SerializeToString,
- google_dot_longrunning_dot_operations__pb2.Operation.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def GetBackup(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/GetBackup",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.GetBackupRequest.SerializeToString,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.Backup.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def UpdateBackup(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/UpdateBackup",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.UpdateBackupRequest.SerializeToString,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.Backup.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def DeleteBackup(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/DeleteBackup",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.DeleteBackupRequest.SerializeToString,
- google_dot_protobuf_dot_empty__pb2.Empty.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def ListBackups(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/ListBackups",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.ListBackupsRequest.SerializeToString,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.ListBackupsResponse.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def RestoreDatabase(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/RestoreDatabase",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.RestoreDatabaseRequest.SerializeToString,
- google_dot_longrunning_dot_operations__pb2.Operation.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def ListDatabaseOperations(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabaseOperations",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabaseOperationsRequest.SerializeToString,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabaseOperationsResponse.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
-
- @staticmethod
- def ListBackupOperations(
- request,
- target,
- options=(),
- channel_credentials=None,
- call_credentials=None,
- compression=None,
- wait_for_ready=None,
- timeout=None,
- metadata=None,
- ):
- return grpc.experimental.unary_unary(
- request,
- target,
- "/google.spanner.admin.database.v1.DatabaseAdmin/ListBackupOperations",
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.ListBackupOperationsRequest.SerializeToString,
- google_dot_cloud_dot_spanner__admin__database__v1_dot_proto_dot_backup__pb2.ListBackupOperationsResponse.FromString,
- options,
- channel_credentials,
- call_credentials,
- compression,
- wait_for_ready,
- timeout,
- metadata,
- )
diff --git a/google/cloud/spanner_admin_database_v1/py.typed b/google/cloud/spanner_admin_database_v1/py.typed
new file mode 100644
index 0000000000..29f334aad6
--- /dev/null
+++ b/google/cloud/spanner_admin_database_v1/py.typed
@@ -0,0 +1,2 @@
+# Marker file for PEP 561.
+# The google-cloud-spanner-admin-database package uses inline types.
diff --git a/google/cloud/spanner_admin_database_v1/services/__init__.py b/google/cloud/spanner_admin_database_v1/services/__init__.py
new file mode 100644
index 0000000000..42ffdf2bc4
--- /dev/null
+++ b/google/cloud/spanner_admin_database_v1/services/__init__.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py b/google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py
new file mode 100644
index 0000000000..1fd198c176
--- /dev/null
+++ b/google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py
@@ -0,0 +1,24 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from .client import DatabaseAdminClient
+from .async_client import DatabaseAdminAsyncClient
+
+__all__ = (
+ "DatabaseAdminClient",
+ "DatabaseAdminAsyncClient",
+)
diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py
new file mode 100644
index 0000000000..4f15f2e2c8
--- /dev/null
+++ b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py
@@ -0,0 +1,1925 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+import functools
+import re
+from typing import Dict, Sequence, Tuple, Type, Union
+import pkg_resources
+
+import google.api_core.client_options as ClientOptions # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.api_core import operation # type: ignore
+from google.api_core import operation_async # type: ignore
+from google.cloud.spanner_admin_database_v1.services.database_admin import pagers
+from google.cloud.spanner_admin_database_v1.types import backup
+from google.cloud.spanner_admin_database_v1.types import backup as gsad_backup
+from google.cloud.spanner_admin_database_v1.types import spanner_database_admin
+from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore
+from google.iam.v1 import policy_pb2 as policy # type: ignore
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+from google.protobuf import timestamp_pb2 as timestamp # type: ignore
+
+from .transports.base import DatabaseAdminTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc_asyncio import DatabaseAdminGrpcAsyncIOTransport
+from .client import DatabaseAdminClient
+
+
+class DatabaseAdminAsyncClient:
+ """Cloud Spanner Database Admin API
+ The Cloud Spanner Database Admin API can be used to create,
+ drop, and list databases. It also enables updating the schema of
+ pre-existing databases. It can be also used to create, delete
+ and list backups for a database and to restore from an existing
+ backup.
+ """
+
+ _client: DatabaseAdminClient
+
+ DEFAULT_ENDPOINT = DatabaseAdminClient.DEFAULT_ENDPOINT
+ DEFAULT_MTLS_ENDPOINT = DatabaseAdminClient.DEFAULT_MTLS_ENDPOINT
+
+ backup_path = staticmethod(DatabaseAdminClient.backup_path)
+ parse_backup_path = staticmethod(DatabaseAdminClient.parse_backup_path)
+ database_path = staticmethod(DatabaseAdminClient.database_path)
+ parse_database_path = staticmethod(DatabaseAdminClient.parse_database_path)
+ instance_path = staticmethod(DatabaseAdminClient.instance_path)
+ parse_instance_path = staticmethod(DatabaseAdminClient.parse_instance_path)
+
+ common_billing_account_path = staticmethod(
+ DatabaseAdminClient.common_billing_account_path
+ )
+ parse_common_billing_account_path = staticmethod(
+ DatabaseAdminClient.parse_common_billing_account_path
+ )
+
+ common_folder_path = staticmethod(DatabaseAdminClient.common_folder_path)
+ parse_common_folder_path = staticmethod(
+ DatabaseAdminClient.parse_common_folder_path
+ )
+
+ common_organization_path = staticmethod(
+ DatabaseAdminClient.common_organization_path
+ )
+ parse_common_organization_path = staticmethod(
+ DatabaseAdminClient.parse_common_organization_path
+ )
+
+ common_project_path = staticmethod(DatabaseAdminClient.common_project_path)
+ parse_common_project_path = staticmethod(
+ DatabaseAdminClient.parse_common_project_path
+ )
+
+ common_location_path = staticmethod(DatabaseAdminClient.common_location_path)
+ parse_common_location_path = staticmethod(
+ DatabaseAdminClient.parse_common_location_path
+ )
+
+ from_service_account_file = DatabaseAdminClient.from_service_account_file
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> DatabaseAdminTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ DatabaseAdminTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
+ get_transport_class = functools.partial(
+ type(DatabaseAdminClient).get_transport_class, type(DatabaseAdminClient)
+ )
+
+ def __init__(
+ self,
+ *,
+ credentials: credentials.Credentials = None,
+ transport: Union[str, DatabaseAdminTransport] = "grpc_asyncio",
+ client_options: ClientOptions = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the database admin client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.DatabaseAdminTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (ClientOptions): Custom options for the client. It
+ won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+
+ Raises:
+ google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+
+ self._client = DatabaseAdminClient(
+ credentials=credentials,
+ transport=transport,
+ client_options=client_options,
+ client_info=client_info,
+ )
+
+ async def list_databases(
+ self,
+ request: spanner_database_admin.ListDatabasesRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListDatabasesAsyncPager:
+ r"""Lists Cloud Spanner databases.
+
+ Args:
+ request (:class:`~.spanner_database_admin.ListDatabasesRequest`):
+ The request object. The request for
+ [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
+ parent (:class:`str`):
+ Required. The instance whose databases should be listed.
+ Values are of the form
+ ``projects//instances/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListDatabasesAsyncPager:
+ The response for
+ [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = spanner_database_admin.ListDatabasesRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.list_databases,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.ListDatabasesAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def create_database(
+ self,
+ request: spanner_database_admin.CreateDatabaseRequest = None,
+ *,
+ parent: str = None,
+ create_statement: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation_async.AsyncOperation:
+ r"""Creates a new Cloud Spanner database and starts to prepare it
+ for serving. The returned [long-running
+ operation][google.longrunning.Operation] will have a name of the
+ format ``/operations/`` and can be
+ used to track preparation of the database. The
+ [metadata][google.longrunning.Operation.metadata] field type is
+ [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata].
+ The [response][google.longrunning.Operation.response] field type
+ is [Database][google.spanner.admin.database.v1.Database], if
+ successful.
+
+ Args:
+ request (:class:`~.spanner_database_admin.CreateDatabaseRequest`):
+ The request object. The request for
+ [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
+ parent (:class:`str`):
+ Required. The name of the instance that will serve the
+ new database. Values are of the form
+ ``projects//instances/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ create_statement (:class:`str`):
+ Required. A ``CREATE DATABASE`` statement, which
+ specifies the ID of the new database. The database ID
+ must conform to the regular expression
+ ``[a-z][a-z0-9_\-]*[a-z0-9]`` and be between 2 and 30
+ characters in length. If the database ID is a reserved
+ word or if it contains a hyphen, the database ID must be
+ enclosed in backticks (:literal:`\``).
+ This corresponds to the ``create_statement`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation_async.AsyncOperation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.spanner_database_admin.Database``: A Cloud
+ Spanner database.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([parent, create_statement])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = spanner_database_admin.CreateDatabaseRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if create_statement is not None:
+ request.create_statement = create_statement
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.create_database,
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation_async.from_gapic(
+ response,
+ self._client._transport.operations_client,
+ spanner_database_admin.Database,
+ metadata_type=spanner_database_admin.CreateDatabaseMetadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def get_database(
+ self,
+ request: spanner_database_admin.GetDatabaseRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> spanner_database_admin.Database:
+ r"""Gets the state of a Cloud Spanner database.
+
+ Args:
+ request (:class:`~.spanner_database_admin.GetDatabaseRequest`):
+ The request object. The request for
+ [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase].
+ name (:class:`str`):
+ Required. The name of the requested database. Values are
+ of the form
+ ``projects//instances//databases/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.spanner_database_admin.Database:
+ A Cloud Spanner database.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = spanner_database_admin.GetDatabaseRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.get_database,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def update_database_ddl(
+ self,
+ request: spanner_database_admin.UpdateDatabaseDdlRequest = None,
+ *,
+ database: str = None,
+ statements: Sequence[str] = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation_async.AsyncOperation:
+ r"""Updates the schema of a Cloud Spanner database by
+ creating/altering/dropping tables, columns, indexes, etc. The
+ returned [long-running operation][google.longrunning.Operation]
+ will have a name of the format
+ ``/operations/`` and can be used to
+ track execution of the schema change(s). The
+ [metadata][google.longrunning.Operation.metadata] field type is
+ [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata].
+ The operation has no response.
+
+ Args:
+ request (:class:`~.spanner_database_admin.UpdateDatabaseDdlRequest`):
+ The request object. Enqueues the given DDL statements to
+ be applied, in order but not necessarily all at once, to
+ the database schema at some point (or points) in the
+ future. The server checks that the statements are
+ executable (syntactically valid, name tables that exist,
+ etc.) before enqueueing them, but they may still fail
+ upon
+ later execution (e.g., if a statement from another batch
+ of statements is applied first and it conflicts in some
+ way, or if there is some data-related problem like a
+ `NULL` value in a column to which `NOT NULL` would be
+ added). If a statement fails, all subsequent statements
+ in the batch are automatically cancelled.
+ Each batch of statements is assigned a name which can be
+ used with the
+ [Operations][google.longrunning.Operations] API to
+ monitor progress. See the
+ [operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id]
+ field for more details.
+ database (:class:`str`):
+ Required. The database to update.
+ This corresponds to the ``database`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ statements (:class:`Sequence[str]`):
+ Required. DDL statements to be
+ applied to the database.
+ This corresponds to the ``statements`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation_async.AsyncOperation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.empty.Empty``: A generic empty message that
+ you can re-use to avoid defining duplicated empty
+ messages in your APIs. A typical example is to use it as
+ the request or the response type of an API method. For
+ instance:
+
+ ::
+
+ service Foo {
+ rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
+ }
+
+ The JSON representation for ``Empty`` is empty JSON
+ object ``{}``.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([database, statements])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = spanner_database_admin.UpdateDatabaseDdlRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if database is not None:
+ request.database = database
+
+ if statements:
+ request.statements.extend(statements)
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.update_database_ddl,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation_async.from_gapic(
+ response,
+ self._client._transport.operations_client,
+ empty.Empty,
+ metadata_type=spanner_database_admin.UpdateDatabaseDdlMetadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def drop_database(
+ self,
+ request: spanner_database_admin.DropDatabaseRequest = None,
+ *,
+ database: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Drops (aka deletes) a Cloud Spanner database. Completed backups
+ for the database will be retained according to their
+ ``expire_time``.
+
+ Args:
+ request (:class:`~.spanner_database_admin.DropDatabaseRequest`):
+ The request object. The request for
+ [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase].
+ database (:class:`str`):
+ Required. The database to be dropped.
+ This corresponds to the ``database`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([database])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = spanner_database_admin.DropDatabaseRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if database is not None:
+ request.database = database
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.drop_database,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
+ )
+
+ # Send the request.
+ await rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+ async def get_database_ddl(
+ self,
+ request: spanner_database_admin.GetDatabaseDdlRequest = None,
+ *,
+ database: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> spanner_database_admin.GetDatabaseDdlResponse:
+ r"""Returns the schema of a Cloud Spanner database as a list of
+ formatted DDL statements. This method does not show pending
+ schema updates, those may be queried using the
+ [Operations][google.longrunning.Operations] API.
+
+ Args:
+ request (:class:`~.spanner_database_admin.GetDatabaseDdlRequest`):
+ The request object. The request for
+ [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
+ database (:class:`str`):
+ Required. The database whose schema
+ we wish to get.
+ This corresponds to the ``database`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.spanner_database_admin.GetDatabaseDdlResponse:
+ The response for
+ [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([database])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = spanner_database_admin.GetDatabaseDdlRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if database is not None:
+ request.database = database
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.get_database_ddl,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def set_iam_policy(
+ self,
+ request: iam_policy.SetIamPolicyRequest = None,
+ *,
+ resource: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> policy.Policy:
+ r"""Sets the access control policy on a database or backup resource.
+ Replaces any existing policy.
+
+ Authorization requires ``spanner.databases.setIamPolicy``
+ permission on
+ [resource][google.iam.v1.SetIamPolicyRequest.resource]. For
+ backups, authorization requires ``spanner.backups.setIamPolicy``
+ permission on
+ [resource][google.iam.v1.SetIamPolicyRequest.resource].
+
+ Args:
+ request (:class:`~.iam_policy.SetIamPolicyRequest`):
+ The request object. Request message for `SetIamPolicy`
+ method.
+ resource (:class:`str`):
+ REQUIRED: The resource for which the
+ policy is being specified. See the
+ operation documentation for the
+ appropriate value for this field.
+ This corresponds to the ``resource`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.policy.Policy:
+ Defines an Identity and Access Management (IAM) policy.
+ It is used to specify access control policies for Cloud
+ Platform resources.
+
+ A ``Policy`` is a collection of ``bindings``. A
+ ``binding`` binds one or more ``members`` to a single
+ ``role``. Members can be user accounts, service
+ accounts, Google groups, and domains (such as G Suite).
+ A ``role`` is a named list of permissions (defined by
+ IAM or configured by users). A ``binding`` can
+ optionally specify a ``condition``, which is a logic
+ expression that further constrains the role binding
+ based on attributes about the request and/or target
+ resource.
+
+ **JSON Example**
+
+ ::
+
+ {
+ "bindings": [
+ {
+ "role": "roles/resourcemanager.organizationAdmin",
+ "members": [
+ "user:mike@example.com",
+ "group:admins@example.com",
+ "domain:google.com",
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
+ ]
+ },
+ {
+ "role": "roles/resourcemanager.organizationViewer",
+ "members": ["user:eve@example.com"],
+ "condition": {
+ "title": "expirable access",
+ "description": "Does not grant access after Sep 2020",
+ "expression": "request.time <
+ timestamp('2020-10-01T00:00:00.000Z')",
+ }
+ }
+ ]
+ }
+
+ **YAML Example**
+
+ ::
+
+ bindings:
+ - members:
+ - user:mike@example.com
+ - group:admins@example.com
+ - domain:google.com
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
+ role: roles/resourcemanager.organizationAdmin
+ - members:
+ - user:eve@example.com
+ role: roles/resourcemanager.organizationViewer
+ condition:
+ title: expirable access
+ description: Does not grant access after Sep 2020
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
+
+ For a description of IAM and its features, see the `IAM
+ developer's
+ guide `__.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([resource])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # The request isn't a proto-plus wrapped type,
+ # so it must be constructed via keyword expansion.
+ if isinstance(request, dict):
+ request = iam_policy.SetIamPolicyRequest(**request)
+
+ elif not request:
+ request = iam_policy.SetIamPolicyRequest(resource=resource,)
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.set_iam_policy,
+ default_timeout=30.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def get_iam_policy(
+ self,
+ request: iam_policy.GetIamPolicyRequest = None,
+ *,
+ resource: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> policy.Policy:
+ r"""Gets the access control policy for a database or backup
+ resource. Returns an empty policy if a database or backup exists
+ but does not have a policy set.
+
+ Authorization requires ``spanner.databases.getIamPolicy``
+ permission on
+ [resource][google.iam.v1.GetIamPolicyRequest.resource]. For
+ backups, authorization requires ``spanner.backups.getIamPolicy``
+ permission on
+ [resource][google.iam.v1.GetIamPolicyRequest.resource].
+
+ Args:
+ request (:class:`~.iam_policy.GetIamPolicyRequest`):
+ The request object. Request message for `GetIamPolicy`
+ method.
+ resource (:class:`str`):
+ REQUIRED: The resource for which the
+ policy is being requested. See the
+ operation documentation for the
+ appropriate value for this field.
+ This corresponds to the ``resource`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.policy.Policy:
+ Defines an Identity and Access Management (IAM) policy.
+ It is used to specify access control policies for Cloud
+ Platform resources.
+
+ A ``Policy`` is a collection of ``bindings``. A
+ ``binding`` binds one or more ``members`` to a single
+ ``role``. Members can be user accounts, service
+ accounts, Google groups, and domains (such as G Suite).
+ A ``role`` is a named list of permissions (defined by
+ IAM or configured by users). A ``binding`` can
+ optionally specify a ``condition``, which is a logic
+ expression that further constrains the role binding
+ based on attributes about the request and/or target
+ resource.
+
+ **JSON Example**
+
+ ::
+
+ {
+ "bindings": [
+ {
+ "role": "roles/resourcemanager.organizationAdmin",
+ "members": [
+ "user:mike@example.com",
+ "group:admins@example.com",
+ "domain:google.com",
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
+ ]
+ },
+ {
+ "role": "roles/resourcemanager.organizationViewer",
+ "members": ["user:eve@example.com"],
+ "condition": {
+ "title": "expirable access",
+ "description": "Does not grant access after Sep 2020",
+ "expression": "request.time <
+ timestamp('2020-10-01T00:00:00.000Z')",
+ }
+ }
+ ]
+ }
+
+ **YAML Example**
+
+ ::
+
+ bindings:
+ - members:
+ - user:mike@example.com
+ - group:admins@example.com
+ - domain:google.com
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
+ role: roles/resourcemanager.organizationAdmin
+ - members:
+ - user:eve@example.com
+ role: roles/resourcemanager.organizationViewer
+ condition:
+ title: expirable access
+ description: Does not grant access after Sep 2020
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
+
+ For a description of IAM and its features, see the `IAM
+ developer's
+ guide `__.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([resource])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # The request isn't a proto-plus wrapped type,
+ # so it must be constructed via keyword expansion.
+ if isinstance(request, dict):
+ request = iam_policy.GetIamPolicyRequest(**request)
+
+ elif not request:
+ request = iam_policy.GetIamPolicyRequest(resource=resource,)
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.get_iam_policy,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=30.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def test_iam_permissions(
+ self,
+ request: iam_policy.TestIamPermissionsRequest = None,
+ *,
+ resource: str = None,
+ permissions: Sequence[str] = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> iam_policy.TestIamPermissionsResponse:
+ r"""Returns permissions that the caller has on the specified
+ database or backup resource.
+
+ Attempting this RPC on a non-existent Cloud Spanner database
+ will result in a NOT_FOUND error if the user has
+ ``spanner.databases.list`` permission on the containing Cloud
+ Spanner instance. Otherwise returns an empty set of permissions.
+ Calling this method on a backup that does not exist will result
+ in a NOT_FOUND error if the user has ``spanner.backups.list``
+ permission on the containing instance.
+
+ Args:
+ request (:class:`~.iam_policy.TestIamPermissionsRequest`):
+ The request object. Request message for
+ `TestIamPermissions` method.
+ resource (:class:`str`):
+ REQUIRED: The resource for which the
+ policy detail is being requested. See
+ the operation documentation for the
+ appropriate value for this field.
+ This corresponds to the ``resource`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ permissions (:class:`Sequence[str]`):
+ The set of permissions to check for the ``resource``.
+ Permissions with wildcards (such as '*' or 'storage.*')
+ are not allowed. For more information see `IAM
+ Overview `__.
+ This corresponds to the ``permissions`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.iam_policy.TestIamPermissionsResponse:
+ Response message for ``TestIamPermissions`` method.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([resource, permissions])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # The request isn't a proto-plus wrapped type,
+ # so it must be constructed via keyword expansion.
+ if isinstance(request, dict):
+ request = iam_policy.TestIamPermissionsRequest(**request)
+
+ elif not request:
+ request = iam_policy.TestIamPermissionsRequest(
+ resource=resource, permissions=permissions,
+ )
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.test_iam_permissions,
+ default_timeout=30.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def create_backup(
+ self,
+ request: gsad_backup.CreateBackupRequest = None,
+ *,
+ parent: str = None,
+ backup: gsad_backup.Backup = None,
+ backup_id: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation_async.AsyncOperation:
+ r"""Starts creating a new Cloud Spanner Backup. The returned backup
+ [long-running operation][google.longrunning.Operation] will have
+ a name of the format
+ ``projects//instances//backups//operations/``
+ and can be used to track creation of the backup. The
+ [metadata][google.longrunning.Operation.metadata] field type is
+ [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata].
+ The [response][google.longrunning.Operation.response] field type
+ is [Backup][google.spanner.admin.database.v1.Backup], if
+ successful. Cancelling the returned operation will stop the
+ creation and delete the backup. There can be only one pending
+ backup creation per database. Backup creation of different
+ databases can run concurrently.
+
+ Args:
+ request (:class:`~.gsad_backup.CreateBackupRequest`):
+ The request object. The request for
+ [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
+ parent (:class:`str`):
+ Required. The name of the instance in which the backup
+ will be created. This must be the same instance that
+ contains the database the backup will be created from.
+ The backup will be stored in the location(s) specified
+ in the instance configuration of this instance. Values
+ are of the form
+ ``projects//instances/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ backup (:class:`~.gsad_backup.Backup`):
+ Required. The backup to create.
+ This corresponds to the ``backup`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ backup_id (:class:`str`):
+ Required. The id of the backup to be created. The
+ ``backup_id`` appended to ``parent`` forms the full
+ backup name of the form
+ ``projects//instances//backups/``.
+ This corresponds to the ``backup_id`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation_async.AsyncOperation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.gsad_backup.Backup``: A backup of a Cloud
+ Spanner database.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([parent, backup, backup_id])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gsad_backup.CreateBackupRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if backup is not None:
+ request.backup = backup
+ if backup_id is not None:
+ request.backup_id = backup_id
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.create_backup,
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation_async.from_gapic(
+ response,
+ self._client._transport.operations_client,
+ gsad_backup.Backup,
+ metadata_type=gsad_backup.CreateBackupMetadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def get_backup(
+ self,
+ request: backup.GetBackupRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> backup.Backup:
+ r"""Gets metadata on a pending or completed
+ [Backup][google.spanner.admin.database.v1.Backup].
+
+ Args:
+ request (:class:`~.backup.GetBackupRequest`):
+ The request object. The request for
+ [GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup].
+ name (:class:`str`):
+ Required. Name of the backup. Values are of the form
+ ``projects//instances//backups/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.backup.Backup:
+ A backup of a Cloud Spanner database.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = backup.GetBackupRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.get_backup,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def update_backup(
+ self,
+ request: gsad_backup.UpdateBackupRequest = None,
+ *,
+ backup: gsad_backup.Backup = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gsad_backup.Backup:
+ r"""Updates a pending or completed
+ [Backup][google.spanner.admin.database.v1.Backup].
+
+ Args:
+ request (:class:`~.gsad_backup.UpdateBackupRequest`):
+ The request object. The request for
+ [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup].
+ backup (:class:`~.gsad_backup.Backup`):
+ Required. The backup to update. ``backup.name``, and the
+ fields to be updated as specified by ``update_mask`` are
+ required. Other fields are ignored. Update is only
+ supported for the following fields:
+
+ - ``backup.expire_time``.
+
+ This corresponds to the ``backup`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ Required. A mask specifying which fields (e.g.
+ ``expire_time``) in the Backup resource should be
+ updated. This mask is relative to the Backup resource,
+ not to the request message. The field mask must always
+ be specified; this prevents any future fields from being
+ erased accidentally by clients that do not know about
+ them.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gsad_backup.Backup:
+ A backup of a Cloud Spanner database.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([backup, update_mask])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = gsad_backup.UpdateBackupRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if backup is not None:
+ request.backup = backup
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.update_backup,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("backup.name", request.backup.name),)
+ ),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ async def delete_backup(
+ self,
+ request: backup.DeleteBackupRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes a pending or completed
+ [Backup][google.spanner.admin.database.v1.Backup].
+
+ Args:
+ request (:class:`~.backup.DeleteBackupRequest`):
+ The request object. The request for
+ [DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup].
+ name (:class:`str`):
+ Required. Name of the backup to delete. Values are of
+ the form
+ ``projects//instances//backups/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = backup.DeleteBackupRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.delete_backup,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ await rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+ async def list_backups(
+ self,
+ request: backup.ListBackupsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListBackupsAsyncPager:
+ r"""Lists completed and pending backups. Backups returned are
+ ordered by ``create_time`` in descending order, starting from
+ the most recent ``create_time``.
+
+ Args:
+ request (:class:`~.backup.ListBackupsRequest`):
+ The request object. The request for
+ [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
+ parent (:class:`str`):
+ Required. The instance to list backups from. Values are
+ of the form ``projects//instances/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListBackupsAsyncPager:
+ The response for
+ [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = backup.ListBackupsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.list_backups,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.ListBackupsAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def restore_database(
+ self,
+ request: spanner_database_admin.RestoreDatabaseRequest = None,
+ *,
+ parent: str = None,
+ database_id: str = None,
+ backup: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation_async.AsyncOperation:
+ r"""Create a new database by restoring from a completed backup. The
+ new database must be in the same project and in an instance with
+ the same instance configuration as the instance containing the
+ backup. The returned database [long-running
+ operation][google.longrunning.Operation] has a name of the
+ format
+ ``projects//instances//databases//operations/``,
+ and can be used to track the progress of the operation, and to
+ cancel it. The [metadata][google.longrunning.Operation.metadata]
+ field type is
+ [RestoreDatabaseMetadata][google.spanner.admin.database.v1.RestoreDatabaseMetadata].
+ The [response][google.longrunning.Operation.response] type is
+ [Database][google.spanner.admin.database.v1.Database], if
+ successful. Cancelling the returned operation will stop the
+ restore and delete the database. There can be only one database
+ being restored into an instance at a time. Once the restore
+ operation completes, a new restore operation can be initiated,
+ without waiting for the optimize operation associated with the
+ first restore to complete.
+
+ Args:
+ request (:class:`~.spanner_database_admin.RestoreDatabaseRequest`):
+ The request object. The request for
+ [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
+ parent (:class:`str`):
+ Required. The name of the instance in which to create
+ the restored database. This instance must be in the same
+ project and have the same instance configuration as the
+ instance containing the source backup. Values are of the
+ form ``projects//instances/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ database_id (:class:`str`):
+ Required. The id of the database to create and restore
+ to. This database must not already exist. The
+ ``database_id`` appended to ``parent`` forms the full
+ database name of the form
+ ``projects//instances//databases/``.
+ This corresponds to the ``database_id`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ backup (:class:`str`):
+ Name of the backup from which to restore. Values are of
+ the form
+ ``projects//instances//backups/``.
+ This corresponds to the ``backup`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation_async.AsyncOperation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.spanner_database_admin.Database``: A Cloud
+ Spanner database.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([parent, database_id, backup])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = spanner_database_admin.RestoreDatabaseRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if database_id is not None:
+ request.database_id = database_id
+ if backup is not None:
+ request.backup = backup
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.restore_database,
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation_async.from_gapic(
+ response,
+ self._client._transport.operations_client,
+ spanner_database_admin.Database,
+ metadata_type=spanner_database_admin.RestoreDatabaseMetadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def list_database_operations(
+ self,
+ request: spanner_database_admin.ListDatabaseOperationsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListDatabaseOperationsAsyncPager:
+ r"""Lists database
+ [longrunning-operations][google.longrunning.Operation]. A
+ database operation has a name of the form
+ ``projects//instances//databases//operations/``.
+ The long-running operation
+ [metadata][google.longrunning.Operation.metadata] field type
+ ``metadata.type_url`` describes the type of the metadata.
+ Operations returned include those that have
+ completed/failed/canceled within the last 7 days, and pending
+ operations.
+
+ Args:
+ request (:class:`~.spanner_database_admin.ListDatabaseOperationsRequest`):
+ The request object. The request for
+ [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
+ parent (:class:`str`):
+ Required. The instance of the database operations.
+ Values are of the form
+ ``projects//instances/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListDatabaseOperationsAsyncPager:
+ The response for
+ [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = spanner_database_admin.ListDatabaseOperationsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.list_database_operations,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.ListDatabaseOperationsAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def list_backup_operations(
+ self,
+ request: backup.ListBackupOperationsRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListBackupOperationsAsyncPager:
+ r"""Lists the backup [long-running
+ operations][google.longrunning.Operation] in the given instance.
+ A backup operation has a name of the form
+ ``projects//instances//backups//operations/``.
+ The long-running operation
+ [metadata][google.longrunning.Operation.metadata] field type
+ ``metadata.type_url`` describes the type of the metadata.
+ Operations returned include those that have
+ completed/failed/canceled within the last 7 days, and pending
+ operations. Operations returned are ordered by
+ ``operation.metadata.value.progress.start_time`` in descending
+ order starting from the most recently started operation.
+
+ Args:
+ request (:class:`~.backup.ListBackupOperationsRequest`):
+ The request object. The request for
+ [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
+ parent (:class:`str`):
+ Required. The instance of the backup operations. Values
+ are of the form
+ ``projects//instances/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListBackupOperationsAsyncPager:
+ The response for
+ [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ request = backup.ListBackupOperationsRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = gapic_v1.method_async.wrap_method(
+ self._client._transport.list_backup_operations,
+ default_retry=retries.Retry(
+ initial=1.0,
+ maximum=32.0,
+ multiplier=1.3,
+ predicate=retries.if_exception_type(
+ exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
+ ),
+ ),
+ default_timeout=3600.0,
+ client_info=DEFAULT_CLIENT_INFO,
+ )
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__aiter__` convenience method.
+ response = pagers.ListBackupOperationsAsyncPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+
+try:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=pkg_resources.get_distribution(
+ "google-cloud-spanner-admin-database",
+ ).version,
+ )
+except pkg_resources.DistributionNotFound:
+ DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+
+
+__all__ = ("DatabaseAdminAsyncClient",)
diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py
new file mode 100644
index 0000000000..3edfd9c9ed
--- /dev/null
+++ b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py
@@ -0,0 +1,2047 @@
+# -*- coding: utf-8 -*-
+
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+from collections import OrderedDict
+from distutils import util
+import os
+import re
+from typing import Callable, Dict, Optional, Sequence, Tuple, Type, Union
+import pkg_resources
+
+from google.api_core import client_options as client_options_lib # type: ignore
+from google.api_core import exceptions # type: ignore
+from google.api_core import gapic_v1 # type: ignore
+from google.api_core import retry as retries # type: ignore
+from google.auth import credentials # type: ignore
+from google.auth.transport import mtls # type: ignore
+from google.auth.transport.grpc import SslCredentials # type: ignore
+from google.auth.exceptions import MutualTLSChannelError # type: ignore
+from google.oauth2 import service_account # type: ignore
+
+from google.api_core import operation # type: ignore
+from google.api_core import operation_async # type: ignore
+from google.cloud.spanner_admin_database_v1.services.database_admin import pagers
+from google.cloud.spanner_admin_database_v1.types import backup
+from google.cloud.spanner_admin_database_v1.types import backup as gsad_backup
+from google.cloud.spanner_admin_database_v1.types import spanner_database_admin
+from google.iam.v1 import iam_policy_pb2 as iam_policy # type: ignore
+from google.iam.v1 import policy_pb2 as policy # type: ignore
+from google.longrunning import operations_pb2 as operations # type: ignore
+from google.protobuf import empty_pb2 as empty # type: ignore
+from google.protobuf import field_mask_pb2 as field_mask # type: ignore
+from google.protobuf import timestamp_pb2 as timestamp # type: ignore
+
+from .transports.base import DatabaseAdminTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc import DatabaseAdminGrpcTransport
+from .transports.grpc_asyncio import DatabaseAdminGrpcAsyncIOTransport
+
+
+class DatabaseAdminClientMeta(type):
+ """Metaclass for the DatabaseAdmin client.
+
+ This provides class-level methods for building and retrieving
+ support objects (e.g. transport) without polluting the client instance
+ objects.
+ """
+
+ _transport_registry = OrderedDict() # type: Dict[str, Type[DatabaseAdminTransport]]
+ _transport_registry["grpc"] = DatabaseAdminGrpcTransport
+ _transport_registry["grpc_asyncio"] = DatabaseAdminGrpcAsyncIOTransport
+
+ def get_transport_class(cls, label: str = None,) -> Type[DatabaseAdminTransport]:
+ """Return an appropriate transport class.
+
+ Args:
+ label: The name of the desired transport. If none is
+ provided, then the first transport in the registry is used.
+
+ Returns:
+ The transport class to use.
+ """
+ # If a specific transport is requested, return that one.
+ if label:
+ return cls._transport_registry[label]
+
+ # No transport is requested; return the default (that is, the first one
+ # in the dictionary).
+ return next(iter(cls._transport_registry.values()))
+
+
+class DatabaseAdminClient(metaclass=DatabaseAdminClientMeta):
+ """Cloud Spanner Database Admin API
+ The Cloud Spanner Database Admin API can be used to create,
+ drop, and list databases. It also enables updating the schema of
+ pre-existing databases. It can be also used to create, delete
+ and list backups for a database and to restore from an existing
+ backup.
+ """
+
+ @staticmethod
+ def _get_default_mtls_endpoint(api_endpoint):
+ """Convert api endpoint to mTLS endpoint.
+ Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to
+ "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively.
+ Args:
+ api_endpoint (Optional[str]): the api endpoint to convert.
+ Returns:
+ str: converted mTLS api endpoint.
+ """
+ if not api_endpoint:
+ return api_endpoint
+
+ mtls_endpoint_re = re.compile(
+ r"(?P[^.]+)(?P\.mtls)?(?P\.sandbox)?(?P\.googleapis\.com)?"
+ )
+
+ m = mtls_endpoint_re.match(api_endpoint)
+ name, mtls, sandbox, googledomain = m.groups()
+ if mtls or not googledomain:
+ return api_endpoint
+
+ if sandbox:
+ return api_endpoint.replace(
+ "sandbox.googleapis.com", "mtls.sandbox.googleapis.com"
+ )
+
+ return api_endpoint.replace(".googleapis.com", ".mtls.googleapis.com")
+
+ DEFAULT_ENDPOINT = "spanner.googleapis.com"
+ DEFAULT_MTLS_ENDPOINT = _get_default_mtls_endpoint.__func__( # type: ignore
+ DEFAULT_ENDPOINT
+ )
+
+ @classmethod
+ def from_service_account_file(cls, filename: str, *args, **kwargs):
+ """Creates an instance of this client using the provided credentials
+ file.
+
+ Args:
+ filename (str): The path to the service account private key json
+ file.
+ args: Additional arguments to pass to the constructor.
+ kwargs: Additional arguments to pass to the constructor.
+
+ Returns:
+ {@api.name}: The constructed client.
+ """
+ credentials = service_account.Credentials.from_service_account_file(filename)
+ kwargs["credentials"] = credentials
+ return cls(*args, **kwargs)
+
+ from_service_account_json = from_service_account_file
+
+ @property
+ def transport(self) -> DatabaseAdminTransport:
+ """Return the transport used by the client instance.
+
+ Returns:
+ DatabaseAdminTransport: The transport used by the client instance.
+ """
+ return self._transport
+
+ @staticmethod
+ def backup_path(project: str, instance: str, backup: str,) -> str:
+ """Return a fully-qualified backup string."""
+ return "projects/{project}/instances/{instance}/backups/{backup}".format(
+ project=project, instance=instance, backup=backup,
+ )
+
+ @staticmethod
+ def parse_backup_path(path: str) -> Dict[str, str]:
+ """Parse a backup path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/instances/(?P.+?)/backups/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def database_path(project: str, instance: str, database: str,) -> str:
+ """Return a fully-qualified database string."""
+ return "projects/{project}/instances/{instance}/databases/{database}".format(
+ project=project, instance=instance, database=database,
+ )
+
+ @staticmethod
+ def parse_database_path(path: str) -> Dict[str, str]:
+ """Parse a database path into its component segments."""
+ m = re.match(
+ r"^projects/(?P.+?)/instances/(?P.+?)/databases/(?P.+?)$",
+ path,
+ )
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def instance_path(project: str, instance: str,) -> str:
+ """Return a fully-qualified instance string."""
+ return "projects/{project}/instances/{instance}".format(
+ project=project, instance=instance,
+ )
+
+ @staticmethod
+ def parse_instance_path(path: str) -> Dict[str, str]:
+ """Parse a instance path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/instances/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_billing_account_path(billing_account: str,) -> str:
+ """Return a fully-qualified billing_account string."""
+ return "billingAccounts/{billing_account}".format(
+ billing_account=billing_account,
+ )
+
+ @staticmethod
+ def parse_common_billing_account_path(path: str) -> Dict[str, str]:
+ """Parse a billing_account path into its component segments."""
+ m = re.match(r"^billingAccounts/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_folder_path(folder: str,) -> str:
+ """Return a fully-qualified folder string."""
+ return "folders/{folder}".format(folder=folder,)
+
+ @staticmethod
+ def parse_common_folder_path(path: str) -> Dict[str, str]:
+ """Parse a folder path into its component segments."""
+ m = re.match(r"^folders/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_organization_path(organization: str,) -> str:
+ """Return a fully-qualified organization string."""
+ return "organizations/{organization}".format(organization=organization,)
+
+ @staticmethod
+ def parse_common_organization_path(path: str) -> Dict[str, str]:
+ """Parse a organization path into its component segments."""
+ m = re.match(r"^organizations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_project_path(project: str,) -> str:
+ """Return a fully-qualified project string."""
+ return "projects/{project}".format(project=project,)
+
+ @staticmethod
+ def parse_common_project_path(path: str) -> Dict[str, str]:
+ """Parse a project path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ @staticmethod
+ def common_location_path(project: str, location: str,) -> str:
+ """Return a fully-qualified location string."""
+ return "projects/{project}/locations/{location}".format(
+ project=project, location=location,
+ )
+
+ @staticmethod
+ def parse_common_location_path(path: str) -> Dict[str, str]:
+ """Parse a location path into its component segments."""
+ m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path)
+ return m.groupdict() if m else {}
+
+ def __init__(
+ self,
+ *,
+ credentials: Optional[credentials.Credentials] = None,
+ transport: Union[str, DatabaseAdminTransport, None] = None,
+ client_options: Optional[client_options_lib.ClientOptions] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiate the database admin client.
+
+ Args:
+ credentials (Optional[google.auth.credentials.Credentials]): The
+ authorization credentials to attach to requests. These
+ credentials identify the application to the service; if none
+ are specified, the client will attempt to ascertain the
+ credentials from the environment.
+ transport (Union[str, ~.DatabaseAdminTransport]): The
+ transport to use. If set to None, a transport is chosen
+ automatically.
+ client_options (client_options_lib.ClientOptions): Custom options for the
+ client. It won't take effect if a ``transport`` instance is provided.
+ (1) The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
+ environment variable can also be used to override the endpoint:
+ "always" (always use the default mTLS endpoint), "never" (always
+ use the default regular endpoint) and "auto" (auto switch to the
+ default mTLS endpoint if client certificate is present, this is
+ the default value). However, the ``api_endpoint`` property takes
+ precedence if provided.
+ (2) If GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide client certificate for mutual TLS transport. If
+ not provided, the default SSL client certificate will be used if
+ present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
+ set, no client certificate will be used.
+ client_info (google.api_core.gapic_v1.client_info.ClientInfo):
+ The client info used to send a user-agent string along with
+ API requests. If ``None``, then default info will be used.
+ Generally, you only need to set this if you're developing
+ your own client library.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
+ creation failed for any reason.
+ """
+ if isinstance(client_options, dict):
+ client_options = client_options_lib.from_dict(client_options)
+ if client_options is None:
+ client_options = client_options_lib.ClientOptions()
+
+ # Create SSL credentials for mutual TLS if needed.
+ use_client_cert = bool(
+ util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
+ )
+
+ ssl_credentials = None
+ is_mtls = False
+ if use_client_cert:
+ if client_options.client_cert_source:
+ import grpc # type: ignore
+
+ cert, key = client_options.client_cert_source()
+ ssl_credentials = grpc.ssl_channel_credentials(
+ certificate_chain=cert, private_key=key
+ )
+ is_mtls = True
+ else:
+ creds = SslCredentials()
+ is_mtls = creds.is_mtls
+ ssl_credentials = creds.ssl_credentials if is_mtls else None
+
+ # Figure out which api endpoint to use.
+ if client_options.api_endpoint is not None:
+ api_endpoint = client_options.api_endpoint
+ else:
+ use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto")
+ if use_mtls_env == "never":
+ api_endpoint = self.DEFAULT_ENDPOINT
+ elif use_mtls_env == "always":
+ api_endpoint = self.DEFAULT_MTLS_ENDPOINT
+ elif use_mtls_env == "auto":
+ api_endpoint = (
+ self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT
+ )
+ else:
+ raise MutualTLSChannelError(
+ "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted values: never, auto, always"
+ )
+
+ # Save or instantiate the transport.
+ # Ordinarily, we provide the transport, but allowing a custom transport
+ # instance provides an extensibility point for unusual situations.
+ if isinstance(transport, DatabaseAdminTransport):
+ # transport is a DatabaseAdminTransport instance.
+ if credentials or client_options.credentials_file:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its credentials directly."
+ )
+ if client_options.scopes:
+ raise ValueError(
+ "When providing a transport instance, "
+ "provide its scopes directly."
+ )
+ self._transport = transport
+ else:
+ Transport = type(self).get_transport_class(transport)
+ self._transport = Transport(
+ credentials=credentials,
+ credentials_file=client_options.credentials_file,
+ host=api_endpoint,
+ scopes=client_options.scopes,
+ ssl_channel_credentials=ssl_credentials,
+ quota_project_id=client_options.quota_project_id,
+ client_info=client_info,
+ )
+
+ def list_databases(
+ self,
+ request: spanner_database_admin.ListDatabasesRequest = None,
+ *,
+ parent: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> pagers.ListDatabasesPager:
+ r"""Lists Cloud Spanner databases.
+
+ Args:
+ request (:class:`~.spanner_database_admin.ListDatabasesRequest`):
+ The request object. The request for
+ [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
+ parent (:class:`str`):
+ Required. The instance whose databases should be listed.
+ Values are of the form
+ ``projects//instances/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.pagers.ListDatabasesPager:
+ The response for
+ [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
+
+ Iterating over this object will yield results and
+ resolve additional pages automatically.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([parent])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a spanner_database_admin.ListDatabasesRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, spanner_database_admin.ListDatabasesRequest):
+ request = spanner_database_admin.ListDatabasesRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.list_databases]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # This method is paged; wrap the response in a pager, which provides
+ # an `__iter__` convenience method.
+ response = pagers.ListDatabasesPager(
+ method=rpc, request=request, response=response, metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ def create_database(
+ self,
+ request: spanner_database_admin.CreateDatabaseRequest = None,
+ *,
+ parent: str = None,
+ create_statement: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation.Operation:
+ r"""Creates a new Cloud Spanner database and starts to prepare it
+ for serving. The returned [long-running
+ operation][google.longrunning.Operation] will have a name of the
+ format ``/operations/`` and can be
+ used to track preparation of the database. The
+ [metadata][google.longrunning.Operation.metadata] field type is
+ [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata].
+ The [response][google.longrunning.Operation.response] field type
+ is [Database][google.spanner.admin.database.v1.Database], if
+ successful.
+
+ Args:
+ request (:class:`~.spanner_database_admin.CreateDatabaseRequest`):
+ The request object. The request for
+ [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
+ parent (:class:`str`):
+ Required. The name of the instance that will serve the
+ new database. Values are of the form
+ ``projects//instances/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ create_statement (:class:`str`):
+ Required. A ``CREATE DATABASE`` statement, which
+ specifies the ID of the new database. The database ID
+ must conform to the regular expression
+ ``[a-z][a-z0-9_\-]*[a-z0-9]`` and be between 2 and 30
+ characters in length. If the database ID is a reserved
+ word or if it contains a hyphen, the database ID must be
+ enclosed in backticks (:literal:`\``).
+ This corresponds to the ``create_statement`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation.Operation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.spanner_database_admin.Database``: A Cloud
+ Spanner database.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([parent, create_statement])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a spanner_database_admin.CreateDatabaseRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, spanner_database_admin.CreateDatabaseRequest):
+ request = spanner_database_admin.CreateDatabaseRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if create_statement is not None:
+ request.create_statement = create_statement
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.create_database]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation.from_gapic(
+ response,
+ self._transport.operations_client,
+ spanner_database_admin.Database,
+ metadata_type=spanner_database_admin.CreateDatabaseMetadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ def get_database(
+ self,
+ request: spanner_database_admin.GetDatabaseRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> spanner_database_admin.Database:
+ r"""Gets the state of a Cloud Spanner database.
+
+ Args:
+ request (:class:`~.spanner_database_admin.GetDatabaseRequest`):
+ The request object. The request for
+ [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase].
+ name (:class:`str`):
+ Required. The name of the requested database. Values are
+ of the form
+ ``projects//instances//databases/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.spanner_database_admin.Database:
+ A Cloud Spanner database.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a spanner_database_admin.GetDatabaseRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, spanner_database_admin.GetDatabaseRequest):
+ request = spanner_database_admin.GetDatabaseRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.get_database]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def update_database_ddl(
+ self,
+ request: spanner_database_admin.UpdateDatabaseDdlRequest = None,
+ *,
+ database: str = None,
+ statements: Sequence[str] = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation.Operation:
+ r"""Updates the schema of a Cloud Spanner database by
+ creating/altering/dropping tables, columns, indexes, etc. The
+ returned [long-running operation][google.longrunning.Operation]
+ will have a name of the format
+ ``/operations/`` and can be used to
+ track execution of the schema change(s). The
+ [metadata][google.longrunning.Operation.metadata] field type is
+ [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata].
+ The operation has no response.
+
+ Args:
+ request (:class:`~.spanner_database_admin.UpdateDatabaseDdlRequest`):
+ The request object. Enqueues the given DDL statements to
+ be applied, in order but not necessarily all at once, to
+ the database schema at some point (or points) in the
+ future. The server checks that the statements are
+ executable (syntactically valid, name tables that exist,
+ etc.) before enqueueing them, but they may still fail
+ upon
+ later execution (e.g., if a statement from another batch
+ of statements is applied first and it conflicts in some
+ way, or if there is some data-related problem like a
+ `NULL` value in a column to which `NOT NULL` would be
+ added). If a statement fails, all subsequent statements
+ in the batch are automatically cancelled.
+ Each batch of statements is assigned a name which can be
+ used with the
+ [Operations][google.longrunning.Operations] API to
+ monitor progress. See the
+ [operation_id][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id]
+ field for more details.
+ database (:class:`str`):
+ Required. The database to update.
+ This corresponds to the ``database`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ statements (:class:`Sequence[str]`):
+ Required. DDL statements to be
+ applied to the database.
+ This corresponds to the ``statements`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation.Operation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.empty.Empty``: A generic empty message that
+ you can re-use to avoid defining duplicated empty
+ messages in your APIs. A typical example is to use it as
+ the request or the response type of an API method. For
+ instance:
+
+ ::
+
+ service Foo {
+ rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty);
+ }
+
+ The JSON representation for ``Empty`` is empty JSON
+ object ``{}``.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([database, statements])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a spanner_database_admin.UpdateDatabaseDdlRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, spanner_database_admin.UpdateDatabaseDdlRequest):
+ request = spanner_database_admin.UpdateDatabaseDdlRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if database is not None:
+ request.database = database
+
+ if statements:
+ request.statements.extend(statements)
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.update_database_ddl]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation.from_gapic(
+ response,
+ self._transport.operations_client,
+ empty.Empty,
+ metadata_type=spanner_database_admin.UpdateDatabaseDdlMetadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ def drop_database(
+ self,
+ request: spanner_database_admin.DropDatabaseRequest = None,
+ *,
+ database: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Drops (aka deletes) a Cloud Spanner database. Completed backups
+ for the database will be retained according to their
+ ``expire_time``.
+
+ Args:
+ request (:class:`~.spanner_database_admin.DropDatabaseRequest`):
+ The request object. The request for
+ [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase].
+ database (:class:`str`):
+ Required. The database to be dropped.
+ This corresponds to the ``database`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([database])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a spanner_database_admin.DropDatabaseRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, spanner_database_admin.DropDatabaseRequest):
+ request = spanner_database_admin.DropDatabaseRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if database is not None:
+ request.database = database
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.drop_database]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
+ )
+
+ # Send the request.
+ rpc(
+ request, retry=retry, timeout=timeout, metadata=metadata,
+ )
+
+ def get_database_ddl(
+ self,
+ request: spanner_database_admin.GetDatabaseDdlRequest = None,
+ *,
+ database: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> spanner_database_admin.GetDatabaseDdlResponse:
+ r"""Returns the schema of a Cloud Spanner database as a list of
+ formatted DDL statements. This method does not show pending
+ schema updates, those may be queried using the
+ [Operations][google.longrunning.Operations] API.
+
+ Args:
+ request (:class:`~.spanner_database_admin.GetDatabaseDdlRequest`):
+ The request object. The request for
+ [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
+ database (:class:`str`):
+ Required. The database whose schema
+ we wish to get.
+ This corresponds to the ``database`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.spanner_database_admin.GetDatabaseDdlResponse:
+ The response for
+ [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([database])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a spanner_database_admin.GetDatabaseDdlRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, spanner_database_admin.GetDatabaseDdlRequest):
+ request = spanner_database_admin.GetDatabaseDdlRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if database is not None:
+ request.database = database
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.get_database_ddl]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("database", request.database),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def set_iam_policy(
+ self,
+ request: iam_policy.SetIamPolicyRequest = None,
+ *,
+ resource: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> policy.Policy:
+ r"""Sets the access control policy on a database or backup resource.
+ Replaces any existing policy.
+
+ Authorization requires ``spanner.databases.setIamPolicy``
+ permission on
+ [resource][google.iam.v1.SetIamPolicyRequest.resource]. For
+ backups, authorization requires ``spanner.backups.setIamPolicy``
+ permission on
+ [resource][google.iam.v1.SetIamPolicyRequest.resource].
+
+ Args:
+ request (:class:`~.iam_policy.SetIamPolicyRequest`):
+ The request object. Request message for `SetIamPolicy`
+ method.
+ resource (:class:`str`):
+ REQUIRED: The resource for which the
+ policy is being specified. See the
+ operation documentation for the
+ appropriate value for this field.
+ This corresponds to the ``resource`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.policy.Policy:
+ Defines an Identity and Access Management (IAM) policy.
+ It is used to specify access control policies for Cloud
+ Platform resources.
+
+ A ``Policy`` is a collection of ``bindings``. A
+ ``binding`` binds one or more ``members`` to a single
+ ``role``. Members can be user accounts, service
+ accounts, Google groups, and domains (such as G Suite).
+ A ``role`` is a named list of permissions (defined by
+ IAM or configured by users). A ``binding`` can
+ optionally specify a ``condition``, which is a logic
+ expression that further constrains the role binding
+ based on attributes about the request and/or target
+ resource.
+
+ **JSON Example**
+
+ ::
+
+ {
+ "bindings": [
+ {
+ "role": "roles/resourcemanager.organizationAdmin",
+ "members": [
+ "user:mike@example.com",
+ "group:admins@example.com",
+ "domain:google.com",
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
+ ]
+ },
+ {
+ "role": "roles/resourcemanager.organizationViewer",
+ "members": ["user:eve@example.com"],
+ "condition": {
+ "title": "expirable access",
+ "description": "Does not grant access after Sep 2020",
+ "expression": "request.time <
+ timestamp('2020-10-01T00:00:00.000Z')",
+ }
+ }
+ ]
+ }
+
+ **YAML Example**
+
+ ::
+
+ bindings:
+ - members:
+ - user:mike@example.com
+ - group:admins@example.com
+ - domain:google.com
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
+ role: roles/resourcemanager.organizationAdmin
+ - members:
+ - user:eve@example.com
+ role: roles/resourcemanager.organizationViewer
+ condition:
+ title: expirable access
+ description: Does not grant access after Sep 2020
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
+
+ For a description of IAM and its features, see the `IAM
+ developer's
+ guide `__.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([resource])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # The request isn't a proto-plus wrapped type,
+ # so it must be constructed via keyword expansion.
+ if isinstance(request, dict):
+ request = iam_policy.SetIamPolicyRequest(**request)
+
+ elif not request:
+ request = iam_policy.SetIamPolicyRequest(resource=resource,)
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.set_iam_policy]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def get_iam_policy(
+ self,
+ request: iam_policy.GetIamPolicyRequest = None,
+ *,
+ resource: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> policy.Policy:
+ r"""Gets the access control policy for a database or backup
+ resource. Returns an empty policy if a database or backup exists
+ but does not have a policy set.
+
+ Authorization requires ``spanner.databases.getIamPolicy``
+ permission on
+ [resource][google.iam.v1.GetIamPolicyRequest.resource]. For
+ backups, authorization requires ``spanner.backups.getIamPolicy``
+ permission on
+ [resource][google.iam.v1.GetIamPolicyRequest.resource].
+
+ Args:
+ request (:class:`~.iam_policy.GetIamPolicyRequest`):
+ The request object. Request message for `GetIamPolicy`
+ method.
+ resource (:class:`str`):
+ REQUIRED: The resource for which the
+ policy is being requested. See the
+ operation documentation for the
+ appropriate value for this field.
+ This corresponds to the ``resource`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.policy.Policy:
+ Defines an Identity and Access Management (IAM) policy.
+ It is used to specify access control policies for Cloud
+ Platform resources.
+
+ A ``Policy`` is a collection of ``bindings``. A
+ ``binding`` binds one or more ``members`` to a single
+ ``role``. Members can be user accounts, service
+ accounts, Google groups, and domains (such as G Suite).
+ A ``role`` is a named list of permissions (defined by
+ IAM or configured by users). A ``binding`` can
+ optionally specify a ``condition``, which is a logic
+ expression that further constrains the role binding
+ based on attributes about the request and/or target
+ resource.
+
+ **JSON Example**
+
+ ::
+
+ {
+ "bindings": [
+ {
+ "role": "roles/resourcemanager.organizationAdmin",
+ "members": [
+ "user:mike@example.com",
+ "group:admins@example.com",
+ "domain:google.com",
+ "serviceAccount:my-project-id@appspot.gserviceaccount.com"
+ ]
+ },
+ {
+ "role": "roles/resourcemanager.organizationViewer",
+ "members": ["user:eve@example.com"],
+ "condition": {
+ "title": "expirable access",
+ "description": "Does not grant access after Sep 2020",
+ "expression": "request.time <
+ timestamp('2020-10-01T00:00:00.000Z')",
+ }
+ }
+ ]
+ }
+
+ **YAML Example**
+
+ ::
+
+ bindings:
+ - members:
+ - user:mike@example.com
+ - group:admins@example.com
+ - domain:google.com
+ - serviceAccount:my-project-id@appspot.gserviceaccount.com
+ role: roles/resourcemanager.organizationAdmin
+ - members:
+ - user:eve@example.com
+ role: roles/resourcemanager.organizationViewer
+ condition:
+ title: expirable access
+ description: Does not grant access after Sep 2020
+ expression: request.time < timestamp('2020-10-01T00:00:00.000Z')
+
+ For a description of IAM and its features, see the `IAM
+ developer's
+ guide `__.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([resource])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # The request isn't a proto-plus wrapped type,
+ # so it must be constructed via keyword expansion.
+ if isinstance(request, dict):
+ request = iam_policy.GetIamPolicyRequest(**request)
+
+ elif not request:
+ request = iam_policy.GetIamPolicyRequest(resource=resource,)
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.get_iam_policy]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def test_iam_permissions(
+ self,
+ request: iam_policy.TestIamPermissionsRequest = None,
+ *,
+ resource: str = None,
+ permissions: Sequence[str] = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> iam_policy.TestIamPermissionsResponse:
+ r"""Returns permissions that the caller has on the specified
+ database or backup resource.
+
+ Attempting this RPC on a non-existent Cloud Spanner database
+ will result in a NOT_FOUND error if the user has
+ ``spanner.databases.list`` permission on the containing Cloud
+ Spanner instance. Otherwise returns an empty set of permissions.
+ Calling this method on a backup that does not exist will result
+ in a NOT_FOUND error if the user has ``spanner.backups.list``
+ permission on the containing instance.
+
+ Args:
+ request (:class:`~.iam_policy.TestIamPermissionsRequest`):
+ The request object. Request message for
+ `TestIamPermissions` method.
+ resource (:class:`str`):
+ REQUIRED: The resource for which the
+ policy detail is being requested. See
+ the operation documentation for the
+ appropriate value for this field.
+ This corresponds to the ``resource`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ permissions (:class:`Sequence[str]`):
+ The set of permissions to check for the ``resource``.
+ Permissions with wildcards (such as '*' or 'storage.*')
+ are not allowed. For more information see `IAM
+ Overview `__.
+ This corresponds to the ``permissions`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.iam_policy.TestIamPermissionsResponse:
+ Response message for ``TestIamPermissions`` method.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([resource, permissions])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # The request isn't a proto-plus wrapped type,
+ # so it must be constructed via keyword expansion.
+ if isinstance(request, dict):
+ request = iam_policy.TestIamPermissionsRequest(**request)
+
+ elif not request:
+ request = iam_policy.TestIamPermissionsRequest(
+ resource=resource, permissions=permissions,
+ )
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.test_iam_permissions]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("resource", request.resource),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def create_backup(
+ self,
+ request: gsad_backup.CreateBackupRequest = None,
+ *,
+ parent: str = None,
+ backup: gsad_backup.Backup = None,
+ backup_id: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> operation.Operation:
+ r"""Starts creating a new Cloud Spanner Backup. The returned backup
+ [long-running operation][google.longrunning.Operation] will have
+ a name of the format
+ ``projects//instances//backups//operations/``
+ and can be used to track creation of the backup. The
+ [metadata][google.longrunning.Operation.metadata] field type is
+ [CreateBackupMetadata][google.spanner.admin.database.v1.CreateBackupMetadata].
+ The [response][google.longrunning.Operation.response] field type
+ is [Backup][google.spanner.admin.database.v1.Backup], if
+ successful. Cancelling the returned operation will stop the
+ creation and delete the backup. There can be only one pending
+ backup creation per database. Backup creation of different
+ databases can run concurrently.
+
+ Args:
+ request (:class:`~.gsad_backup.CreateBackupRequest`):
+ The request object. The request for
+ [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
+ parent (:class:`str`):
+ Required. The name of the instance in which the backup
+ will be created. This must be the same instance that
+ contains the database the backup will be created from.
+ The backup will be stored in the location(s) specified
+ in the instance configuration of this instance. Values
+ are of the form
+ ``projects//instances/``.
+ This corresponds to the ``parent`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ backup (:class:`~.gsad_backup.Backup`):
+ Required. The backup to create.
+ This corresponds to the ``backup`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ backup_id (:class:`str`):
+ Required. The id of the backup to be created. The
+ ``backup_id`` appended to ``parent`` forms the full
+ backup name of the form
+ ``projects//instances//backups/``.
+ This corresponds to the ``backup_id`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.operation.Operation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:``~.gsad_backup.Backup``: A backup of a Cloud
+ Spanner database.
+
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([parent, backup, backup_id])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gsad_backup.CreateBackupRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gsad_backup.CreateBackupRequest):
+ request = gsad_backup.CreateBackupRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if parent is not None:
+ request.parent = parent
+ if backup is not None:
+ request.backup = backup
+ if backup_id is not None:
+ request.backup_id = backup_id
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.create_backup]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Wrap the response in an operation future.
+ response = operation.from_gapic(
+ response,
+ self._transport.operations_client,
+ gsad_backup.Backup,
+ metadata_type=gsad_backup.CreateBackupMetadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ def get_backup(
+ self,
+ request: backup.GetBackupRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> backup.Backup:
+ r"""Gets metadata on a pending or completed
+ [Backup][google.spanner.admin.database.v1.Backup].
+
+ Args:
+ request (:class:`~.backup.GetBackupRequest`):
+ The request object. The request for
+ [GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup].
+ name (:class:`str`):
+ Required. Name of the backup. Values are of the form
+ ``projects//instances//backups/``.
+ This corresponds to the ``name`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.backup.Backup:
+ A backup of a Cloud Spanner database.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([name])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a backup.GetBackupRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, backup.GetBackupRequest):
+ request = backup.GetBackupRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if name is not None:
+ request.name = name
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.get_backup]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def update_backup(
+ self,
+ request: gsad_backup.UpdateBackupRequest = None,
+ *,
+ backup: gsad_backup.Backup = None,
+ update_mask: field_mask.FieldMask = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> gsad_backup.Backup:
+ r"""Updates a pending or completed
+ [Backup][google.spanner.admin.database.v1.Backup].
+
+ Args:
+ request (:class:`~.gsad_backup.UpdateBackupRequest`):
+ The request object. The request for
+ [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup].
+ backup (:class:`~.gsad_backup.Backup`):
+ Required. The backup to update. ``backup.name``, and the
+ fields to be updated as specified by ``update_mask`` are
+ required. Other fields are ignored. Update is only
+ supported for the following fields:
+
+ - ``backup.expire_time``.
+
+ This corresponds to the ``backup`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+ update_mask (:class:`~.field_mask.FieldMask`):
+ Required. A mask specifying which fields (e.g.
+ ``expire_time``) in the Backup resource should be
+ updated. This mask is relative to the Backup resource,
+ not to the request message. The field mask must always
+ be specified; this prevents any future fields from being
+ erased accidentally by clients that do not know about
+ them.
+ This corresponds to the ``update_mask`` field
+ on the ``request`` instance; if ``request`` is provided, this
+ should not be set.
+
+ retry (google.api_core.retry.Retry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, str]]): Strings which should be
+ sent along with the request as metadata.
+
+ Returns:
+ ~.gsad_backup.Backup:
+ A backup of a Cloud Spanner database.
+ """
+ # Create or coerce a protobuf request object.
+ # Sanity check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ has_flattened_params = any([backup, update_mask])
+ if request is not None and has_flattened_params:
+ raise ValueError(
+ "If the `request` argument is set, then none of "
+ "the individual field arguments should be set."
+ )
+
+ # Minor optimization to avoid making a copy if the user passes
+ # in a gsad_backup.UpdateBackupRequest.
+ # There's no risk of modifying the input as we've already verified
+ # there are no flattened fields.
+ if not isinstance(request, gsad_backup.UpdateBackupRequest):
+ request = gsad_backup.UpdateBackupRequest(request)
+
+ # If we have keyword arguments corresponding to fields on the
+ # request, apply these.
+
+ if backup is not None:
+ request.backup = backup
+ if update_mask is not None:
+ request.update_mask = update_mask
+
+ # Wrap the RPC method; this adds retry and timeout information,
+ # and friendly error handling.
+ rpc = self._transport._wrapped_methods[self._transport.update_backup]
+
+ # Certain fields should be provided within the metadata header;
+ # add these here.
+ metadata = tuple(metadata) + (
+ gapic_v1.routing_header.to_grpc_metadata(
+ (("backup.name", request.backup.name),)
+ ),
+ )
+
+ # Send the request.
+ response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,)
+
+ # Done; return the response.
+ return response
+
+ def delete_backup(
+ self,
+ request: backup.DeleteBackupRequest = None,
+ *,
+ name: str = None,
+ retry: retries.Retry = gapic_v1.method.DEFAULT,
+ timeout: float = None,
+ metadata: Sequence[Tuple[str, str]] = (),
+ ) -> None:
+ r"""Deletes a pending or completed
+ [Backup][google.spanner.admin.database.v1.Backup].
+
+ Args:
+ request (:class:`~.backup.DeleteBackupRequest`):
+ The request object. The request for
+ [DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup].
+ name (:class:`str`):
+ Required. Name of the backup to delete. Values are of
+ the form
+ ``projects//instances/