Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ exclude =
# Exclude generated code.
**/proto/**
**/gapic/**
**/services/**
**/types/**
*_pb2.py

# Standard linting exemptions.
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
dist
build
eggs
.eggs
parts
bin
var
Expand Down Expand Up @@ -49,6 +50,7 @@ bigquery/docs/generated
# Virtual environment
env/
coverage.xml
sponge_log.xml

# System test environment variables.
system_tests/local_test_setup
Expand Down
2 changes: 0 additions & 2 deletions .kokoro/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

#!/bin/bash

set -eo pipefail

# Start the releasetool reporter
Expand Down
3 changes: 3 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,6 @@ recursive-include google *.json *.proto
recursive-include tests *
global-exclude *.py[co]
global-exclude __pycache__

# Exclude scripts for samples readmegen
prune scripts/readme-gen
7 changes: 2 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,21 +38,18 @@
"sphinx.ext.napoleon",
"sphinx.ext.todo",
"sphinx.ext.viewcode",
"recommonmark",
]

# 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']
Expand Down
2 changes: 2 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
.. include:: README.rst

.. include:: multiprocessing.rst

Usage Documentation
-------------------
.. toctree::
Expand Down
7 changes: 7 additions & 0 deletions docs/multiprocessing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. note::

Because this client uses :mod:`grpcio` 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` or
:class:`multiprocessing.Process`.
208 changes: 104 additions & 104 deletions google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,110 @@ def __init__(
self._inner_api_calls = {}

# Service calls
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/<project>/instances/<instance>``.
page_size (int): The maximum number of resources contained in the
underlying API response. If page streaming is performed per-
resource, this parameter does not affect the return value. If page
streaming is performed per-page, this determines the maximum number
of resources in a page.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
timeout (Optional[float]): The amount of time, in seconds, to wait
for the request to complete. Note that if ``retry`` is
specified, the timeout applies to each individual attempt.
metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
that is provided to the method.

Returns:
A :class:`~google.api_core.page_iterator.PageIterator` instance.
An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Database` instances.
You can also iterate over the pages of the response
using its `pages` property.

Raises:
google.api_core.exceptions.GoogleAPICallError: If the request
failed for any reason.
google.api_core.exceptions.RetryError: If the request failed due
to a retryable error and retry attempts failed.
ValueError: If the parameters are invalid.
"""
# Wrap the transport method to add retry and timeout logic.
if "list_databases" not in self._inner_api_calls:
self._inner_api_calls[
"list_databases"
] = google.api_core.gapic_v1.method.wrap_method(
self.transport.list_databases,
default_retry=self._method_configs["ListDatabases"].retry,
default_timeout=self._method_configs["ListDatabases"].timeout,
client_info=self._client_info,
)

request = spanner_database_admin_pb2.ListDatabasesRequest(
parent=parent, page_size=page_size
)
if metadata is None:
metadata = []
metadata = list(metadata)
try:
routing_header = [("parent", parent)]
except AttributeError:
pass
else:
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
routing_header
)
metadata.append(routing_metadata)

iterator = google.api_core.page_iterator.GRPCIterator(
client=None,
method=functools.partial(
self._inner_api_calls["list_databases"],
retry=retry,
timeout=timeout,
metadata=metadata,
),
request=request,
items_field="databases",
request_token_field="page_token",
response_token_field="next_page_token",
)
return iterator

def create_database(
self,
parent,
Expand Down Expand Up @@ -1817,107 +1921,3 @@ def list_backup_operations(
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/<project>/instances/<instance>``.
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
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@
}
},
"methods": {
"ListDatabases": {
"timeout_millis": 3600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"CreateDatabase": {
"timeout_millis": 3600000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"GetDatabase": {
"timeout_millis": 30000,
"timeout_millis": 3600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
Expand All @@ -38,7 +43,7 @@
"retry_params_name": "default",
},
"GetDatabaseDdl": {
"timeout_millis": 30000,
"timeout_millis": 3600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
Expand All @@ -63,12 +68,12 @@
"retry_params_name": "default",
},
"GetBackup": {
"timeout_millis": 600000,
"timeout_millis": 3600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"UpdateBackup": {
"timeout_millis": 600000,
"timeout_millis": 3600000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
Expand All @@ -78,7 +83,7 @@
"retry_params_name": "default",
},
"ListBackups": {
"timeout_millis": 600000,
"timeout_millis": 3600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
Expand All @@ -88,17 +93,12 @@
"retry_params_name": "default",
},
"ListDatabaseOperations": {
"timeout_millis": 600000,
"timeout_millis": 3600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ListBackupOperations": {
"timeout_millis": 600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ListDatabases": {
"timeout_millis": 60000,
"timeout_millis": 3600000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
Expand Down
Loading