- On January 1, 2020 this library will no longer support Python 2 on the latest released version.
- Previously released library versions will continue to be available. For more information please
+ As of January 1, 2020 this library no longer supports Python 2 on the latest released version.
+ Library versions released prior to that date will continue to be available. For more information please
visit
Python 2 support on Google Cloud.
{% block body %} {% endblock %}
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
deleted file mode 100644
index c767b23afa..0000000000
--- a/docs/api-reference.rst
+++ /dev/null
@@ -1,33 +0,0 @@
-API Reference
-=============
-
-The following classes and methods constitute the Spanner client.
-Most likely, you will be interacting almost exclusively with these:
-
-.. toctree::
- :maxdepth: 1
-
- client-api
- instance-api
- database-api
- session-api
- keyset-api
- snapshot-api
- batch-api
- transaction-api
- streamed-api
-
-
-The classes and methods above depend on the following, lower-level
-classes and methods. Documentation for these is provided for completion,
-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
diff --git a/docs/batch-usage.rst b/docs/batch-usage.rst
index 419ca106e6..0da1086779 100644
--- a/docs/batch-usage.rst
+++ b/docs/batch-usage.rst
@@ -1,36 +1,64 @@
Batching Modifications
######################
-A :class:`~google.cloud.spanner.batch.Batch` represents a set of data
+A :class:`~google.cloud.spanner_v1.batch.Batch` represents a set of data
modification operations to be performed on tables in a database. Use of a
``Batch`` does not require creating an explicit
-:class:`~google.cloud.spanner.snapshot.Snapshot` or
-:class:`~google.cloud.spanner.transaction.Transaction`. Until
-:meth:`~google.cloud.spanner.batch.Batch.commit` is called on a ``Batch``,
+:class:`~google.cloud.spanner_v1.snapshot.Snapshot` or
+:class:`~google.cloud.spanner_v1.transaction.Transaction`. Until
+:meth:`~google.cloud.spanner_v1.batch.Batch.commit` is called on a ``Batch``,
no changes are propagated to the back-end.
-Starting a Batch
-----------------
+Use Batch via BatchCheckout
+--------------------------------
-Construct a :class:`~google.cloud.spanner.batch.Batch` object from a :class:`~google.cloud.spanner.database.Database` object:
+:meth:`Database.batch` creates a :class:`~google.cloud.spanner_v1.database.BatchCheckout`
+instance to use as a context manager to handle creating and committing a
+:class:`~google.cloud.spanner_v1.batch.Batch`. The
+:class:`BatchCheckout` will automatically call
+:meth:`~google.cloud.spanner_v1.batch.Batch.commit` if the ``with`` block exits
+without raising an exception.
.. code:: python
- from google.cloud import spanner
+ from google.cloud.spanner import KeySet
client = spanner.Client()
instance = client.instance(INSTANCE_NAME)
database = instance.database(DATABASE_NAME)
- batch = database.batch()
+ to_delete = KeySet(keys=[
+ ('bharney@example.com',)
+ ('nonesuch@example.com',)
+ ])
+
+ with database.batch() as batch:
+
+ batch.insert(
+ 'citizens', columns=['email', 'first_name', 'last_name', 'age'],
+ values=[
+ ['phred@exammple.com', 'Phred', 'Phlyntstone', 32],
+ ['bharney@example.com', 'Bharney', 'Rhubble', 31],
+ ])
+
+ batch.update(
+ 'citizens', columns=['email', 'age'],
+ values=[
+ ['phred@exammple.com', 33],
+ ['bharney@example.com', 32],
+ ])
+
+ ...
+
+ batch.delete('citizens', to_delete)
Inserting records using a Batch
-------------------------------
-:meth:`Batch.insert` adds one or more new records to a table. Fails if
-any of the records already exists.
+:meth:`Batch.insert` adds one or more new records to a table. This fails if
+any of the records already exist.
.. code:: python
@@ -53,8 +81,8 @@ any of the records already exists.
Update records using a Batch
-------------------------------
-:meth:`Batch.update` updates one or more existing records in a table. Fails
-if any of the records does not already exist.
+:meth:`Batch.update` updates one or more existing records in a table. This fails
+if any of the records do not already exist.
.. code:: python
@@ -127,8 +155,8 @@ column values are set to null.
Delete records using a Batch
----------------------------
-:meth:`Batch.delete` removes one or more records from a table. Non-existent
-rows do not cause errors.
+:meth:`Batch.delete` removes one or more records from a table. Attempting to delete
+rows that do not exist will not cause errors.
.. code:: python
@@ -151,50 +179,13 @@ After describing the modifications to be made to table data via the
the back-end by calling :meth:`Batch.commit`, which makes the ``Commit``
API call.
-.. code:: python
-
- batch.commit()
-
-
-Use a Batch as a Context Manager
---------------------------------
-
-Rather than calling :meth:`Batch.commit` manually, you can use the
-:class:`Batch` instance as a context manager, and have it called automatically
-if the ``with`` block exits without raising an exception.
+You do not need to call this yourself as
+:class:`~google.cloud.spanner_v1.database.BatchCheckout` will call
+this method automatically upon exiting the ``with`` block.
.. code:: python
- from google.cloud.spanner import KeySet
-
- client = spanner.Client()
- instance = client.instance(INSTANCE_NAME)
- database = instance.database(DATABASE_NAME)
-
- to_delete = KeySet(keys=[
- ('bharney@example.com',)
- ('nonesuch@example.com',)
- ])
-
- with database.batch() as batch:
-
- batch.insert(
- 'citizens', columns=['email', 'first_name', 'last_name', 'age'],
- values=[
- ['phred@exammple.com', 'Phred', 'Phlyntstone', 32],
- ['bharney@example.com', 'Bharney', 'Rhubble', 31],
- ])
-
- batch.update(
- 'citizens', columns=['email', 'age'],
- values=[
- ['phred@exammple.com', 33],
- ['bharney@example.com', 32],
- ])
-
- ...
-
- batch.delete('citizens', to_delete)
+ batch.commit()
Next Step
diff --git a/docs/client-usage.rst b/docs/client-usage.rst
index 801c9cb135..7ba3390e59 100644
--- a/docs/client-usage.rst
+++ b/docs/client-usage.rst
@@ -1,5 +1,5 @@
-Spanner Client
-==============
+Spanner Client Usage
+====================
.. _spanner-client:
@@ -16,17 +16,6 @@ and creating other objects:
from google.cloud import spanner
client = spanner.Client()
-Long-lived Defaults
--------------------
-
-When creating a :class:`~google.cloud.spanner_v1.client.Client`, the
-``user_agent`` and ``timeout_seconds`` arguments have sensible
-defaults
-(:data:`~google.cloud.spanner_v1.client.DEFAULT_USER_AGENT` and
-:data:`~google.cloud.spanner_v1.client.DEFAULT_TIMEOUT_SECONDS`).
-However, you may over-ride them and these will be used throughout all API
-requests made with the ``client`` you create.
-
Configuration
-------------
@@ -61,18 +50,29 @@ Configuration
Be sure to use the **Project ID**, not the **Project Number**.
-
-Warnings about Multiprocessing
+Using a Cloud Spanner Emulator
------------------------------
-.. warning::
- When using multiprocessing, the application may hang if a
- :class:`Client
` instance is created
- before :class:`multiprocessing.Pool` or :class:`multiprocessing.Process`
- invokes :func:`os.fork`. The issue is under investigation, but may be only
- happening on Macintosh and not Linux. See `GRPC/GRPC#12455
- `_ for
- more information.
+There are two ways to use the client with a Cloud Spanner emulator: programmatically or via an environment variable.
+
+To programmatically use an emulator, you must specify the project, the endpoint of the emulator, and use anonymous credentials:
+
+.. code:: python
+
+ from google.cloud import spanner
+ from google.auth.credentials import AnonymousCredentials
+
+ client = spanner.Client(
+ project='my-project',
+ client_options={"api_endpoint": "0.0.0.0:9010"},
+ credentials=AnonymousCredentials()
+ )
+
+To use an emulator via an environment variable, set the `SPANNER_EMULATOR_HOST` environment variable to the emulator endpoint:
+
+.. code::
+
+ export SPANNER_EMULATOR_HOST=0.0.0.0:9010
Next Step
---------
diff --git a/docs/conf.py b/docs/conf.py
index 4fffc063c8..78e49ed55c 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -1,4 +1,17 @@
# -*- coding: utf-8 -*-
+# Copyright 2024 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
#
# google-cloud-spanner documentation build configuration file
#
@@ -20,12 +33,16 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
sys.path.insert(0, os.path.abspath(".."))
+# For plugins that can not read conf.py.
+# See also: https://github.com/docascode/sphinx-docfx-yaml/issues/85
+sys.path.insert(0, os.path.abspath("."))
+
__version__ = ""
# -- 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
@@ -35,6 +52,7 @@
"sphinx.ext.autosummary",
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
+ "sphinx.ext.doctest",
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
@@ -43,17 +61,13 @@
# autodoc/autosummary flags
autoclass_content = "both"
-autodoc_default_flags = ["members"]
+autodoc_default_options = {"members": True}
autosummary_generate = True
# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]
-# Allow markdown includes (so releases.md can include CHANGLEOG.md)
-# http://www.sphinx-doc.org/en/master/markdown.html
-source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}
-
# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
# source_suffix = ['.rst', '.md']
@@ -62,13 +76,13 @@
# The encoding of source files.
# source_encoding = 'utf-8-sig'
-# The master toctree document.
-master_doc = "index"
+# The root toctree document.
+root_doc = "index"
# General information about the project.
-project = u"google-cloud-spanner"
-copyright = u"2019, Google"
-author = u"Google APIs"
+project = "google-cloud-spanner"
+copyright = "2019, Google"
+author = "Google APIs"
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@@ -94,7 +108,13 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
-exclude_patterns = ["_build"]
+exclude_patterns = [
+ "_build",
+ "**/.nox/**/*",
+ "samples/AUTHORING_GUIDE.md",
+ "samples/CONTRIBUTING.md",
+ "samples/snippets/README.rst",
+]
# The reST default role (used for this markup: `text`) to use for all
# documents.
@@ -260,9 +280,9 @@
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(
- master_doc,
+ root_doc,
"google-cloud-spanner.tex",
- u"google-cloud-spanner Documentation",
+ "google-cloud-spanner Documentation",
author,
"manual",
)
@@ -295,9 +315,9 @@
# (source start file, name, description, authors, manual section).
man_pages = [
(
- master_doc,
+ root_doc,
"google-cloud-spanner",
- u"google-cloud-spanner Documentation",
+ "google-cloud-spanner Documentation",
[author],
1,
)
@@ -314,9 +334,9 @@
# dir menu entry, description, category)
texinfo_documents = [
(
- master_doc,
+ root_doc,
"google-cloud-spanner",
- u"google-cloud-spanner Documentation",
+ "google-cloud-spanner Documentation",
author,
"google-cloud-spanner",
"google-cloud-spanner Library",
@@ -339,10 +359,15 @@
# Example configuration for intersphinx: refer to the Python standard library.
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),
- "grpc": ("https://grpc.io/grpc/python/", None),
+ "python": ("https://python.readthedocs.org/en/latest/", None),
+ "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None),
+ "google.api_core": (
+ "https://googleapis.dev/python/google-api-core/latest/",
+ None,
+ ),
+ "grpc": ("https://grpc.github.io/grpc/python/", None),
+ "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None),
+ "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None),
}
diff --git a/docs/database-usage.rst b/docs/database-usage.rst
index 8989501a7d..afcfa06cb2 100644
--- a/docs/database-usage.rst
+++ b/docs/database-usage.rst
@@ -1,7 +1,7 @@
-Database Admin
-==============
+Database Admin Usage
+====================
-After creating a :class:`~google.cloud.spanner.instance.Instance`, you can
+After creating an :class:`~google.cloud.spanner_v1.instance.Instance`, you can
interact with individual databases for that instance.
@@ -9,30 +9,31 @@ List Databases
--------------
To iterate over all existing databases for an instance, use its
-:meth:`~google.cloud.spanner.instance.Instance.list_databases` method:
+:meth:`~google.cloud.spanner_v1.instance.Instance.list_databases` method:
.. code:: python
for database in instance.list_databases():
# `database` is a `Database` object.
-This method yields :class:`~.spanner_admin_database_v1.types.Database`
+This method yields :class:`~google.cloud.spanner_v1.database.Database`
objects.
Database Factory
----------------
-To create a :class:`~google.cloud.spanner.database.Database` object:
+To create a :class:`~google.cloud.spanner_v1.database.Database` object:
.. code:: python
database = instance.database(database_id, ddl_statements)
-- ``ddl_statements`` is a string containing DDL for the new database.
+- ``ddl_statements`` is a list of strings containing DDL statements for the new database.
-You can also use :meth:`Instance.database` to create a local wrapper for
-a database that has already been created:
+You can also use the :meth:`~google.cloud.spanner_v1.instance.Instance.database` method
+on an :class:`~google.cloud.spanner_v1.instance.Instance` object to create a local wrapper
+for a database that has already been created:
.. code:: python
@@ -43,7 +44,7 @@ Create a new Database
---------------------
After creating the database object, use its
-:meth:`~google.cloud.spanner.database.Database.create` method to
+:meth:`~google.cloud.spanner_v1.database.Database.create` method to
trigger its creation on the server:
.. code:: python
@@ -52,8 +53,8 @@ trigger its creation on the server:
.. note::
- Creating an instance triggers a "long-running operation" and
- returns an :class:`~concurrent.futures.Future`-like object. Use
+ Creating a database triggers a "long-running operation" and
+ returns a :class:`~concurrent.futures.Future`-like object. Use
the :meth:`~concurrent.futures.Future.result` method to wait for
and inspect the result.
@@ -62,21 +63,21 @@ Update an existing Database
---------------------------
After creating the database object, you can apply additional DDL statements
-via its :meth:`~google.cloud.spanner.database.Database.update_ddl` method:
+via its :meth:`~google.cloud.spanner_v1.database.Database.update_ddl` method:
.. code:: python
operation = database.update_ddl(ddl_statements, operation_id)
-- ``ddl_statements`` is a string containing DDL to be applied to
- the database.
+- ``ddl_statements`` is a list of strings containing DDL statements to be
+ applied to the database.
- ``operation_id`` is a string ID for the long-running operation.
.. note::
- Update an instance triggers a "long-running operation" and
- returns a :class:`google.cloud.spanner.database.Operation`
+ Updating a database triggers a "long-running operation" and
+ returns an :class:`~google.cloud.spanner_v1.database.Operation`
object. See :ref:`check-on-current-database-operation` for polling
to find out if the operation is completed.
@@ -85,7 +86,7 @@ Drop a Database
---------------
Drop a database using its
-:meth:`~google.cloud.spanner.database.Database.drop` method:
+:meth:`~google.cloud.spanner_v1.database.Database.drop` method:
.. code:: python
@@ -97,14 +98,15 @@ Drop a database using its
Check on Current Database Operation
-----------------------------------
-The :meth:`~google.cloud.spanner.database.Database.create` and
-:meth:`~google.cloud.spanner.database.Database.update` methods of instance
-object trigger long-running operations on the server, and return instances
+The :meth:`~google.cloud.spanner_v1.database.Database.create` and
+:meth:`~google.cloud.spanner_v1.database.Database.update_ddl` methods of the
+:class:`~google.cloud.spanner_v1.database.Database` object trigger
+long-running operations on the server, and return operations
conforming to the :class:`~.concurrent.futures.Future` class.
.. code:: python
- >>> operation = instance.create()
+ >>> operation = database.create()
>>> operation.result()
@@ -116,7 +118,7 @@ Use a Snapshot to Read / Query the Database
A snapshot represents a read-only point-in-time view of the database.
-Calling :meth:`~google.cloud.spanner.database.Database.snapshot` with
+Calling :meth:`~google.cloud.spanner_v1.database.Database.snapshot` with
no arguments creates a snapshot with strong concurrency:
.. code:: python
@@ -124,16 +126,17 @@ no arguments creates a snapshot with strong concurrency:
with database.snapshot() as snapshot:
do_something_with(snapshot)
-See :class:`~google.cloud.spanner.snapshot.Snapshot` for the other options
+See :class:`~google.cloud.spanner_v1.snapshot.Snapshot` for the other options
which can be passed.
.. note::
- :meth:`~google.cloud.spanner.database.Database.snapshot` returns an
+ :meth:`~google.cloud.spanner_v1.database.Database.snapshot` returns an
object intended to be used as a Python context manager (i.e., as the
- target of a ``with`` statement). Use the instance, and any result
- sets returned by its ``read`` or ``execute_sql`` methods, only inside
- the block created by the ``with`` statement.
+ target of a ``with`` statement). Perform all iterations within the
+ context of the ``with database.snapshot()`` block.
+
+
See :doc:`snapshot-usage` for more complete examples of snapshot usage.
@@ -151,7 +154,7 @@ on the rows of tables in the database.
.. note::
- :meth:`~google.cloud.spanner.database.Database.batch` returns an
+ :meth:`~google.cloud.spanner_v1.database.Database.batch` returns an
object intended to be used as a Python context manager (i.e., as the
target of a ``with`` statement). It applies any changes made inside
the block of its ``with`` statement when exiting the block, unless an
@@ -187,15 +190,15 @@ transaction as a required argument:
.. note::
- :meth:`~google.cloud.spanner.database.Database.run_in_transaction`
+ :meth:`~google.cloud.spanner_v1.database.Database.run_in_transaction`
commits the transaction automatically if the "unit of work" function
returns without raising an exception.
.. note::
- :meth:`~google.cloud.spanner.database.Database.run_in_transaction`
- retries the "unit of work" function if the read / query operatoins
- or the commit are aborted due to concurrent updates
+ :meth:`~google.cloud.spanner_v1.database.Database.run_in_transaction`
+ retries the "unit of work" function if the read / query operations
+ or the commit are aborted due to concurrent updates.
See :doc:`transaction-usage` for more complete examples of transaction usage.
@@ -203,10 +206,10 @@ Configuring a session pool for a database
-----------------------------------------
Under the covers, the ``snapshot``, ``batch``, and ``run_in_transaction``
-methods use a pool of :class:`~google.cloud.spanner.session.Session` objects
+methods use a pool of :class:`~google.cloud.spanner_v1.session.Session` objects
to manage their communication with the back-end. You can configure
one of the pools manually to control the number of sessions, timeouts, etc.,
-and then passing it to the :class:`~google.cloud.spanner.database.Database`
+and then pass it to the :class:`~google.cloud.spanner_v1.database.Database`
constructor:
.. code-block:: python
@@ -221,12 +224,12 @@ constructor:
pool = spanner.FixedSizePool(size=10, default_timeout=5)
database = instance.database(DATABASE_NAME, pool=pool)
-Note that creating a database with a pool may presume that its database
-already exists, as it may need to pre-create sessions (rather than creating
-them on demand, as the default implementation does).
+Note that creating a database with a pool will require the database to
+already exist if the pool implementation needs to pre-create sessions
+(rather than creating them on demand, as the default implementation does).
You can supply your own pool implementation, which must satisfy the
-contract laid out in :class:`~google.cloud.spanner.pool.AbstractSessionPool`:
+contract laid out in :class:`~google.cloud.spanner_v1.pool.AbstractSessionPool`:
.. code-block:: python
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/index.rst b/docs/index.rst
index 729f42d0e0..0de0483409 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1,26 +1,51 @@
.. include:: README.rst
+.. include:: multiprocessing.rst
+
Usage Documentation
-------------------
.. toctree::
- :maxdepth: 1
- :titlesonly:
+ :maxdepth: 2
client-usage
- instance-usage
- database-usage
+ table-usage
batch-usage
snapshot-usage
transaction-usage
+ database-usage
+ instance-usage
+
API Documentation
-----------------
.. toctree::
:maxdepth: 1
:titlesonly:
- api-reference
advanced-session-pool-topics
+ opentelemetry-tracing
+
+ spanner_v1/client
+ spanner_v1/instance
+ spanner_v1/database
+ spanner_v1/table
+ spanner_v1/session
+ spanner_v1/keyset
+ spanner_v1/snapshot
+ spanner_v1/batch
+ spanner_v1/transaction
+ spanner_v1/streamed
+
+ spanner_v1/services_
+ spanner_v1/types_
+ spanner_admin_database_v1/services_
+ spanner_admin_database_v1/types_
+ spanner_admin_database_v1/database_admin
+ spanner_admin_instance_v1/services_
+ spanner_admin_instance_v1/types_
+ spanner_admin_instance_v1/instance_admin
+
+
Changelog
---------
@@ -31,3 +56,8 @@ For a list of all ``google-cloud-spanner`` releases:
:maxdepth: 2
changelog
+
+.. toctree::
+ :hidden:
+
+ summary_overview.md
diff --git a/docs/instance-usage.rst b/docs/instance-usage.rst
index 909e36b93f..b45b69acc6 100644
--- a/docs/instance-usage.rst
+++ b/docs/instance-usage.rst
@@ -1,7 +1,7 @@
-Instance Admin
-==============
+Instance Admin Usage
+====================
-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/multiprocessing.rst b/docs/multiprocessing.rst
new file mode 100644
index 0000000000..536d17b2ea
--- /dev/null
+++ b/docs/multiprocessing.rst
@@ -0,0 +1,7 @@
+.. note::
+
+ Because this client uses :mod:`grpc` library, it is safe to
+ share instances across threads. In multiprocessing scenarios, the best
+ practice is to create client instances *after* the invocation of
+ :func:`os.fork` by :class:`multiprocessing.pool.Pool` or
+ :class:`multiprocessing.Process`.
diff --git a/docs/opentelemetry-tracing.rst b/docs/opentelemetry-tracing.rst
new file mode 100644
index 0000000000..c581d2cb87
--- /dev/null
+++ b/docs/opentelemetry-tracing.rst
@@ -0,0 +1,96 @@
+Tracing with OpenTelemetry
+==========================
+
+This library uses `OpenTelemetry `_ to automatically generate traces providing insight on calls to Cloud Spanner.
+For information on the benefits and utility of tracing, see the `Cloud Trace docs `_.
+
+To take advantage of these traces, we first need to install OpenTelemetry:
+
+.. code-block:: sh
+
+ pip install opentelemetry-api opentelemetry-sdk
+ pip install opentelemetry-exporter-gcp-trace
+
+We also need to tell OpenTelemetry which exporter to use. To export Spanner traces to `Cloud Tracing `_, add the following lines to your application:
+
+.. code:: python
+
+ from opentelemetry import trace
+ from opentelemetry.sdk.trace import TracerProvider
+ from opentelemetry.sdk.trace.sampling import TraceIdRatioBased
+ from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
+ # BatchSpanProcessor exports spans to Cloud Trace
+ # in a seperate thread to not block on the main thread
+ from opentelemetry.sdk.trace.export import BatchSpanProcessor
+
+ # Create and export one trace every 1000 requests
+ sampler = TraceIdRatioBased(1/1000)
+ tracer_provider = TracerProvider(sampler=sampler)
+ tracer_provider.add_span_processor(
+ # Initialize the cloud tracing exporter
+ BatchSpanProcessor(CloudTraceSpanExporter())
+ )
+ observability_options = dict(
+ tracer_provider=tracer_provider,
+
+ # By default extended_tracing is set to True due
+ # to legacy reasons to avoid breaking changes, you
+ # can modify it though using the environment variable
+ # SPANNER_ENABLE_EXTENDED_TRACING=false.
+ enable_extended_tracing=False,
+
+ # By default end to end tracing is set to False. Set to True
+ # for getting spans for Spanner server.
+ enable_end_to_end_tracing=True,
+ )
+ spanner = spanner.NewClient(project_id, observability_options=observability_options)
+
+
+To get more fine-grained traces from gRPC, you can enable the gRPC instrumentation by the following
+
+.. code-block:: sh
+
+ pip install opentelemetry-instrumentation opentelemetry-instrumentation-grpc
+
+and then in your Python code, please add the following lines:
+
+.. code:: python
+
+ from opentelemetry.instrumentation.grpc import GrpcInstrumentorClient
+ grpc_client_instrumentor = GrpcInstrumentorClient()
+ grpc_client_instrumentor.instrument()
+
+
+Generated spanner traces should now be available on `Cloud Trace `_.
+
+Tracing is most effective when many libraries are instrumented to provide insight over the entire lifespan of a request.
+For a list of libraries that can be instrumented, see the `OpenTelemetry Integrations` section of the `OpenTelemetry Python docs `_
+
+Annotating spans with SQL
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+By default your spans will be annotated with SQL statements where appropriate, but that can be a PII (Personally Identifiable Information)
+leak. Sadly due to legacy behavior, we cannot simply turn off this behavior by default. However you can control this behavior by setting
+
+ SPANNER_ENABLE_EXTENDED_TRACING=false
+
+to turn it off globally or when creating each SpannerClient, please set `observability_options.enable_extended_tracing=false`
+
+End to end tracing
+~~~~~~~~~~~~~~~~~~~~~~~~~
+
+In addition to client-side tracing, you can opt in for end-to-end tracing. End-to-end tracing helps you understand and debug latency issues that are specific to Spanner. Refer [here](https://cloud.google.com/spanner/docs/tracing-overview) for more information.
+
+To configure end-to-end tracing.
+
+1. Opt in for end-to-end tracing. You can opt-in by either:
+* Setting the environment variable `SPANNER_ENABLE_END_TO_END_TRACING=true` before your application is started
+* In code, by setting `observability_options.enable_end_to_end_tracing=true` when creating each SpannerClient.
+
+2. Set the trace context propagation in OpenTelemetry.
+
+.. code:: python
+
+ from opentelemetry.propagate import set_global_textmap
+ from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
+ set_global_textmap(TraceContextTextMapPropagator())
\ No newline at end of file
diff --git a/docs/snapshot-usage.rst b/docs/snapshot-usage.rst
index 4c5a5b2420..0f00686a54 100644
--- a/docs/snapshot-usage.rst
+++ b/docs/snapshot-usage.rst
@@ -1,8 +1,8 @@
Read-only Transactions via Snapshots
####################################
-A :class:`~google.cloud.spanner.snapshot.Snapshot` represents a read-only
-transaction: when multiple read operations are peformed via a Snapshot,
+A :class:`~google.cloud.spanner_v1.snapshot.Snapshot` represents a read-only
+transaction: when multiple read operations are performed via a Snapshot,
the results are consistent as of a particular point in time.
@@ -15,7 +15,8 @@ transactions are visible:
.. code:: python
- snapshot = database.snapshot()
+ with database.snapshot() as snapshot:
+ ...
You can also specify a weaker bound, which can either be to perform all
reads as of a given timestamp:
@@ -23,9 +24,10 @@ reads as of a given timestamp:
.. code:: python
import datetime
- from pytz import UTC
- TIMESTAMP = datetime.datetime.utcnow().replace(tzinfo=UTC)
- snapshot = database.snapshot(read_timestamp=TIMESTAMP)
+ TIMESTAMP = datetime.datetime.utcnow().replace(tzinfo=datetime.timezone.utc)
+
+ with database.snapshot(read_timestamp=TIMESTAMP) as snapshot:
+ ...
or as of a given duration in the past:
@@ -33,7 +35,9 @@ or as of a given duration in the past:
import datetime
DURATION = datetime.timedelta(seconds=5)
- snapshot = database.snapshot(exact_staleness=DURATION)
+
+ with database.snapshot(exact_staleness=DURATION) as snapshot:
+ ...
Single Use and Multiple Use Snapshots
-------------------------------------
@@ -48,41 +52,43 @@ reused.
.. code:: python
- snapshot = database.snapshot(multi_use=True)
+ with database.snapshot(multi_use=True) as snapshot:
+ ...
-:meth:`~.spanner_v1.snapshot.Snapshot.begin` can only be used on a
+:meth:`~google.cloud.spanner_v1.snapshot.Snapshot.begin` can only be used on a
snapshot with ``multi_use=True``. In which case it is also necessary
to call if you need to have multiple pending operations.
Read Table Data
---------------
-Read data for selected rows from a table in the database. Calls
-the ``Read`` API, which returns all rows specified in ``key_set``, or else
-fails if the result set is too large,
+To read data for selected rows from a table in the database, call
+:meth:`~google.cloud.spanner_v1.snapshot.Snapshot.read` which will return
+all rows specified in ``keyset``, or fail if the result set is too large,
.. code:: python
with database.snapshot() as snapshot:
result = snapshot.read(
table='table-name', columns=['first_name', 'last_name', 'age'],
- key_set=['phred@example.com', 'bharney@example.com'])
+ keyset=spanner.KeySet([['phred@example.com'], ['bharney@example.com']]))
- for row in result.rows:
+ for row in result:
print(row)
.. note::
- Perform all iteration within the context of the ``with database.snapshot()``
+ Perform all iterations within the context of the ``with database.snapshot()``
block.
Execute a SQL Select Statement
------------------------------
-Read data from a query against tables in the database. Calls
-the ``ExecuteSql`` API, which returns all rows matching the query, or else
-fails if the result set is too large,
+To read data from tables in the database using a query, call
+:meth:`~google.cloud.spanner_v1.snapshot.Snapshot.execute_sql`
+which will return all rows matching the query, or fail if the
+result set is too large,
.. code:: python
@@ -93,7 +99,7 @@ fails if the result set is too large,
'WHERE p.employee_id == e.employee_id')
result = snapshot.execute_sql(QUERY)
- for row in list(result):
+ for row in result:
print(row)
.. note::
diff --git a/docs/spanner_admin_database_v1/database_admin.rst b/docs/spanner_admin_database_v1/database_admin.rst
new file mode 100644
index 0000000000..bd6aab00e4
--- /dev/null
+++ b/docs/spanner_admin_database_v1/database_admin.rst
@@ -0,0 +1,10 @@
+DatabaseAdmin
+-------------------------------
+
+.. automodule:: google.cloud.spanner_admin_database_v1.services.database_admin
+ :members:
+ :inherited-members:
+
+.. automodule:: google.cloud.spanner_admin_database_v1.services.database_admin.pagers
+ :members:
+ :inherited-members:
diff --git a/docs/spanner_admin_database_v1/services_.rst b/docs/spanner_admin_database_v1/services_.rst
new file mode 100644
index 0000000000..55e57d8dc0
--- /dev/null
+++ b/docs/spanner_admin_database_v1/services_.rst
@@ -0,0 +1,6 @@
+Services for Google Cloud Spanner Admin Database v1 API
+=======================================================
+.. toctree::
+ :maxdepth: 2
+
+ database_admin
diff --git a/docs/spanner_admin_database_v1/types_.rst b/docs/spanner_admin_database_v1/types_.rst
new file mode 100644
index 0000000000..fe6c27778b
--- /dev/null
+++ b/docs/spanner_admin_database_v1/types_.rst
@@ -0,0 +1,6 @@
+Types for Google Cloud Spanner Admin Database v1 API
+====================================================
+
+.. automodule:: google.cloud.spanner_admin_database_v1.types
+ :members:
+ :show-inheritance:
diff --git a/docs/spanner_admin_instance_v1/instance_admin.rst b/docs/spanner_admin_instance_v1/instance_admin.rst
new file mode 100644
index 0000000000..fe820b3fad
--- /dev/null
+++ b/docs/spanner_admin_instance_v1/instance_admin.rst
@@ -0,0 +1,10 @@
+InstanceAdmin
+-------------------------------
+
+.. automodule:: google.cloud.spanner_admin_instance_v1.services.instance_admin
+ :members:
+ :inherited-members:
+
+.. automodule:: google.cloud.spanner_admin_instance_v1.services.instance_admin.pagers
+ :members:
+ :inherited-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..407d44cc34
--- /dev/null
+++ b/docs/spanner_admin_instance_v1/services_.rst
@@ -0,0 +1,6 @@
+Services for Google Cloud Spanner Admin Instance v1 API
+=======================================================
+.. toctree::
+ :maxdepth: 2
+
+ instance_admin
diff --git a/docs/spanner_admin_instance_v1/types_.rst b/docs/spanner_admin_instance_v1/types_.rst
new file mode 100644
index 0000000000..250cf6bf9b
--- /dev/null
+++ b/docs/spanner_admin_instance_v1/types_.rst
@@ -0,0 +1,6 @@
+Types for Google Cloud Spanner Admin Instance v1 API
+====================================================
+
+.. automodule:: google.cloud.spanner_admin_instance_v1.types
+ :members:
+ :show-inheritance:
diff --git a/docs/batch-api.rst b/docs/spanner_v1/batch.rst
similarity index 100%
rename from docs/batch-api.rst
rename to docs/spanner_v1/batch.rst
diff --git a/docs/client-api.rst b/docs/spanner_v1/client.rst
similarity index 100%
rename from docs/client-api.rst
rename to docs/spanner_v1/client.rst
diff --git a/docs/database-api.rst b/docs/spanner_v1/database.rst
similarity index 100%
rename from docs/database-api.rst
rename to docs/spanner_v1/database.rst
diff --git a/docs/instance-api.rst b/docs/spanner_v1/instance.rst
similarity index 100%
rename from docs/instance-api.rst
rename to docs/spanner_v1/instance.rst
diff --git a/docs/keyset-api.rst b/docs/spanner_v1/keyset.rst
similarity index 100%
rename from docs/keyset-api.rst
rename to docs/spanner_v1/keyset.rst
diff --git a/docs/spanner_v1/services_.rst b/docs/spanner_v1/services_.rst
new file mode 100644
index 0000000000..3bbbb55f79
--- /dev/null
+++ b/docs/spanner_v1/services_.rst
@@ -0,0 +1,6 @@
+Services for Google Cloud Spanner v1 API
+========================================
+.. toctree::
+ :maxdepth: 2
+
+ spanner
diff --git a/docs/session-api.rst b/docs/spanner_v1/session.rst
similarity index 100%
rename from docs/session-api.rst
rename to docs/spanner_v1/session.rst
diff --git a/docs/snapshot-api.rst b/docs/spanner_v1/snapshot.rst
similarity index 100%
rename from docs/snapshot-api.rst
rename to docs/spanner_v1/snapshot.rst
diff --git a/docs/spanner_v1/spanner.rst b/docs/spanner_v1/spanner.rst
new file mode 100644
index 0000000000..b51f4447e4
--- /dev/null
+++ b/docs/spanner_v1/spanner.rst
@@ -0,0 +1,10 @@
+Spanner
+-------------------------
+
+.. automodule:: google.cloud.spanner_v1.services.spanner
+ :members:
+ :inherited-members:
+
+.. automodule:: google.cloud.spanner_v1.services.spanner.pagers
+ :members:
+ :inherited-members:
diff --git a/docs/streamed-api.rst b/docs/spanner_v1/streamed.rst
similarity index 100%
rename from docs/streamed-api.rst
rename to docs/spanner_v1/streamed.rst
diff --git a/docs/spanner_v1/table.rst b/docs/spanner_v1/table.rst
new file mode 100644
index 0000000000..86b81dc86e
--- /dev/null
+++ b/docs/spanner_v1/table.rst
@@ -0,0 +1,6 @@
+Table API
+=========
+
+.. automodule:: google.cloud.spanner_v1.table
+ :members:
+ :show-inheritance:
diff --git a/docs/transaction-api.rst b/docs/spanner_v1/transaction.rst
similarity index 100%
rename from docs/transaction-api.rst
rename to docs/spanner_v1/transaction.rst
diff --git a/docs/spanner_v1/types_.rst b/docs/spanner_v1/types_.rst
new file mode 100644
index 0000000000..c7ff7e6c71
--- /dev/null
+++ b/docs/spanner_v1/types_.rst
@@ -0,0 +1,6 @@
+Types for Google Cloud Spanner v1 API
+=====================================
+
+.. automodule:: google.cloud.spanner_v1.types
+ :members:
+ :show-inheritance:
diff --git a/docs/summary_overview.md b/docs/summary_overview.md
new file mode 100644
index 0000000000..ffaf71df07
--- /dev/null
+++ b/docs/summary_overview.md
@@ -0,0 +1,22 @@
+[
+This is a templated file. Adding content to this file may result in it being
+reverted. Instead, if you want to place additional content, create an
+"overview_content.md" file in `docs/` directory. The Sphinx tool will
+pick up on the content and merge the content.
+]: #
+
+# Cloud Spanner API
+
+Overview of the APIs available for Cloud Spanner API.
+
+## All entries
+
+Classes, methods and properties & attributes for
+Cloud Spanner API.
+
+[classes](https://cloud.google.com/python/docs/reference/spanner/latest/summary_class.html)
+
+[methods](https://cloud.google.com/python/docs/reference/spanner/latest/summary_method.html)
+
+[properties and
+attributes](https://cloud.google.com/python/docs/reference/spanner/latest/summary_property.html)
diff --git a/docs/table-usage.rst b/docs/table-usage.rst
new file mode 100644
index 0000000000..01459b5f8e
--- /dev/null
+++ b/docs/table-usage.rst
@@ -0,0 +1,47 @@
+Table Admin Usage
+=================
+
+After creating an :class:`~google.cloud.spanner_v1.database.Database`, you can
+interact with individual tables for that instance.
+
+
+List Tables
+-----------
+
+To iterate over all existing tables for an database, use its
+:meth:`~google.cloud.spanner_v1.database.Database.list_tables` method:
+
+.. code:: python
+
+ for table in database.list_tables():
+ # `table` is a `Table` object.
+
+This method yields :class:`~google.cloud.spanner_v1.table.Table` objects.
+
+
+Table Factory
+-------------
+
+A :class:`~google.cloud.spanner_v1.table.Table` object can be created with the
+:meth:`~google.cloud.spanner_v1.database.Database.table` factory method:
+
+.. code:: python
+
+ table = database.table("my_table_id")
+ if table.exists():
+ print("Table with ID 'my_table' exists.")
+ else:
+ print("Table with ID 'my_table' does not exist."
+
+
+Getting the Table Schema
+------------------------
+
+Use the :attr:`~google.cloud.spanner_v1.table.Table.schema` property to inspect
+the columns of a table as a list of
+:class:`~google.cloud.spanner_v1.types.StructType.Field` objects.
+
+.. code:: python
+
+ for field in table.schema
+ # `field` is a `Field` object.
diff --git a/docs/transaction-usage.rst b/docs/transaction-usage.rst
index e475894939..78026bf5a4 100644
--- a/docs/transaction-usage.rst
+++ b/docs/transaction-usage.rst
@@ -1,11 +1,12 @@
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 `_.
To learn more about how to use them in the Python client, continue reading.
@@ -90,8 +91,8 @@ any of the records already exists.
Update records using a Transaction
----------------------------------
-:meth:`Transaction.update` updates one or more existing records in a table. Fails
-if any of the records does not already exist.
+:meth:`Transaction.update` updates one or more existing records in a table.
+Fails if any of the records does not already exist.
.. code:: python
@@ -178,9 +179,9 @@ Using :meth:`~Database.run_in_transaction`
Rather than calling :meth:`~Transaction.commit` or :meth:`~Transaction.rollback`
manually, you should use :meth:`~Database.run_in_transaction` to run the
-function that you need. The transaction's :meth:`~Transaction.commit` method
+function that you need. The transaction's :meth:`~Transaction.commit` method
will be called automatically if the ``with`` block exits without raising an
-exception. The function will automatically be retried for
+exception. The function will automatically be retried for
:class:`~google.api_core.exceptions.Aborted` errors, but will raise on
:class:`~google.api_core.exceptions.GoogleAPICallError` and
:meth:`~Transaction.rollback` will be called on all others.
@@ -188,25 +189,30 @@ exception. The function will automatically be retried for
.. code:: python
def _unit_of_work(transaction):
-
transaction.insert(
- 'citizens', columns=['email', 'first_name', 'last_name', 'age'],
+ 'citizens',
+ columns=['email', 'first_name', 'last_name', 'age'],
values=[
['phred@exammple.com', 'Phred', 'Phlyntstone', 32],
['bharney@example.com', 'Bharney', 'Rhubble', 31],
- ])
+ ]
+ )
transaction.update(
- 'citizens', columns=['email', 'age'],
+ 'citizens',
+ columns=['email', 'age'],
values=[
['phred@exammple.com', 33],
['bharney@example.com', 32],
- ])
+ ]
+ )
...
- transaction.delete('citizens',
- keyset['bharney@example.com', 'nonesuch@example.com'])
+ transaction.delete(
+ 'citizens',
+ keyset=['bharney@example.com', 'nonesuch@example.com']
+ )
db.run_in_transaction(_unit_of_work)
@@ -242,7 +248,7 @@ If an exception is raised inside the ``with`` block, the transaction's
...
transaction.delete('citizens',
- keyset['bharney@example.com', 'nonesuch@example.com'])
+ keyset=['bharney@example.com', 'nonesuch@example.com'])
Begin a Transaction
diff --git a/examples/grpc_instrumentation_enabled.py b/examples/grpc_instrumentation_enabled.py
new file mode 100644
index 0000000000..c8bccd0a9d
--- /dev/null
+++ b/examples/grpc_instrumentation_enabled.py
@@ -0,0 +1,73 @@
+# -*- coding: utf-8 -*-
+# Copyright 2024 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+import os
+import time
+
+import google.cloud.spanner as spanner
+from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
+from opentelemetry.sdk.trace import TracerProvider
+from opentelemetry.sdk.trace.export import BatchSpanProcessor
+from opentelemetry.sdk.trace.sampling import ALWAYS_ON
+from opentelemetry import trace
+
+# Enable the gRPC instrumentation if you'd like more introspection.
+from opentelemetry.instrumentation.grpc import GrpcInstrumentorClient
+
+grpc_client_instrumentor = GrpcInstrumentorClient()
+grpc_client_instrumentor.instrument()
+
+
+def main():
+ # Setup common variables that'll be used between Spanner and traces.
+ project_id = os.environ.get('SPANNER_PROJECT_ID', 'test-project')
+
+ # Setup OpenTelemetry, trace and Cloud Trace exporter.
+ tracer_provider = TracerProvider(sampler=ALWAYS_ON)
+ trace_exporter = CloudTraceSpanExporter(project_id=project_id)
+ tracer_provider.add_span_processor(BatchSpanProcessor(trace_exporter))
+ trace.set_tracer_provider(tracer_provider)
+ # Retrieve a tracer from the global tracer provider.
+ tracer = tracer_provider.get_tracer('MyApp')
+
+ # Setup the Cloud Spanner Client.
+ spanner_client = spanner.Client(project_id)
+
+ instance = spanner_client.instance('test-instance')
+ database = instance.database('test-db')
+
+ # Now run our queries
+ with tracer.start_as_current_span('QueryInformationSchema'):
+ with database.snapshot() as snapshot:
+ with tracer.start_as_current_span('InformationSchema'):
+ info_schema = snapshot.execute_sql(
+ 'SELECT * FROM INFORMATION_SCHEMA.TABLES')
+ for row in info_schema:
+ print(row)
+
+ with tracer.start_as_current_span('ServerTimeQuery'):
+ with database.snapshot() as snapshot:
+ # Purposefully issue a bad SQL statement to examine exceptions
+ # that get recorded and a ERROR span status.
+ try:
+ data = snapshot.execute_sql('SELECT CURRENT_TIMESTAMPx()')
+ for row in data:
+ print(row)
+ except Exception as e:
+ pass
+
+
+if __name__ == '__main__':
+ main()
diff --git a/examples/trace.py b/examples/trace.py
new file mode 100644
index 0000000000..5b826ca5ad
--- /dev/null
+++ b/examples/trace.py
@@ -0,0 +1,104 @@
+# -*- coding: utf-8 -*-
+# Copyright 2024 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License
+
+import os
+import time
+
+import google.cloud.spanner as spanner
+from opentelemetry.exporter.cloud_trace import CloudTraceSpanExporter
+from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import OTLPSpanExporter
+from opentelemetry.sdk.trace import TracerProvider
+from opentelemetry.sdk.trace.export import BatchSpanProcessor
+from opentelemetry.sdk.trace.sampling import ALWAYS_ON
+from opentelemetry import trace
+from opentelemetry.propagate import set_global_textmap
+from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator
+
+# Setup common variables that'll be used between Spanner and traces.
+project_id = os.environ.get('SPANNER_PROJECT_ID', 'test-project')
+
+def spanner_with_cloud_trace():
+ # [START spanner_opentelemetry_traces_cloudtrace_usage]
+ # Setup OpenTelemetry, trace and Cloud Trace exporter.
+ tracer_provider = TracerProvider(sampler=ALWAYS_ON)
+ trace_exporter = CloudTraceSpanExporter(project_id=project_id)
+ tracer_provider.add_span_processor(BatchSpanProcessor(trace_exporter))
+
+ # Setup the Cloud Spanner Client.
+ spanner_client = spanner.Client(
+ project_id,
+ observability_options=dict(tracer_provider=tracer_provider, enable_extended_tracing=True, enable_end_to_end_tracing=True),
+ )
+
+ # [END spanner_opentelemetry_traces_cloudtrace_usage]
+ return spanner_client
+
+def spanner_with_otlp():
+ # [START spanner_opentelemetry_traces_otlp_usage]
+ # Setup OpenTelemetry, trace and OTLP exporter.
+ tracer_provider = TracerProvider(sampler=ALWAYS_ON)
+ otlp_exporter = OTLPSpanExporter(endpoint="http://localhost:4317")
+ tracer_provider.add_span_processor(BatchSpanProcessor(otlp_exporter))
+
+ # Setup the Cloud Spanner Client.
+ spanner_client = spanner.Client(
+ project_id,
+ observability_options=dict(tracer_provider=tracer_provider, enable_extended_tracing=True, enable_end_to_end_tracing=True),
+ )
+ # [END spanner_opentelemetry_traces_otlp_usage]
+ return spanner_client
+
+
+def main():
+ # Setup OpenTelemetry, trace and Cloud Trace exporter.
+ tracer_provider = TracerProvider(sampler=ALWAYS_ON)
+ trace_exporter = CloudTraceSpanExporter(project_id=project_id)
+ tracer_provider.add_span_processor(BatchSpanProcessor(trace_exporter))
+
+ # Setup the Cloud Spanner Client.
+ # Change to "spanner_client = spanner_with_otlp" to use OTLP exporter
+ spanner_client = spanner_with_cloud_trace()
+ instance = spanner_client.instance('test-instance')
+ database = instance.database('test-db')
+
+ # Set W3C Trace Context as the global propagator for end to end tracing.
+ set_global_textmap(TraceContextTextMapPropagator())
+
+ # Retrieve a tracer from our custom tracer provider.
+ tracer = tracer_provider.get_tracer('MyApp')
+
+ # Now run our queries
+ with tracer.start_as_current_span('QueryInformationSchema'):
+ with database.snapshot() as snapshot:
+ with tracer.start_as_current_span('InformationSchema'):
+ info_schema = snapshot.execute_sql(
+ 'SELECT * FROM INFORMATION_SCHEMA.TABLES')
+ for row in info_schema:
+ print(row)
+
+ with tracer.start_as_current_span('ServerTimeQuery'):
+ with database.snapshot() as snapshot:
+ # Purposefully issue a bad SQL statement to examine exceptions
+ # that get recorded and a ERROR span status.
+ try:
+ data = snapshot.execute_sql('SELECT CURRENT_TIMESTAMPx()')
+ for row in data:
+ print(row)
+ except Exception as e:
+ print(e)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/google/__init__.py b/google/__init__.py
deleted file mode 100644
index 2f4b4738ae..0000000000
--- a/google/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-try:
- import pkg_resources
-
- pkg_resources.declare_namespace(__name__)
-except ImportError:
- import pkgutil
-
- __path__ = pkgutil.extend_path(__path__, __name__)
diff --git a/google/cloud/__init__.py b/google/cloud/__init__.py
deleted file mode 100644
index 2f4b4738ae..0000000000
--- a/google/cloud/__init__.py
+++ /dev/null
@@ -1,8 +0,0 @@
-try:
- import pkg_resources
-
- pkg_resources.declare_namespace(__name__)
-except ImportError:
- import pkgutil
-
- __path__ = pkgutil.extend_path(__path__, __name__)
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..d7fddf0236 100644
--- a/google/cloud/spanner_admin_database_v1/__init__.py
+++ b/google/cloud/spanner_admin_database_v1/__init__.py
@@ -1,29 +1,150 @@
# -*- coding: utf-8 -*-
-#
-# Copyright 2018 Google LLC
+# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
-# 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 google.cloud.spanner_admin_database_v1 import gapic_version as package_version
-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
+__version__ = package_version.__version__
-class DatabaseAdminClient(database_admin_client.DatabaseAdminClient):
- __doc__ = database_admin_client.DatabaseAdminClient.__doc__
- enums = enums
+from .services.database_admin import DatabaseAdminClient
+from .services.database_admin import DatabaseAdminAsyncClient
+from .types.backup import Backup
+from .types.backup import BackupInfo
+from .types.backup import BackupInstancePartition
+from .types.backup import CopyBackupEncryptionConfig
+from .types.backup import CopyBackupMetadata
+from .types.backup import CopyBackupRequest
+from .types.backup import CreateBackupEncryptionConfig
+from .types.backup import CreateBackupMetadata
+from .types.backup import CreateBackupRequest
+from .types.backup import DeleteBackupRequest
+from .types.backup import FullBackupSpec
+from .types.backup import GetBackupRequest
+from .types.backup import IncrementalBackupSpec
+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.backup_schedule import BackupSchedule
+from .types.backup_schedule import BackupScheduleSpec
+from .types.backup_schedule import CreateBackupScheduleRequest
+from .types.backup_schedule import CrontabSpec
+from .types.backup_schedule import DeleteBackupScheduleRequest
+from .types.backup_schedule import GetBackupScheduleRequest
+from .types.backup_schedule import ListBackupSchedulesRequest
+from .types.backup_schedule import ListBackupSchedulesResponse
+from .types.backup_schedule import UpdateBackupScheduleRequest
+from .types.common import EncryptionConfig
+from .types.common import EncryptionInfo
+from .types.common import OperationProgress
+from .types.common import DatabaseDialect
+from .types.spanner_database_admin import AddSplitPointsRequest
+from .types.spanner_database_admin import AddSplitPointsResponse
+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 DatabaseRole
+from .types.spanner_database_admin import DdlStatementActionInfo
+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 InternalUpdateGraphOperationRequest
+from .types.spanner_database_admin import InternalUpdateGraphOperationResponse
+from .types.spanner_database_admin import ListDatabaseOperationsRequest
+from .types.spanner_database_admin import ListDatabaseOperationsResponse
+from .types.spanner_database_admin import ListDatabaseRolesRequest
+from .types.spanner_database_admin import ListDatabaseRolesResponse
+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 RestoreDatabaseEncryptionConfig
+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 SplitPoints
+from .types.spanner_database_admin import UpdateDatabaseDdlMetadata
+from .types.spanner_database_admin import UpdateDatabaseDdlRequest
+from .types.spanner_database_admin import UpdateDatabaseMetadata
+from .types.spanner_database_admin import UpdateDatabaseRequest
+from .types.spanner_database_admin import RestoreSourceType
-__all__ = ("enums", "types", "DatabaseAdminClient")
+__all__ = (
+ "DatabaseAdminAsyncClient",
+ "AddSplitPointsRequest",
+ "AddSplitPointsResponse",
+ "Backup",
+ "BackupInfo",
+ "BackupInstancePartition",
+ "BackupSchedule",
+ "BackupScheduleSpec",
+ "CopyBackupEncryptionConfig",
+ "CopyBackupMetadata",
+ "CopyBackupRequest",
+ "CreateBackupEncryptionConfig",
+ "CreateBackupMetadata",
+ "CreateBackupRequest",
+ "CreateBackupScheduleRequest",
+ "CreateDatabaseMetadata",
+ "CreateDatabaseRequest",
+ "CrontabSpec",
+ "Database",
+ "DatabaseAdminClient",
+ "DatabaseDialect",
+ "DatabaseRole",
+ "DdlStatementActionInfo",
+ "DeleteBackupRequest",
+ "DeleteBackupScheduleRequest",
+ "DropDatabaseRequest",
+ "EncryptionConfig",
+ "EncryptionInfo",
+ "FullBackupSpec",
+ "GetBackupRequest",
+ "GetBackupScheduleRequest",
+ "GetDatabaseDdlRequest",
+ "GetDatabaseDdlResponse",
+ "GetDatabaseRequest",
+ "IncrementalBackupSpec",
+ "InternalUpdateGraphOperationRequest",
+ "InternalUpdateGraphOperationResponse",
+ "ListBackupOperationsRequest",
+ "ListBackupOperationsResponse",
+ "ListBackupSchedulesRequest",
+ "ListBackupSchedulesResponse",
+ "ListBackupsRequest",
+ "ListBackupsResponse",
+ "ListDatabaseOperationsRequest",
+ "ListDatabaseOperationsResponse",
+ "ListDatabaseRolesRequest",
+ "ListDatabaseRolesResponse",
+ "ListDatabasesRequest",
+ "ListDatabasesResponse",
+ "OperationProgress",
+ "OptimizeRestoredDatabaseMetadata",
+ "RestoreDatabaseEncryptionConfig",
+ "RestoreDatabaseMetadata",
+ "RestoreDatabaseRequest",
+ "RestoreInfo",
+ "RestoreSourceType",
+ "SplitPoints",
+ "UpdateBackupRequest",
+ "UpdateBackupScheduleRequest",
+ "UpdateDatabaseDdlMetadata",
+ "UpdateDatabaseDdlRequest",
+ "UpdateDatabaseMetadata",
+ "UpdateDatabaseRequest",
+)
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 f41559acc1..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 (`````).
- 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 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 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 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 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 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 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_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
-
- 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
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 d6f830eeee..0000000000
--- a/google/cloud/spanner_admin_database_v1/gapic/database_admin_client_config.py
+++ /dev/null
@@ -1,108 +0,0 @@
-config = {
- "interfaces": {
- "google.spanner.admin.database.v1.DatabaseAdmin": {
- "retry_codes": {
- "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"],
- "non_idempotent": [],
- },
- "retry_params": {
- "default": {
- "initial_retry_delay_millis": 1000,
- "retry_delay_multiplier": 1.3,
- "max_retry_delay_millis": 32000,
- "initial_rpc_timeout_millis": 60000,
- "rpc_timeout_multiplier": 1.0,
- "max_rpc_timeout_millis": 60000,
- "total_timeout_millis": 600000,
- }
- },
- "methods": {
- "CreateDatabase": {
- "timeout_millis": 3600000,
- "retry_codes_name": "non_idempotent",
- "retry_params_name": "default",
- },
- "GetDatabase": {
- "timeout_millis": 30000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- "UpdateDatabaseDdl": {
- "timeout_millis": 3600000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- "DropDatabase": {
- "timeout_millis": 3600000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- "GetDatabaseDdl": {
- "timeout_millis": 30000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- "SetIamPolicy": {
- "timeout_millis": 30000,
- "retry_codes_name": "non_idempotent",
- "retry_params_name": "default",
- },
- "GetIamPolicy": {
- "timeout_millis": 30000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- "TestIamPermissions": {
- "timeout_millis": 30000,
- "retry_codes_name": "non_idempotent",
- "retry_params_name": "default",
- },
- "CreateBackup": {
- "timeout_millis": 30000,
- "retry_codes_name": "non_idempotent",
- "retry_params_name": "default",
- },
- "GetBackup": {
- "timeout_millis": 30000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- "UpdateBackup": {
- "timeout_millis": 30000,
- "retry_codes_name": "non_idempotent",
- "retry_params_name": "default",
- },
- "DeleteBackup": {
- "timeout_millis": 30000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- "ListBackups": {
- "timeout_millis": 30000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- "RestoreDatabase": {
- "timeout_millis": 30000,
- "retry_codes_name": "non_idempotent",
- "retry_params_name": "default",
- },
- "ListDatabaseOperations": {
- "timeout_millis": 30000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- "ListBackupOperations": {
- "timeout_millis": 30000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- "ListDatabases": {
- "timeout_millis": 60000,
- "retry_codes_name": "idempotent",
- "retry_params_name": "default",
- },
- },
- }
- }
-}
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 d972ddfc57..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 2fb41caab2..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 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 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 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 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 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 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_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
-
- @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
diff --git a/google/cloud/spanner_admin_database_v1/gapic_metadata.json b/google/cloud/spanner_admin_database_v1/gapic_metadata.json
new file mode 100644
index 0000000000..027a4f612b
--- /dev/null
+++ b/google/cloud/spanner_admin_database_v1/gapic_metadata.json
@@ -0,0 +1,433 @@
+ {
+ "comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
+ "language": "python",
+ "libraryPackage": "google.cloud.spanner_admin_database_v1",
+ "protoPackage": "google.spanner.admin.database.v1",
+ "schema": "1.0",
+ "services": {
+ "DatabaseAdmin": {
+ "clients": {
+ "grpc": {
+ "libraryClient": "DatabaseAdminClient",
+ "rpcs": {
+ "AddSplitPoints": {
+ "methods": [
+ "add_split_points"
+ ]
+ },
+ "CopyBackup": {
+ "methods": [
+ "copy_backup"
+ ]
+ },
+ "CreateBackup": {
+ "methods": [
+ "create_backup"
+ ]
+ },
+ "CreateBackupSchedule": {
+ "methods": [
+ "create_backup_schedule"
+ ]
+ },
+ "CreateDatabase": {
+ "methods": [
+ "create_database"
+ ]
+ },
+ "DeleteBackup": {
+ "methods": [
+ "delete_backup"
+ ]
+ },
+ "DeleteBackupSchedule": {
+ "methods": [
+ "delete_backup_schedule"
+ ]
+ },
+ "DropDatabase": {
+ "methods": [
+ "drop_database"
+ ]
+ },
+ "GetBackup": {
+ "methods": [
+ "get_backup"
+ ]
+ },
+ "GetBackupSchedule": {
+ "methods": [
+ "get_backup_schedule"
+ ]
+ },
+ "GetDatabase": {
+ "methods": [
+ "get_database"
+ ]
+ },
+ "GetDatabaseDdl": {
+ "methods": [
+ "get_database_ddl"
+ ]
+ },
+ "GetIamPolicy": {
+ "methods": [
+ "get_iam_policy"
+ ]
+ },
+ "InternalUpdateGraphOperation": {
+ "methods": [
+ "internal_update_graph_operation"
+ ]
+ },
+ "ListBackupOperations": {
+ "methods": [
+ "list_backup_operations"
+ ]
+ },
+ "ListBackupSchedules": {
+ "methods": [
+ "list_backup_schedules"
+ ]
+ },
+ "ListBackups": {
+ "methods": [
+ "list_backups"
+ ]
+ },
+ "ListDatabaseOperations": {
+ "methods": [
+ "list_database_operations"
+ ]
+ },
+ "ListDatabaseRoles": {
+ "methods": [
+ "list_database_roles"
+ ]
+ },
+ "ListDatabases": {
+ "methods": [
+ "list_databases"
+ ]
+ },
+ "RestoreDatabase": {
+ "methods": [
+ "restore_database"
+ ]
+ },
+ "SetIamPolicy": {
+ "methods": [
+ "set_iam_policy"
+ ]
+ },
+ "TestIamPermissions": {
+ "methods": [
+ "test_iam_permissions"
+ ]
+ },
+ "UpdateBackup": {
+ "methods": [
+ "update_backup"
+ ]
+ },
+ "UpdateBackupSchedule": {
+ "methods": [
+ "update_backup_schedule"
+ ]
+ },
+ "UpdateDatabase": {
+ "methods": [
+ "update_database"
+ ]
+ },
+ "UpdateDatabaseDdl": {
+ "methods": [
+ "update_database_ddl"
+ ]
+ }
+ }
+ },
+ "grpc-async": {
+ "libraryClient": "DatabaseAdminAsyncClient",
+ "rpcs": {
+ "AddSplitPoints": {
+ "methods": [
+ "add_split_points"
+ ]
+ },
+ "CopyBackup": {
+ "methods": [
+ "copy_backup"
+ ]
+ },
+ "CreateBackup": {
+ "methods": [
+ "create_backup"
+ ]
+ },
+ "CreateBackupSchedule": {
+ "methods": [
+ "create_backup_schedule"
+ ]
+ },
+ "CreateDatabase": {
+ "methods": [
+ "create_database"
+ ]
+ },
+ "DeleteBackup": {
+ "methods": [
+ "delete_backup"
+ ]
+ },
+ "DeleteBackupSchedule": {
+ "methods": [
+ "delete_backup_schedule"
+ ]
+ },
+ "DropDatabase": {
+ "methods": [
+ "drop_database"
+ ]
+ },
+ "GetBackup": {
+ "methods": [
+ "get_backup"
+ ]
+ },
+ "GetBackupSchedule": {
+ "methods": [
+ "get_backup_schedule"
+ ]
+ },
+ "GetDatabase": {
+ "methods": [
+ "get_database"
+ ]
+ },
+ "GetDatabaseDdl": {
+ "methods": [
+ "get_database_ddl"
+ ]
+ },
+ "GetIamPolicy": {
+ "methods": [
+ "get_iam_policy"
+ ]
+ },
+ "InternalUpdateGraphOperation": {
+ "methods": [
+ "internal_update_graph_operation"
+ ]
+ },
+ "ListBackupOperations": {
+ "methods": [
+ "list_backup_operations"
+ ]
+ },
+ "ListBackupSchedules": {
+ "methods": [
+ "list_backup_schedules"
+ ]
+ },
+ "ListBackups": {
+ "methods": [
+ "list_backups"
+ ]
+ },
+ "ListDatabaseOperations": {
+ "methods": [
+ "list_database_operations"
+ ]
+ },
+ "ListDatabaseRoles": {
+ "methods": [
+ "list_database_roles"
+ ]
+ },
+ "ListDatabases": {
+ "methods": [
+ "list_databases"
+ ]
+ },
+ "RestoreDatabase": {
+ "methods": [
+ "restore_database"
+ ]
+ },
+ "SetIamPolicy": {
+ "methods": [
+ "set_iam_policy"
+ ]
+ },
+ "TestIamPermissions": {
+ "methods": [
+ "test_iam_permissions"
+ ]
+ },
+ "UpdateBackup": {
+ "methods": [
+ "update_backup"
+ ]
+ },
+ "UpdateBackupSchedule": {
+ "methods": [
+ "update_backup_schedule"
+ ]
+ },
+ "UpdateDatabase": {
+ "methods": [
+ "update_database"
+ ]
+ },
+ "UpdateDatabaseDdl": {
+ "methods": [
+ "update_database_ddl"
+ ]
+ }
+ }
+ },
+ "rest": {
+ "libraryClient": "DatabaseAdminClient",
+ "rpcs": {
+ "AddSplitPoints": {
+ "methods": [
+ "add_split_points"
+ ]
+ },
+ "CopyBackup": {
+ "methods": [
+ "copy_backup"
+ ]
+ },
+ "CreateBackup": {
+ "methods": [
+ "create_backup"
+ ]
+ },
+ "CreateBackupSchedule": {
+ "methods": [
+ "create_backup_schedule"
+ ]
+ },
+ "CreateDatabase": {
+ "methods": [
+ "create_database"
+ ]
+ },
+ "DeleteBackup": {
+ "methods": [
+ "delete_backup"
+ ]
+ },
+ "DeleteBackupSchedule": {
+ "methods": [
+ "delete_backup_schedule"
+ ]
+ },
+ "DropDatabase": {
+ "methods": [
+ "drop_database"
+ ]
+ },
+ "GetBackup": {
+ "methods": [
+ "get_backup"
+ ]
+ },
+ "GetBackupSchedule": {
+ "methods": [
+ "get_backup_schedule"
+ ]
+ },
+ "GetDatabase": {
+ "methods": [
+ "get_database"
+ ]
+ },
+ "GetDatabaseDdl": {
+ "methods": [
+ "get_database_ddl"
+ ]
+ },
+ "GetIamPolicy": {
+ "methods": [
+ "get_iam_policy"
+ ]
+ },
+ "InternalUpdateGraphOperation": {
+ "methods": [
+ "internal_update_graph_operation"
+ ]
+ },
+ "ListBackupOperations": {
+ "methods": [
+ "list_backup_operations"
+ ]
+ },
+ "ListBackupSchedules": {
+ "methods": [
+ "list_backup_schedules"
+ ]
+ },
+ "ListBackups": {
+ "methods": [
+ "list_backups"
+ ]
+ },
+ "ListDatabaseOperations": {
+ "methods": [
+ "list_database_operations"
+ ]
+ },
+ "ListDatabaseRoles": {
+ "methods": [
+ "list_database_roles"
+ ]
+ },
+ "ListDatabases": {
+ "methods": [
+ "list_databases"
+ ]
+ },
+ "RestoreDatabase": {
+ "methods": [
+ "restore_database"
+ ]
+ },
+ "SetIamPolicy": {
+ "methods": [
+ "set_iam_policy"
+ ]
+ },
+ "TestIamPermissions": {
+ "methods": [
+ "test_iam_permissions"
+ ]
+ },
+ "UpdateBackup": {
+ "methods": [
+ "update_backup"
+ ]
+ },
+ "UpdateBackupSchedule": {
+ "methods": [
+ "update_backup_schedule"
+ ]
+ },
+ "UpdateDatabase": {
+ "methods": [
+ "update_database"
+ ]
+ },
+ "UpdateDatabaseDdl": {
+ "methods": [
+ "update_database_ddl"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/google/cloud/spanner_admin_database_v1/gapic_version.py b/google/cloud/spanner_admin_database_v1/gapic_version.py
new file mode 100644
index 0000000000..fa3f4c040d
--- /dev/null
+++ b/google/cloud/spanner_admin_database_v1/gapic_version.py
@@ -0,0 +1,16 @@
+# -*- coding: utf-8 -*-
+# Copyright 2022 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+__version__ = "3.58.0" # {x-release-please-version}
diff --git a/google/cloud/spanner_admin_database_v1/proto/backup.proto b/google/cloud/spanner_admin_database_v1/proto/backup.proto
deleted file mode 100644
index d9b6fd74cd..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/backup.proto
+++ /dev/null
@@ -1,363 +0,0 @@
-// 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.
-
-syntax = "proto3";
-
-package google.spanner.admin.database.v1;
-
-import "google/api/field_behavior.proto";
-import "google/api/resource.proto";
-import "google/longrunning/operations.proto";
-import "google/protobuf/field_mask.proto";
-import "google/protobuf/timestamp.proto";
-import "google/spanner/admin/database/v1/common.proto";
-import "google/api/annotations.proto";
-
-option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
-option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
-option java_multiple_files = true;
-option java_outer_classname = "BackupProto";
-option java_package = "com.google.spanner.admin.database.v1";
-option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1";
-
-// A backup of a Cloud Spanner database.
-message Backup {
- option (google.api.resource) = {
- type: "spanner.googleapis.com/Backup"
- pattern: "projects/{project}/instances/{instance}/backups/{backup}"
- };
-
- // Indicates the current state of the backup.
- enum State {
- // Not specified.
- STATE_UNSPECIFIED = 0;
-
- // The pending backup is still being created. Operations on the
- // backup may fail with `FAILED_PRECONDITION` in this state.
- CREATING = 1;
-
- // The backup is complete and ready for use.
- READY = 2;
- }
-
- // 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/`.
- string database = 2;
-
- // 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.
- google.protobuf.Timestamp expire_time = 3;
-
- // Output only for the [CreateBackup][google.spanner.admin.database.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
- // `projects//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/`.
- string name = 1;
-
- // 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.
- google.protobuf.Timestamp create_time = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. Size of the backup in bytes.
- int64 size_bytes = 5 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. The current state of the backup.
- State state = 6 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. The names of the restored databases that reference the backup.
- // The database names are of
- // the form `projects//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.
- repeated string referencing_databases = 7 [(google.api.field_behavior) = OUTPUT_ONLY];
-}
-
-// The request for [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
-message CreateBackupRequest {
- // 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/`.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Instance"
- }
- ];
-
- // 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/`.
- string backup_id = 2 [(google.api.field_behavior) = REQUIRED];
-
- // Required. The backup to create.
- Backup backup = 3 [(google.api.field_behavior) = REQUIRED];
-}
-
-// Metadata type for the operation returned by
-// [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
-message CreateBackupMetadata {
- // The name of the backup being created.
- string name = 1;
-
- // The name of the database the backup is created from.
- string database = 2;
-
- // The progress of the
- // [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup] operation.
- OperationProgress progress = 3;
-
- // The time at which cancellation of this operation was received.
- // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
- // 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.GetOperation] 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`.
- google.protobuf.Timestamp cancel_time = 4;
-}
-
-// The request for [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup].
-message UpdateBackupRequest {
- // 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`.
- Backup backup = 1 [(google.api.field_behavior) = REQUIRED];
-
- // 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.
- google.protobuf.FieldMask update_mask = 2 [(google.api.field_behavior) = REQUIRED];
-}
-
-// The request for [GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup].
-message GetBackupRequest {
- // Required. Name of the backup.
- // Values are of the form
- // `projects//instances//backups/`.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Backup"
- }
- ];
-}
-
-// The request for [DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup].
-message DeleteBackupRequest {
- // Required. Name of the backup to delete.
- // Values are of the form
- // `projects//instances//backups/`.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Backup"
- }
- ];
-}
-
-// The request for [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
-message ListBackupsRequest {
- // Required. The instance to list backups from. Values are of the
- // form `projects//instances/`.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Instance"
- }
- ];
-
- // 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
- string filter = 2;
-
- // Number of backups to be returned in the response. If 0 or
- // less, defaults to the server's maximum allowed page size.
- int32 page_size = 3;
-
- // If non-empty, `page_token` should contain a
- // [next_page_token][google.spanner.admin.database.v1.ListBackupsResponse.next_page_token] from a
- // previous [ListBackupsResponse][google.spanner.admin.database.v1.ListBackupsResponse] to the same `parent` and with the same
- // `filter`.
- string page_token = 4;
-}
-
-// The response for [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
-message ListBackupsResponse {
- // The list of matching backups. Backups returned are ordered by `create_time`
- // in descending order, starting from the most recent `create_time`.
- repeated Backup backups = 1;
-
- // `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.
- string next_page_token = 2;
-}
-
-// The request for
-// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
-message ListBackupOperationsRequest {
- // Required. The instance of the backup operations. Values are of
- // the form `projects//instances/`.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Instance"
- }
- ];
-
- // 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][google.spanner.admin.database.v1.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][google.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.
- string filter = 2;
-
- // Number of operations to be returned in the response. If 0 or
- // less, defaults to the server's maximum allowed page size.
- int32 page_size = 3;
-
- // If non-empty, `page_token` should contain a
- // [next_page_token][google.spanner.admin.database.v1.ListBackupOperationsResponse.next_page_token]
- // from a previous [ListBackupOperationsResponse][google.spanner.admin.database.v1.ListBackupOperationsResponse] to the
- // same `parent` and with the same `filter`.
- string page_token = 4;
-}
-
-// The response for
-// [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
-message ListBackupOperationsResponse {
- // 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.CreateBackupMetadata]. 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.
- repeated google.longrunning.Operation operations = 1;
-
- // `next_page_token` can be sent in a subsequent
- // [ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations]
- // call to fetch more of the matching metadata.
- string next_page_token = 2;
-}
-
-// Information about a backup.
-message BackupInfo {
- // Name of the backup.
- string backup = 1;
-
- // The backup contains an externally consistent copy of `source_database` at
- // the timestamp specified by `create_time`.
- google.protobuf.Timestamp create_time = 2;
-
- // Name of the database the backup was created from.
- string source_database = 3;
-}
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 edc596bd94..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/backup_pb2.py
+++ /dev/null
@@ -1,1379 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: google/cloud/spanner/admin/database_v1/proto/backup.proto
-
-import sys
-
-_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1"))
-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_dot_admin_dot_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"
- ),
- 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"\xa7\x03\n\x06\x42\x61\x63kup\x12\x10\n\x08\x64\x61tabase\x18\x02 \x01(\t\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\xd1\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\\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_dot_admin_dot_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,
- values=[
- _descriptor.EnumValueDescriptor(
- name="STATE_UNSPECIFIED",
- index=0,
- number=0,
- serialized_options=None,
- type=None,
- ),
- _descriptor.EnumValueDescriptor(
- name="CREATING", index=1, number=1, serialized_options=None, type=None
- ),
- _descriptor.EnumValueDescriptor(
- name="READY", index=2, number=2, serialized_options=None, type=None
- ),
- ],
- containing_type=None,
- serialized_options=None,
- serialized_start=623,
- serialized_end=678,
-)
-_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,
- 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=None,
- file=DESCRIPTOR,
- ),
- _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,
- ),
- _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,
- ),
- _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,
- ),
- _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,
- ),
- _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,
- ),
- _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,
- ),
- ],
- 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=772,
-)
-
-
-_CREATEBACKUPREQUEST = _descriptor.Descriptor(
- name="CreateBackupRequest",
- full_name="google.spanner.admin.database.v1.CreateBackupRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- 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,
- ),
- _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,
- ),
- _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,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=775,
- serialized_end=940,
-)
-
-
-_CREATEBACKUPMETADATA = _descriptor.Descriptor(
- name="CreateBackupMetadata",
- full_name="google.spanner.admin.database.v1.CreateBackupMetadata",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- 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,
- ),
- _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,
- ),
- _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,
- ),
- _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,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=943,
- serialized_end=1117,
-)
-
-
-_UPDATEBACKUPREQUEST = _descriptor.Descriptor(
- name="UpdateBackupRequest",
- full_name="google.spanner.admin.database.v1.UpdateBackupRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- 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,
- ),
- _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,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1120,
- serialized_end=1258,
-)
-
-
-_GETBACKUPREQUEST = _descriptor.Descriptor(
- name="GetBackupRequest",
- full_name="google.spanner.admin.database.v1.GetBackupRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- 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,
- )
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1260,
- serialized_end=1331,
-)
-
-
-_DELETEBACKUPREQUEST = _descriptor.Descriptor(
- name="DeleteBackupRequest",
- full_name="google.spanner.admin.database.v1.DeleteBackupRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- 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,
- )
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1333,
- serialized_end=1407,
-)
-
-
-_LISTBACKUPSREQUEST = _descriptor.Descriptor(
- name="ListBackupsRequest",
- full_name="google.spanner.admin.database.v1.ListBackupsRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- 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,
- ),
- _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,
- ),
- _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,
- ),
- _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,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1410,
- serialized_end=1542,
-)
-
-
-_LISTBACKUPSRESPONSE = _descriptor.Descriptor(
- name="ListBackupsResponse",
- full_name="google.spanner.admin.database.v1.ListBackupsResponse",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- 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,
- ),
- _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,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1544,
- serialized_end=1649,
-)
-
-
-_LISTBACKUPOPERATIONSREQUEST = _descriptor.Descriptor(
- name="ListBackupOperationsRequest",
- full_name="google.spanner.admin.database.v1.ListBackupOperationsRequest",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- 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,
- ),
- _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,
- ),
- _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,
- ),
- _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,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1652,
- serialized_end=1793,
-)
-
-
-_LISTBACKUPOPERATIONSRESPONSE = _descriptor.Descriptor(
- name="ListBackupOperationsResponse",
- full_name="google.spanner.admin.database.v1.ListBackupOperationsResponse",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- 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,
- ),
- _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,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1795,
- serialized_end=1901,
-)
-
-
-_BACKUPINFO = _descriptor.Descriptor(
- name="BackupInfo",
- full_name="google.spanner.admin.database.v1.BackupInfo",
- filename=None,
- file=DESCRIPTOR,
- containing_type=None,
- 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,
- ),
- _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,
- ),
- _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,
- ),
- ],
- extensions=[],
- nested_types=[],
- enum_types=[],
- serialized_options=None,
- is_extendable=False,
- syntax="proto3",
- extension_ranges=[],
- oneofs=[],
- serialized_start=1903,
- serialized_end=2005,
-)
-
-_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_dot_admin_dot_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,),
- dict(
- 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,),
- dict(
- DESCRIPTOR=_CREATEBACKUPREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2",
- __doc__="""The request for
- [CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- DESCRIPTOR=_CREATEBACKUPMETADATA,
- __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2",
- __doc__="""Metadata type for the operation returned by
- [CreateBackup][google.spanner.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,),
- dict(
- DESCRIPTOR=_UPDATEBACKUPREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2",
- __doc__="""The request for
- [UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- 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,),
- dict(
- DESCRIPTOR=_DELETEBACKUPREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2",
- __doc__="""The request for
- [DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- DESCRIPTOR=_LISTBACKUPSREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2",
- __doc__="""The request for
- [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.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\_tok
- en][google.spanner.admin.database.v1.ListBackupsResponse.next\
- _page\_token] from a previous [ListBackupsResponse][google.spa
- nner.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,),
- dict(
- DESCRIPTOR=_LISTBACKUPSRESPONSE,
- __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2",
- __doc__="""The response for
- [ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- DESCRIPTOR=_LISTBACKUPOPERATIONSREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.backup_pb2",
- __doc__="""The request for
- [ListBackupOperations][google.spanner.admin.database.v1.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\_tok
- en][google.spanner.admin.database.v1.ListBackupOperationsRespo
- nse.next\_page\_token] from a previous [ListBackupOperationsRe
- sponse][google.spanner.admin.database.v1.ListBackupOperationsR
- esponse] 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,),
- dict(
- 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,),
- dict(
- 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["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 07cb78fe03..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/backup_pb2_grpc.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
-import grpc
diff --git a/google/cloud/spanner_admin_database_v1/proto/common.proto b/google/cloud/spanner_admin_database_v1/proto/common.proto
deleted file mode 100644
index 4914cb8ac7..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/common.proto
+++ /dev/null
@@ -1,43 +0,0 @@
-// 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.
-
-syntax = "proto3";
-
-package google.spanner.admin.database.v1;
-
-import "google/api/field_behavior.proto";
-import "google/protobuf/timestamp.proto";
-import "google/api/annotations.proto";
-
-option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
-option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
-option java_multiple_files = true;
-option java_outer_classname = "CommonProto";
-option java_package = "com.google.spanner.admin.database.v1";
-option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1";
-
-// Encapsulates progress related information for a Cloud Spanner long
-// running operation.
-message OperationProgress {
- // Percent completion of the operation.
- // Values are between 0 and 100 inclusive.
- int32 progress_percent = 1;
-
- // Time the request was received.
- google.protobuf.Timestamp start_time = 2;
-
- // If set, the time at which this operation failed or was completed
- // successfully.
- google.protobuf.Timestamp end_time = 3;
-}
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 3acf791486..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/common_pb2.py
+++ /dev/null
@@ -1,151 +0,0 @@
-# -*- coding: utf-8 -*-
-# Generated by the protocol buffer compiler. DO NOT EDIT!
-# source: google/cloud/spanner/admin/database_v1/proto/common.proto
-
-import sys
-
-_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1"))
-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"
- ),
- 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\xd1\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\\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,
- 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,
- ),
- _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,
- ),
- _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,
- ),
- ],
- 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,),
- dict(
- 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 07cb78fe03..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/common_pb2_grpc.py
+++ /dev/null
@@ -1,2 +0,0 @@
-# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT!
-import grpc
diff --git a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto b/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto
deleted file mode 100644
index d48adc8aba..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin.proto
+++ /dev/null
@@ -1,726 +0,0 @@
-// 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.
-
-syntax = "proto3";
-
-package google.spanner.admin.database.v1;
-
-import "google/api/annotations.proto";
-import "google/api/client.proto";
-import "google/api/field_behavior.proto";
-import "google/api/resource.proto";
-import "google/iam/v1/iam_policy.proto";
-import "google/iam/v1/policy.proto";
-import "google/longrunning/operations.proto";
-import "google/protobuf/empty.proto";
-import "google/protobuf/timestamp.proto";
-import "google/spanner/admin/database/v1/backup.proto";
-import "google/spanner/admin/database/v1/common.proto";
-
-option csharp_namespace = "Google.Cloud.Spanner.Admin.Database.V1";
-option go_package = "google.golang.org/genproto/googleapis/spanner/admin/database/v1;database";
-option java_multiple_files = true;
-option java_outer_classname = "SpannerDatabaseAdminProto";
-option java_package = "com.google.spanner.admin.database.v1";
-option php_namespace = "Google\\Cloud\\Spanner\\Admin\\Database\\V1";
-option (google.api.resource_definition) = {
- type: "spanner.googleapis.com/Instance"
- pattern: "projects/{project}/instances/{instance}"
-};
-
-// 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 DatabaseAdmin {
- option (google.api.default_host) = "spanner.googleapis.com";
- option (google.api.oauth_scopes) =
- "https://www.googleapis.com/auth/cloud-platform,"
- "https://www.googleapis.com/auth/spanner.admin";
-
- // Lists Cloud Spanner databases.
- rpc ListDatabases(ListDatabasesRequest) returns (ListDatabasesResponse) {
- option (google.api.http) = {
- get: "/v1/{parent=projects/*/instances/*}/databases"
- };
- option (google.api.method_signature) = "parent";
- }
-
- // 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.
- rpc CreateDatabase(CreateDatabaseRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1/{parent=projects/*/instances/*}/databases"
- body: "*"
- };
- option (google.api.method_signature) = "parent,create_statement";
- option (google.longrunning.operation_info) = {
- response_type: "google.spanner.admin.database.v1.Database"
- metadata_type: "google.spanner.admin.database.v1.CreateDatabaseMetadata"
- };
- }
-
- // Gets the state of a Cloud Spanner database.
- rpc GetDatabase(GetDatabaseRequest) returns (Database) {
- option (google.api.http) = {
- get: "/v1/{name=projects/*/instances/*/databases/*}"
- };
- option (google.api.method_signature) = "name";
- }
-
- // 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.
- rpc UpdateDatabaseDdl(UpdateDatabaseDdlRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- patch: "/v1/{database=projects/*/instances/*/databases/*}/ddl"
- body: "*"
- };
- option (google.api.method_signature) = "database,statements";
- option (google.longrunning.operation_info) = {
- response_type: "google.protobuf.Empty"
- metadata_type: "google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata"
- };
- }
-
- // Drops (aka deletes) a Cloud Spanner database.
- // Completed backups for the database will be retained according to their
- // `expire_time`.
- rpc DropDatabase(DropDatabaseRequest) returns (google.protobuf.Empty) {
- option (google.api.http) = {
- delete: "/v1/{database=projects/*/instances/*/databases/*}"
- };
- option (google.api.method_signature) = "database";
- }
-
- // 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.
- rpc GetDatabaseDdl(GetDatabaseDdlRequest) returns (GetDatabaseDdlResponse) {
- option (google.api.http) = {
- get: "/v1/{database=projects/*/instances/*/databases/*}/ddl"
- };
- option (google.api.method_signature) = "database";
- }
-
- // 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].
- rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) {
- option (google.api.http) = {
- post: "/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy"
- body: "*"
- additional_bindings {
- post: "/v1/{resource=projects/*/instances/*/backups/*}:setIamPolicy"
- body: "*"
- }
- };
- option (google.api.method_signature) = "resource,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][google.iam.v1.GetIamPolicyRequest.resource].
- // For backups, authorization requires `spanner.backups.getIamPolicy`
- // permission on [resource][google.iam.v1.GetIamPolicyRequest.resource].
- rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) {
- option (google.api.http) = {
- post: "/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy"
- body: "*"
- additional_bindings {
- post: "/v1/{resource=projects/*/instances/*/backups/*}:getIamPolicy"
- body: "*"
- }
- };
- option (google.api.method_signature) = "resource";
- }
-
- // 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.
- rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) {
- option (google.api.http) = {
- post: "/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions"
- body: "*"
- additional_bindings {
- post: "/v1/{resource=projects/*/instances/*/backups/*}:testIamPermissions"
- body: "*"
- }
- };
- option (google.api.method_signature) = "resource,permissions";
- }
-
- // 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.
- rpc CreateBackup(CreateBackupRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1/{parent=projects/*/instances/*}/backups"
- body: "backup"
- };
- option (google.api.method_signature) = "parent,backup,backup_id";
- option (google.longrunning.operation_info) = {
- response_type: "Backup"
- metadata_type: "google.spanner.admin.database.v1.CreateBackupMetadata"
- };
- }
-
- // Gets metadata on a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
- rpc GetBackup(GetBackupRequest) returns (Backup) {
- option (google.api.http) = {
- get: "/v1/{name=projects/*/instances/*/backups/*}"
- };
- option (google.api.method_signature) = "name";
- }
-
- // Updates a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
- rpc UpdateBackup(UpdateBackupRequest) returns (Backup) {
- option (google.api.http) = {
- patch: "/v1/{backup.name=projects/*/instances/*/backups/*}"
- body: "backup"
- };
- option (google.api.method_signature) = "backup,update_mask";
- }
-
- // Deletes a pending or completed [Backup][google.spanner.admin.database.v1.Backup].
- rpc DeleteBackup(DeleteBackupRequest) returns (google.protobuf.Empty) {
- option (google.api.http) = {
- delete: "/v1/{name=projects/*/instances/*/backups/*}"
- };
- option (google.api.method_signature) = "name";
- }
-
- // Lists completed and pending backups.
- // Backups returned are ordered by `create_time` in descending order,
- // starting from the most recent `create_time`.
- rpc ListBackups(ListBackupsRequest) returns (ListBackupsResponse) {
- option (google.api.http) = {
- get: "/v1/{parent=projects/*/instances/*}/backups"
- };
- option (google.api.method_signature) = "parent";
- }
-
- // 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.
- rpc RestoreDatabase(RestoreDatabaseRequest) returns (google.longrunning.Operation) {
- option (google.api.http) = {
- post: "/v1/{parent=projects/*/instances/*}/databases:restore"
- body: "*"
- };
- option (google.api.method_signature) = "parent,database_id,backup";
- option (google.longrunning.operation_info) = {
- response_type: "google.spanner.admin.database.v1.Database"
- metadata_type: "google.spanner.admin.database.v1.RestoreDatabaseMetadata"
- };
- }
-
- // 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.
- rpc ListDatabaseOperations(ListDatabaseOperationsRequest) returns (ListDatabaseOperationsResponse) {
- option (google.api.http) = {
- get: "/v1/{parent=projects/*/instances/*}/databaseOperations"
- };
- option (google.api.method_signature) = "parent";
- }
-
- // 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.
- rpc ListBackupOperations(ListBackupOperationsRequest) returns (ListBackupOperationsResponse) {
- option (google.api.http) = {
- get: "/v1/{parent=projects/*/instances/*}/backupOperations"
- };
- option (google.api.method_signature) = "parent";
- }
-}
-
-// Information about the database restore.
-message RestoreInfo {
- // The type of the restore source.
- RestoreSourceType source_type = 1;
-
- // Information about the source used to restore the database.
- oneof source_info {
- // Information about the backup used to restore the database. The backup
- // may no longer exist.
- BackupInfo backup_info = 2;
- }
-}
-
-// A Cloud Spanner database.
-message Database {
- option (google.api.resource) = {
- type: "spanner.googleapis.com/Database"
- pattern: "projects/{project}/instances/{instance}/databases/{database}"
- };
-
- // Indicates the current state of the database.
- enum State {
- // Not specified.
- STATE_UNSPECIFIED = 0;
-
- // The database is still being created. Operations on the database may fail
- // with `FAILED_PRECONDITION` in this state.
- CREATING = 1;
-
- // The database is fully created and ready for use.
- READY = 2;
-
- // 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.
- READY_OPTIMIZING = 3;
- }
-
- // Required. The name of the database. Values are of the form
- // `projects//instances//databases/`,
- // where `` is as specified in the `CREATE DATABASE`
- // statement. This name can be passed to other API methods to
- // identify the database.
- string name = 1 [(google.api.field_behavior) = REQUIRED];
-
- // Output only. The current database state.
- State state = 2 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. If exists, the time at which the database creation started.
- google.protobuf.Timestamp create_time = 3 [(google.api.field_behavior) = OUTPUT_ONLY];
-
- // Output only. Applicable only for restored databases. Contains information
- // about the restore source.
- RestoreInfo restore_info = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
-}
-
-// The request for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
-message ListDatabasesRequest {
- // Required. The instance whose databases should be listed.
- // Values are of the form `projects//instances/`.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Instance"
- }
- ];
-
- // Number of databases to be returned in the response. If 0 or less,
- // defaults to the server's maximum allowed page size.
- int32 page_size = 3;
-
- // If non-empty, `page_token` should contain a
- // [next_page_token][google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token] from a
- // previous [ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse].
- string page_token = 4;
-}
-
-// The response for [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
-message ListDatabasesResponse {
- // Databases that matched the request.
- repeated Database databases = 1;
-
- // `next_page_token` can be sent in a subsequent
- // [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases] call to fetch more
- // of the matching databases.
- string next_page_token = 2;
-}
-
-// The request for [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
-message CreateDatabaseRequest {
- // Required. The name of the instance that will serve the new database.
- // Values are of the form `projects//instances/`.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Instance"
- }
- ];
-
- // 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 (`` ` ``).
- string create_statement = 2 [(google.api.field_behavior) = REQUIRED];
-
- // 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.
- repeated string extra_statements = 3 [(google.api.field_behavior) = OPTIONAL];
-}
-
-// Metadata type for the operation returned by
-// [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase].
-message CreateDatabaseMetadata {
- // The database being created.
- string database = 1 [(google.api.resource_reference) = {
- type: "spanner.googleapis.com/Database"
- }];
-}
-
-// The request for [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase].
-message GetDatabaseRequest {
- // Required. The name of the requested database. Values are of the form
- // `projects//instances//databases/`.
- string name = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Database"
- }
- ];
-}
-
-// 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.
-message UpdateDatabaseDdlRequest {
- // Required. The database to update.
- string database = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Database"
- }
- ];
-
- // Required. DDL statements to be applied to the database.
- repeated string statements = 2 [(google.api.field_behavior) = REQUIRED];
-
- // 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
- // [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl] call is replayed,
- // or the return value is otherwise lost: the [database][google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.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`.
- string operation_id = 3;
-}
-
-// Metadata type for the operation returned by
-// [UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl].
-message UpdateDatabaseDdlMetadata {
- // The database being modified.
- string database = 1 [(google.api.resource_reference) = {
- type: "spanner.googleapis.com/Database"
- }];
-
- // For an update this list contains all the statements. For an
- // individual statement, this list contains only that statement.
- repeated string statements = 2;
-
- // 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]`.
- repeated google.protobuf.Timestamp commit_timestamps = 3;
-}
-
-// The request for [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase].
-message DropDatabaseRequest {
- // Required. The database to be dropped.
- string database = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Database"
- }
- ];
-}
-
-// The request for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
-message GetDatabaseDdlRequest {
- // Required. The database whose schema we wish to get.
- string database = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Database"
- }
- ];
-}
-
-// The response for [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
-message GetDatabaseDdlResponse {
- // A list of formatted DDL statements defining the schema of the database
- // specified in the request.
- repeated string statements = 1;
-}
-
-// The request for
-// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
-message ListDatabaseOperationsRequest {
- // Required. The instance of the database operations.
- // Values are of the form `projects//instances/`.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Instance"
- }
- ];
-
- // 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][google.spanner.admin.database.v1.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][google.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.
- string filter = 2;
-
- // Number of operations to be returned in the response. If 0 or
- // less, defaults to the server's maximum allowed page size.
- int32 page_size = 3;
-
- // If non-empty, `page_token` should contain a
- // [next_page_token][google.spanner.admin.database.v1.ListDatabaseOperationsResponse.next_page_token]
- // from a previous [ListDatabaseOperationsResponse][google.spanner.admin.database.v1.ListDatabaseOperationsResponse] to the
- // same `parent` and with the same `filter`.
- string page_token = 4;
-}
-
-// The response for
-// [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
-message ListDatabaseOperationsResponse {
- // 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.
- repeated google.longrunning.Operation operations = 1;
-
- // `next_page_token` can be sent in a subsequent
- // [ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations]
- // call to fetch more of the matching metadata.
- string next_page_token = 2;
-}
-
-// The request for
-// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
-message RestoreDatabaseRequest {
- // 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/`.
- string parent = 1 [
- (google.api.field_behavior) = REQUIRED,
- (google.api.resource_reference) = {
- type: "spanner.googleapis.com/Instance"
- }
- ];
-
- // 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/`.
- string database_id = 2 [(google.api.field_behavior) = REQUIRED];
-
- // Required. The source from which to restore.
- oneof source {
- // Name of the backup from which to restore. Values are of the form
- // `projects//instances//backups/`.
- string backup = 3 [(google.api.resource_reference) = {
- type: "spanner.googleapis.com/Backup"
- }];
- }
-}
-
-// Metadata type for the long-running operation returned by
-// [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
-message RestoreDatabaseMetadata {
- // Name of the database being created and restored to.
- string name = 1;
-
- // The type of the restore source.
- RestoreSourceType source_type = 2;
-
- // Information about the source used to restore the database, as specified by
- // `source` in [RestoreDatabaseRequest][google.spanner.admin.database.v1.RestoreDatabaseRequest].
- oneof source_info {
- // Information about the backup used to restore the database.
- BackupInfo backup_info = 3;
- }
-
- // The progress of the
- // [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase]
- // operation.
- OperationProgress progress = 4;
-
- // The time at which cancellation of this operation was received.
- // [Operations.CancelOperation][google.longrunning.Operations.CancelOperation]
- // 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.GetOperation] 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`.
- google.protobuf.Timestamp cancel_time = 5;
-
- // 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.
- string optimize_database_operation_name = 6;
-}
-
-// 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.
-message OptimizeRestoredDatabaseMetadata {
- // Name of the restored database being optimized.
- string name = 1;
-
- // The progress of the post-restore optimizations.
- OperationProgress progress = 2;
-}
-
-// Indicates the type of the restore source.
-enum RestoreSourceType {
- // No restore associated.
- TYPE_UNSPECIFIED = 0;
-
- // A backup was used as the source of the restore.
- BACKUP = 1;
-}
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 125ab3f86b..0000000000
--- a/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py
+++ /dev/null
@@ -1,2124 +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
-
-import sys
-
-_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1"))
-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_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2,
-)
-from google.cloud.spanner_admin_database_v1.proto import (
- common_pb2 as google_dot_cloud_dot_spanner_dot_admin_dot_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\352AJ\n\037spanner.googleapis.com/Instance\022'projects/{project}/instances/{instance}"
- ),
- 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\xac\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\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_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.DESCRIPTOR,
- google_dot_cloud_dot_spanner_dot_admin_dot_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,
- values=[
- _descriptor.EnumValueDescriptor(
- name="TYPE_UNSPECIFIED",
- index=0,
- number=0,
- serialized_options=None,
- type=None,
- ),
- _descriptor.EnumValueDescriptor(
- name="BACKUP", index=1, number=1, serialized_options=None, type=None
- ),
- ],
- 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,
- values=[
- _descriptor.EnumValueDescriptor(
- name="STATE_UNSPECIFIED",
- index=0,
- number=0,
- serialized_options=None,
- type=None,
- ),
- _descriptor.EnumValueDescriptor(
- name="CREATING", index=1, number=1, serialized_options=None, type=None
- ),
- _descriptor.EnumValueDescriptor(
- name="READY", index=2, number=2, serialized_options=None, type=None
- ),
- _descriptor.EnumValueDescriptor(
- name="READY_OPTIMIZING",
- index=3,
- number=3,
- serialized_options=None,
- type=None,
- ),
- ],
- 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,
- 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,
- ),
- _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,
- ),
- ],
- 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,
- 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,
- 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,
- ),
- _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,
- ),
- _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,
- ),
- _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,
- ),
- ],
- 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,),
- dict(
- DESCRIPTOR=_LISTDATABASESREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""The request for
- [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- DESCRIPTOR=_LISTDATABASESRESPONSE,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""The response for
- [ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- DESCRIPTOR=_CREATEDATABASEREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""The request for
- [CreateDatabase][google.spanner.admin.database.v1.DatabaseAdmin.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 (`````).
- 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,),
- dict(
- DESCRIPTOR=_CREATEDATABASEMETADATA,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""Metadata type for the operation returned by
- [CreateDatabase][google.spanner.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,),
- dict(
- DESCRIPTOR=_GETDATABASEREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""The request for
- [GetDatabase][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- 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.UpdateDatabaseDdlRequest.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,),
- dict(
- 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,),
- dict(
- DESCRIPTOR=_DROPDATABASEREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""The request for
- [DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- DESCRIPTOR=_GETDATABASEDDLREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""The request for
- [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- DESCRIPTOR=_GETDATABASEDDLRESPONSE,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""The response for
- [GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- 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,),
- dict(
- DESCRIPTOR=_LISTDATABASEOPERATIONSRESPONSE,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""The response for
- [ListDatabaseOperations][google.spanner.admin.database.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,),
- dict(
- DESCRIPTOR=_RESTOREDATABASEREQUEST,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""The request for
- [RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.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,),
- dict(
- DESCRIPTOR=_RESTOREDATABASEMETADATA,
- __module__="google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2",
- __doc__="""Metadata type for the long-running operation returned by
- [RestoreDatabase][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,),
- dict(
- 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"
- ),
- serialized_start=3100,
- serialized_end=7054,
- 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"
- ),
- ),
- _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'
- ),
- ),
- _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"
- ),
- ),
- _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"
- ),
- ),
- _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"
- ),
- ),
- _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"
- ),
- ),
- _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_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabasesRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_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_dot_admin_dot_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_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2.GetDatabaseRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_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_dot_admin_dot_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_dot_admin_dot_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_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2.GetDatabaseDdlRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_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_dot_admin_dot_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_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.GetBackupRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_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_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.UpdateBackupRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_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_dot_admin_dot_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_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.ListBackupsRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_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_dot_admin_dot_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_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2.ListDatabaseOperationsRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_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_dot_admin_dot_database__v1_dot_proto_dot_backup__pb2.ListBackupOperationsRequest.FromString,
- response_serializer=google_dot_cloud_dot_spanner_dot_admin_dot_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,))
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..cbf94b283c
--- /dev/null
+++ b/google/cloud/spanner_admin_database_v1/services/__init__.py
@@ -0,0 +1,15 @@
+# -*- coding: utf-8 -*-
+# Copyright 2025 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
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..580a7ed2a2
--- /dev/null
+++ b/google/cloud/spanner_admin_database_v1/services/database_admin/__init__.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+# Copyright 2025 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+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..0e08065a7d
--- /dev/null
+++ b/google/cloud/spanner_admin_database_v1/services/database_admin/async_client.py
@@ -0,0 +1,4218 @@
+# -*- coding: utf-8 -*-
+# Copyright 2025 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+import logging as std_logging
+from collections import OrderedDict
+import re
+from typing import (
+ Dict,
+ Callable,
+ Mapping,
+ MutableMapping,
+ MutableSequence,
+ Optional,
+ Sequence,
+ Tuple,
+ Type,
+ Union,
+)
+import uuid
+
+from google.cloud.spanner_admin_database_v1 import gapic_version as package_version
+
+from google.api_core.client_options import ClientOptions
+from google.api_core import exceptions as core_exceptions
+from google.api_core import gapic_v1
+from google.api_core import retry_async as retries
+from google.auth import credentials as ga_credentials # type: ignore
+from google.oauth2 import service_account # type: ignore
+import google.protobuf
+
+
+try:
+ OptionalRetry = Union[retries.AsyncRetry, gapic_v1.method._MethodDefault, None]
+except AttributeError: # pragma: NO COVER
+ OptionalRetry = Union[retries.AsyncRetry, object, None] # 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 backup_schedule
+from google.cloud.spanner_admin_database_v1.types import (
+ backup_schedule as gsad_backup_schedule,
+)
+from google.cloud.spanner_admin_database_v1.types import common
+from google.cloud.spanner_admin_database_v1.types import spanner_database_admin
+from google.iam.v1 import iam_policy_pb2 # type: ignore
+from google.iam.v1 import policy_pb2 # type: ignore
+from google.longrunning import operations_pb2 # type: ignore
+from google.longrunning import operations_pb2 # type: ignore
+from google.protobuf import duration_pb2 # type: ignore
+from google.protobuf import empty_pb2 # type: ignore
+from google.protobuf import field_mask_pb2 # type: ignore
+from google.protobuf import timestamp_pb2 # type: ignore
+from .transports.base import DatabaseAdminTransport, DEFAULT_CLIENT_INFO
+from .transports.grpc_asyncio import DatabaseAdminGrpcAsyncIOTransport
+from .client import DatabaseAdminClient
+
+try:
+ from google.api_core import client_logging # type: ignore
+
+ CLIENT_LOGGING_SUPPORTED = True # pragma: NO COVER
+except ImportError: # pragma: NO COVER
+ CLIENT_LOGGING_SUPPORTED = False
+
+_LOGGER = std_logging.getLogger(__name__)
+
+
+class DatabaseAdminAsyncClient:
+ """Cloud Spanner Database Admin API
+
+ The Cloud Spanner Database Admin API can be used to:
+
+ - create, drop, and list databases
+ - update the schema of pre-existing databases
+ - create, delete, copy and list backups for a database
+ - restore a database from an existing backup
+ """
+
+ _client: DatabaseAdminClient
+
+ # Copy defaults from the synchronous client for use here.
+ # Note: DEFAULT_ENDPOINT is deprecated. Use _DEFAULT_ENDPOINT_TEMPLATE instead.
+ DEFAULT_ENDPOINT = DatabaseAdminClient.DEFAULT_ENDPOINT
+ DEFAULT_MTLS_ENDPOINT = DatabaseAdminClient.DEFAULT_MTLS_ENDPOINT
+ _DEFAULT_ENDPOINT_TEMPLATE = DatabaseAdminClient._DEFAULT_ENDPOINT_TEMPLATE
+ _DEFAULT_UNIVERSE = DatabaseAdminClient._DEFAULT_UNIVERSE
+
+ backup_path = staticmethod(DatabaseAdminClient.backup_path)
+ parse_backup_path = staticmethod(DatabaseAdminClient.parse_backup_path)
+ backup_schedule_path = staticmethod(DatabaseAdminClient.backup_schedule_path)
+ parse_backup_schedule_path = staticmethod(
+ DatabaseAdminClient.parse_backup_schedule_path
+ )
+ crypto_key_path = staticmethod(DatabaseAdminClient.crypto_key_path)
+ parse_crypto_key_path = staticmethod(DatabaseAdminClient.parse_crypto_key_path)
+ crypto_key_version_path = staticmethod(DatabaseAdminClient.crypto_key_version_path)
+ parse_crypto_key_version_path = staticmethod(
+ DatabaseAdminClient.parse_crypto_key_version_path
+ )
+ database_path = staticmethod(DatabaseAdminClient.database_path)
+ parse_database_path = staticmethod(DatabaseAdminClient.parse_database_path)
+ database_role_path = staticmethod(DatabaseAdminClient.database_role_path)
+ parse_database_role_path = staticmethod(
+ DatabaseAdminClient.parse_database_role_path
+ )
+ instance_path = staticmethod(DatabaseAdminClient.instance_path)
+ parse_instance_path = staticmethod(DatabaseAdminClient.parse_instance_path)
+ instance_partition_path = staticmethod(DatabaseAdminClient.instance_partition_path)
+ parse_instance_partition_path = staticmethod(
+ DatabaseAdminClient.parse_instance_partition_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
+ )
+
+ @classmethod
+ def from_service_account_info(cls, info: dict, *args, **kwargs):
+ """Creates an instance of this client using the provided credentials
+ info.
+
+ Args:
+ info (dict): The service account private key info.
+ args: Additional arguments to pass to the constructor.
+ kwargs: Additional arguments to pass to the constructor.
+
+ Returns:
+ DatabaseAdminAsyncClient: The constructed client.
+ """
+ return DatabaseAdminClient.from_service_account_info.__func__(DatabaseAdminAsyncClient, info, *args, **kwargs) # type: ignore
+
+ @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:
+ DatabaseAdminAsyncClient: The constructed client.
+ """
+ return DatabaseAdminClient.from_service_account_file.__func__(DatabaseAdminAsyncClient, filename, *args, **kwargs) # type: ignore
+
+ from_service_account_json = from_service_account_file
+
+ @classmethod
+ def get_mtls_endpoint_and_cert_source(
+ cls, client_options: Optional[ClientOptions] = None
+ ):
+ """Return the API endpoint and client cert source for mutual TLS.
+
+ The client cert source is determined in the following order:
+ (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the
+ client cert source is None.
+ (2) if `client_options.client_cert_source` is provided, use the provided one; if the
+ default client cert source exists, use the default one; otherwise the client cert
+ source is None.
+
+ The API endpoint is determined in the following order:
+ (1) if `client_options.api_endpoint` if provided, use the provided one.
+ (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the
+ default mTLS endpoint; if the environment variable is "never", use the default API
+ endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise
+ use the default API endpoint.
+
+ More details can be found at https://google.aip.dev/auth/4114.
+
+ Args:
+ client_options (google.api_core.client_options.ClientOptions): Custom options for the
+ client. Only the `api_endpoint` and `client_cert_source` properties may be used
+ in this method.
+
+ Returns:
+ Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the
+ client cert source to use.
+
+ Raises:
+ google.auth.exceptions.MutualTLSChannelError: If any errors happen.
+ """
+ return DatabaseAdminClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore
+
+ @property
+ def transport(self) -> DatabaseAdminTransport:
+ """Returns the transport used by the client instance.
+
+ Returns:
+ DatabaseAdminTransport: The transport used by the client instance.
+ """
+ return self._client.transport
+
+ @property
+ def api_endpoint(self):
+ """Return the API endpoint used by the client instance.
+
+ Returns:
+ str: The API endpoint used by the client instance.
+ """
+ return self._client._api_endpoint
+
+ @property
+ def universe_domain(self) -> str:
+ """Return the universe domain used by the client instance.
+
+ Returns:
+ str: The universe domain used
+ by the client instance.
+ """
+ return self._client._universe_domain
+
+ get_transport_class = DatabaseAdminClient.get_transport_class
+
+ def __init__(
+ self,
+ *,
+ credentials: Optional[ga_credentials.Credentials] = None,
+ transport: Optional[
+ Union[str, DatabaseAdminTransport, Callable[..., DatabaseAdminTransport]]
+ ] = "grpc_asyncio",
+ client_options: Optional[ClientOptions] = None,
+ client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
+ ) -> None:
+ """Instantiates the database admin async 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 (Optional[Union[str,DatabaseAdminTransport,Callable[..., DatabaseAdminTransport]]]):
+ The transport to use, or a Callable that constructs and returns a new transport to use.
+ If a Callable is given, it will be called with the same set of initialization
+ arguments as used in the DatabaseAdminTransport constructor.
+ If set to None, a transport is chosen automatically.
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]):
+ Custom options for the client.
+
+ 1. The ``api_endpoint`` property can be used to override the
+ default endpoint provided by the client when ``transport`` is
+ not explicitly provided. Only if this property is not set and
+ ``transport`` was not explicitly provided, the endpoint is
+ determined by the GOOGLE_API_USE_MTLS_ENDPOINT environment
+ variable, which have one of the following values:
+ "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).
+
+ 2. If the GOOGLE_API_USE_CLIENT_CERTIFICATE environment variable
+ is "true", then the ``client_cert_source`` property can be used
+ to provide a client certificate for mTLS 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.
+
+ 3. The ``universe_domain`` property can be used to override the
+ default "googleapis.com" universe. Note that ``api_endpoint``
+ property still takes precedence; and ``universe_domain`` is
+ currently not supported for mTLS.
+
+ 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.
+ """
+ self._client = DatabaseAdminClient(
+ credentials=credentials,
+ transport=transport,
+ client_options=client_options,
+ client_info=client_info,
+ )
+
+ if CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(
+ std_logging.DEBUG
+ ): # pragma: NO COVER
+ _LOGGER.debug(
+ "Created client `google.spanner.admin.database_v1.DatabaseAdminAsyncClient`.",
+ extra={
+ "serviceName": "google.spanner.admin.database.v1.DatabaseAdmin",
+ "universeDomain": getattr(
+ self._client._transport._credentials, "universe_domain", ""
+ ),
+ "credentialsType": f"{type(self._client._transport._credentials).__module__}.{type(self._client._transport._credentials).__qualname__}",
+ "credentialsInfo": getattr(
+ self.transport._credentials, "get_cred_info", lambda: None
+ )(),
+ }
+ if hasattr(self._client._transport, "_credentials")
+ else {
+ "serviceName": "google.spanner.admin.database.v1.DatabaseAdmin",
+ "credentialsType": None,
+ },
+ )
+
+ async def list_databases(
+ self,
+ request: Optional[
+ Union[spanner_database_admin.ListDatabasesRequest, dict]
+ ] = None,
+ *,
+ parent: Optional[str] = None,
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
+ ) -> pagers.ListDatabasesAsyncPager:
+ r"""Lists Cloud Spanner databases.
+
+ .. code-block:: python
+
+ # This snippet has been automatically generated and should be regarded as a
+ # code template only.
+ # It will require modifications to work:
+ # - It may require correct/in-range values for request initialization.
+ # - It may require specifying regional endpoints when creating the service
+ # client as shown in:
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
+ from google.cloud import spanner_admin_database_v1
+
+ async def sample_list_databases():
+ # Create a client
+ client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
+
+ # Initialize request argument(s)
+ request = spanner_admin_database_v1.ListDatabasesRequest(
+ parent="parent_value",
+ )
+
+ # Make the request
+ page_result = client.list_databases(request=request)
+
+ # Handle the response
+ async for response in page_result:
+ print(response)
+
+ Args:
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListDatabasesRequest, dict]]):
+ 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_async.AsyncRetry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
+ sent along with the request as metadata. Normally, each value must be of type `str`,
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
+ be of type `bytes`.
+
+ Returns:
+ google.cloud.spanner_admin_database_v1.services.database_admin.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.
+ # - Quick check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ flattened_params = [parent]
+ has_flattened_params = (
+ len([param for param in flattened_params if param is not None]) > 0
+ )
+ 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."
+ )
+
+ # - Use the request object if provided (there's no risk of modifying the input as
+ # there are no flattened fields), or create one.
+ 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._client._transport._wrapped_methods[
+ self._client._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),)),
+ )
+
+ # Validate the universe domain.
+ self._client._validate_universe_domain()
+
+ # 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,
+ retry=retry,
+ timeout=timeout,
+ metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def create_database(
+ self,
+ request: Optional[
+ Union[spanner_database_admin.CreateDatabaseRequest, dict]
+ ] = None,
+ *,
+ parent: Optional[str] = None,
+ create_statement: Optional[str] = None,
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
+ ) -> 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.
+
+ .. code-block:: python
+
+ # This snippet has been automatically generated and should be regarded as a
+ # code template only.
+ # It will require modifications to work:
+ # - It may require correct/in-range values for request initialization.
+ # - It may require specifying regional endpoints when creating the service
+ # client as shown in:
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
+ from google.cloud import spanner_admin_database_v1
+
+ async def sample_create_database():
+ # Create a client
+ client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
+
+ # Initialize request argument(s)
+ request = spanner_admin_database_v1.CreateDatabaseRequest(
+ parent="parent_value",
+ create_statement="create_statement_value",
+ )
+
+ # Make the request
+ operation = client.create_database(request=request)
+
+ print("Waiting for operation to complete...")
+
+ response = (await operation).result()
+
+ # Handle the response
+ print(response)
+
+ Args:
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.CreateDatabaseRequest, dict]]):
+ 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_async.AsyncRetry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
+ sent along with the request as metadata. Normally, each value must be of type `str`,
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
+ be of type `bytes`.
+
+ Returns:
+ google.api_core.operation_async.AsyncOperation:
+ An object representing a long-running operation.
+
+ The result type for the operation will be
+ :class:`google.cloud.spanner_admin_database_v1.types.Database`
+ A Cloud Spanner database.
+
+ """
+ # Create or coerce a protobuf request object.
+ # - Quick check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ flattened_params = [parent, create_statement]
+ has_flattened_params = (
+ len([param for param in flattened_params if param is not None]) > 0
+ )
+ 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."
+ )
+
+ # - Use the request object if provided (there's no risk of modifying the input as
+ # there are no flattened fields), or create one.
+ 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._client._transport._wrapped_methods[
+ self._client._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),)),
+ )
+
+ # Validate the universe domain.
+ self._client._validate_universe_domain()
+
+ # 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: Optional[
+ Union[spanner_database_admin.GetDatabaseRequest, dict]
+ ] = None,
+ *,
+ name: Optional[str] = None,
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
+ ) -> spanner_database_admin.Database:
+ r"""Gets the state of a Cloud Spanner database.
+
+ .. code-block:: python
+
+ # This snippet has been automatically generated and should be regarded as a
+ # code template only.
+ # It will require modifications to work:
+ # - It may require correct/in-range values for request initialization.
+ # - It may require specifying regional endpoints when creating the service
+ # client as shown in:
+ # https://googleapis.dev/python/google-api-core/latest/client_options.html
+ from google.cloud import spanner_admin_database_v1
+
+ async def sample_get_database():
+ # Create a client
+ client = spanner_admin_database_v1.DatabaseAdminAsyncClient()
+
+ # Initialize request argument(s)
+ request = spanner_admin_database_v1.GetDatabaseRequest(
+ name="name_value",
+ )
+
+ # Make the request
+ response = await client.get_database(request=request)
+
+ # Handle the response
+ print(response)
+
+ Args:
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.GetDatabaseRequest, dict]]):
+ 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_async.AsyncRetry): Designation of what errors, if any,
+ should be retried.
+ timeout (float): The timeout for this request.
+ metadata (Sequence[Tuple[str, Union[str, bytes]]]): Key/value pairs which should be
+ sent along with the request as metadata. Normally, each value must be of type `str`,
+ but for metadata keys ending with the suffix `-bin`, the corresponding values must
+ be of type `bytes`.
+
+ Returns:
+ google.cloud.spanner_admin_database_v1.types.Database:
+ A Cloud Spanner database.
+ """
+ # Create or coerce a protobuf request object.
+ # - Quick check: If we got a request object, we should *not* have
+ # gotten any keyword arguments that map to the request.
+ flattened_params = [name]
+ has_flattened_params = (
+ len([param for param in flattened_params if param is not None]) > 0
+ )
+ 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."
+ )
+
+ # - Use the request object if provided (there's no risk of modifying the input as
+ # there are no flattened fields), or create one.
+ 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._client._transport._wrapped_methods[
+ self._client._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),)),
+ )
+
+ # Validate the universe domain.
+ self._client._validate_universe_domain()
+
+ # Send the request.
+ response = await rpc(
+ request,
+ retry=retry,
+ timeout=timeout,
+ metadata=metadata,
+ )
+
+ # Done; return the response.
+ return response
+
+ async def update_database(
+ self,
+ request: Optional[
+ Union[spanner_database_admin.UpdateDatabaseRequest, dict]
+ ] = None,
+ *,
+ database: Optional[spanner_database_admin.Database] = None,
+ update_mask: Optional[field_mask_pb2.FieldMask] = None,
+ retry: OptionalRetry = gapic_v1.method.DEFAULT,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
+ metadata: Sequence[Tuple[str, Union[str, bytes]]] = (),
+ ) -> operation_async.AsyncOperation:
+ r"""Updates a Cloud Spanner database. The returned [long-running
+ operation][google.longrunning.Operation] can be used to track
+ the progress of updating the database. If the named database
+ does not exist, returns ``NOT_FOUND``.
+
+ While the operation is pending:
+
+ - The database's
+ [reconciling][google.spanner.admin.database.v1.Database.reconciling]
+ field is set to true.
+ - Cancelling the operation is best-effort. If the cancellation
+ succeeds, the operation metadata's
+ [cancel_time][google.spanner.admin.database.v1.UpdateDatabaseMetadata.cancel_time]
+ is set, the updates are reverted, and the operation terminates
+ with a ``CANCELLED`` status.
+ - New UpdateDatabase requests will return a
+ ``FAILED_PRECONDITION`` error until the pending operation is
+ done (returns successfully or with error).
+ - Reading the database via the API continues to give the
+ pre-request values.
+
+ Upon completion of the returned operation:
+
+ - The new values are in effect and readable via the API.
+ - The database's
+ [reconciling][google.spanner.admin.database.v1.Database.reconciling]
+ field becomes false.
+
+ The returned [long-running
+ operation][google.longrunning.Operation] will have a name of the
+ format
+ ``projects/