diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml
index fccaa8e844..889f77dfa2 100644
--- a/.github/.OwlBot.lock.yaml
+++ b/.github/.OwlBot.lock.yaml
@@ -1,4 +1,4 @@
-# Copyright 2022 Google LLC
+# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
@@ -13,4 +13,4 @@
# limitations under the License.
docker:
image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest
- digest: sha256:3bf87e47c2173d7eed42714589dc4da2c07c3268610f1e47f8e1a30decbfc7f1
+ digest: sha256:c43f1d918bcf817d337aa29ff833439494a158a0831508fda4ec75dc4c0d0320
diff --git a/.github/release-please.yml b/.github/release-please.yml
index 5161ab347c..dbd2cc9deb 100644
--- a/.github/release-please.yml
+++ b/.github/release-please.yml
@@ -1,5 +1,6 @@
releaseType: python
handleGHRelease: true
+manifest: true
# NOTE: this section is generated by synthtool.languages.python
# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py
branches:
diff --git a/.kokoro/samples/python3.11/common.cfg b/.kokoro/samples/python3.11/common.cfg
new file mode 100644
index 0000000000..fb30c1b856
--- /dev/null
+++ b/.kokoro/samples/python3.11/common.cfg
@@ -0,0 +1,40 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+# Build logs will be here
+action {
+ define_artifacts {
+ regex: "**/*sponge_log.xml"
+ }
+}
+
+# Specify which tests to run
+env_vars: {
+ key: "RUN_TESTS_SESSION"
+ value: "py-3.11"
+}
+
+# Declare build specific Cloud project.
+env_vars: {
+ key: "BUILD_SPECIFIC_GCLOUD_PROJECT"
+ value: "python-docs-samples-tests-311"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-spanner/.kokoro/test-samples.sh"
+}
+
+# Configure the docker image for kokoro-trampoline.
+env_vars: {
+ key: "TRAMPOLINE_IMAGE"
+ value: "gcr.io/cloud-devrel-kokoro-resources/python-samples-testing-docker"
+}
+
+# Download secrets for samples
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/python-docs-samples"
+
+# Download trampoline resources.
+gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline"
+
+# Use the trampoline script to run in docker.
+build_file: "python-spanner/.kokoro/trampoline_v2.sh"
\ No newline at end of file
diff --git a/.kokoro/samples/python3.11/continuous.cfg b/.kokoro/samples/python3.11/continuous.cfg
new file mode 100644
index 0000000000..a1c8d9759c
--- /dev/null
+++ b/.kokoro/samples/python3.11/continuous.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.kokoro/samples/python3.11/periodic-head.cfg b/.kokoro/samples/python3.11/periodic-head.cfg
new file mode 100644
index 0000000000..b6133a1180
--- /dev/null
+++ b/.kokoro/samples/python3.11/periodic-head.cfg
@@ -0,0 +1,11 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
+
+env_vars: {
+ key: "TRAMPOLINE_BUILD_FILE"
+ value: "github/python-spanner/.kokoro/test-samples-against-head.sh"
+}
diff --git a/.kokoro/samples/python3.11/periodic.cfg b/.kokoro/samples/python3.11/periodic.cfg
new file mode 100644
index 0000000000..71cd1e597e
--- /dev/null
+++ b/.kokoro/samples/python3.11/periodic.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "False"
+}
diff --git a/.kokoro/samples/python3.11/presubmit.cfg b/.kokoro/samples/python3.11/presubmit.cfg
new file mode 100644
index 0000000000..a1c8d9759c
--- /dev/null
+++ b/.kokoro/samples/python3.11/presubmit.cfg
@@ -0,0 +1,6 @@
+# Format: //devtools/kokoro/config/proto/build.proto
+
+env_vars: {
+ key: "INSTALL_LIBRARY_FROM_SOURCE"
+ value: "True"
+}
\ No newline at end of file
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
new file mode 100644
index 0000000000..631b492c41
--- /dev/null
+++ b/.release-please-manifest.json
@@ -0,0 +1,3 @@
+{
+ ".": "3.27.0"
+}
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9561b0cc7d..1b30ef2212 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,29 @@
[1]: https://pypi.org/project/google-cloud-spanner/#history
+## [3.27.0](https://github.com/googleapis/python-spanner/compare/v3.26.0...v3.27.0) (2023-01-10)
+
+
+### Features
+
+* Add support for python 3.11 ([#879](https://github.com/googleapis/python-spanner/issues/879)) ([4b8c2cf](https://github.com/googleapis/python-spanner/commit/4b8c2cf6c30892ad977e3db6c3a147a93af649e6))
+* Add typing to proto.Message based class attributes ([4683d10](https://github.com/googleapis/python-spanner/commit/4683d10c75e24aa222591d6001e07aacb6b4ee46))
+
+
+### Bug Fixes
+
+* Add dict typing for client_options ([4683d10](https://github.com/googleapis/python-spanner/commit/4683d10c75e24aa222591d6001e07aacb6b4ee46))
+* **deps:** Require google-api-core >=1.34.0, >=2.11.0 ([4683d10](https://github.com/googleapis/python-spanner/commit/4683d10c75e24aa222591d6001e07aacb6b4ee46))
+* Drop packaging dependency ([4683d10](https://github.com/googleapis/python-spanner/commit/4683d10c75e24aa222591d6001e07aacb6b4ee46))
+* Drop usage of pkg_resources ([4683d10](https://github.com/googleapis/python-spanner/commit/4683d10c75e24aa222591d6001e07aacb6b4ee46))
+* Fix timeout default values ([4683d10](https://github.com/googleapis/python-spanner/commit/4683d10c75e24aa222591d6001e07aacb6b4ee46))
+
+
+### Documentation
+
+* **samples:** Snippetgen handling of repeated enum field ([4683d10](https://github.com/googleapis/python-spanner/commit/4683d10c75e24aa222591d6001e07aacb6b4ee46))
+* **samples:** Snippetgen should call await on the operation coroutine before calling result ([4683d10](https://github.com/googleapis/python-spanner/commit/4683d10c75e24aa222591d6001e07aacb6b4ee46))
+
## [3.26.0](https://github.com/googleapis/python-spanner/compare/v3.25.0...v3.26.0) (2022-12-15)
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 15a1381764..0ea84d3216 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -22,7 +22,7 @@ In order to add a feature:
documentation.
- The feature must work fully on the following CPython versions:
- 3.7, 3.8, 3.9 and 3.10 on both UNIX and Windows.
+ 3.7, 3.8, 3.9, 3.10 and 3.11 on both UNIX and Windows.
- The feature must not add unnecessary dependencies (where
"unnecessary" is of course subjective, but new dependencies should
@@ -72,7 +72,7 @@ We use `nox `__ to instrument our tests.
- To run a single unit test::
- $ nox -s unit-3.10 -- -k
+ $ nox -s unit-3.11 -- -k
.. note::
@@ -225,11 +225,13 @@ We support:
- `Python 3.8`_
- `Python 3.9`_
- `Python 3.10`_
+- `Python 3.11`_
.. _Python 3.7: https://docs.python.org/3.7/
.. _Python 3.8: https://docs.python.org/3.8/
.. _Python 3.9: https://docs.python.org/3.9/
.. _Python 3.10: https://docs.python.org/3.10/
+.. _Python 3.11: https://docs.python.org/3.11/
Supported versions can be found in our ``noxfile.py`` `config`_.
diff --git a/docs/spanner_admin_database_v1/types.rst b/docs/spanner_admin_database_v1/types.rst
index 95e1d7f88b..fe6c27778b 100644
--- a/docs/spanner_admin_database_v1/types.rst
+++ b/docs/spanner_admin_database_v1/types.rst
@@ -3,5 +3,4 @@ Types for Google Cloud Spanner Admin Database v1 API
.. automodule:: google.cloud.spanner_admin_database_v1.types
:members:
- :undoc-members:
:show-inheritance:
diff --git a/docs/spanner_admin_instance_v1/types.rst b/docs/spanner_admin_instance_v1/types.rst
index 8f7204ebce..250cf6bf9b 100644
--- a/docs/spanner_admin_instance_v1/types.rst
+++ b/docs/spanner_admin_instance_v1/types.rst
@@ -3,5 +3,4 @@ Types for Google Cloud Spanner Admin Instance v1 API
.. automodule:: google.cloud.spanner_admin_instance_v1.types
:members:
- :undoc-members:
:show-inheritance:
diff --git a/docs/spanner_v1/types.rst b/docs/spanner_v1/types.rst
index 8678aba188..c7ff7e6c71 100644
--- a/docs/spanner_v1/types.rst
+++ b/docs/spanner_v1/types.rst
@@ -3,5 +3,4 @@ Types for Google Cloud Spanner v1 API
.. automodule:: google.cloud.spanner_v1.types
:members:
- :undoc-members:
:show-inheritance:
diff --git a/google/cloud/spanner_admin_database_v1/__init__.py b/google/cloud/spanner_admin_database_v1/__init__.py
index a70cf0acfd..a985273089 100644
--- a/google/cloud/spanner_admin_database_v1/__init__.py
+++ b/google/cloud/spanner_admin_database_v1/__init__.py
@@ -13,6 +13,10 @@
# 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
+
+__version__ = package_version.__version__
+
from .services.database_admin import DatabaseAdminClient
from .services.database_admin import DatabaseAdminAsyncClient
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..f0856cadb7
--- /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.27.0" # {x-release-please-version}
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
index 7aa227856f..cc3768f664 100644
--- 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
@@ -16,8 +16,19 @@
from collections import OrderedDict
import functools
import re
-from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
-import pkg_resources
+from typing import (
+ Dict,
+ Mapping,
+ MutableMapping,
+ MutableSequence,
+ Optional,
+ Sequence,
+ Tuple,
+ Type,
+ Union,
+)
+
+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
@@ -156,7 +167,7 @@ def get_mtls_endpoint_and_cert_source(
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 variabel is "never", use the default API
+ 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.
@@ -192,9 +203,9 @@ def transport(self) -> DatabaseAdminTransport:
def __init__(
self,
*,
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, DatabaseAdminTransport] = "grpc_asyncio",
- client_options: ClientOptions = None,
+ client_options: Optional[ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiates the database admin client.
@@ -238,11 +249,13 @@ def __init__(
async def list_databases(
self,
- request: Union[spanner_database_admin.ListDatabasesRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.ListDatabasesRequest, dict]
+ ] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDatabasesAsyncPager:
r"""Lists Cloud Spanner databases.
@@ -275,7 +288,7 @@ async def sample_list_databases():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.ListDatabasesRequest, dict]):
+ 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`):
@@ -364,12 +377,14 @@ async def sample_list_databases():
async def create_database(
self,
- request: Union[spanner_database_admin.CreateDatabaseRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.CreateDatabaseRequest, dict]
+ ] = None,
*,
- parent: str = None,
- create_statement: str = None,
+ parent: Optional[str] = None,
+ create_statement: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates a new Cloud Spanner database and starts to prepare it
@@ -409,13 +424,13 @@ async def sample_create_database():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.CreateDatabaseRequest, dict]):
+ 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`):
@@ -507,11 +522,13 @@ async def sample_create_database():
async def get_database(
self,
- request: Union[spanner_database_admin.GetDatabaseRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.GetDatabaseRequest, dict]
+ ] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner_database_admin.Database:
r"""Gets the state of a Cloud Spanner database.
@@ -543,7 +560,7 @@ async def sample_get_database():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.GetDatabaseRequest, dict]):
+ 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`):
@@ -618,12 +635,14 @@ async def sample_get_database():
async def update_database_ddl(
self,
- request: Union[spanner_database_admin.UpdateDatabaseDdlRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.UpdateDatabaseDdlRequest, dict]
+ ] = None,
*,
- database: str = None,
- statements: Sequence[str] = None,
+ database: Optional[str] = None,
+ statements: Optional[MutableSequence[str]] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Updates the schema of a Cloud Spanner database by
@@ -662,13 +681,13 @@ async def sample_update_database_ddl():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.UpdateDatabaseDdlRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.UpdateDatabaseDdlRequest, dict]]):
The request object. Enqueues the given DDL statements to
be applied, in order but not necessarily all at once, to
the database schema at some point (or points) in the
@@ -693,7 +712,7 @@ async def sample_update_database_ddl():
This corresponds to the ``database`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
- statements (:class:`Sequence[str]`):
+ statements (:class:`MutableSequence[str]`):
Required. DDL statements to be
applied to the database.
@@ -786,11 +805,13 @@ async def sample_update_database_ddl():
async def drop_database(
self,
- request: Union[spanner_database_admin.DropDatabaseRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.DropDatabaseRequest, dict]
+ ] = None,
*,
- database: str = None,
+ database: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Drops (aka deletes) a Cloud Spanner database. Completed backups
@@ -822,7 +843,7 @@ async def sample_drop_database():
await client.drop_database(request=request)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.DropDatabaseRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.DropDatabaseRequest, dict]]):
The request object. The request for
[DropDatabase][google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase].
database (:class:`str`):
@@ -887,11 +908,13 @@ async def sample_drop_database():
async def get_database_ddl(
self,
- request: Union[spanner_database_admin.GetDatabaseDdlRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.GetDatabaseDdlRequest, dict]
+ ] = None,
*,
- database: str = None,
+ database: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner_database_admin.GetDatabaseDdlResponse:
r"""Returns the schema of a Cloud Spanner database as a list of
@@ -926,7 +949,7 @@ async def sample_get_database_ddl():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlRequest, dict]]):
The request object. The request for
[GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
database (:class:`str`):
@@ -1003,11 +1026,11 @@ async def sample_get_database_ddl():
async def set_iam_policy(
self,
- request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None,
*,
- resource: str = None,
+ resource: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
r"""Sets the access control policy on a database or backup resource.
@@ -1048,7 +1071,7 @@ async def sample_set_iam_policy():
print(response)
Args:
- request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]):
+ request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]):
The request object. Request message for `SetIamPolicy`
method.
resource (:class:`str`):
@@ -1177,11 +1200,11 @@ async def sample_set_iam_policy():
async def get_iam_policy(
self,
- request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None,
*,
- resource: str = None,
+ resource: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
r"""Gets the access control policy for a database or backup
@@ -1223,7 +1246,7 @@ async def sample_get_iam_policy():
print(response)
Args:
- request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]):
+ request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]):
The request object. Request message for `GetIamPolicy`
method.
resource (:class:`str`):
@@ -1362,12 +1385,12 @@ async def sample_get_iam_policy():
async def test_iam_permissions(
self,
- request: Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None,
*,
- resource: str = None,
- permissions: Sequence[str] = None,
+ resource: Optional[str] = None,
+ permissions: Optional[MutableSequence[str]] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> iam_policy_pb2.TestIamPermissionsResponse:
r"""Returns permissions that the caller has on the specified
@@ -1410,7 +1433,7 @@ async def sample_test_iam_permissions():
print(response)
Args:
- request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]):
+ request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]):
The request object. Request message for
`TestIamPermissions` method.
resource (:class:`str`):
@@ -1422,7 +1445,7 @@ async def sample_test_iam_permissions():
This corresponds to the ``resource`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
- permissions (:class:`Sequence[str]`):
+ permissions (:class:`MutableSequence[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
@@ -1488,13 +1511,13 @@ async def sample_test_iam_permissions():
async def create_backup(
self,
- request: Union[gsad_backup.CreateBackupRequest, dict] = None,
+ request: Optional[Union[gsad_backup.CreateBackupRequest, dict]] = None,
*,
- parent: str = None,
- backup: gsad_backup.Backup = None,
- backup_id: str = None,
+ parent: Optional[str] = None,
+ backup: Optional[gsad_backup.Backup] = None,
+ backup_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Starts creating a new Cloud Spanner Backup. The returned backup
@@ -1537,13 +1560,13 @@ async def sample_create_backup():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.CreateBackupRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.CreateBackupRequest, dict]]):
The request object. The request for
[CreateBackup][google.spanner.admin.database.v1.DatabaseAdmin.CreateBackup].
parent (:class:`str`):
@@ -1643,14 +1666,14 @@ async def sample_create_backup():
async def copy_backup(
self,
- request: Union[backup.CopyBackupRequest, dict] = None,
+ request: Optional[Union[backup.CopyBackupRequest, dict]] = None,
*,
- parent: str = None,
- backup_id: str = None,
- source_backup: str = None,
- expire_time: timestamp_pb2.Timestamp = None,
+ parent: Optional[str] = None,
+ backup_id: Optional[str] = None,
+ source_backup: Optional[str] = None,
+ expire_time: Optional[timestamp_pb2.Timestamp] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Starts copying a Cloud Spanner Backup. The returned backup
@@ -1694,13 +1717,13 @@ async def sample_copy_backup():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.CopyBackupRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.CopyBackupRequest, dict]]):
The request object. The request for
[CopyBackup][google.spanner.admin.database.v1.DatabaseAdmin.CopyBackup].
parent (:class:`str`):
@@ -1816,11 +1839,11 @@ async def sample_copy_backup():
async def get_backup(
self,
- request: Union[backup.GetBackupRequest, dict] = None,
+ request: Optional[Union[backup.GetBackupRequest, dict]] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> backup.Backup:
r"""Gets metadata on a pending or completed
@@ -1853,7 +1876,7 @@ async def sample_get_backup():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.GetBackupRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.GetBackupRequest, dict]]):
The request object. The request for
[GetBackup][google.spanner.admin.database.v1.DatabaseAdmin.GetBackup].
name (:class:`str`):
@@ -1927,12 +1950,12 @@ async def sample_get_backup():
async def update_backup(
self,
- request: Union[gsad_backup.UpdateBackupRequest, dict] = None,
+ request: Optional[Union[gsad_backup.UpdateBackupRequest, dict]] = None,
*,
- backup: gsad_backup.Backup = None,
- update_mask: field_mask_pb2.FieldMask = None,
+ backup: Optional[gsad_backup.Backup] = None,
+ update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> gsad_backup.Backup:
r"""Updates a pending or completed
@@ -1964,7 +1987,7 @@ async def sample_update_backup():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.UpdateBackupRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.UpdateBackupRequest, dict]]):
The request object. The request for
[UpdateBackup][google.spanner.admin.database.v1.DatabaseAdmin.UpdateBackup].
backup (:class:`google.cloud.spanner_admin_database_v1.types.Backup`):
@@ -2058,11 +2081,11 @@ async def sample_update_backup():
async def delete_backup(
self,
- request: Union[backup.DeleteBackupRequest, dict] = None,
+ request: Optional[Union[backup.DeleteBackupRequest, dict]] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes a pending or completed
@@ -2092,7 +2115,7 @@ async def sample_delete_backup():
await client.delete_backup(request=request)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.DeleteBackupRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.DeleteBackupRequest, dict]]):
The request object. The request for
[DeleteBackup][google.spanner.admin.database.v1.DatabaseAdmin.DeleteBackup].
name (:class:`str`):
@@ -2160,11 +2183,11 @@ async def sample_delete_backup():
async def list_backups(
self,
- request: Union[backup.ListBackupsRequest, dict] = None,
+ request: Optional[Union[backup.ListBackupsRequest, dict]] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListBackupsAsyncPager:
r"""Lists completed and pending backups. Backups returned are
@@ -2199,7 +2222,7 @@ async def sample_list_backups():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.ListBackupsRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListBackupsRequest, dict]]):
The request object. The request for
[ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
parent (:class:`str`):
@@ -2287,13 +2310,15 @@ async def sample_list_backups():
async def restore_database(
self,
- request: Union[spanner_database_admin.RestoreDatabaseRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.RestoreDatabaseRequest, dict]
+ ] = None,
*,
- parent: str = None,
- database_id: str = None,
- backup: str = None,
+ parent: Optional[str] = None,
+ database_id: Optional[str] = None,
+ backup: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Create a new database by restoring from a completed backup. The
@@ -2343,13 +2368,13 @@ async def sample_restore_database():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.RestoreDatabaseRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.RestoreDatabaseRequest, dict]]):
The request object. The request for
[RestoreDatabase][google.spanner.admin.database.v1.DatabaseAdmin.RestoreDatabase].
parent (:class:`str`):
@@ -2451,13 +2476,13 @@ async def sample_restore_database():
async def list_database_operations(
self,
- request: Union[
- spanner_database_admin.ListDatabaseOperationsRequest, dict
+ request: Optional[
+ Union[spanner_database_admin.ListDatabaseOperationsRequest, dict]
] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDatabaseOperationsAsyncPager:
r"""Lists database
@@ -2499,7 +2524,7 @@ async def sample_list_database_operations():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.ListDatabaseOperationsRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListDatabaseOperationsRequest, dict]]):
The request object. The request for
[ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
parent (:class:`str`):
@@ -2588,11 +2613,11 @@ async def sample_list_database_operations():
async def list_backup_operations(
self,
- request: Union[backup.ListBackupOperationsRequest, dict] = None,
+ request: Optional[Union[backup.ListBackupOperationsRequest, dict]] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListBackupOperationsAsyncPager:
r"""Lists the backup [long-running
@@ -2636,7 +2661,7 @@ async def sample_list_backup_operations():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.ListBackupOperationsRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListBackupOperationsRequest, dict]]):
The request object. The request for
[ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
parent (:class:`str`):
@@ -2725,11 +2750,13 @@ async def sample_list_backup_operations():
async def list_database_roles(
self,
- request: Union[spanner_database_admin.ListDatabaseRolesRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.ListDatabaseRolesRequest, dict]
+ ] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDatabaseRolesAsyncPager:
r"""Lists Cloud Spanner database roles.
@@ -2762,7 +2789,7 @@ async def sample_list_database_roles():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_database_v1.types.ListDatabaseRolesRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_database_v1.types.ListDatabaseRolesRequest, dict]]):
The request object. The request for
[ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles].
parent (:class:`str`):
@@ -2851,10 +2878,10 @@ async def sample_list_database_roles():
async def list_operations(
self,
- request: operations_pb2.ListOperationsRequest = None,
+ request: Optional[operations_pb2.ListOperationsRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.ListOperationsResponse:
r"""Lists operations that match the specified filter in the request.
@@ -2905,10 +2932,10 @@ async def list_operations(
async def get_operation(
self,
- request: operations_pb2.GetOperationRequest = None,
+ request: Optional[operations_pb2.GetOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.Operation:
r"""Gets the latest state of a long-running operation.
@@ -2959,10 +2986,10 @@ async def get_operation(
async def delete_operation(
self,
- request: operations_pb2.DeleteOperationRequest = None,
+ request: Optional[operations_pb2.DeleteOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes a long-running operation.
@@ -3014,10 +3041,10 @@ async def delete_operation(
async def cancel_operation(
self,
- request: operations_pb2.CancelOperationRequest = None,
+ request: Optional[operations_pb2.CancelOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Starts asynchronous cancellation on a long-running operation.
@@ -3073,14 +3100,9 @@ async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()
-try:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
- gapic_version=pkg_resources.get_distribution(
- "google-cloud-spanner-admin-database",
- ).version,
- )
-except pkg_resources.DistributionNotFound:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=package_version.__version__
+)
__all__ = ("DatabaseAdminAsyncClient",)
diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py
index 23635da722..9c0fc4a0a6 100644
--- a/google/cloud/spanner_admin_database_v1/services/database_admin/client.py
+++ b/google/cloud/spanner_admin_database_v1/services/database_admin/client.py
@@ -16,8 +16,20 @@
from collections import OrderedDict
import os
import re
-from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
-import pkg_resources
+from typing import (
+ Dict,
+ Mapping,
+ MutableMapping,
+ MutableSequence,
+ Optional,
+ Sequence,
+ Tuple,
+ Type,
+ Union,
+ cast,
+)
+
+from google.cloud.spanner_admin_database_v1 import gapic_version as package_version
from google.api_core import client_options as client_options_lib
from google.api_core import exceptions as core_exceptions
@@ -67,7 +79,7 @@ class DatabaseAdminClientMeta(type):
def get_transport_class(
cls,
- label: str = None,
+ label: Optional[str] = None,
) -> Type[DatabaseAdminTransport]:
"""Returns an appropriate transport class.
@@ -408,7 +420,7 @@ def get_mtls_endpoint_and_cert_source(
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 variabel is "never", use the default API
+ 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.
@@ -463,8 +475,8 @@ def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
- transport: Union[str, DatabaseAdminTransport, None] = None,
- client_options: Optional[client_options_lib.ClientOptions] = None,
+ transport: Optional[Union[str, DatabaseAdminTransport]] = None,
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiates the database admin client.
@@ -478,7 +490,7 @@ def __init__(
transport (Union[str, DatabaseAdminTransport]): The
transport to use. If set to None, a transport is chosen
automatically.
- client_options (google.api_core.client_options.ClientOptions): Custom options for the
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
client. It won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
@@ -508,6 +520,7 @@ def __init__(
client_options = client_options_lib.from_dict(client_options)
if client_options is None:
client_options = client_options_lib.ClientOptions()
+ client_options = cast(client_options_lib.ClientOptions, client_options)
api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(
client_options
@@ -560,11 +573,13 @@ def __init__(
def list_databases(
self,
- request: Union[spanner_database_admin.ListDatabasesRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.ListDatabasesRequest, dict]
+ ] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDatabasesPager:
r"""Lists Cloud Spanner databases.
@@ -676,12 +691,14 @@ def sample_list_databases():
def create_database(
self,
- request: Union[spanner_database_admin.CreateDatabaseRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.CreateDatabaseRequest, dict]
+ ] = None,
*,
- parent: str = None,
- create_statement: str = None,
+ parent: Optional[str] = None,
+ create_statement: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Creates a new Cloud Spanner database and starts to prepare it
@@ -819,11 +836,13 @@ def sample_create_database():
def get_database(
self,
- request: Union[spanner_database_admin.GetDatabaseRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.GetDatabaseRequest, dict]
+ ] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner_database_admin.Database:
r"""Gets the state of a Cloud Spanner database.
@@ -920,12 +939,14 @@ def sample_get_database():
def update_database_ddl(
self,
- request: Union[spanner_database_admin.UpdateDatabaseDdlRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.UpdateDatabaseDdlRequest, dict]
+ ] = None,
*,
- database: str = None,
- statements: Sequence[str] = None,
+ database: Optional[str] = None,
+ statements: Optional[MutableSequence[str]] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Updates the schema of a Cloud Spanner database by
@@ -995,7 +1016,7 @@ def sample_update_database_ddl():
This corresponds to the ``database`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
- statements (Sequence[str]):
+ statements (MutableSequence[str]):
Required. DDL statements to be
applied to the database.
@@ -1078,11 +1099,13 @@ def sample_update_database_ddl():
def drop_database(
self,
- request: Union[spanner_database_admin.DropDatabaseRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.DropDatabaseRequest, dict]
+ ] = None,
*,
- database: str = None,
+ database: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Drops (aka deletes) a Cloud Spanner database. Completed backups
@@ -1169,11 +1192,13 @@ def sample_drop_database():
def get_database_ddl(
self,
- request: Union[spanner_database_admin.GetDatabaseDdlRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.GetDatabaseDdlRequest, dict]
+ ] = None,
*,
- database: str = None,
+ database: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner_database_admin.GetDatabaseDdlResponse:
r"""Returns the schema of a Cloud Spanner database as a list of
@@ -1275,11 +1300,11 @@ def sample_get_database_ddl():
def set_iam_policy(
self,
- request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None,
*,
- resource: str = None,
+ resource: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
r"""Sets the access control policy on a database or backup resource.
@@ -1446,11 +1471,11 @@ def sample_set_iam_policy():
def get_iam_policy(
self,
- request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None,
*,
- resource: str = None,
+ resource: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
r"""Gets the access control policy for a database or backup
@@ -1618,12 +1643,12 @@ def sample_get_iam_policy():
def test_iam_permissions(
self,
- request: Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None,
*,
- resource: str = None,
- permissions: Sequence[str] = None,
+ resource: Optional[str] = None,
+ permissions: Optional[MutableSequence[str]] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> iam_policy_pb2.TestIamPermissionsResponse:
r"""Returns permissions that the caller has on the specified
@@ -1678,7 +1703,7 @@ def sample_test_iam_permissions():
This corresponds to the ``resource`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
- permissions (Sequence[str]):
+ permissions (MutableSequence[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
@@ -1742,13 +1767,13 @@ def sample_test_iam_permissions():
def create_backup(
self,
- request: Union[gsad_backup.CreateBackupRequest, dict] = None,
+ request: Optional[Union[gsad_backup.CreateBackupRequest, dict]] = None,
*,
- parent: str = None,
- backup: gsad_backup.Backup = None,
- backup_id: str = None,
+ parent: Optional[str] = None,
+ backup: Optional[gsad_backup.Backup] = None,
+ backup_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Starts creating a new Cloud Spanner Backup. The returned backup
@@ -1897,14 +1922,14 @@ def sample_create_backup():
def copy_backup(
self,
- request: Union[backup.CopyBackupRequest, dict] = None,
+ request: Optional[Union[backup.CopyBackupRequest, dict]] = None,
*,
- parent: str = None,
- backup_id: str = None,
- source_backup: str = None,
- expire_time: timestamp_pb2.Timestamp = None,
+ parent: Optional[str] = None,
+ backup_id: Optional[str] = None,
+ source_backup: Optional[str] = None,
+ expire_time: Optional[timestamp_pb2.Timestamp] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Starts copying a Cloud Spanner Backup. The returned backup
@@ -2070,11 +2095,11 @@ def sample_copy_backup():
def get_backup(
self,
- request: Union[backup.GetBackupRequest, dict] = None,
+ request: Optional[Union[backup.GetBackupRequest, dict]] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> backup.Backup:
r"""Gets metadata on a pending or completed
@@ -2171,12 +2196,12 @@ def sample_get_backup():
def update_backup(
self,
- request: Union[gsad_backup.UpdateBackupRequest, dict] = None,
+ request: Optional[Union[gsad_backup.UpdateBackupRequest, dict]] = None,
*,
- backup: gsad_backup.Backup = None,
- update_mask: field_mask_pb2.FieldMask = None,
+ backup: Optional[gsad_backup.Backup] = None,
+ update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> gsad_backup.Backup:
r"""Updates a pending or completed
@@ -2292,11 +2317,11 @@ def sample_update_backup():
def delete_backup(
self,
- request: Union[backup.DeleteBackupRequest, dict] = None,
+ request: Optional[Union[backup.DeleteBackupRequest, dict]] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes a pending or completed
@@ -2384,11 +2409,11 @@ def sample_delete_backup():
def list_backups(
self,
- request: Union[backup.ListBackupsRequest, dict] = None,
+ request: Optional[Union[backup.ListBackupsRequest, dict]] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListBackupsPager:
r"""Lists completed and pending backups. Backups returned are
@@ -2501,13 +2526,15 @@ def sample_list_backups():
def restore_database(
self,
- request: Union[spanner_database_admin.RestoreDatabaseRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.RestoreDatabaseRequest, dict]
+ ] = None,
*,
- parent: str = None,
- database_id: str = None,
- backup: str = None,
+ parent: Optional[str] = None,
+ database_id: Optional[str] = None,
+ backup: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Create a new database by restoring from a completed backup. The
@@ -2665,13 +2692,13 @@ def sample_restore_database():
def list_database_operations(
self,
- request: Union[
- spanner_database_admin.ListDatabaseOperationsRequest, dict
+ request: Optional[
+ Union[spanner_database_admin.ListDatabaseOperationsRequest, dict]
] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDatabaseOperationsPager:
r"""Lists database
@@ -2794,11 +2821,11 @@ def sample_list_database_operations():
def list_backup_operations(
self,
- request: Union[backup.ListBackupOperationsRequest, dict] = None,
+ request: Optional[Union[backup.ListBackupOperationsRequest, dict]] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListBackupOperationsPager:
r"""Lists the backup [long-running
@@ -2921,11 +2948,13 @@ def sample_list_backup_operations():
def list_database_roles(
self,
- request: Union[spanner_database_admin.ListDatabaseRolesRequest, dict] = None,
+ request: Optional[
+ Union[spanner_database_admin.ListDatabaseRolesRequest, dict]
+ ] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListDatabaseRolesPager:
r"""Lists Cloud Spanner database roles.
@@ -3050,10 +3079,10 @@ def __exit__(self, type, value, traceback):
def list_operations(
self,
- request: operations_pb2.ListOperationsRequest = None,
+ request: Optional[operations_pb2.ListOperationsRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.ListOperationsResponse:
r"""Lists operations that match the specified filter in the request.
@@ -3104,10 +3133,10 @@ def list_operations(
def get_operation(
self,
- request: operations_pb2.GetOperationRequest = None,
+ request: Optional[operations_pb2.GetOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operations_pb2.Operation:
r"""Gets the latest state of a long-running operation.
@@ -3158,10 +3187,10 @@ def get_operation(
def delete_operation(
self,
- request: operations_pb2.DeleteOperationRequest = None,
+ request: Optional[operations_pb2.DeleteOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes a long-running operation.
@@ -3213,10 +3242,10 @@ def delete_operation(
def cancel_operation(
self,
- request: operations_pb2.CancelOperationRequest = None,
+ request: Optional[operations_pb2.CancelOperationRequest] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Starts asynchronous cancellation on a long-running operation.
@@ -3266,14 +3295,9 @@ def cancel_operation(
)
-try:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
- gapic_version=pkg_resources.get_distribution(
- "google-cloud-spanner-admin-database",
- ).version,
- )
-except pkg_resources.DistributionNotFound:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=package_version.__version__
+)
__all__ = ("DatabaseAdminClient",)
diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py
index 26ac640940..e4a522e7ca 100644
--- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py
+++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/base.py
@@ -15,7 +15,8 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
-import pkg_resources
+
+from google.cloud.spanner_admin_database_v1 import gapic_version as package_version
import google.auth # type: ignore
import google.api_core
@@ -35,14 +36,9 @@
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore
-try:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
- gapic_version=pkg_resources.get_distribution(
- "google-cloud-spanner-admin-database",
- ).version,
- )
-except pkg_resources.DistributionNotFound:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=package_version.__version__
+)
class DatabaseAdminTransport(abc.ABC):
@@ -59,7 +55,7 @@ def __init__(
self,
*,
host: str = DEFAULT_HOST,
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py
index bdff991c79..b39f0758e2 100644
--- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py
+++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc.py
@@ -62,14 +62,14 @@ def __init__(
self,
*,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
- credentials_file: str = None,
- scopes: Sequence[str] = None,
- channel: grpc.Channel = None,
- api_mtls_endpoint: str = None,
- client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
- ssl_channel_credentials: grpc.ChannelCredentials = None,
- client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ channel: Optional[grpc.Channel] = None,
+ api_mtls_endpoint: Optional[str] = None,
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
always_use_jwt_access: Optional[bool] = False,
@@ -197,8 +197,8 @@ def __init__(
def create_channel(
cls,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
- credentials_file: str = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
+ credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
**kwargs,
diff --git a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py
index 40cb38cf28..0d5fccf84a 100644
--- a/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py
+++ b/google/cloud/spanner_admin_database_v1/services/database_admin/transports/grpc_asyncio.py
@@ -64,7 +64,7 @@ class DatabaseAdminGrpcAsyncIOTransport(DatabaseAdminTransport):
def create_channel(
cls,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
@@ -107,15 +107,15 @@ def __init__(
self,
*,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
- channel: aio.Channel = None,
- api_mtls_endpoint: str = None,
- client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
- ssl_channel_credentials: grpc.ChannelCredentials = None,
- client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
- quota_project_id=None,
+ channel: Optional[aio.Channel] = None,
+ api_mtls_endpoint: Optional[str] = None,
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
+ quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
always_use_jwt_access: Optional[bool] = False,
api_audience: Optional[str] = None,
diff --git a/google/cloud/spanner_admin_database_v1/types/backup.py b/google/cloud/spanner_admin_database_v1/types/backup.py
index dd42c409b9..12dc541dc3 100644
--- a/google/cloud/spanner_admin_database_v1/types/backup.py
+++ b/google/cloud/spanner_admin_database_v1/types/backup.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.cloud.spanner_admin_database_v1.types import common
@@ -95,7 +97,7 @@ class Backup(proto.Message):
Output only. Size of the backup in bytes.
state (google.cloud.spanner_admin_database_v1.types.Backup.State):
Output only. The current state of the backup.
- referencing_databases (Sequence[str]):
+ referencing_databases (MutableSequence[str]):
Output only. The names of the restored databases that
reference the backup. The database names are of the form
``projects//instances//databases/``.
@@ -110,7 +112,7 @@ class Backup(proto.Message):
database_dialect (google.cloud.spanner_admin_database_v1.types.DatabaseDialect):
Output only. The database dialect information
for the backup.
- referencing_backups (Sequence[str]):
+ referencing_backups (MutableSequence[str]):
Output only. The names of the destination backups being
created by copying this source backup. The backup names are
of the form
@@ -135,57 +137,57 @@ class State(proto.Enum):
CREATING = 1
READY = 2
- database = proto.Field(
+ database: str = proto.Field(
proto.STRING,
number=2,
)
- version_time = proto.Field(
+ version_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=9,
message=timestamp_pb2.Timestamp,
)
- expire_time = proto.Field(
+ expire_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
)
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- create_time = proto.Field(
+ create_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=4,
message=timestamp_pb2.Timestamp,
)
- size_bytes = proto.Field(
+ size_bytes: int = proto.Field(
proto.INT64,
number=5,
)
- state = proto.Field(
+ state: State = proto.Field(
proto.ENUM,
number=6,
enum=State,
)
- referencing_databases = proto.RepeatedField(
+ referencing_databases: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=7,
)
- encryption_info = proto.Field(
+ encryption_info: common.EncryptionInfo = proto.Field(
proto.MESSAGE,
number=8,
message=common.EncryptionInfo,
)
- database_dialect = proto.Field(
+ database_dialect: common.DatabaseDialect = proto.Field(
proto.ENUM,
number=10,
enum=common.DatabaseDialect,
)
- referencing_backups = proto.RepeatedField(
+ referencing_backups: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=11,
)
- max_expire_time = proto.Field(
+ max_expire_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=12,
message=timestamp_pb2.Timestamp,
@@ -220,20 +222,20 @@ class CreateBackupRequest(proto.Message):
= ``USE_DATABASE_ENCRYPTION``.
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- backup_id = proto.Field(
+ backup_id: str = proto.Field(
proto.STRING,
number=2,
)
- backup = proto.Field(
+ backup: "Backup" = proto.Field(
proto.MESSAGE,
number=3,
message="Backup",
)
- encryption_config = proto.Field(
+ encryption_config: "CreateBackupEncryptionConfig" = proto.Field(
proto.MESSAGE,
number=4,
message="CreateBackupEncryptionConfig",
@@ -271,20 +273,20 @@ class CreateBackupMetadata(proto.Message):
1, corresponding to ``Code.CANCELLED``.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- database = proto.Field(
+ database: str = proto.Field(
proto.STRING,
number=2,
)
- progress = proto.Field(
+ progress: common.OperationProgress = proto.Field(
proto.MESSAGE,
number=3,
message=common.OperationProgress,
)
- cancel_time = proto.Field(
+ cancel_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=4,
message=timestamp_pb2.Timestamp,
@@ -327,24 +329,24 @@ class CopyBackupRequest(proto.Message):
= ``USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION``.
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- backup_id = proto.Field(
+ backup_id: str = proto.Field(
proto.STRING,
number=2,
)
- source_backup = proto.Field(
+ source_backup: str = proto.Field(
proto.STRING,
number=3,
)
- expire_time = proto.Field(
+ expire_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=4,
message=timestamp_pb2.Timestamp,
)
- encryption_config = proto.Field(
+ encryption_config: "CopyBackupEncryptionConfig" = proto.Field(
proto.MESSAGE,
number=5,
message="CopyBackupEncryptionConfig",
@@ -385,20 +387,20 @@ class CopyBackupMetadata(proto.Message):
1, corresponding to ``Code.CANCELLED``.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- source_backup = proto.Field(
+ source_backup: str = proto.Field(
proto.STRING,
number=2,
)
- progress = proto.Field(
+ progress: common.OperationProgress = proto.Field(
proto.MESSAGE,
number=3,
message=common.OperationProgress,
)
- cancel_time = proto.Field(
+ cancel_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=4,
message=timestamp_pb2.Timestamp,
@@ -426,12 +428,12 @@ class UpdateBackupRequest(proto.Message):
accidentally by clients that do not know about them.
"""
- backup = proto.Field(
+ backup: "Backup" = proto.Field(
proto.MESSAGE,
number=1,
message="Backup",
)
- update_mask = proto.Field(
+ update_mask: field_mask_pb2.FieldMask = proto.Field(
proto.MESSAGE,
number=2,
message=field_mask_pb2.FieldMask,
@@ -448,7 +450,7 @@ class GetBackupRequest(proto.Message):
``projects//instances//backups/``.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
@@ -465,7 +467,7 @@ class DeleteBackupRequest(proto.Message):
``projects//instances//backups/``.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
@@ -538,19 +540,19 @@ class ListBackupsRequest(proto.Message):
to the same ``parent`` and with the same ``filter``.
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- filter = proto.Field(
+ filter: str = proto.Field(
proto.STRING,
number=2,
)
- page_size = proto.Field(
+ page_size: int = proto.Field(
proto.INT32,
number=3,
)
- page_token = proto.Field(
+ page_token: str = proto.Field(
proto.STRING,
number=4,
)
@@ -561,7 +563,7 @@ class ListBackupsResponse(proto.Message):
[ListBackups][google.spanner.admin.database.v1.DatabaseAdmin.ListBackups].
Attributes:
- backups (Sequence[google.cloud.spanner_admin_database_v1.types.Backup]):
+ backups (MutableSequence[google.cloud.spanner_admin_database_v1.types.Backup]):
The list of matching backups. Backups returned are ordered
by ``create_time`` in descending order, starting from the
most recent ``create_time``.
@@ -575,12 +577,12 @@ class ListBackupsResponse(proto.Message):
def raw_page(self):
return self
- backups = proto.RepeatedField(
+ backups: MutableSequence["Backup"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="Backup",
)
- next_page_token = proto.Field(
+ next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
@@ -694,19 +696,19 @@ class ListBackupOperationsRequest(proto.Message):
to the same ``parent`` and with the same ``filter``.
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- filter = proto.Field(
+ filter: str = proto.Field(
proto.STRING,
number=2,
)
- page_size = proto.Field(
+ page_size: int = proto.Field(
proto.INT32,
number=3,
)
- page_token = proto.Field(
+ page_token: str = proto.Field(
proto.STRING,
number=4,
)
@@ -717,7 +719,7 @@ class ListBackupOperationsResponse(proto.Message):
[ListBackupOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListBackupOperations].
Attributes:
- operations (Sequence[google.longrunning.operations_pb2.Operation]):
+ operations (MutableSequence[google.longrunning.operations_pb2.Operation]):
The list of matching backup [long-running
operations][google.longrunning.Operation]. Each operation's
name will be prefixed by the backup's name. The operation's
@@ -739,12 +741,12 @@ class ListBackupOperationsResponse(proto.Message):
def raw_page(self):
return self
- operations = proto.RepeatedField(
+ operations: MutableSequence[operations_pb2.Operation] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message=operations_pb2.Operation,
)
- next_page_token = proto.Field(
+ next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
@@ -773,21 +775,21 @@ class BackupInfo(proto.Message):
from.
"""
- backup = proto.Field(
+ backup: str = proto.Field(
proto.STRING,
number=1,
)
- version_time = proto.Field(
+ version_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=4,
message=timestamp_pb2.Timestamp,
)
- create_time = proto.Field(
+ create_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=2,
message=timestamp_pb2.Timestamp,
)
- source_database = proto.Field(
+ source_database: str = proto.Field(
proto.STRING,
number=3,
)
@@ -814,12 +816,12 @@ class EncryptionType(proto.Enum):
GOOGLE_DEFAULT_ENCRYPTION = 2
CUSTOMER_MANAGED_ENCRYPTION = 3
- encryption_type = proto.Field(
+ encryption_type: EncryptionType = proto.Field(
proto.ENUM,
number=1,
enum=EncryptionType,
)
- kms_key_name = proto.Field(
+ kms_key_name: str = proto.Field(
proto.STRING,
number=2,
)
@@ -846,12 +848,12 @@ class EncryptionType(proto.Enum):
GOOGLE_DEFAULT_ENCRYPTION = 2
CUSTOMER_MANAGED_ENCRYPTION = 3
- encryption_type = proto.Field(
+ encryption_type: EncryptionType = proto.Field(
proto.ENUM,
number=1,
enum=EncryptionType,
)
- kms_key_name = proto.Field(
+ kms_key_name: str = proto.Field(
proto.STRING,
number=2,
)
diff --git a/google/cloud/spanner_admin_database_v1/types/common.py b/google/cloud/spanner_admin_database_v1/types/common.py
index 6475e588bc..c55fb0c5e4 100644
--- a/google/cloud/spanner_admin_database_v1/types/common.py
+++ b/google/cloud/spanner_admin_database_v1/types/common.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
@@ -52,16 +54,16 @@ class OperationProgress(proto.Message):
failed or was completed successfully.
"""
- progress_percent = proto.Field(
+ progress_percent: int = proto.Field(
proto.INT32,
number=1,
)
- start_time = proto.Field(
+ start_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=2,
message=timestamp_pb2.Timestamp,
)
- end_time = proto.Field(
+ end_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
@@ -78,7 +80,7 @@ class EncryptionConfig(proto.Message):
``projects//locations//keyRings//cryptoKeys/``.
"""
- kms_key_name = proto.Field(
+ kms_key_name: str = proto.Field(
proto.STRING,
number=2,
)
@@ -107,17 +109,17 @@ class Type(proto.Enum):
GOOGLE_DEFAULT_ENCRYPTION = 1
CUSTOMER_MANAGED_ENCRYPTION = 2
- encryption_type = proto.Field(
+ encryption_type: Type = proto.Field(
proto.ENUM,
number=3,
enum=Type,
)
- encryption_status = proto.Field(
+ encryption_status: status_pb2.Status = proto.Field(
proto.MESSAGE,
number=4,
message=status_pb2.Status,
)
- kms_key_version = proto.Field(
+ kms_key_version: str = proto.Field(
proto.STRING,
number=2,
)
diff --git a/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py b/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py
index 17685ac754..c6f998b6b7 100644
--- a/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py
+++ b/google/cloud/spanner_admin_database_v1/types/spanner_database_admin.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.cloud.spanner_admin_database_v1.types import backup as gsad_backup
@@ -71,12 +73,12 @@ class RestoreInfo(proto.Message):
This field is a member of `oneof`_ ``source_info``.
"""
- source_type = proto.Field(
+ source_type: "RestoreSourceType" = proto.Field(
proto.ENUM,
number=1,
enum="RestoreSourceType",
)
- backup_info = proto.Field(
+ backup_info: gsad_backup.BackupInfo = proto.Field(
proto.MESSAGE,
number=2,
oneof="source_info",
@@ -109,7 +111,7 @@ class Database(proto.Message):
the encryption configuration for the database.
For databases that are using Google default or
other types of encryption, this field is empty.
- encryption_info (Sequence[google.cloud.spanner_admin_database_v1.types.EncryptionInfo]):
+ encryption_info (MutableSequence[google.cloud.spanner_admin_database_v1.types.EncryptionInfo]):
Output only. For databases that are using
customer managed encryption, this field contains
the encryption information for the database,
@@ -157,49 +159,49 @@ class State(proto.Enum):
READY = 2
READY_OPTIMIZING = 3
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- state = proto.Field(
+ state: State = proto.Field(
proto.ENUM,
number=2,
enum=State,
)
- create_time = proto.Field(
+ create_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
)
- restore_info = proto.Field(
+ restore_info: "RestoreInfo" = proto.Field(
proto.MESSAGE,
number=4,
message="RestoreInfo",
)
- encryption_config = proto.Field(
+ encryption_config: common.EncryptionConfig = proto.Field(
proto.MESSAGE,
number=5,
message=common.EncryptionConfig,
)
- encryption_info = proto.RepeatedField(
+ encryption_info: MutableSequence[common.EncryptionInfo] = proto.RepeatedField(
proto.MESSAGE,
number=8,
message=common.EncryptionInfo,
)
- version_retention_period = proto.Field(
+ version_retention_period: str = proto.Field(
proto.STRING,
number=6,
)
- earliest_version_time = proto.Field(
+ earliest_version_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=7,
message=timestamp_pb2.Timestamp,
)
- default_leader = proto.Field(
+ default_leader: str = proto.Field(
proto.STRING,
number=9,
)
- database_dialect = proto.Field(
+ database_dialect: common.DatabaseDialect = proto.Field(
proto.ENUM,
number=10,
enum=common.DatabaseDialect,
@@ -226,15 +228,15 @@ class ListDatabasesRequest(proto.Message):
[ListDatabasesResponse][google.spanner.admin.database.v1.ListDatabasesResponse].
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- page_size = proto.Field(
+ page_size: int = proto.Field(
proto.INT32,
number=3,
)
- page_token = proto.Field(
+ page_token: str = proto.Field(
proto.STRING,
number=4,
)
@@ -245,7 +247,7 @@ class ListDatabasesResponse(proto.Message):
[ListDatabases][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases].
Attributes:
- databases (Sequence[google.cloud.spanner_admin_database_v1.types.Database]):
+ databases (MutableSequence[google.cloud.spanner_admin_database_v1.types.Database]):
Databases that matched the request.
next_page_token (str):
``next_page_token`` can be sent in a subsequent
@@ -257,12 +259,12 @@ class ListDatabasesResponse(proto.Message):
def raw_page(self):
return self
- databases = proto.RepeatedField(
+ databases: MutableSequence["Database"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="Database",
)
- next_page_token = proto.Field(
+ next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
@@ -284,7 +286,7 @@ class CreateDatabaseRequest(proto.Message):
between 2 and 30 characters in length. If the database ID is
a reserved word or if it contains a hyphen, the database ID
must be enclosed in backticks (:literal:`\``).
- extra_statements (Sequence[str]):
+ extra_statements (MutableSequence[str]):
Optional. A list of DDL statements to run
inside the newly created database. Statements
can create tables, indexes, etc. These
@@ -301,24 +303,24 @@ class CreateDatabaseRequest(proto.Message):
Database.
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- create_statement = proto.Field(
+ create_statement: str = proto.Field(
proto.STRING,
number=2,
)
- extra_statements = proto.RepeatedField(
+ extra_statements: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=3,
)
- encryption_config = proto.Field(
+ encryption_config: common.EncryptionConfig = proto.Field(
proto.MESSAGE,
number=4,
message=common.EncryptionConfig,
)
- database_dialect = proto.Field(
+ database_dialect: common.DatabaseDialect = proto.Field(
proto.ENUM,
number=5,
enum=common.DatabaseDialect,
@@ -334,7 +336,7 @@ class CreateDatabaseMetadata(proto.Message):
The database being created.
"""
- database = proto.Field(
+ database: str = proto.Field(
proto.STRING,
number=1,
)
@@ -351,7 +353,7 @@ class GetDatabaseRequest(proto.Message):
``projects//instances//databases/``.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
@@ -378,7 +380,7 @@ class UpdateDatabaseDdlRequest(proto.Message):
Attributes:
database (str):
Required. The database to update.
- statements (Sequence[str]):
+ statements (MutableSequence[str]):
Required. DDL statements to be applied to the
database.
operation_id (str):
@@ -405,15 +407,15 @@ class UpdateDatabaseDdlRequest(proto.Message):
returns ``ALREADY_EXISTS``.
"""
- database = proto.Field(
+ database: str = proto.Field(
proto.STRING,
number=1,
)
- statements = proto.RepeatedField(
+ statements: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=2,
)
- operation_id = proto.Field(
+ operation_id: str = proto.Field(
proto.STRING,
number=3,
)
@@ -426,11 +428,11 @@ class UpdateDatabaseDdlMetadata(proto.Message):
Attributes:
database (str):
The database being modified.
- statements (Sequence[str]):
+ statements (MutableSequence[str]):
For an update this list contains all the
statements. For an individual statement, this
list contains only that statement.
- commit_timestamps (Sequence[google.protobuf.timestamp_pb2.Timestamp]):
+ commit_timestamps (MutableSequence[google.protobuf.timestamp_pb2.Timestamp]):
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]``.
@@ -440,7 +442,7 @@ class UpdateDatabaseDdlMetadata(proto.Message):
constraints. When resources become available the
operation will resume and this field will be
false again.
- progress (Sequence[google.cloud.spanner_admin_database_v1.types.OperationProgress]):
+ progress (MutableSequence[google.cloud.spanner_admin_database_v1.types.OperationProgress]):
The progress of the
[UpdateDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl]
operations. Currently, only index creation statements will
@@ -452,24 +454,24 @@ class UpdateDatabaseDdlMetadata(proto.Message):
``statements[i]``.
"""
- database = proto.Field(
+ database: str = proto.Field(
proto.STRING,
number=1,
)
- statements = proto.RepeatedField(
+ statements: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=2,
)
- commit_timestamps = proto.RepeatedField(
+ commit_timestamps: MutableSequence[timestamp_pb2.Timestamp] = proto.RepeatedField(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
)
- throttled = proto.Field(
+ throttled: bool = proto.Field(
proto.BOOL,
number=4,
)
- progress = proto.RepeatedField(
+ progress: MutableSequence[common.OperationProgress] = proto.RepeatedField(
proto.MESSAGE,
number=5,
message=common.OperationProgress,
@@ -485,7 +487,7 @@ class DropDatabaseRequest(proto.Message):
Required. The database to be dropped.
"""
- database = proto.Field(
+ database: str = proto.Field(
proto.STRING,
number=1,
)
@@ -502,7 +504,7 @@ class GetDatabaseDdlRequest(proto.Message):
``projects//instances//databases/``
"""
- database = proto.Field(
+ database: str = proto.Field(
proto.STRING,
number=1,
)
@@ -513,13 +515,13 @@ class GetDatabaseDdlResponse(proto.Message):
[GetDatabaseDdl][google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl].
Attributes:
- statements (Sequence[str]):
+ statements (MutableSequence[str]):
A list of formatted DDL statements defining
the schema of the database specified in the
request.
"""
- statements = proto.RepeatedField(
+ statements: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=1,
)
@@ -597,19 +599,19 @@ class ListDatabaseOperationsRequest(proto.Message):
to the same ``parent`` and with the same ``filter``.
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- filter = proto.Field(
+ filter: str = proto.Field(
proto.STRING,
number=2,
)
- page_size = proto.Field(
+ page_size: int = proto.Field(
proto.INT32,
number=3,
)
- page_token = proto.Field(
+ page_token: str = proto.Field(
proto.STRING,
number=4,
)
@@ -620,7 +622,7 @@ class ListDatabaseOperationsResponse(proto.Message):
[ListDatabaseOperations][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseOperations].
Attributes:
- operations (Sequence[google.longrunning.operations_pb2.Operation]):
+ operations (MutableSequence[google.longrunning.operations_pb2.Operation]):
The list of matching database [long-running
operations][google.longrunning.Operation]. Each operation's
name will be prefixed by the database's name. The
@@ -637,12 +639,12 @@ class ListDatabaseOperationsResponse(proto.Message):
def raw_page(self):
return self
- operations = proto.RepeatedField(
+ operations: MutableSequence[operations_pb2.Operation] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message=operations_pb2.Operation,
)
- next_page_token = proto.Field(
+ next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
@@ -684,20 +686,20 @@ class RestoreDatabaseRequest(proto.Message):
= ``USE_CONFIG_DEFAULT_OR_BACKUP_ENCRYPTION``.
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- database_id = proto.Field(
+ database_id: str = proto.Field(
proto.STRING,
number=2,
)
- backup = proto.Field(
+ backup: str = proto.Field(
proto.STRING,
number=3,
oneof="source",
)
- encryption_config = proto.Field(
+ encryption_config: "RestoreDatabaseEncryptionConfig" = proto.Field(
proto.MESSAGE,
number=4,
message="RestoreDatabaseEncryptionConfig",
@@ -727,12 +729,12 @@ class EncryptionType(proto.Enum):
GOOGLE_DEFAULT_ENCRYPTION = 2
CUSTOMER_MANAGED_ENCRYPTION = 3
- encryption_type = proto.Field(
+ encryption_type: EncryptionType = proto.Field(
proto.ENUM,
number=1,
enum=EncryptionType,
)
- kms_key_name = proto.Field(
+ kms_key_name: str = proto.Field(
proto.STRING,
number=2,
)
@@ -791,32 +793,32 @@ class RestoreDatabaseMetadata(proto.Message):
if the restore was not successful.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- source_type = proto.Field(
+ source_type: "RestoreSourceType" = proto.Field(
proto.ENUM,
number=2,
enum="RestoreSourceType",
)
- backup_info = proto.Field(
+ backup_info: gsad_backup.BackupInfo = proto.Field(
proto.MESSAGE,
number=3,
oneof="source_info",
message=gsad_backup.BackupInfo,
)
- progress = proto.Field(
+ progress: common.OperationProgress = proto.Field(
proto.MESSAGE,
number=4,
message=common.OperationProgress,
)
- cancel_time = proto.Field(
+ cancel_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=5,
message=timestamp_pb2.Timestamp,
)
- optimize_database_operation_name = proto.Field(
+ optimize_database_operation_name: str = proto.Field(
proto.STRING,
number=6,
)
@@ -838,11 +840,11 @@ class OptimizeRestoredDatabaseMetadata(proto.Message):
optimizations.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- progress = proto.Field(
+ progress: common.OperationProgress = proto.Field(
proto.MESSAGE,
number=2,
message=common.OperationProgress,
@@ -862,7 +864,7 @@ class DatabaseRole(proto.Message):
methods to identify the database role.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
@@ -888,15 +890,15 @@ class ListDatabaseRolesRequest(proto.Message):
[ListDatabaseRolesResponse][google.spanner.admin.database.v1.ListDatabaseRolesResponse].
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- page_size = proto.Field(
+ page_size: int = proto.Field(
proto.INT32,
number=2,
)
- page_token = proto.Field(
+ page_token: str = proto.Field(
proto.STRING,
number=3,
)
@@ -907,7 +909,7 @@ class ListDatabaseRolesResponse(proto.Message):
[ListDatabaseRoles][google.spanner.admin.database.v1.DatabaseAdmin.ListDatabaseRoles].
Attributes:
- database_roles (Sequence[google.cloud.spanner_admin_database_v1.types.DatabaseRole]):
+ database_roles (MutableSequence[google.cloud.spanner_admin_database_v1.types.DatabaseRole]):
Database roles that matched the request.
next_page_token (str):
``next_page_token`` can be sent in a subsequent
@@ -919,12 +921,12 @@ class ListDatabaseRolesResponse(proto.Message):
def raw_page(self):
return self
- database_roles = proto.RepeatedField(
+ database_roles: MutableSequence["DatabaseRole"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="DatabaseRole",
)
- next_page_token = proto.Field(
+ next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
diff --git a/google/cloud/spanner_admin_instance_v1/__init__.py b/google/cloud/spanner_admin_instance_v1/__init__.py
index 12ba0676c0..686a7b33d1 100644
--- a/google/cloud/spanner_admin_instance_v1/__init__.py
+++ b/google/cloud/spanner_admin_instance_v1/__init__.py
@@ -13,6 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from google.cloud.spanner_admin_instance_v1 import gapic_version as package_version
+
+__version__ = package_version.__version__
+
from .services.instance_admin import InstanceAdminClient
from .services.instance_admin import InstanceAdminAsyncClient
diff --git a/google/cloud/spanner_admin_instance_v1/gapic_version.py b/google/cloud/spanner_admin_instance_v1/gapic_version.py
new file mode 100644
index 0000000000..f0856cadb7
--- /dev/null
+++ b/google/cloud/spanner_admin_instance_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.27.0" # {x-release-please-version}
diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py
index e42a706845..85acc5c434 100644
--- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py
+++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/async_client.py
@@ -16,8 +16,19 @@
from collections import OrderedDict
import functools
import re
-from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
-import pkg_resources
+from typing import (
+ Dict,
+ Mapping,
+ MutableMapping,
+ MutableSequence,
+ Optional,
+ Sequence,
+ Tuple,
+ Type,
+ Union,
+)
+
+from google.cloud.spanner_admin_instance_v1 import gapic_version as package_version
from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
@@ -154,7 +165,7 @@ def get_mtls_endpoint_and_cert_source(
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 variabel is "never", use the default API
+ 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.
@@ -190,9 +201,9 @@ def transport(self) -> InstanceAdminTransport:
def __init__(
self,
*,
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, InstanceAdminTransport] = "grpc_asyncio",
- client_options: ClientOptions = None,
+ client_options: Optional[ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiates the instance admin client.
@@ -236,11 +247,13 @@ def __init__(
async def list_instance_configs(
self,
- request: Union[spanner_instance_admin.ListInstanceConfigsRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.ListInstanceConfigsRequest, dict]
+ ] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListInstanceConfigsAsyncPager:
r"""Lists the supported instance configurations for a
@@ -274,7 +287,7 @@ async def sample_list_instance_configs():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.ListInstanceConfigsRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.ListInstanceConfigsRequest, dict]]):
The request object. The request for
[ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs].
parent (:class:`str`):
@@ -363,11 +376,13 @@ async def sample_list_instance_configs():
async def get_instance_config(
self,
- request: Union[spanner_instance_admin.GetInstanceConfigRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.GetInstanceConfigRequest, dict]
+ ] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner_instance_admin.InstanceConfig:
r"""Gets information about a particular instance
@@ -400,7 +415,7 @@ async def sample_get_instance_config():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.GetInstanceConfigRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.GetInstanceConfigRequest, dict]]):
The request object. The request for
[GetInstanceConfigRequest][google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceConfig].
name (:class:`str`):
@@ -479,13 +494,15 @@ async def sample_get_instance_config():
async def create_instance_config(
self,
- request: Union[spanner_instance_admin.CreateInstanceConfigRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.CreateInstanceConfigRequest, dict]
+ ] = None,
*,
- parent: str = None,
- instance_config: spanner_instance_admin.InstanceConfig = None,
- instance_config_id: str = None,
+ parent: Optional[str] = None,
+ instance_config: Optional[spanner_instance_admin.InstanceConfig] = None,
+ instance_config_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates an instance config and begins preparing it to be used.
@@ -558,13 +575,13 @@ async def sample_create_instance_config():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.CreateInstanceConfigRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.CreateInstanceConfigRequest, dict]]):
The request object. The request for
[CreateInstanceConfigRequest][InstanceAdmin.CreateInstanceConfigRequest].
parent (:class:`str`):
@@ -668,12 +685,14 @@ async def sample_create_instance_config():
async def update_instance_config(
self,
- request: Union[spanner_instance_admin.UpdateInstanceConfigRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.UpdateInstanceConfigRequest, dict]
+ ] = None,
*,
- instance_config: spanner_instance_admin.InstanceConfig = None,
- update_mask: field_mask_pb2.FieldMask = None,
+ instance_config: Optional[spanner_instance_admin.InstanceConfig] = None,
+ update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Updates an instance config. The returned [long-running
@@ -749,13 +768,13 @@ async def sample_update_instance_config():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.UpdateInstanceConfigRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.UpdateInstanceConfigRequest, dict]]):
The request object. The request for
[UpdateInstanceConfigRequest][InstanceAdmin.UpdateInstanceConfigRequest].
instance_config (:class:`google.cloud.spanner_admin_instance_v1.types.InstanceConfig`):
@@ -855,11 +874,13 @@ async def sample_update_instance_config():
async def delete_instance_config(
self,
- request: Union[spanner_instance_admin.DeleteInstanceConfigRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.DeleteInstanceConfigRequest, dict]
+ ] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes the instance config. Deletion is only allowed when no
@@ -896,7 +917,7 @@ async def sample_delete_instance_config():
await client.delete_instance_config(request=request)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.DeleteInstanceConfigRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.DeleteInstanceConfigRequest, dict]]):
The request object. The request for
[DeleteInstanceConfigRequest][InstanceAdmin.DeleteInstanceConfigRequest].
name (:class:`str`):
@@ -954,13 +975,13 @@ async def sample_delete_instance_config():
async def list_instance_config_operations(
self,
- request: Union[
- spanner_instance_admin.ListInstanceConfigOperationsRequest, dict
+ request: Optional[
+ Union[spanner_instance_admin.ListInstanceConfigOperationsRequest, dict]
] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListInstanceConfigOperationsAsyncPager:
r"""Lists the user-managed instance config [long-running
@@ -1004,7 +1025,7 @@ async def sample_list_instance_config_operations():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.ListInstanceConfigOperationsRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.ListInstanceConfigOperationsRequest, dict]]):
The request object. The request for
[ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations].
parent (:class:`str`):
@@ -1082,11 +1103,13 @@ async def sample_list_instance_config_operations():
async def list_instances(
self,
- request: Union[spanner_instance_admin.ListInstancesRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.ListInstancesRequest, dict]
+ ] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListInstancesAsyncPager:
r"""Lists all instances in the given project.
@@ -1119,7 +1142,7 @@ async def sample_list_instances():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.ListInstancesRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.ListInstancesRequest, dict]]):
The request object. The request for
[ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances].
parent (:class:`str`):
@@ -1208,11 +1231,13 @@ async def sample_list_instances():
async def get_instance(
self,
- request: Union[spanner_instance_admin.GetInstanceRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.GetInstanceRequest, dict]
+ ] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner_instance_admin.Instance:
r"""Gets information about a particular instance.
@@ -1244,7 +1269,7 @@ async def sample_get_instance():
print(response)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.GetInstanceRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.GetInstanceRequest, dict]]):
The request object. The request for
[GetInstance][google.spanner.admin.instance.v1.InstanceAdmin.GetInstance].
name (:class:`str`):
@@ -1321,13 +1346,15 @@ async def sample_get_instance():
async def create_instance(
self,
- request: Union[spanner_instance_admin.CreateInstanceRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.CreateInstanceRequest, dict]
+ ] = None,
*,
- parent: str = None,
- instance_id: str = None,
- instance: spanner_instance_admin.Instance = None,
+ parent: Optional[str] = None,
+ instance_id: Optional[str] = None,
+ instance: Optional[spanner_instance_admin.Instance] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Creates an instance and begins preparing it to begin serving.
@@ -1401,13 +1428,13 @@ async def sample_create_instance():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.CreateInstanceRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.CreateInstanceRequest, dict]]):
The request object. The request for
[CreateInstance][google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance].
parent (:class:`str`):
@@ -1505,12 +1532,14 @@ async def sample_create_instance():
async def update_instance(
self,
- request: Union[spanner_instance_admin.UpdateInstanceRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.UpdateInstanceRequest, dict]
+ ] = None,
*,
- instance: spanner_instance_admin.Instance = None,
- field_mask: field_mask_pb2.FieldMask = None,
+ instance: Optional[spanner_instance_admin.Instance] = None,
+ field_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Updates an instance, and begins allocating or releasing
@@ -1589,13 +1618,13 @@ async def sample_update_instance():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.UpdateInstanceRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.UpdateInstanceRequest, dict]]):
The request object. The request for
[UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance].
instance (:class:`google.cloud.spanner_admin_instance_v1.types.Instance`):
@@ -1692,11 +1721,13 @@ async def sample_update_instance():
async def delete_instance(
self,
- request: Union[spanner_instance_admin.DeleteInstanceRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.DeleteInstanceRequest, dict]
+ ] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes an instance.
@@ -1735,7 +1766,7 @@ async def sample_delete_instance():
await client.delete_instance(request=request)
Args:
- request (Union[google.cloud.spanner_admin_instance_v1.types.DeleteInstanceRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_admin_instance_v1.types.DeleteInstanceRequest, dict]]):
The request object. The request for
[DeleteInstance][google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance].
name (:class:`str`):
@@ -1803,11 +1834,11 @@ async def sample_delete_instance():
async def set_iam_policy(
self,
- request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None,
*,
- resource: str = None,
+ resource: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
r"""Sets the access control policy on an instance resource. Replaces
@@ -1844,7 +1875,7 @@ async def sample_set_iam_policy():
print(response)
Args:
- request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]):
+ request (Optional[Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]]):
The request object. Request message for `SetIamPolicy`
method.
resource (:class:`str`):
@@ -1973,11 +2004,11 @@ async def sample_set_iam_policy():
async def get_iam_policy(
self,
- request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None,
*,
- resource: str = None,
+ resource: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
r"""Gets the access control policy for an instance resource. Returns
@@ -2015,7 +2046,7 @@ async def sample_get_iam_policy():
print(response)
Args:
- request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]):
+ request (Optional[Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]]):
The request object. Request message for `GetIamPolicy`
method.
resource (:class:`str`):
@@ -2154,12 +2185,12 @@ async def sample_get_iam_policy():
async def test_iam_permissions(
self,
- request: Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None,
*,
- resource: str = None,
- permissions: Sequence[str] = None,
+ resource: Optional[str] = None,
+ permissions: Optional[MutableSequence[str]] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> iam_policy_pb2.TestIamPermissionsResponse:
r"""Returns permissions that the caller has on the specified
@@ -2199,7 +2230,7 @@ async def sample_test_iam_permissions():
print(response)
Args:
- request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]):
+ request (Optional[Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]]):
The request object. Request message for
`TestIamPermissions` method.
resource (:class:`str`):
@@ -2211,7 +2242,7 @@ async def sample_test_iam_permissions():
This corresponds to the ``resource`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
- permissions (:class:`Sequence[str]`):
+ permissions (:class:`MutableSequence[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
@@ -2282,14 +2313,9 @@ async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()
-try:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
- gapic_version=pkg_resources.get_distribution(
- "google-cloud-spanner-admin-instance",
- ).version,
- )
-except pkg_resources.DistributionNotFound:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=package_version.__version__
+)
__all__ = ("InstanceAdminAsyncClient",)
diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py
index 9a1a7e38cd..881361de50 100644
--- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py
+++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/client.py
@@ -16,8 +16,20 @@
from collections import OrderedDict
import os
import re
-from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
-import pkg_resources
+from typing import (
+ Dict,
+ Mapping,
+ MutableMapping,
+ MutableSequence,
+ Optional,
+ Sequence,
+ Tuple,
+ Type,
+ Union,
+ cast,
+)
+
+from google.cloud.spanner_admin_instance_v1 import gapic_version as package_version
from google.api_core import client_options as client_options_lib
from google.api_core import exceptions as core_exceptions
@@ -62,7 +74,7 @@ class InstanceAdminClientMeta(type):
def get_transport_class(
cls,
- label: str = None,
+ label: Optional[str] = None,
) -> Type[InstanceAdminTransport]:
"""Returns an appropriate transport class.
@@ -318,7 +330,7 @@ def get_mtls_endpoint_and_cert_source(
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 variabel is "never", use the default API
+ 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.
@@ -373,8 +385,8 @@ def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
- transport: Union[str, InstanceAdminTransport, None] = None,
- client_options: Optional[client_options_lib.ClientOptions] = None,
+ transport: Optional[Union[str, InstanceAdminTransport]] = None,
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiates the instance admin client.
@@ -388,7 +400,7 @@ def __init__(
transport (Union[str, InstanceAdminTransport]): The
transport to use. If set to None, a transport is chosen
automatically.
- client_options (google.api_core.client_options.ClientOptions): Custom options for the
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
client. It won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
@@ -418,6 +430,7 @@ def __init__(
client_options = client_options_lib.from_dict(client_options)
if client_options is None:
client_options = client_options_lib.ClientOptions()
+ client_options = cast(client_options_lib.ClientOptions, client_options)
api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(
client_options
@@ -470,11 +483,13 @@ def __init__(
def list_instance_configs(
self,
- request: Union[spanner_instance_admin.ListInstanceConfigsRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.ListInstanceConfigsRequest, dict]
+ ] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListInstanceConfigsPager:
r"""Lists the supported instance configurations for a
@@ -587,11 +602,13 @@ def sample_list_instance_configs():
def get_instance_config(
self,
- request: Union[spanner_instance_admin.GetInstanceConfigRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.GetInstanceConfigRequest, dict]
+ ] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner_instance_admin.InstanceConfig:
r"""Gets information about a particular instance
@@ -693,13 +710,15 @@ def sample_get_instance_config():
def create_instance_config(
self,
- request: Union[spanner_instance_admin.CreateInstanceConfigRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.CreateInstanceConfigRequest, dict]
+ ] = None,
*,
- parent: str = None,
- instance_config: spanner_instance_admin.InstanceConfig = None,
- instance_config_id: str = None,
+ parent: Optional[str] = None,
+ instance_config: Optional[spanner_instance_admin.InstanceConfig] = None,
+ instance_config_id: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Creates an instance config and begins preparing it to be used.
@@ -882,12 +901,14 @@ def sample_create_instance_config():
def update_instance_config(
self,
- request: Union[spanner_instance_admin.UpdateInstanceConfigRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.UpdateInstanceConfigRequest, dict]
+ ] = None,
*,
- instance_config: spanner_instance_admin.InstanceConfig = None,
- update_mask: field_mask_pb2.FieldMask = None,
+ instance_config: Optional[spanner_instance_admin.InstanceConfig] = None,
+ update_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Updates an instance config. The returned [long-running
@@ -1069,11 +1090,13 @@ def sample_update_instance_config():
def delete_instance_config(
self,
- request: Union[spanner_instance_admin.DeleteInstanceConfigRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.DeleteInstanceConfigRequest, dict]
+ ] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes the instance config. Deletion is only allowed when no
@@ -1168,13 +1191,13 @@ def sample_delete_instance_config():
def list_instance_config_operations(
self,
- request: Union[
- spanner_instance_admin.ListInstanceConfigOperationsRequest, dict
+ request: Optional[
+ Union[spanner_instance_admin.ListInstanceConfigOperationsRequest, dict]
] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListInstanceConfigOperationsPager:
r"""Lists the user-managed instance config [long-running
@@ -1302,11 +1325,13 @@ def sample_list_instance_config_operations():
def list_instances(
self,
- request: Union[spanner_instance_admin.ListInstancesRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.ListInstancesRequest, dict]
+ ] = None,
*,
- parent: str = None,
+ parent: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListInstancesPager:
r"""Lists all instances in the given project.
@@ -1418,11 +1443,13 @@ def sample_list_instances():
def get_instance(
self,
- request: Union[spanner_instance_admin.GetInstanceRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.GetInstanceRequest, dict]
+ ] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner_instance_admin.Instance:
r"""Gets information about a particular instance.
@@ -1521,13 +1548,15 @@ def sample_get_instance():
def create_instance(
self,
- request: Union[spanner_instance_admin.CreateInstanceRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.CreateInstanceRequest, dict]
+ ] = None,
*,
- parent: str = None,
- instance_id: str = None,
- instance: spanner_instance_admin.Instance = None,
+ parent: Optional[str] = None,
+ instance_id: Optional[str] = None,
+ instance: Optional[spanner_instance_admin.Instance] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Creates an instance and begins preparing it to begin serving.
@@ -1705,12 +1734,14 @@ def sample_create_instance():
def update_instance(
self,
- request: Union[spanner_instance_admin.UpdateInstanceRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.UpdateInstanceRequest, dict]
+ ] = None,
*,
- instance: spanner_instance_admin.Instance = None,
- field_mask: field_mask_pb2.FieldMask = None,
+ instance: Optional[spanner_instance_admin.Instance] = None,
+ field_mask: Optional[field_mask_pb2.FieldMask] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Updates an instance, and begins allocating or releasing
@@ -1892,11 +1923,13 @@ def sample_update_instance():
def delete_instance(
self,
- request: Union[spanner_instance_admin.DeleteInstanceRequest, dict] = None,
+ request: Optional[
+ Union[spanner_instance_admin.DeleteInstanceRequest, dict]
+ ] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Deletes an instance.
@@ -1993,11 +2026,11 @@ def sample_delete_instance():
def set_iam_policy(
self,
- request: Union[iam_policy_pb2.SetIamPolicyRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.SetIamPolicyRequest, dict]] = None,
*,
- resource: str = None,
+ resource: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
r"""Sets the access control policy on an instance resource. Replaces
@@ -2160,11 +2193,11 @@ def sample_set_iam_policy():
def get_iam_policy(
self,
- request: Union[iam_policy_pb2.GetIamPolicyRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.GetIamPolicyRequest, dict]] = None,
*,
- resource: str = None,
+ resource: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> policy_pb2.Policy:
r"""Gets the access control policy for an instance resource. Returns
@@ -2328,12 +2361,12 @@ def sample_get_iam_policy():
def test_iam_permissions(
self,
- request: Union[iam_policy_pb2.TestIamPermissionsRequest, dict] = None,
+ request: Optional[Union[iam_policy_pb2.TestIamPermissionsRequest, dict]] = None,
*,
- resource: str = None,
- permissions: Sequence[str] = None,
+ resource: Optional[str] = None,
+ permissions: Optional[MutableSequence[str]] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> iam_policy_pb2.TestIamPermissionsResponse:
r"""Returns permissions that the caller has on the specified
@@ -2385,7 +2418,7 @@ def sample_test_iam_permissions():
This corresponds to the ``resource`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
- permissions (Sequence[str]):
+ permissions (MutableSequence[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
@@ -2461,14 +2494,9 @@ def __exit__(self, type, value, traceback):
self.transport.close()
-try:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
- gapic_version=pkg_resources.get_distribution(
- "google-cloud-spanner-admin-instance",
- ).version,
- )
-except pkg_resources.DistributionNotFound:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=package_version.__version__
+)
__all__ = ("InstanceAdminClient",)
diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py
index 8c49c375d9..61594505db 100644
--- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py
+++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/base.py
@@ -15,7 +15,8 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
-import pkg_resources
+
+from google.cloud.spanner_admin_instance_v1 import gapic_version as package_version
import google.auth # type: ignore
import google.api_core
@@ -32,14 +33,9 @@
from google.longrunning import operations_pb2 # type: ignore
from google.protobuf import empty_pb2 # type: ignore
-try:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
- gapic_version=pkg_resources.get_distribution(
- "google-cloud-spanner-admin-instance",
- ).version,
- )
-except pkg_resources.DistributionNotFound:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=package_version.__version__
+)
class InstanceAdminTransport(abc.ABC):
@@ -56,7 +52,7 @@ def __init__(
self,
*,
host: str = DEFAULT_HOST,
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py
index 5837dc6127..5fdac4001f 100644
--- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py
+++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc.py
@@ -72,14 +72,14 @@ def __init__(
self,
*,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
- credentials_file: str = None,
- scopes: Sequence[str] = None,
- channel: grpc.Channel = None,
- api_mtls_endpoint: str = None,
- client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
- ssl_channel_credentials: grpc.ChannelCredentials = None,
- client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ channel: Optional[grpc.Channel] = None,
+ api_mtls_endpoint: Optional[str] = None,
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
always_use_jwt_access: Optional[bool] = False,
@@ -207,8 +207,8 @@ def __init__(
def create_channel(
cls,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
- credentials_file: str = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
+ credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
**kwargs,
diff --git a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py
index c38ef38069..4d4a518558 100644
--- a/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py
+++ b/google/cloud/spanner_admin_instance_v1/services/instance_admin/transports/grpc_asyncio.py
@@ -74,7 +74,7 @@ class InstanceAdminGrpcAsyncIOTransport(InstanceAdminTransport):
def create_channel(
cls,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
@@ -117,15 +117,15 @@ def __init__(
self,
*,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
- channel: aio.Channel = None,
- api_mtls_endpoint: str = None,
- client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
- ssl_channel_credentials: grpc.ChannelCredentials = None,
- client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
- quota_project_id=None,
+ channel: Optional[aio.Channel] = None,
+ api_mtls_endpoint: Optional[str] = None,
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
+ quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
always_use_jwt_access: Optional[bool] = False,
api_audience: Optional[str] = None,
diff --git a/google/cloud/spanner_admin_instance_v1/types/common.py b/google/cloud/spanner_admin_instance_v1/types/common.py
index 49c2de342b..5083cd06eb 100644
--- a/google/cloud/spanner_admin_instance_v1/types/common.py
+++ b/google/cloud/spanner_admin_instance_v1/types/common.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
@@ -41,16 +43,16 @@ class OperationProgress(proto.Message):
failed or was completed successfully.
"""
- progress_percent = proto.Field(
+ progress_percent: int = proto.Field(
proto.INT32,
number=1,
)
- start_time = proto.Field(
+ start_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=2,
message=timestamp_pb2.Timestamp,
)
- end_time = proto.Field(
+ end_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
diff --git a/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py b/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py
index cf11297f76..de336a59d6 100644
--- a/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py
+++ b/google/cloud/spanner_admin_instance_v1/types/spanner_instance_admin.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.cloud.spanner_admin_instance_v1.types import common
@@ -76,16 +78,16 @@ class ReplicaType(proto.Enum):
READ_ONLY = 2
WITNESS = 3
- location = proto.Field(
+ location: str = proto.Field(
proto.STRING,
number=1,
)
- type_ = proto.Field(
+ type_: ReplicaType = proto.Field(
proto.ENUM,
number=2,
enum=ReplicaType,
)
- default_leader_location = proto.Field(
+ default_leader_location: bool = proto.Field(
proto.BOOL,
number=3,
)
@@ -107,11 +109,11 @@ class InstanceConfig(proto.Message):
config_type (google.cloud.spanner_admin_instance_v1.types.InstanceConfig.Type):
Output only. Whether this instance config is
a Google or User Managed Configuration.
- replicas (Sequence[google.cloud.spanner_admin_instance_v1.types.ReplicaInfo]):
+ replicas (MutableSequence[google.cloud.spanner_admin_instance_v1.types.ReplicaInfo]):
The geographic placement of nodes in this
instance configuration and their replication
properties.
- optional_replicas (Sequence[google.cloud.spanner_admin_instance_v1.types.ReplicaInfo]):
+ optional_replicas (MutableSequence[google.cloud.spanner_admin_instance_v1.types.ReplicaInfo]):
Output only. The available optional replicas
to choose from for user managed configurations.
Populated for Google managed configurations.
@@ -122,7 +124,7 @@ class InstanceConfig(proto.Message):
configurations. ``base_config`` must refer to a
configuration of type GOOGLE_MANAGED in the same project as
this configuration.
- labels (Mapping[str, str]):
+ labels (MutableMapping[str, str]):
Cloud Labels are a flexible and lightweight mechanism for
organizing cloud resources into groups that reflect a
customer's organizational needs and deployment strategies.
@@ -169,7 +171,7 @@ class InstanceConfig(proto.Message):
If no etag is provided in the call to update
instance config, then the existing instance
config is overwritten blindly.
- leader_options (Sequence[str]):
+ leader_options (MutableSequence[str]):
Allowed values of the "default_leader" schema option for
databases in instances that use this instance configuration.
reconciling (bool):
@@ -193,51 +195,51 @@ class State(proto.Enum):
CREATING = 1
READY = 2
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- display_name = proto.Field(
+ display_name: str = proto.Field(
proto.STRING,
number=2,
)
- config_type = proto.Field(
+ config_type: Type = proto.Field(
proto.ENUM,
number=5,
enum=Type,
)
- replicas = proto.RepeatedField(
+ replicas: MutableSequence["ReplicaInfo"] = proto.RepeatedField(
proto.MESSAGE,
number=3,
message="ReplicaInfo",
)
- optional_replicas = proto.RepeatedField(
+ optional_replicas: MutableSequence["ReplicaInfo"] = proto.RepeatedField(
proto.MESSAGE,
number=6,
message="ReplicaInfo",
)
- base_config = proto.Field(
+ base_config: str = proto.Field(
proto.STRING,
number=7,
)
- labels = proto.MapField(
+ labels: MutableMapping[str, str] = proto.MapField(
proto.STRING,
proto.STRING,
number=8,
)
- etag = proto.Field(
+ etag: str = proto.Field(
proto.STRING,
number=9,
)
- leader_options = proto.RepeatedField(
+ leader_options: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=4,
)
- reconciling = proto.Field(
+ reconciling: bool = proto.Field(
proto.BOOL,
number=10,
)
- state = proto.Field(
+ state: State = proto.Field(
proto.ENUM,
number=11,
enum=State,
@@ -293,7 +295,7 @@ class Instance(proto.Message):
the state must be either omitted or set to ``CREATING``. For
[UpdateInstance][google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance],
the state must be either omitted or set to ``READY``.
- labels (Mapping[str, str]):
+ labels (MutableMapping[str, str]):
Cloud Labels are a flexible and lightweight mechanism for
organizing cloud resources into groups that reflect a
customer's organizational needs and deployment strategies.
@@ -322,7 +324,7 @@ class Instance(proto.Message):
being disallowed. For example, representing labels as the
string: name + "*" + value would prove problematic if we
were to allow "*" in a future release.
- endpoint_uris (Sequence[str]):
+ endpoint_uris (MutableSequence[str]):
Deprecated. This field is not populated.
create_time (google.protobuf.timestamp_pb2.Timestamp):
Output only. The time at which the instance
@@ -338,46 +340,46 @@ class State(proto.Enum):
CREATING = 1
READY = 2
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- config = proto.Field(
+ config: str = proto.Field(
proto.STRING,
number=2,
)
- display_name = proto.Field(
+ display_name: str = proto.Field(
proto.STRING,
number=3,
)
- node_count = proto.Field(
+ node_count: int = proto.Field(
proto.INT32,
number=5,
)
- processing_units = proto.Field(
+ processing_units: int = proto.Field(
proto.INT32,
number=9,
)
- state = proto.Field(
+ state: State = proto.Field(
proto.ENUM,
number=6,
enum=State,
)
- labels = proto.MapField(
+ labels: MutableMapping[str, str] = proto.MapField(
proto.STRING,
proto.STRING,
number=7,
)
- endpoint_uris = proto.RepeatedField(
+ endpoint_uris: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=8,
)
- create_time = proto.Field(
+ create_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=11,
message=timestamp_pb2.Timestamp,
)
- update_time = proto.Field(
+ update_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=12,
message=timestamp_pb2.Timestamp,
@@ -404,15 +406,15 @@ class ListInstanceConfigsRequest(proto.Message):
[ListInstanceConfigsResponse][google.spanner.admin.instance.v1.ListInstanceConfigsResponse].
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- page_size = proto.Field(
+ page_size: int = proto.Field(
proto.INT32,
number=2,
)
- page_token = proto.Field(
+ page_token: str = proto.Field(
proto.STRING,
number=3,
)
@@ -423,7 +425,7 @@ class ListInstanceConfigsResponse(proto.Message):
[ListInstanceConfigs][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs].
Attributes:
- instance_configs (Sequence[google.cloud.spanner_admin_instance_v1.types.InstanceConfig]):
+ instance_configs (MutableSequence[google.cloud.spanner_admin_instance_v1.types.InstanceConfig]):
The list of requested instance
configurations.
next_page_token (str):
@@ -436,12 +438,12 @@ class ListInstanceConfigsResponse(proto.Message):
def raw_page(self):
return self
- instance_configs = proto.RepeatedField(
+ instance_configs: MutableSequence["InstanceConfig"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="InstanceConfig",
)
- next_page_token = proto.Field(
+ next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
@@ -458,7 +460,7 @@ class GetInstanceConfigRequest(proto.Message):
``projects//instanceConfigs/``.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
@@ -492,20 +494,20 @@ class CreateInstanceConfigRequest(proto.Message):
response.
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- instance_config_id = proto.Field(
+ instance_config_id: str = proto.Field(
proto.STRING,
number=2,
)
- instance_config = proto.Field(
+ instance_config: "InstanceConfig" = proto.Field(
proto.MESSAGE,
number=3,
message="InstanceConfig",
)
- validate_only = proto.Field(
+ validate_only: bool = proto.Field(
proto.BOOL,
number=4,
)
@@ -539,17 +541,17 @@ class UpdateInstanceConfigRequest(proto.Message):
response.
"""
- instance_config = proto.Field(
+ instance_config: "InstanceConfig" = proto.Field(
proto.MESSAGE,
number=1,
message="InstanceConfig",
)
- update_mask = proto.Field(
+ update_mask: field_mask_pb2.FieldMask = proto.Field(
proto.MESSAGE,
number=2,
message=field_mask_pb2.FieldMask,
)
- validate_only = proto.Field(
+ validate_only: bool = proto.Field(
proto.BOOL,
number=3,
)
@@ -580,15 +582,15 @@ class DeleteInstanceConfigRequest(proto.Message):
response.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- etag = proto.Field(
+ etag: str = proto.Field(
proto.STRING,
number=2,
)
- validate_only = proto.Field(
+ validate_only: bool = proto.Field(
proto.BOOL,
number=3,
)
@@ -663,19 +665,19 @@ class ListInstanceConfigOperationsRequest(proto.Message):
to the same ``parent`` and with the same ``filter``.
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- filter = proto.Field(
+ filter: str = proto.Field(
proto.STRING,
number=2,
)
- page_size = proto.Field(
+ page_size: int = proto.Field(
proto.INT32,
number=3,
)
- page_token = proto.Field(
+ page_token: str = proto.Field(
proto.STRING,
number=4,
)
@@ -686,7 +688,7 @@ class ListInstanceConfigOperationsResponse(proto.Message):
[ListInstanceConfigOperations][google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigOperations].
Attributes:
- operations (Sequence[google.longrunning.operations_pb2.Operation]):
+ operations (MutableSequence[google.longrunning.operations_pb2.Operation]):
The list of matching instance config [long-running
operations][google.longrunning.Operation]. Each operation's
name will be prefixed by the instance config's name. The
@@ -703,12 +705,12 @@ class ListInstanceConfigOperationsResponse(proto.Message):
def raw_page(self):
return self
- operations = proto.RepeatedField(
+ operations: MutableSequence[operations_pb2.Operation] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message=operations_pb2.Operation,
)
- next_page_token = proto.Field(
+ next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
@@ -730,11 +732,11 @@ class GetInstanceRequest(proto.Message):
are returned.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- field_mask = proto.Field(
+ field_mask: field_mask_pb2.FieldMask = proto.Field(
proto.MESSAGE,
number=2,
message=field_mask_pb2.FieldMask,
@@ -759,15 +761,15 @@ class CreateInstanceRequest(proto.Message):
``/instances/``.
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- instance_id = proto.Field(
+ instance_id: str = proto.Field(
proto.STRING,
number=2,
)
- instance = proto.Field(
+ instance: "Instance" = proto.Field(
proto.MESSAGE,
number=3,
message="Instance",
@@ -816,19 +818,19 @@ class ListInstancesRequest(proto.Message):
containing "dev".
"""
- parent = proto.Field(
+ parent: str = proto.Field(
proto.STRING,
number=1,
)
- page_size = proto.Field(
+ page_size: int = proto.Field(
proto.INT32,
number=2,
)
- page_token = proto.Field(
+ page_token: str = proto.Field(
proto.STRING,
number=3,
)
- filter = proto.Field(
+ filter: str = proto.Field(
proto.STRING,
number=4,
)
@@ -839,7 +841,7 @@ class ListInstancesResponse(proto.Message):
[ListInstances][google.spanner.admin.instance.v1.InstanceAdmin.ListInstances].
Attributes:
- instances (Sequence[google.cloud.spanner_admin_instance_v1.types.Instance]):
+ instances (MutableSequence[google.cloud.spanner_admin_instance_v1.types.Instance]):
The list of requested instances.
next_page_token (str):
``next_page_token`` can be sent in a subsequent
@@ -851,12 +853,12 @@ class ListInstancesResponse(proto.Message):
def raw_page(self):
return self
- instances = proto.RepeatedField(
+ instances: MutableSequence["Instance"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="Instance",
)
- next_page_token = proto.Field(
+ next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
@@ -882,12 +884,12 @@ class UpdateInstanceRequest(proto.Message):
them.
"""
- instance = proto.Field(
+ instance: "Instance" = proto.Field(
proto.MESSAGE,
number=1,
message="Instance",
)
- field_mask = proto.Field(
+ field_mask: field_mask_pb2.FieldMask = proto.Field(
proto.MESSAGE,
number=2,
message=field_mask_pb2.FieldMask,
@@ -904,7 +906,7 @@ class DeleteInstanceRequest(proto.Message):
of the form ``projects//instances/``
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
@@ -931,22 +933,22 @@ class CreateInstanceMetadata(proto.Message):
was completed successfully.
"""
- instance = proto.Field(
+ instance: "Instance" = proto.Field(
proto.MESSAGE,
number=1,
message="Instance",
)
- start_time = proto.Field(
+ start_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=2,
message=timestamp_pb2.Timestamp,
)
- cancel_time = proto.Field(
+ cancel_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
)
- end_time = proto.Field(
+ end_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=4,
message=timestamp_pb2.Timestamp,
@@ -974,22 +976,22 @@ class UpdateInstanceMetadata(proto.Message):
was completed successfully.
"""
- instance = proto.Field(
+ instance: "Instance" = proto.Field(
proto.MESSAGE,
number=1,
message="Instance",
)
- start_time = proto.Field(
+ start_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=2,
message=timestamp_pb2.Timestamp,
)
- cancel_time = proto.Field(
+ cancel_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
)
- end_time = proto.Field(
+ end_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=4,
message=timestamp_pb2.Timestamp,
@@ -1012,17 +1014,17 @@ class CreateInstanceConfigMetadata(proto.Message):
cancelled.
"""
- instance_config = proto.Field(
+ instance_config: "InstanceConfig" = proto.Field(
proto.MESSAGE,
number=1,
message="InstanceConfig",
)
- progress = proto.Field(
+ progress: common.OperationProgress = proto.Field(
proto.MESSAGE,
number=2,
message=common.OperationProgress,
)
- cancel_time = proto.Field(
+ cancel_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
@@ -1045,17 +1047,17 @@ class UpdateInstanceConfigMetadata(proto.Message):
cancelled.
"""
- instance_config = proto.Field(
+ instance_config: "InstanceConfig" = proto.Field(
proto.MESSAGE,
number=1,
message="InstanceConfig",
)
- progress = proto.Field(
+ progress: common.OperationProgress = proto.Field(
proto.MESSAGE,
number=2,
message=common.OperationProgress,
)
- cancel_time = proto.Field(
+ cancel_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
diff --git a/google/cloud/spanner_dbapi/version.py b/google/cloud/spanner_dbapi/version.py
index e75d5da91b..6fbb80eb90 100644
--- a/google/cloud/spanner_dbapi/version.py
+++ b/google/cloud/spanner_dbapi/version.py
@@ -12,9 +12,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-import pkg_resources
import platform
+from google.cloud.spanner_v1 import gapic_version as package_version
PY_VERSION = platform.python_version()
-VERSION = pkg_resources.get_distribution("google-cloud-spanner").version
+VERSION = package_version.__version__
DEFAULT_USER_AGENT = "gl-dbapi/" + VERSION
diff --git a/google/cloud/spanner_v1/__init__.py b/google/cloud/spanner_v1/__init__.py
index e38e876d79..039919563f 100644
--- a/google/cloud/spanner_v1/__init__.py
+++ b/google/cloud/spanner_v1/__init__.py
@@ -16,9 +16,9 @@
#
from __future__ import absolute_import
-import pkg_resources
+from google.cloud.spanner_v1 import gapic_version as package_version
-__version__: str = pkg_resources.get_distribution("google-cloud-spanner").version
+__version__: str = package_version.__version__
from .services.spanner import SpannerClient
from .types.commit_response import CommitResponse
diff --git a/google/cloud/spanner_v1/gapic_version.py b/google/cloud/spanner_v1/gapic_version.py
new file mode 100644
index 0000000000..f0856cadb7
--- /dev/null
+++ b/google/cloud/spanner_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.27.0" # {x-release-please-version}
diff --git a/google/cloud/spanner_v1/services/spanner/async_client.py b/google/cloud/spanner_v1/services/spanner/async_client.py
index 1fef0d8776..6a4f45b9ee 100644
--- a/google/cloud/spanner_v1/services/spanner/async_client.py
+++ b/google/cloud/spanner_v1/services/spanner/async_client.py
@@ -19,6 +19,8 @@
from typing import (
Dict,
Mapping,
+ MutableMapping,
+ MutableSequence,
Optional,
AsyncIterable,
Awaitable,
@@ -27,7 +29,8 @@
Type,
Union,
)
-import pkg_resources
+
+from google.cloud.spanner_v1 import gapic_version as package_version
from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
@@ -136,7 +139,7 @@ def get_mtls_endpoint_and_cert_source(
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 variabel is "never", use the default API
+ 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.
@@ -172,9 +175,9 @@ def transport(self) -> SpannerTransport:
def __init__(
self,
*,
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, SpannerTransport] = "grpc_asyncio",
- client_options: ClientOptions = None,
+ client_options: Optional[ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiates the spanner client.
@@ -218,11 +221,11 @@ def __init__(
async def create_session(
self,
- request: Union[spanner.CreateSessionRequest, dict] = None,
+ request: Optional[Union[spanner.CreateSessionRequest, dict]] = None,
*,
- database: str = None,
+ database: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.Session:
r"""Creates a new session. A session can be used to perform
@@ -272,7 +275,7 @@ async def sample_create_session():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.CreateSessionRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.CreateSessionRequest, dict]]):
The request object. The request for
[CreateSession][google.spanner.v1.Spanner.CreateSession].
database (:class:`str`):
@@ -345,12 +348,12 @@ async def sample_create_session():
async def batch_create_sessions(
self,
- request: Union[spanner.BatchCreateSessionsRequest, dict] = None,
+ request: Optional[Union[spanner.BatchCreateSessionsRequest, dict]] = None,
*,
- database: str = None,
- session_count: int = None,
+ database: Optional[str] = None,
+ session_count: Optional[int] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.BatchCreateSessionsResponse:
r"""Creates multiple new sessions.
@@ -386,7 +389,7 @@ async def sample_batch_create_sessions():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.BatchCreateSessionsRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.BatchCreateSessionsRequest, dict]]):
The request object. The request for
[BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
database (:class:`str`):
@@ -475,11 +478,11 @@ async def sample_batch_create_sessions():
async def get_session(
self,
- request: Union[spanner.GetSessionRequest, dict] = None,
+ request: Optional[Union[spanner.GetSessionRequest, dict]] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.Session:
r"""Gets a session. Returns ``NOT_FOUND`` if the session does not
@@ -513,7 +516,7 @@ async def sample_get_session():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.GetSessionRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.GetSessionRequest, dict]]):
The request object. The request for
[GetSession][google.spanner.v1.Spanner.GetSession].
name (:class:`str`):
@@ -586,11 +589,11 @@ async def sample_get_session():
async def list_sessions(
self,
- request: Union[spanner.ListSessionsRequest, dict] = None,
+ request: Optional[Union[spanner.ListSessionsRequest, dict]] = None,
*,
- database: str = None,
+ database: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListSessionsAsyncPager:
r"""Lists all sessions in a given database.
@@ -623,7 +626,7 @@ async def sample_list_sessions():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.ListSessionsRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.ListSessionsRequest, dict]]):
The request object. The request for
[ListSessions][google.spanner.v1.Spanner.ListSessions].
database (:class:`str`):
@@ -710,11 +713,11 @@ async def sample_list_sessions():
async def delete_session(
self,
- request: Union[spanner.DeleteSessionRequest, dict] = None,
+ request: Optional[Union[spanner.DeleteSessionRequest, dict]] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Ends a session, releasing server resources associated
@@ -745,7 +748,7 @@ async def sample_delete_session():
await client.delete_session(request=request)
Args:
- request (Union[google.cloud.spanner_v1.types.DeleteSessionRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.DeleteSessionRequest, dict]]):
The request object. The request for
[DeleteSession][google.spanner.v1.Spanner.DeleteSession].
name (:class:`str`):
@@ -811,10 +814,10 @@ async def sample_delete_session():
async def execute_sql(
self,
- request: Union[spanner.ExecuteSqlRequest, dict] = None,
+ request: Optional[Union[spanner.ExecuteSqlRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> result_set.ResultSet:
r"""Executes an SQL statement, returning all results in a single
@@ -860,7 +863,7 @@ async def sample_execute_sql():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.ExecuteSqlRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.ExecuteSqlRequest, dict]]):
The request object. The request for
[ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
[ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
@@ -915,10 +918,10 @@ async def sample_execute_sql():
def execute_streaming_sql(
self,
- request: Union[spanner.ExecuteSqlRequest, dict] = None,
+ request: Optional[Union[spanner.ExecuteSqlRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> Awaitable[AsyncIterable[result_set.PartialResultSet]]:
r"""Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except
@@ -957,7 +960,7 @@ async def sample_execute_streaming_sql():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.ExecuteSqlRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.ExecuteSqlRequest, dict]]):
The request object. The request for
[ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and
[ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql].
@@ -1006,10 +1009,10 @@ async def sample_execute_streaming_sql():
async def execute_batch_dml(
self,
- request: Union[spanner.ExecuteBatchDmlRequest, dict] = None,
+ request: Optional[Union[spanner.ExecuteBatchDmlRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.ExecuteBatchDmlResponse:
r"""Executes a batch of SQL DML statements. This method allows many
@@ -1059,7 +1062,7 @@ async def sample_execute_batch_dml():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.ExecuteBatchDmlRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.ExecuteBatchDmlRequest, dict]]):
The request object. The request for
[ExecuteBatchDml][google.spanner.v1.Spanner.ExecuteBatchDml].
retry (google.api_core.retry.Retry): Designation of what errors, if any,
@@ -1150,10 +1153,10 @@ async def sample_execute_batch_dml():
async def read(
self,
- request: Union[spanner.ReadRequest, dict] = None,
+ request: Optional[Union[spanner.ReadRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> result_set.ResultSet:
r"""Reads rows from the database using key lookups and scans, as a
@@ -1201,7 +1204,7 @@ async def sample_read():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.ReadRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.ReadRequest, dict]]):
The request object. The request for
[Read][google.spanner.v1.Spanner.Read] and
[StreamingRead][google.spanner.v1.Spanner.StreamingRead].
@@ -1256,10 +1259,10 @@ async def sample_read():
def streaming_read(
self,
- request: Union[spanner.ReadRequest, dict] = None,
+ request: Optional[Union[spanner.ReadRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> Awaitable[AsyncIterable[result_set.PartialResultSet]]:
r"""Like [Read][google.spanner.v1.Spanner.Read], except returns the
@@ -1299,7 +1302,7 @@ async def sample_streaming_read():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.ReadRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.ReadRequest, dict]]):
The request object. The request for
[Read][google.spanner.v1.Spanner.Read] and
[StreamingRead][google.spanner.v1.Spanner.StreamingRead].
@@ -1348,12 +1351,12 @@ async def sample_streaming_read():
async def begin_transaction(
self,
- request: Union[spanner.BeginTransactionRequest, dict] = None,
+ request: Optional[Union[spanner.BeginTransactionRequest, dict]] = None,
*,
- session: str = None,
- options: transaction.TransactionOptions = None,
+ session: Optional[str] = None,
+ options: Optional[transaction.TransactionOptions] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> transaction.Transaction:
r"""Begins a new transaction. This step can often be skipped:
@@ -1389,7 +1392,7 @@ async def sample_begin_transaction():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.BeginTransactionRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.BeginTransactionRequest, dict]]):
The request object. The request for
[BeginTransaction][google.spanner.v1.Spanner.BeginTransaction].
session (:class:`str`):
@@ -1471,14 +1474,14 @@ async def sample_begin_transaction():
async def commit(
self,
- request: Union[spanner.CommitRequest, dict] = None,
+ request: Optional[Union[spanner.CommitRequest, dict]] = None,
*,
- session: str = None,
- transaction_id: bytes = None,
- mutations: Sequence[mutation.Mutation] = None,
- single_use_transaction: transaction.TransactionOptions = None,
+ session: Optional[str] = None,
+ transaction_id: Optional[bytes] = None,
+ mutations: Optional[MutableSequence[mutation.Mutation]] = None,
+ single_use_transaction: Optional[transaction.TransactionOptions] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> commit_response.CommitResponse:
r"""Commits a transaction. The request includes the mutations to be
@@ -1526,7 +1529,7 @@ async def sample_commit():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.CommitRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.CommitRequest, dict]]):
The request object. The request for
[Commit][google.spanner.v1.Spanner.Commit].
session (:class:`str`):
@@ -1543,7 +1546,7 @@ async def sample_commit():
This corresponds to the ``transaction_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
- mutations (:class:`Sequence[google.cloud.spanner_v1.types.Mutation]`):
+ mutations (:class:`MutableSequence[google.cloud.spanner_v1.types.Mutation]`):
The mutations to be executed when
this transaction commits. All mutations
are applied atomically, in the order
@@ -1640,12 +1643,12 @@ async def sample_commit():
async def rollback(
self,
- request: Union[spanner.RollbackRequest, dict] = None,
+ request: Optional[Union[spanner.RollbackRequest, dict]] = None,
*,
- session: str = None,
- transaction_id: bytes = None,
+ session: Optional[str] = None,
+ transaction_id: Optional[bytes] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Rolls back a transaction, releasing any locks it holds. It is a
@@ -1684,7 +1687,7 @@ async def sample_rollback():
await client.rollback(request=request)
Args:
- request (Union[google.cloud.spanner_v1.types.RollbackRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.RollbackRequest, dict]]):
The request object. The request for
[Rollback][google.spanner.v1.Spanner.Rollback].
session (:class:`str`):
@@ -1759,10 +1762,10 @@ async def sample_rollback():
async def partition_query(
self,
- request: Union[spanner.PartitionQueryRequest, dict] = None,
+ request: Optional[Union[spanner.PartitionQueryRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.PartitionResponse:
r"""Creates a set of partition tokens that can be used to execute a
@@ -1808,7 +1811,7 @@ async def sample_partition_query():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.PartitionQueryRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.PartitionQueryRequest, dict]]):
The request object. The request for
[PartitionQuery][google.spanner.v1.Spanner.PartitionQuery]
retry (google.api_core.retry.Retry): Designation of what errors, if any,
@@ -1863,10 +1866,10 @@ async def sample_partition_query():
async def partition_read(
self,
- request: Union[spanner.PartitionReadRequest, dict] = None,
+ request: Optional[Union[spanner.PartitionReadRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.PartitionResponse:
r"""Creates a set of partition tokens that can be used to execute a
@@ -1915,7 +1918,7 @@ async def sample_partition_read():
print(response)
Args:
- request (Union[google.cloud.spanner_v1.types.PartitionReadRequest, dict]):
+ request (Optional[Union[google.cloud.spanner_v1.types.PartitionReadRequest, dict]]):
The request object. The request for
[PartitionRead][google.spanner.v1.Spanner.PartitionRead]
retry (google.api_core.retry.Retry): Designation of what errors, if any,
@@ -1975,14 +1978,9 @@ async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()
-try:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
- gapic_version=pkg_resources.get_distribution(
- "google-cloud-spanner",
- ).version,
- )
-except pkg_resources.DistributionNotFound:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=package_version.__version__
+)
__all__ = ("SpannerAsyncClient",)
diff --git a/google/cloud/spanner_v1/services/spanner/client.py b/google/cloud/spanner_v1/services/spanner/client.py
index e507d5668b..b743d5e003 100644
--- a/google/cloud/spanner_v1/services/spanner/client.py
+++ b/google/cloud/spanner_v1/services/spanner/client.py
@@ -16,8 +16,21 @@
from collections import OrderedDict
import os
import re
-from typing import Dict, Mapping, Optional, Iterable, Sequence, Tuple, Type, Union
-import pkg_resources
+from typing import (
+ Dict,
+ Mapping,
+ MutableMapping,
+ MutableSequence,
+ Optional,
+ Iterable,
+ Sequence,
+ Tuple,
+ Type,
+ Union,
+ cast,
+)
+
+from google.cloud.spanner_v1 import gapic_version as package_version
from google.api_core import client_options as client_options_lib
from google.api_core import exceptions as core_exceptions
@@ -62,7 +75,7 @@ class SpannerClientMeta(type):
def get_transport_class(
cls,
- label: str = None,
+ label: Optional[str] = None,
) -> Type[SpannerTransport]:
"""Returns an appropriate transport class.
@@ -309,7 +322,7 @@ def get_mtls_endpoint_and_cert_source(
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 variabel is "never", use the default API
+ 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.
@@ -364,8 +377,8 @@ def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
- transport: Union[str, SpannerTransport, None] = None,
- client_options: Optional[client_options_lib.ClientOptions] = None,
+ transport: Optional[Union[str, SpannerTransport]] = None,
+ client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiates the spanner client.
@@ -379,7 +392,7 @@ def __init__(
transport (Union[str, SpannerTransport]): The
transport to use. If set to None, a transport is chosen
automatically.
- client_options (google.api_core.client_options.ClientOptions): Custom options for the
+ client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
client. It won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
@@ -409,6 +422,7 @@ def __init__(
client_options = client_options_lib.from_dict(client_options)
if client_options is None:
client_options = client_options_lib.ClientOptions()
+ client_options = cast(client_options_lib.ClientOptions, client_options)
api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(
client_options
@@ -461,11 +475,11 @@ def __init__(
def create_session(
self,
- request: Union[spanner.CreateSessionRequest, dict] = None,
+ request: Optional[Union[spanner.CreateSessionRequest, dict]] = None,
*,
- database: str = None,
+ database: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.Session:
r"""Creates a new session. A session can be used to perform
@@ -579,12 +593,12 @@ def sample_create_session():
def batch_create_sessions(
self,
- request: Union[spanner.BatchCreateSessionsRequest, dict] = None,
+ request: Optional[Union[spanner.BatchCreateSessionsRequest, dict]] = None,
*,
- database: str = None,
- session_count: int = None,
+ database: Optional[str] = None,
+ session_count: Optional[int] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.BatchCreateSessionsResponse:
r"""Creates multiple new sessions.
@@ -700,11 +714,11 @@ def sample_batch_create_sessions():
def get_session(
self,
- request: Union[spanner.GetSessionRequest, dict] = None,
+ request: Optional[Union[spanner.GetSessionRequest, dict]] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.Session:
r"""Gets a session. Returns ``NOT_FOUND`` if the session does not
@@ -802,11 +816,11 @@ def sample_get_session():
def list_sessions(
self,
- request: Union[spanner.ListSessionsRequest, dict] = None,
+ request: Optional[Union[spanner.ListSessionsRequest, dict]] = None,
*,
- database: str = None,
+ database: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> pagers.ListSessionsPager:
r"""Lists all sessions in a given database.
@@ -917,11 +931,11 @@ def sample_list_sessions():
def delete_session(
self,
- request: Union[spanner.DeleteSessionRequest, dict] = None,
+ request: Optional[Union[spanner.DeleteSessionRequest, dict]] = None,
*,
- name: str = None,
+ name: Optional[str] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Ends a session, releasing server resources associated
@@ -1009,10 +1023,10 @@ def sample_delete_session():
def execute_sql(
self,
- request: Union[spanner.ExecuteSqlRequest, dict] = None,
+ request: Optional[Union[spanner.ExecuteSqlRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> result_set.ResultSet:
r"""Executes an SQL statement, returning all results in a single
@@ -1105,10 +1119,10 @@ def sample_execute_sql():
def execute_streaming_sql(
self,
- request: Union[spanner.ExecuteSqlRequest, dict] = None,
+ request: Optional[Union[spanner.ExecuteSqlRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> Iterable[result_set.PartialResultSet]:
r"""Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except
@@ -1197,10 +1211,10 @@ def sample_execute_streaming_sql():
def execute_batch_dml(
self,
- request: Union[spanner.ExecuteBatchDmlRequest, dict] = None,
+ request: Optional[Union[spanner.ExecuteBatchDmlRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.ExecuteBatchDmlResponse:
r"""Executes a batch of SQL DML statements. This method allows many
@@ -1333,10 +1347,10 @@ def sample_execute_batch_dml():
def read(
self,
- request: Union[spanner.ReadRequest, dict] = None,
+ request: Optional[Union[spanner.ReadRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> result_set.ResultSet:
r"""Reads rows from the database using key lookups and scans, as a
@@ -1431,10 +1445,10 @@ def sample_read():
def streaming_read(
self,
- request: Union[spanner.ReadRequest, dict] = None,
+ request: Optional[Union[spanner.ReadRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> Iterable[result_set.PartialResultSet]:
r"""Like [Read][google.spanner.v1.Spanner.Read], except returns the
@@ -1524,12 +1538,12 @@ def sample_streaming_read():
def begin_transaction(
self,
- request: Union[spanner.BeginTransactionRequest, dict] = None,
+ request: Optional[Union[spanner.BeginTransactionRequest, dict]] = None,
*,
- session: str = None,
- options: transaction.TransactionOptions = None,
+ session: Optional[str] = None,
+ options: Optional[transaction.TransactionOptions] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> transaction.Transaction:
r"""Begins a new transaction. This step can often be skipped:
@@ -1638,14 +1652,14 @@ def sample_begin_transaction():
def commit(
self,
- request: Union[spanner.CommitRequest, dict] = None,
+ request: Optional[Union[spanner.CommitRequest, dict]] = None,
*,
- session: str = None,
- transaction_id: bytes = None,
- mutations: Sequence[mutation.Mutation] = None,
- single_use_transaction: transaction.TransactionOptions = None,
+ session: Optional[str] = None,
+ transaction_id: Optional[bytes] = None,
+ mutations: Optional[MutableSequence[mutation.Mutation]] = None,
+ single_use_transaction: Optional[transaction.TransactionOptions] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> commit_response.CommitResponse:
r"""Commits a transaction. The request includes the mutations to be
@@ -1710,7 +1724,7 @@ def sample_commit():
This corresponds to the ``transaction_id`` field
on the ``request`` instance; if ``request`` is provided, this
should not be set.
- mutations (Sequence[google.cloud.spanner_v1.types.Mutation]):
+ mutations (MutableSequence[google.cloud.spanner_v1.types.Mutation]):
The mutations to be executed when
this transaction commits. All mutations
are applied atomically, in the order
@@ -1798,12 +1812,12 @@ def sample_commit():
def rollback(
self,
- request: Union[spanner.RollbackRequest, dict] = None,
+ request: Optional[Union[spanner.RollbackRequest, dict]] = None,
*,
- session: str = None,
- transaction_id: bytes = None,
+ session: Optional[str] = None,
+ transaction_id: Optional[bytes] = None,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> None:
r"""Rolls back a transaction, releasing any locks it holds. It is a
@@ -1908,10 +1922,10 @@ def sample_rollback():
def partition_query(
self,
- request: Union[spanner.PartitionQueryRequest, dict] = None,
+ request: Optional[Union[spanner.PartitionQueryRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.PartitionResponse:
r"""Creates a set of partition tokens that can be used to execute a
@@ -2004,10 +2018,10 @@ def sample_partition_query():
def partition_read(
self,
- request: Union[spanner.PartitionReadRequest, dict] = None,
+ request: Optional[Union[spanner.PartitionReadRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
- timeout: float = None,
+ timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> spanner.PartitionResponse:
r"""Creates a set of partition tokens that can be used to execute a
@@ -2115,14 +2129,9 @@ def __exit__(self, type, value, traceback):
self.transport.close()
-try:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
- gapic_version=pkg_resources.get_distribution(
- "google-cloud-spanner",
- ).version,
- )
-except pkg_resources.DistributionNotFound:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=package_version.__version__
+)
__all__ = ("SpannerClient",)
diff --git a/google/cloud/spanner_v1/services/spanner/transports/base.py b/google/cloud/spanner_v1/services/spanner/transports/base.py
index 4c4f24ab9a..ccae2873bb 100644
--- a/google/cloud/spanner_v1/services/spanner/transports/base.py
+++ b/google/cloud/spanner_v1/services/spanner/transports/base.py
@@ -15,7 +15,8 @@
#
import abc
from typing import Awaitable, Callable, Dict, Optional, Sequence, Union
-import pkg_resources
+
+from google.cloud.spanner_v1 import gapic_version as package_version
import google.auth # type: ignore
import google.api_core
@@ -31,14 +32,9 @@
from google.cloud.spanner_v1.types import transaction
from google.protobuf import empty_pb2 # type: ignore
-try:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
- gapic_version=pkg_resources.get_distribution(
- "google-cloud-spanner",
- ).version,
- )
-except pkg_resources.DistributionNotFound:
- DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
+DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
+ gapic_version=package_version.__version__
+)
class SpannerTransport(abc.ABC):
@@ -55,7 +51,7 @@ def __init__(
self,
*,
host: str = DEFAULT_HOST,
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
diff --git a/google/cloud/spanner_v1/services/spanner/transports/grpc.py b/google/cloud/spanner_v1/services/spanner/transports/grpc.py
index 06169e3d83..42d55e37b3 100644
--- a/google/cloud/spanner_v1/services/spanner/transports/grpc.py
+++ b/google/cloud/spanner_v1/services/spanner/transports/grpc.py
@@ -53,14 +53,14 @@ def __init__(
self,
*,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
- credentials_file: str = None,
- scopes: Sequence[str] = None,
- channel: grpc.Channel = None,
- api_mtls_endpoint: str = None,
- client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
- ssl_channel_credentials: grpc.ChannelCredentials = None,
- client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
+ credentials_file: Optional[str] = None,
+ scopes: Optional[Sequence[str]] = None,
+ channel: Optional[grpc.Channel] = None,
+ api_mtls_endpoint: Optional[str] = None,
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
always_use_jwt_access: Optional[bool] = False,
@@ -187,8 +187,8 @@ def __init__(
def create_channel(
cls,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
- credentials_file: str = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
+ credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
**kwargs,
diff --git a/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py b/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py
index aabeb1cbb1..3f3c941cb5 100644
--- a/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py
+++ b/google/cloud/spanner_v1/services/spanner/transports/grpc_asyncio.py
@@ -55,7 +55,7 @@ class SpannerGrpcAsyncIOTransport(SpannerTransport):
def create_channel(
cls,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
@@ -98,15 +98,15 @@ def __init__(
self,
*,
host: str = "spanner.googleapis.com",
- credentials: ga_credentials.Credentials = None,
+ credentials: Optional[ga_credentials.Credentials] = None,
credentials_file: Optional[str] = None,
scopes: Optional[Sequence[str]] = None,
- channel: aio.Channel = None,
- api_mtls_endpoint: str = None,
- client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
- ssl_channel_credentials: grpc.ChannelCredentials = None,
- client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
- quota_project_id=None,
+ channel: Optional[aio.Channel] = None,
+ api_mtls_endpoint: Optional[str] = None,
+ client_cert_source: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
+ ssl_channel_credentials: Optional[grpc.ChannelCredentials] = None,
+ client_cert_source_for_mtls: Optional[Callable[[], Tuple[bytes, bytes]]] = None,
+ quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
always_use_jwt_access: Optional[bool] = False,
api_audience: Optional[str] = None,
diff --git a/google/cloud/spanner_v1/types/commit_response.py b/google/cloud/spanner_v1/types/commit_response.py
index 837cbbf4f4..be4f20ee64 100644
--- a/google/cloud/spanner_v1/types/commit_response.py
+++ b/google/cloud/spanner_v1/types/commit_response.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore
@@ -55,17 +57,17 @@ class CommitStats(proto.Message):
`INVALID_ARGUMENT `__.
"""
- mutation_count = proto.Field(
+ mutation_count: int = proto.Field(
proto.INT64,
number=1,
)
- commit_timestamp = proto.Field(
+ commit_timestamp: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=1,
message=timestamp_pb2.Timestamp,
)
- commit_stats = proto.Field(
+ commit_stats: CommitStats = proto.Field(
proto.MESSAGE,
number=2,
message=CommitStats,
diff --git a/google/cloud/spanner_v1/types/keys.py b/google/cloud/spanner_v1/types/keys.py
index 81e6e1360c..5fcbb1b5bf 100644
--- a/google/cloud/spanner_v1/types/keys.py
+++ b/google/cloud/spanner_v1/types/keys.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.protobuf import struct_pb2 # type: ignore
@@ -172,25 +174,25 @@ class KeyRange(proto.Message):
This field is a member of `oneof`_ ``end_key_type``.
"""
- start_closed = proto.Field(
+ start_closed: struct_pb2.ListValue = proto.Field(
proto.MESSAGE,
number=1,
oneof="start_key_type",
message=struct_pb2.ListValue,
)
- start_open = proto.Field(
+ start_open: struct_pb2.ListValue = proto.Field(
proto.MESSAGE,
number=2,
oneof="start_key_type",
message=struct_pb2.ListValue,
)
- end_closed = proto.Field(
+ end_closed: struct_pb2.ListValue = proto.Field(
proto.MESSAGE,
number=3,
oneof="end_key_type",
message=struct_pb2.ListValue,
)
- end_open = proto.Field(
+ end_open: struct_pb2.ListValue = proto.Field(
proto.MESSAGE,
number=4,
oneof="end_key_type",
@@ -208,13 +210,13 @@ class KeySet(proto.Message):
Spanner behaves as if the key were only specified once.
Attributes:
- keys (Sequence[google.protobuf.struct_pb2.ListValue]):
+ keys (MutableSequence[google.protobuf.struct_pb2.ListValue]):
A list of specific keys. Entries in ``keys`` should have
exactly as many elements as there are columns in the primary
or index key with which this ``KeySet`` is used. Individual
key values are encoded as described
[here][google.spanner.v1.TypeCode].
- ranges (Sequence[google.cloud.spanner_v1.types.KeyRange]):
+ ranges (MutableSequence[google.cloud.spanner_v1.types.KeyRange]):
A list of key ranges. See
[KeyRange][google.spanner.v1.KeyRange] for more information
about key range specifications.
@@ -225,17 +227,17 @@ class KeySet(proto.Message):
only yielded once.
"""
- keys = proto.RepeatedField(
+ keys: MutableSequence[struct_pb2.ListValue] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message=struct_pb2.ListValue,
)
- ranges = proto.RepeatedField(
+ ranges: MutableSequence["KeyRange"] = proto.RepeatedField(
proto.MESSAGE,
number=2,
message="KeyRange",
)
- all_ = proto.Field(
+ all_: bool = proto.Field(
proto.BOOL,
number=3,
)
diff --git a/google/cloud/spanner_v1/types/mutation.py b/google/cloud/spanner_v1/types/mutation.py
index 2ad2db30ac..8fa9980331 100644
--- a/google/cloud/spanner_v1/types/mutation.py
+++ b/google/cloud/spanner_v1/types/mutation.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.cloud.spanner_v1.types import keys
@@ -98,7 +100,7 @@ class Write(proto.Message):
table (str):
Required. The table whose rows will be
written.
- columns (Sequence[str]):
+ columns (MutableSequence[str]):
The names of the columns in
[table][google.spanner.v1.Mutation.Write.table] to be
written.
@@ -106,7 +108,7 @@ class Write(proto.Message):
The list of columns must contain enough columns to allow
Cloud Spanner to derive values for all primary key columns
in the row(s) to be modified.
- values (Sequence[google.protobuf.struct_pb2.ListValue]):
+ values (MutableSequence[google.protobuf.struct_pb2.ListValue]):
The values to be written. ``values`` can contain more than
one list of values. If it does, then multiple rows are
written, one for each entry in ``values``. Each list in
@@ -121,15 +123,15 @@ class Write(proto.Message):
[here][google.spanner.v1.TypeCode].
"""
- table = proto.Field(
+ table: str = proto.Field(
proto.STRING,
number=1,
)
- columns = proto.RepeatedField(
+ columns: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=2,
)
- values = proto.RepeatedField(
+ values: MutableSequence[struct_pb2.ListValue] = proto.RepeatedField(
proto.MESSAGE,
number=3,
message=struct_pb2.ListValue,
@@ -152,41 +154,41 @@ class Delete(proto.Message):
succeed even if some or all rows do not exist.
"""
- table = proto.Field(
+ table: str = proto.Field(
proto.STRING,
number=1,
)
- key_set = proto.Field(
+ key_set: keys.KeySet = proto.Field(
proto.MESSAGE,
number=2,
message=keys.KeySet,
)
- insert = proto.Field(
+ insert: Write = proto.Field(
proto.MESSAGE,
number=1,
oneof="operation",
message=Write,
)
- update = proto.Field(
+ update: Write = proto.Field(
proto.MESSAGE,
number=2,
oneof="operation",
message=Write,
)
- insert_or_update = proto.Field(
+ insert_or_update: Write = proto.Field(
proto.MESSAGE,
number=3,
oneof="operation",
message=Write,
)
- replace = proto.Field(
+ replace: Write = proto.Field(
proto.MESSAGE,
number=4,
oneof="operation",
message=Write,
)
- delete = proto.Field(
+ delete: Delete = proto.Field(
proto.MESSAGE,
number=5,
oneof="operation",
diff --git a/google/cloud/spanner_v1/types/query_plan.py b/google/cloud/spanner_v1/types/query_plan.py
index 465e9972be..f097b582b9 100644
--- a/google/cloud/spanner_v1/types/query_plan.py
+++ b/google/cloud/spanner_v1/types/query_plan.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.protobuf import struct_pb2 # type: ignore
@@ -44,7 +46,7 @@ class PlanNode(proto.Message):
directly embed a description of the node in its parent.
display_name (str):
The display name for the node.
- child_links (Sequence[google.cloud.spanner_v1.types.PlanNode.ChildLink]):
+ child_links (MutableSequence[google.cloud.spanner_v1.types.PlanNode.ChildLink]):
List of child node ``index``\ es and their relationship to
this parent.
short_representation (google.cloud.spanner_v1.types.PlanNode.ShortRepresentation):
@@ -105,15 +107,15 @@ class ChildLink(proto.Message):
to the variable names assigned to the columns.
"""
- child_index = proto.Field(
+ child_index: int = proto.Field(
proto.INT32,
number=1,
)
- type_ = proto.Field(
+ type_: str = proto.Field(
proto.STRING,
number=2,
)
- variable = proto.Field(
+ variable: str = proto.Field(
proto.STRING,
number=3,
)
@@ -126,7 +128,7 @@ class ShortRepresentation(proto.Message):
description (str):
A string representation of the expression
subtree rooted at this node.
- subqueries (Mapping[str, int]):
+ subqueries (MutableMapping[str, int]):
A mapping of (subquery variable name) -> (subquery node id)
for cases where the ``description`` string of this node
references a ``SCALAR`` subquery contained in the expression
@@ -134,45 +136,45 @@ class ShortRepresentation(proto.Message):
subquery may not necessarily be a direct child of this node.
"""
- description = proto.Field(
+ description: str = proto.Field(
proto.STRING,
number=1,
)
- subqueries = proto.MapField(
+ subqueries: MutableMapping[str, int] = proto.MapField(
proto.STRING,
proto.INT32,
number=2,
)
- index = proto.Field(
+ index: int = proto.Field(
proto.INT32,
number=1,
)
- kind = proto.Field(
+ kind: Kind = proto.Field(
proto.ENUM,
number=2,
enum=Kind,
)
- display_name = proto.Field(
+ display_name: str = proto.Field(
proto.STRING,
number=3,
)
- child_links = proto.RepeatedField(
+ child_links: MutableSequence[ChildLink] = proto.RepeatedField(
proto.MESSAGE,
number=4,
message=ChildLink,
)
- short_representation = proto.Field(
+ short_representation: ShortRepresentation = proto.Field(
proto.MESSAGE,
number=5,
message=ShortRepresentation,
)
- metadata = proto.Field(
+ metadata: struct_pb2.Struct = proto.Field(
proto.MESSAGE,
number=6,
message=struct_pb2.Struct,
)
- execution_stats = proto.Field(
+ execution_stats: struct_pb2.Struct = proto.Field(
proto.MESSAGE,
number=7,
message=struct_pb2.Struct,
@@ -184,14 +186,14 @@ class QueryPlan(proto.Message):
plan.
Attributes:
- plan_nodes (Sequence[google.cloud.spanner_v1.types.PlanNode]):
+ plan_nodes (MutableSequence[google.cloud.spanner_v1.types.PlanNode]):
The nodes in the query plan. Plan nodes are returned in
pre-order starting with the plan root. Each
[PlanNode][google.spanner.v1.PlanNode]'s ``id`` corresponds
to its index in ``plan_nodes``.
"""
- plan_nodes = proto.RepeatedField(
+ plan_nodes: MutableSequence["PlanNode"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="PlanNode",
diff --git a/google/cloud/spanner_v1/types/result_set.py b/google/cloud/spanner_v1/types/result_set.py
index 2990a015b5..8a07d456df 100644
--- a/google/cloud/spanner_v1/types/result_set.py
+++ b/google/cloud/spanner_v1/types/result_set.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.cloud.spanner_v1.types import query_plan as gs_query_plan
@@ -40,7 +42,7 @@ class ResultSet(proto.Message):
metadata (google.cloud.spanner_v1.types.ResultSetMetadata):
Metadata about the result set, such as row
type information.
- rows (Sequence[google.protobuf.struct_pb2.ListValue]):
+ rows (MutableSequence[google.protobuf.struct_pb2.ListValue]):
Each element in ``rows`` is a row whose format is defined by
[metadata.row_type][google.spanner.v1.ResultSetMetadata.row_type].
The ith element in each row matches the ith field in
@@ -60,17 +62,17 @@ class ResultSet(proto.Message):
[ExecuteSqlRequest.query_mode][google.spanner.v1.ExecuteSqlRequest.query_mode].
"""
- metadata = proto.Field(
+ metadata: "ResultSetMetadata" = proto.Field(
proto.MESSAGE,
number=1,
message="ResultSetMetadata",
)
- rows = proto.RepeatedField(
+ rows: MutableSequence[struct_pb2.ListValue] = proto.RepeatedField(
proto.MESSAGE,
number=2,
message=struct_pb2.ListValue,
)
- stats = proto.Field(
+ stats: "ResultSetStats" = proto.Field(
proto.MESSAGE,
number=3,
message="ResultSetStats",
@@ -87,7 +89,7 @@ class PartialResultSet(proto.Message):
Metadata about the result set, such as row
type information. Only present in the first
response.
- values (Sequence[google.protobuf.struct_pb2.Value]):
+ values (MutableSequence[google.protobuf.struct_pb2.Value]):
A streamed result set consists of a stream of values, which
might be split into many ``PartialResultSet`` messages to
accommodate large rows and/or large values. Every N complete
@@ -192,25 +194,25 @@ class PartialResultSet(proto.Message):
statements.
"""
- metadata = proto.Field(
+ metadata: "ResultSetMetadata" = proto.Field(
proto.MESSAGE,
number=1,
message="ResultSetMetadata",
)
- values = proto.RepeatedField(
+ values: MutableSequence[struct_pb2.Value] = proto.RepeatedField(
proto.MESSAGE,
number=2,
message=struct_pb2.Value,
)
- chunked_value = proto.Field(
+ chunked_value: bool = proto.Field(
proto.BOOL,
number=3,
)
- resume_token = proto.Field(
+ resume_token: bytes = proto.Field(
proto.BYTES,
number=4,
)
- stats = proto.Field(
+ stats: "ResultSetStats" = proto.Field(
proto.MESSAGE,
number=5,
message="ResultSetStats",
@@ -254,17 +256,17 @@ class ResultSetMetadata(proto.Message):
]
"""
- row_type = proto.Field(
+ row_type: gs_type.StructType = proto.Field(
proto.MESSAGE,
number=1,
message=gs_type.StructType,
)
- transaction = proto.Field(
+ transaction: gs_transaction.Transaction = proto.Field(
proto.MESSAGE,
number=2,
message=gs_transaction.Transaction,
)
- undeclared_parameters = proto.Field(
+ undeclared_parameters: gs_type.StructType = proto.Field(
proto.MESSAGE,
number=3,
message=gs_type.StructType,
@@ -312,22 +314,22 @@ class ResultSetStats(proto.Message):
This field is a member of `oneof`_ ``row_count``.
"""
- query_plan = proto.Field(
+ query_plan: gs_query_plan.QueryPlan = proto.Field(
proto.MESSAGE,
number=1,
message=gs_query_plan.QueryPlan,
)
- query_stats = proto.Field(
+ query_stats: struct_pb2.Struct = proto.Field(
proto.MESSAGE,
number=2,
message=struct_pb2.Struct,
)
- row_count_exact = proto.Field(
+ row_count_exact: int = proto.Field(
proto.INT64,
number=3,
oneof="row_count",
)
- row_count_lower_bound = proto.Field(
+ row_count_lower_bound: int = proto.Field(
proto.INT64,
number=4,
oneof="row_count",
diff --git a/google/cloud/spanner_v1/types/spanner.py b/google/cloud/spanner_v1/types/spanner.py
index 8862ad5cbb..3f531b588b 100644
--- a/google/cloud/spanner_v1/types/spanner.py
+++ b/google/cloud/spanner_v1/types/spanner.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.cloud.spanner_v1.types import keys
@@ -65,11 +67,11 @@ class CreateSessionRequest(proto.Message):
Required. The session to create.
"""
- database = proto.Field(
+ database: str = proto.Field(
proto.STRING,
number=1,
)
- session = proto.Field(
+ session: "Session" = proto.Field(
proto.MESSAGE,
number=2,
message="Session",
@@ -97,16 +99,16 @@ class BatchCreateSessionsRequest(proto.Message):
as necessary).
"""
- database = proto.Field(
+ database: str = proto.Field(
proto.STRING,
number=1,
)
- session_template = proto.Field(
+ session_template: "Session" = proto.Field(
proto.MESSAGE,
number=2,
message="Session",
)
- session_count = proto.Field(
+ session_count: int = proto.Field(
proto.INT32,
number=3,
)
@@ -117,11 +119,11 @@ class BatchCreateSessionsResponse(proto.Message):
[BatchCreateSessions][google.spanner.v1.Spanner.BatchCreateSessions].
Attributes:
- session (Sequence[google.cloud.spanner_v1.types.Session]):
+ session (MutableSequence[google.cloud.spanner_v1.types.Session]):
The freshly created sessions.
"""
- session = proto.RepeatedField(
+ session: MutableSequence["Session"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="Session",
@@ -135,7 +137,7 @@ class Session(proto.Message):
name (str):
Output only. The name of the session. This is
always system-assigned.
- labels (Mapping[str, str]):
+ labels (MutableMapping[str, str]):
The labels for the session.
- Label keys must be between 1 and 63 characters long and
@@ -160,26 +162,26 @@ class Session(proto.Message):
The database role which created this session.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- labels = proto.MapField(
+ labels: MutableMapping[str, str] = proto.MapField(
proto.STRING,
proto.STRING,
number=2,
)
- create_time = proto.Field(
+ create_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=3,
message=timestamp_pb2.Timestamp,
)
- approximate_last_use_time = proto.Field(
+ approximate_last_use_time: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=4,
message=timestamp_pb2.Timestamp,
)
- creator_role = proto.Field(
+ creator_role: str = proto.Field(
proto.STRING,
number=5,
)
@@ -194,7 +196,7 @@ class GetSessionRequest(proto.Message):
retrieve.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
@@ -231,19 +233,19 @@ class ListSessionsRequest(proto.Message):
and the value of the label contains the string "dev".
"""
- database = proto.Field(
+ database: str = proto.Field(
proto.STRING,
number=1,
)
- page_size = proto.Field(
+ page_size: int = proto.Field(
proto.INT32,
number=2,
)
- page_token = proto.Field(
+ page_token: str = proto.Field(
proto.STRING,
number=3,
)
- filter = proto.Field(
+ filter: str = proto.Field(
proto.STRING,
number=4,
)
@@ -254,7 +256,7 @@ class ListSessionsResponse(proto.Message):
[ListSessions][google.spanner.v1.Spanner.ListSessions].
Attributes:
- sessions (Sequence[google.cloud.spanner_v1.types.Session]):
+ sessions (MutableSequence[google.cloud.spanner_v1.types.Session]):
The list of requested sessions.
next_page_token (str):
``next_page_token`` can be sent in a subsequent
@@ -266,12 +268,12 @@ class ListSessionsResponse(proto.Message):
def raw_page(self):
return self
- sessions = proto.RepeatedField(
+ sessions: MutableSequence["Session"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="Session",
)
- next_page_token = proto.Field(
+ next_page_token: str = proto.Field(
proto.STRING,
number=2,
)
@@ -286,7 +288,7 @@ class DeleteSessionRequest(proto.Message):
Required. The name of the session to delete.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
@@ -347,16 +349,16 @@ class Priority(proto.Enum):
PRIORITY_MEDIUM = 2
PRIORITY_HIGH = 3
- priority = proto.Field(
+ priority: Priority = proto.Field(
proto.ENUM,
number=1,
enum=Priority,
)
- request_tag = proto.Field(
+ request_tag: str = proto.Field(
proto.STRING,
number=2,
)
- transaction_tag = proto.Field(
+ transaction_tag: str = proto.Field(
proto.STRING,
number=3,
)
@@ -404,7 +406,7 @@ class ExecuteSqlRequest(proto.Message):
It is an error to execute a SQL statement with unbound
parameters.
- param_types (Mapping[str, google.cloud.spanner_v1.types.Type]):
+ param_types (MutableMapping[str, google.cloud.spanner_v1.types.Type]):
It is not always possible for Cloud Spanner to infer the
right SQL type from a JSON value. For example, values of
type ``BYTES`` and values of type ``STRING`` both appear in
@@ -525,62 +527,62 @@ class QueryOptions(proto.Message):
garbage collection fails with an ``INVALID_ARGUMENT`` error.
"""
- optimizer_version = proto.Field(
+ optimizer_version: str = proto.Field(
proto.STRING,
number=1,
)
- optimizer_statistics_package = proto.Field(
+ optimizer_statistics_package: str = proto.Field(
proto.STRING,
number=2,
)
- session = proto.Field(
+ session: str = proto.Field(
proto.STRING,
number=1,
)
- transaction = proto.Field(
+ transaction: gs_transaction.TransactionSelector = proto.Field(
proto.MESSAGE,
number=2,
message=gs_transaction.TransactionSelector,
)
- sql = proto.Field(
+ sql: str = proto.Field(
proto.STRING,
number=3,
)
- params = proto.Field(
+ params: struct_pb2.Struct = proto.Field(
proto.MESSAGE,
number=4,
message=struct_pb2.Struct,
)
- param_types = proto.MapField(
+ param_types: MutableMapping[str, gs_type.Type] = proto.MapField(
proto.STRING,
proto.MESSAGE,
number=5,
message=gs_type.Type,
)
- resume_token = proto.Field(
+ resume_token: bytes = proto.Field(
proto.BYTES,
number=6,
)
- query_mode = proto.Field(
+ query_mode: QueryMode = proto.Field(
proto.ENUM,
number=7,
enum=QueryMode,
)
- partition_token = proto.Field(
+ partition_token: bytes = proto.Field(
proto.BYTES,
number=8,
)
- seqno = proto.Field(
+ seqno: int = proto.Field(
proto.INT64,
number=9,
)
- query_options = proto.Field(
+ query_options: QueryOptions = proto.Field(
proto.MESSAGE,
number=10,
message=QueryOptions,
)
- request_options = proto.Field(
+ request_options: "RequestOptions" = proto.Field(
proto.MESSAGE,
number=11,
message="RequestOptions",
@@ -602,7 +604,7 @@ class ExecuteBatchDmlRequest(proto.Message):
transactions are not supported. The caller must
either supply an existing transaction ID or
begin a new transaction.
- statements (Sequence[google.cloud.spanner_v1.types.ExecuteBatchDmlRequest.Statement]):
+ statements (MutableSequence[google.cloud.spanner_v1.types.ExecuteBatchDmlRequest.Statement]):
Required. The list of statements to execute in this batch.
Statements are executed serially, such that the effects of
statement ``i`` are visible to statement ``i+1``. Each
@@ -651,7 +653,7 @@ class Statement(proto.Message):
It is an error to execute a SQL statement with unbound
parameters.
- param_types (Mapping[str, google.cloud.spanner_v1.types.Type]):
+ param_types (MutableMapping[str, google.cloud.spanner_v1.types.Type]):
It is not always possible for Cloud Spanner to infer the
right SQL type from a JSON value. For example, values of
type ``BYTES`` and values of type ``STRING`` both appear in
@@ -665,41 +667,41 @@ class Statement(proto.Message):
SQL types.
"""
- sql = proto.Field(
+ sql: str = proto.Field(
proto.STRING,
number=1,
)
- params = proto.Field(
+ params: struct_pb2.Struct = proto.Field(
proto.MESSAGE,
number=2,
message=struct_pb2.Struct,
)
- param_types = proto.MapField(
+ param_types: MutableMapping[str, gs_type.Type] = proto.MapField(
proto.STRING,
proto.MESSAGE,
number=3,
message=gs_type.Type,
)
- session = proto.Field(
+ session: str = proto.Field(
proto.STRING,
number=1,
)
- transaction = proto.Field(
+ transaction: gs_transaction.TransactionSelector = proto.Field(
proto.MESSAGE,
number=2,
message=gs_transaction.TransactionSelector,
)
- statements = proto.RepeatedField(
+ statements: MutableSequence[Statement] = proto.RepeatedField(
proto.MESSAGE,
number=3,
message=Statement,
)
- seqno = proto.Field(
+ seqno: int = proto.Field(
proto.INT64,
number=4,
)
- request_options = proto.Field(
+ request_options: "RequestOptions" = proto.Field(
proto.MESSAGE,
number=5,
message="RequestOptions",
@@ -742,7 +744,7 @@ class ExecuteBatchDmlResponse(proto.Message):
were not executed.
Attributes:
- result_sets (Sequence[google.cloud.spanner_v1.types.ResultSet]):
+ result_sets (MutableSequence[google.cloud.spanner_v1.types.ResultSet]):
One [ResultSet][google.spanner.v1.ResultSet] for each
statement in the request that ran successfully, in the same
order as the statements in the request. Each
@@ -761,12 +763,12 @@ class ExecuteBatchDmlResponse(proto.Message):
statement.
"""
- result_sets = proto.RepeatedField(
+ result_sets: MutableSequence[result_set.ResultSet] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message=result_set.ResultSet,
)
- status = proto.Field(
+ status: status_pb2.Status = proto.Field(
proto.MESSAGE,
number=2,
message=status_pb2.Status,
@@ -798,11 +800,11 @@ class PartitionOptions(proto.Message):
this maximum count request.
"""
- partition_size_bytes = proto.Field(
+ partition_size_bytes: int = proto.Field(
proto.INT64,
number=1,
)
- max_partitions = proto.Field(
+ max_partitions: int = proto.Field(
proto.INT64,
number=2,
)
@@ -851,7 +853,7 @@ class PartitionQueryRequest(proto.Message):
It is an error to execute a SQL statement with unbound
parameters.
- param_types (Mapping[str, google.cloud.spanner_v1.types.Type]):
+ param_types (MutableMapping[str, google.cloud.spanner_v1.types.Type]):
It is not always possible for Cloud Spanner to infer the
right SQL type from a JSON value. For example, values of
type ``BYTES`` and values of type ``STRING`` both appear in
@@ -867,31 +869,31 @@ class PartitionQueryRequest(proto.Message):
partitions are created.
"""
- session = proto.Field(
+ session: str = proto.Field(
proto.STRING,
number=1,
)
- transaction = proto.Field(
+ transaction: gs_transaction.TransactionSelector = proto.Field(
proto.MESSAGE,
number=2,
message=gs_transaction.TransactionSelector,
)
- sql = proto.Field(
+ sql: str = proto.Field(
proto.STRING,
number=3,
)
- params = proto.Field(
+ params: struct_pb2.Struct = proto.Field(
proto.MESSAGE,
number=4,
message=struct_pb2.Struct,
)
- param_types = proto.MapField(
+ param_types: MutableMapping[str, gs_type.Type] = proto.MapField(
proto.STRING,
proto.MESSAGE,
number=5,
message=gs_type.Type,
)
- partition_options = proto.Field(
+ partition_options: "PartitionOptions" = proto.Field(
proto.MESSAGE,
number=6,
message="PartitionOptions",
@@ -922,7 +924,7 @@ class PartitionReadRequest(proto.Message):
and sorting result rows. See
[key_set][google.spanner.v1.PartitionReadRequest.key_set]
for further information.
- columns (Sequence[str]):
+ columns (MutableSequence[str]):
The columns of
[table][google.spanner.v1.PartitionReadRequest.table] to be
returned for each row matching this request.
@@ -947,33 +949,33 @@ class PartitionReadRequest(proto.Message):
partitions are created.
"""
- session = proto.Field(
+ session: str = proto.Field(
proto.STRING,
number=1,
)
- transaction = proto.Field(
+ transaction: gs_transaction.TransactionSelector = proto.Field(
proto.MESSAGE,
number=2,
message=gs_transaction.TransactionSelector,
)
- table = proto.Field(
+ table: str = proto.Field(
proto.STRING,
number=3,
)
- index = proto.Field(
+ index: str = proto.Field(
proto.STRING,
number=4,
)
- columns = proto.RepeatedField(
+ columns: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=5,
)
- key_set = proto.Field(
+ key_set: keys.KeySet = proto.Field(
proto.MESSAGE,
number=6,
message=keys.KeySet,
)
- partition_options = proto.Field(
+ partition_options: "PartitionOptions" = proto.Field(
proto.MESSAGE,
number=9,
message="PartitionOptions",
@@ -993,7 +995,7 @@ class Partition(proto.Message):
token.
"""
- partition_token = proto.Field(
+ partition_token: bytes = proto.Field(
proto.BYTES,
number=1,
)
@@ -1005,18 +1007,18 @@ class PartitionResponse(proto.Message):
[PartitionRead][google.spanner.v1.Spanner.PartitionRead]
Attributes:
- partitions (Sequence[google.cloud.spanner_v1.types.Partition]):
+ partitions (MutableSequence[google.cloud.spanner_v1.types.Partition]):
Partitions created by this request.
transaction (google.cloud.spanner_v1.types.Transaction):
Transaction created by this request.
"""
- partitions = proto.RepeatedField(
+ partitions: MutableSequence["Partition"] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message="Partition",
)
- transaction = proto.Field(
+ transaction: gs_transaction.Transaction = proto.Field(
proto.MESSAGE,
number=2,
message=gs_transaction.Transaction,
@@ -1046,7 +1048,7 @@ class ReadRequest(proto.Message):
result rows. See
[key_set][google.spanner.v1.ReadRequest.key_set] for further
information.
- columns (Sequence[str]):
+ columns (MutableSequence[str]):
Required. The columns of
[table][google.spanner.v1.ReadRequest.table] to be returned
for each row matching this request.
@@ -1097,45 +1099,45 @@ class ReadRequest(proto.Message):
Common options for this request.
"""
- session = proto.Field(
+ session: str = proto.Field(
proto.STRING,
number=1,
)
- transaction = proto.Field(
+ transaction: gs_transaction.TransactionSelector = proto.Field(
proto.MESSAGE,
number=2,
message=gs_transaction.TransactionSelector,
)
- table = proto.Field(
+ table: str = proto.Field(
proto.STRING,
number=3,
)
- index = proto.Field(
+ index: str = proto.Field(
proto.STRING,
number=4,
)
- columns = proto.RepeatedField(
+ columns: MutableSequence[str] = proto.RepeatedField(
proto.STRING,
number=5,
)
- key_set = proto.Field(
+ key_set: keys.KeySet = proto.Field(
proto.MESSAGE,
number=6,
message=keys.KeySet,
)
- limit = proto.Field(
+ limit: int = proto.Field(
proto.INT64,
number=8,
)
- resume_token = proto.Field(
+ resume_token: bytes = proto.Field(
proto.BYTES,
number=9,
)
- partition_token = proto.Field(
+ partition_token: bytes = proto.Field(
proto.BYTES,
number=10,
)
- request_options = proto.Field(
+ request_options: "RequestOptions" = proto.Field(
proto.MESSAGE,
number=11,
message="RequestOptions",
@@ -1160,16 +1162,16 @@ class BeginTransactionRequest(proto.Message):
this transaction instead.
"""
- session = proto.Field(
+ session: str = proto.Field(
proto.STRING,
number=1,
)
- options = proto.Field(
+ options: gs_transaction.TransactionOptions = proto.Field(
proto.MESSAGE,
number=2,
message=gs_transaction.TransactionOptions,
)
- request_options = proto.Field(
+ request_options: "RequestOptions" = proto.Field(
proto.MESSAGE,
number=3,
message="RequestOptions",
@@ -1206,7 +1208,7 @@ class CommitRequest(proto.Message):
and [Commit][google.spanner.v1.Spanner.Commit] instead.
This field is a member of `oneof`_ ``transaction``.
- mutations (Sequence[google.cloud.spanner_v1.types.Mutation]):
+ mutations (MutableSequence[google.cloud.spanner_v1.types.Mutation]):
The mutations to be executed when this
transaction commits. All mutations are applied
atomically, in the order they appear in this
@@ -1220,31 +1222,31 @@ class CommitRequest(proto.Message):
Common options for this request.
"""
- session = proto.Field(
+ session: str = proto.Field(
proto.STRING,
number=1,
)
- transaction_id = proto.Field(
+ transaction_id: bytes = proto.Field(
proto.BYTES,
number=2,
oneof="transaction",
)
- single_use_transaction = proto.Field(
+ single_use_transaction: gs_transaction.TransactionOptions = proto.Field(
proto.MESSAGE,
number=3,
oneof="transaction",
message=gs_transaction.TransactionOptions,
)
- mutations = proto.RepeatedField(
+ mutations: MutableSequence[mutation.Mutation] = proto.RepeatedField(
proto.MESSAGE,
number=4,
message=mutation.Mutation,
)
- return_commit_stats = proto.Field(
+ return_commit_stats: bool = proto.Field(
proto.BOOL,
number=5,
)
- request_options = proto.Field(
+ request_options: "RequestOptions" = proto.Field(
proto.MESSAGE,
number=6,
message="RequestOptions",
@@ -1262,11 +1264,11 @@ class RollbackRequest(proto.Message):
Required. The transaction to roll back.
"""
- session = proto.Field(
+ session: str = proto.Field(
proto.STRING,
number=1,
)
- transaction_id = proto.Field(
+ transaction_id: bytes = proto.Field(
proto.BYTES,
number=2,
)
diff --git a/google/cloud/spanner_v1/types/transaction.py b/google/cloud/spanner_v1/types/transaction.py
index 0c7cb06bf0..99256ee510 100644
--- a/google/cloud/spanner_v1/types/transaction.py
+++ b/google/cloud/spanner_v1/types/transaction.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
from google.protobuf import duration_pb2 # type: ignore
@@ -414,7 +416,7 @@ class ReadLockMode(proto.Enum):
PESSIMISTIC = 1
OPTIMISTIC = 2
- read_lock_mode = proto.Field(
+ read_lock_mode: "TransactionOptions.ReadWrite.ReadLockMode" = proto.Field(
proto.ENUM,
number=1,
enum="TransactionOptions.ReadWrite.ReadLockMode",
@@ -507,53 +509,53 @@ class ReadOnly(proto.Message):
message that describes the transaction.
"""
- strong = proto.Field(
+ strong: bool = proto.Field(
proto.BOOL,
number=1,
oneof="timestamp_bound",
)
- min_read_timestamp = proto.Field(
+ min_read_timestamp: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=2,
oneof="timestamp_bound",
message=timestamp_pb2.Timestamp,
)
- max_staleness = proto.Field(
+ max_staleness: duration_pb2.Duration = proto.Field(
proto.MESSAGE,
number=3,
oneof="timestamp_bound",
message=duration_pb2.Duration,
)
- read_timestamp = proto.Field(
+ read_timestamp: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=4,
oneof="timestamp_bound",
message=timestamp_pb2.Timestamp,
)
- exact_staleness = proto.Field(
+ exact_staleness: duration_pb2.Duration = proto.Field(
proto.MESSAGE,
number=5,
oneof="timestamp_bound",
message=duration_pb2.Duration,
)
- return_read_timestamp = proto.Field(
+ return_read_timestamp: bool = proto.Field(
proto.BOOL,
number=6,
)
- read_write = proto.Field(
+ read_write: ReadWrite = proto.Field(
proto.MESSAGE,
number=1,
oneof="mode",
message=ReadWrite,
)
- partitioned_dml = proto.Field(
+ partitioned_dml: PartitionedDml = proto.Field(
proto.MESSAGE,
number=3,
oneof="mode",
message=PartitionedDml,
)
- read_only = proto.Field(
+ read_only: ReadOnly = proto.Field(
proto.MESSAGE,
number=2,
oneof="mode",
@@ -583,11 +585,11 @@ class Transaction(proto.Message):
nanoseconds. Example: ``"2014-10-02T15:01:23.045123456Z"``.
"""
- id = proto.Field(
+ id: bytes = proto.Field(
proto.BYTES,
number=1,
)
- read_timestamp = proto.Field(
+ read_timestamp: timestamp_pb2.Timestamp = proto.Field(
proto.MESSAGE,
number=2,
message=timestamp_pb2.Timestamp,
@@ -632,18 +634,18 @@ class TransactionSelector(proto.Message):
This field is a member of `oneof`_ ``selector``.
"""
- single_use = proto.Field(
+ single_use: "TransactionOptions" = proto.Field(
proto.MESSAGE,
number=1,
oneof="selector",
message="TransactionOptions",
)
- id = proto.Field(
+ id: bytes = proto.Field(
proto.BYTES,
number=2,
oneof="selector",
)
- begin = proto.Field(
+ begin: "TransactionOptions" = proto.Field(
proto.MESSAGE,
number=3,
oneof="selector",
diff --git a/google/cloud/spanner_v1/types/type.py b/google/cloud/spanner_v1/types/type.py
index 7e0f01b184..53eb7ad205 100644
--- a/google/cloud/spanner_v1/types/type.py
+++ b/google/cloud/spanner_v1/types/type.py
@@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
+from typing import MutableMapping, MutableSequence
+
import proto # type: ignore
@@ -94,22 +96,22 @@ class Type(proto.Message):
on the read path.
"""
- code = proto.Field(
+ code: "TypeCode" = proto.Field(
proto.ENUM,
number=1,
enum="TypeCode",
)
- array_element_type = proto.Field(
+ array_element_type: "Type" = proto.Field(
proto.MESSAGE,
number=2,
message="Type",
)
- struct_type = proto.Field(
+ struct_type: "StructType" = proto.Field(
proto.MESSAGE,
number=3,
message="StructType",
)
- type_annotation = proto.Field(
+ type_annotation: "TypeAnnotationCode" = proto.Field(
proto.ENUM,
number=4,
enum="TypeAnnotationCode",
@@ -121,7 +123,7 @@ class StructType(proto.Message):
[STRUCT][google.spanner.v1.TypeCode.STRUCT] type.
Attributes:
- fields (Sequence[google.cloud.spanner_v1.types.StructType.Field]):
+ fields (MutableSequence[google.cloud.spanner_v1.types.StructType.Field]):
The list of fields that make up this struct. Order is
significant, because values of this struct type are
represented as lists, where the order of field values
@@ -148,17 +150,17 @@ class Field(proto.Message):
The type of the field.
"""
- name = proto.Field(
+ name: str = proto.Field(
proto.STRING,
number=1,
)
- type_ = proto.Field(
+ type_: "Type" = proto.Field(
proto.MESSAGE,
number=2,
message="Type",
)
- fields = proto.RepeatedField(
+ fields: MutableSequence[Field] = proto.RepeatedField(
proto.MESSAGE,
number=1,
message=Field,
diff --git a/noxfile.py b/noxfile.py
index 5b4b9df14b..e4f7ebc8b5 100644
--- a/noxfile.py
+++ b/noxfile.py
@@ -31,7 +31,7 @@
DEFAULT_PYTHON_VERSION = "3.8"
-UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10"]
+UNIT_TEST_PYTHON_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
UNIT_TEST_STANDARD_DEPENDENCIES = [
"mock",
"asyncmock",
diff --git a/owlbot.py b/owlbot.py
index d29b310d6a..90edb8cf86 100644
--- a/owlbot.py
+++ b/owlbot.py
@@ -15,6 +15,7 @@
"""This script is used to synthesize generated parts of this library."""
from pathlib import Path
+import shutil
from typing import List, Optional
import synthtool as s
@@ -72,38 +73,12 @@ def get_staging_dirs(
spanner_admin_instance_default_version = "v1"
spanner_admin_database_default_version = "v1"
-for library in get_staging_dirs(spanner_default_version, "spanner"):
- # Work around gapic generator bug https://github.com/googleapis/gapic-generator-python/issues/902
- s.replace(
- library / f"google/cloud/spanner_{library.name}/types/transaction.py",
- r""".
- Attributes:""",
- r""".\n
- Attributes:""",
- )
-
- # Work around gapic generator bug https://github.com/googleapis/gapic-generator-python/issues/902
- s.replace(
- library / f"google/cloud/spanner_{library.name}/types/transaction.py",
- r""".
- Attributes:""",
- r""".\n
- Attributes:""",
- )
+clean_up_generated_samples = True
- # Remove headings from docstring. Requested change upstream in cl/377290854 due to https://google.aip.dev/192#formatting.
- s.replace(
- library / f"google/cloud/spanner_{library.name}/types/transaction.py",
- """\n ==.*?==\n""",
- ":",
- )
-
- # Remove headings from docstring. Requested change upstream in cl/377290854 due to https://google.aip.dev/192#formatting.
- s.replace(
- library / f"google/cloud/spanner_{library.name}/types/transaction.py",
- """\n --.*?--\n""",
- ":",
- )
+for library in get_staging_dirs(spanner_default_version, "spanner"):
+ if clean_up_generated_samples:
+ shutil.rmtree("samples/generated_samples", ignore_errors=True)
+ clean_up_generated_samples = False
s.move(
library,
@@ -112,23 +87,35 @@ def get_staging_dirs(
"*.*",
"docs/index.rst",
"google/cloud/spanner_v1/__init__.py",
+ "**/gapic_version.py",
+ "testing/constraints-3.7.txt",
],
)
for library in get_staging_dirs(
spanner_admin_instance_default_version, "spanner_admin_instance"
):
+ s.replace(
+ library / "google/cloud/spanner_admin_instance_v*/__init__.py",
+ "from google.cloud.spanner_admin_instance import gapic_version as package_version",
+ f"from google.cloud.spanner_admin_instance_{library.name} import gapic_version as package_version",
+ )
s.move(
library,
- excludes=["google/cloud/spanner_admin_instance/**", "*.*", "docs/index.rst"],
+ excludes=["google/cloud/spanner_admin_instance/**", "*.*", "docs/index.rst", "**/gapic_version.py", "testing/constraints-3.7.txt",],
)
for library in get_staging_dirs(
spanner_admin_database_default_version, "spanner_admin_database"
):
+ s.replace(
+ library / "google/cloud/spanner_admin_database_v*/__init__.py",
+ "from google.cloud.spanner_admin_database import gapic_version as package_version",
+ f"from google.cloud.spanner_admin_database_{library.name} import gapic_version as package_version",
+ )
s.move(
library,
- excludes=["google/cloud/spanner_admin_database/**", "*.*", "docs/index.rst"],
+ excludes=["google/cloud/spanner_admin_database/**", "*.*", "docs/index.rst", "**/gapic_version.py", "testing/constraints-3.7.txt",],
)
s.remove_staging_dirs()
@@ -149,6 +136,7 @@ def get_staging_dirs(
".coveragerc",
".github/workflows", # exclude gh actions as credentials are needed for tests
"README.rst",
+ ".github/release-please.yml",
],
)
@@ -166,7 +154,6 @@ def get_staging_dirs(
# Update samples folder in CONTRIBUTING.rst
s.replace("CONTRIBUTING.rst", "samples/snippets", "samples/samples")
-python.configure_previous_major_version_branches()
# ----------------------------------------------------------------------------
# Samples templates
# ----------------------------------------------------------------------------
@@ -261,11 +248,6 @@ def system\(session\):""",
def system(session, database_dialect):""",
)
-s.replace("noxfile.py",
- """\*session.posargs\n \)""",
- """*session.posargs,\n )"""
-)
-
s.replace("noxfile.py",
"""system_test_path,
\*session.posargs,""",
@@ -295,16 +277,4 @@ def system(session, database_dialect):""",
def prerelease_deps(session, database_dialect):"""
)
-s.replace(
- "noxfile.py",
- r"""# Install all test dependencies, then install this package into the
- # virtualenv's dist-packages.
- session.install\("mock", "pytest", "google-cloud-testutils", "-c", constraints_path\)
- session.install\("-e", ".", "-c", constraints_path\)""",
- """# Install all test dependencies, then install this package into the
- # virtualenv's dist-packages.
- session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path)
- session.install("-e", ".[tracing]", "-c", constraints_path)""",
-)
-
s.shell.run(["nox", "-s", "blacken"], hide_output=False)
diff --git a/release-please-config.json b/release-please-config.json
new file mode 100644
index 0000000000..faae5c405c
--- /dev/null
+++ b/release-please-config.json
@@ -0,0 +1,35 @@
+{
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
+ "packages": {
+ ".": {
+ "release-type": "python",
+ "extra-files": [
+ "google/cloud/spanner_admin_instance_v1/gapic_version.py",
+ "google/cloud/spanner_v1/gapic_version.py",
+ "google/cloud/spanner_admin_database_v1/gapic_version.py",
+ {
+ "type": "json",
+ "path": "samples/generated_samples/snippet_metadata_google.spanner.v1.json",
+ "jsonpath": "$.clientLibrary.version"
+ },
+ {
+ "type": "json",
+ "path": "samples/generated_samples/snippet_metadata_google.spanner.admin.instance.v1.json",
+ "jsonpath": "$.clientLibrary.version"
+ },
+ {
+ "type": "json",
+ "path": "samples/generated_samples/snippet_metadata_google.spanner.admin.database.v1.json",
+ "jsonpath": "$.clientLibrary.version"
+ }
+ ]
+ }
+ },
+ "release-type": "python",
+ "plugins": [
+ {
+ "type": "sentence-case"
+ }
+ ],
+ "initial-version": "0.1.0"
+}
diff --git a/samples/generated_samples/snippet_metadata_spanner admin database_v1.json b/samples/generated_samples/snippet_metadata_google.spanner.admin.database.v1.json
similarity index 99%
rename from samples/generated_samples/snippet_metadata_spanner admin database_v1.json
rename to samples/generated_samples/snippet_metadata_google.spanner.admin.database.v1.json
index 75d3eac77a..bfc8e8b3bd 100644
--- a/samples/generated_samples/snippet_metadata_spanner admin database_v1.json
+++ b/samples/generated_samples/snippet_metadata_google.spanner.admin.database.v1.json
@@ -7,7 +7,8 @@
}
],
"language": "PYTHON",
- "name": "google-cloud-spanner-admin-database"
+ "name": "google-cloud-spanner-admin-database",
+ "version": "3.27.0"
},
"snippets": [
{
@@ -2666,7 +2667,7 @@
},
{
"name": "permissions",
- "type": "Sequence[str]"
+ "type": "MutableSequence[str]"
},
{
"name": "retry",
@@ -2750,7 +2751,7 @@
},
{
"name": "permissions",
- "type": "Sequence[str]"
+ "type": "MutableSequence[str]"
},
{
"name": "retry",
@@ -3004,7 +3005,7 @@
},
{
"name": "statements",
- "type": "Sequence[str]"
+ "type": "MutableSequence[str]"
},
{
"name": "retry",
@@ -3088,7 +3089,7 @@
},
{
"name": "statements",
- "type": "Sequence[str]"
+ "type": "MutableSequence[str]"
},
{
"name": "retry",
diff --git a/samples/generated_samples/snippet_metadata_spanner admin instance_v1.json b/samples/generated_samples/snippet_metadata_google.spanner.admin.instance.v1.json
similarity index 99%
rename from samples/generated_samples/snippet_metadata_spanner admin instance_v1.json
rename to samples/generated_samples/snippet_metadata_google.spanner.admin.instance.v1.json
index 51f67db6dc..b0c96ead27 100644
--- a/samples/generated_samples/snippet_metadata_spanner admin instance_v1.json
+++ b/samples/generated_samples/snippet_metadata_google.spanner.admin.instance.v1.json
@@ -7,7 +7,8 @@
}
],
"language": "PYTHON",
- "name": "google-cloud-spanner-admin-instance"
+ "name": "google-cloud-spanner-admin-instance",
+ "version": "3.27.0"
},
"snippets": [
{
@@ -1829,7 +1830,7 @@
},
{
"name": "permissions",
- "type": "Sequence[str]"
+ "type": "MutableSequence[str]"
},
{
"name": "retry",
@@ -1913,7 +1914,7 @@
},
{
"name": "permissions",
- "type": "Sequence[str]"
+ "type": "MutableSequence[str]"
},
{
"name": "retry",
diff --git a/samples/generated_samples/snippet_metadata_spanner_v1.json b/samples/generated_samples/snippet_metadata_google.spanner.v1.json
similarity index 99%
rename from samples/generated_samples/snippet_metadata_spanner_v1.json
rename to samples/generated_samples/snippet_metadata_google.spanner.v1.json
index 718014ae79..ad3afc34b0 100644
--- a/samples/generated_samples/snippet_metadata_spanner_v1.json
+++ b/samples/generated_samples/snippet_metadata_google.spanner.v1.json
@@ -7,7 +7,8 @@
}
],
"language": "PYTHON",
- "name": "google-cloud-spanner"
+ "name": "google-cloud-spanner",
+ "version": "3.27.0"
},
"snippets": [
{
@@ -380,7 +381,7 @@
},
{
"name": "mutations",
- "type": "Sequence[google.cloud.spanner_v1.types.Mutation]"
+ "type": "MutableSequence[google.cloud.spanner_v1.types.Mutation]"
},
{
"name": "single_use_transaction",
@@ -472,7 +473,7 @@
},
{
"name": "mutations",
- "type": "Sequence[google.cloud.spanner_v1.types.Mutation]"
+ "type": "MutableSequence[google.cloud.spanner_v1.types.Mutation]"
},
{
"name": "single_use_transaction",
diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_async.py
index 86ca5ea324..63dd1a1230 100644
--- a/samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_async.py
+++ b/samples/generated_samples/spanner_v1_generated_database_admin_copy_backup_async.py
@@ -50,7 +50,7 @@ async def sample_copy_backup():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_create_backup_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_create_backup_async.py
index cc4af95448..530f39e816 100644
--- a/samples/generated_samples/spanner_v1_generated_database_admin_create_backup_async.py
+++ b/samples/generated_samples/spanner_v1_generated_database_admin_create_backup_async.py
@@ -49,7 +49,7 @@ async def sample_create_backup():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_create_database_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_create_database_async.py
index 31729f831d..e9525c02ec 100644
--- a/samples/generated_samples/spanner_v1_generated_database_admin_create_database_async.py
+++ b/samples/generated_samples/spanner_v1_generated_database_admin_create_database_async.py
@@ -49,7 +49,7 @@ async def sample_create_database():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_restore_database_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_restore_database_async.py
index 629503eadd..bf5b073250 100644
--- a/samples/generated_samples/spanner_v1_generated_database_admin_restore_database_async.py
+++ b/samples/generated_samples/spanner_v1_generated_database_admin_restore_database_async.py
@@ -50,7 +50,7 @@ async def sample_restore_database():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
diff --git a/samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_async.py b/samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_async.py
index 0aaa6b7526..7b7d438b6e 100644
--- a/samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_async.py
+++ b/samples/generated_samples/spanner_v1_generated_database_admin_update_database_ddl_async.py
@@ -49,7 +49,7 @@ async def sample_update_database_ddl():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_async.py
index a13e8f72fc..baf18d92d1 100644
--- a/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_async.py
+++ b/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_async.py
@@ -55,7 +55,7 @@ async def sample_create_instance():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_config_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_config_async.py
index 432ea6a1af..804a0b94f7 100644
--- a/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_config_async.py
+++ b/samples/generated_samples/spanner_v1_generated_instance_admin_create_instance_config_async.py
@@ -49,7 +49,7 @@ async def sample_create_instance_config():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_async.py
index c261c565a5..214b138ea4 100644
--- a/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_async.py
+++ b/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_async.py
@@ -53,7 +53,7 @@ async def sample_update_instance():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
diff --git a/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_config_async.py b/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_config_async.py
index 6c4ffdadad..6f33a85a25 100644
--- a/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_config_async.py
+++ b/samples/generated_samples/spanner_v1_generated_instance_admin_update_instance_config_async.py
@@ -47,7 +47,7 @@ async def sample_update_instance_config():
print("Waiting for operation to complete...")
- response = await operation.result()
+ response = (await operation).result()
# Handle the response
print(response)
diff --git a/samples/samples/noxfile.py b/samples/samples/noxfile.py
index f5c32b2278..7c8a63994c 100644
--- a/samples/samples/noxfile.py
+++ b/samples/samples/noxfile.py
@@ -89,7 +89,7 @@ def get_pytest_env_vars() -> Dict[str, str]:
# DO NOT EDIT - automatically generated.
# All versions used to test samples.
-ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10"]
+ALL_VERSIONS = ["3.7", "3.8", "3.9", "3.10", "3.11"]
# Any default versions that should be ignored.
IGNORED_VERSIONS = TEST_CONFIG["ignored_versions"]
diff --git a/samples/samples/requirements-test.txt b/samples/samples/requirements-test.txt
index 55c9ea9350..e0a67f11e7 100644
--- a/samples/samples/requirements-test.txt
+++ b/samples/samples/requirements-test.txt
@@ -1,4 +1,4 @@
pytest==7.2.0
pytest-dependency==0.5.1
-mock==4.0.3
+mock==5.0.1
google-cloud-testutils==1.3.3
diff --git a/samples/samples/requirements.txt b/samples/samples/requirements.txt
index 3ece31cb72..c6353c9fb6 100644
--- a/samples/samples/requirements.txt
+++ b/samples/samples/requirements.txt
@@ -1,2 +1,2 @@
-google-cloud-spanner==3.25.0
+google-cloud-spanner==3.26.0
futures==3.4.0; python_version < "3"
diff --git a/setup.py b/setup.py
index e75a858af1..86f2203d20 100644
--- a/setup.py
+++ b/setup.py
@@ -1,4 +1,5 @@
-# Copyright 2018 Google LLC
+# -*- 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.
@@ -11,30 +12,35 @@
# WITHOUT 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 io
import os
-import setuptools
-
+import setuptools # type: ignore
-# Package metadata.
+package_root = os.path.abspath(os.path.dirname(__file__))
name = "google-cloud-spanner"
-description = "Cloud Spanner API client library"
-version = "3.26.0"
-# Should be one of:
-# 'Development Status :: 3 - Alpha'
-# 'Development Status :: 4 - Beta'
-# 'Development Status :: 5 - Production/Stable'
-release_status = "Development Status :: 5 - Production/Stable"
+
+
+description = "Google Cloud Spanner API client library"
+
+version = {}
+with open(os.path.join(package_root, "google/cloud/spanner_v1/gapic_version.py")) as fp:
+ exec(fp.read(), version)
+version = version["__version__"]
+
+if version[0] == "0":
+ release_status = "Development Status :: 4 - Beta"
+else:
+ release_status = "Development Status :: 5 - Production/Stable"
+
dependencies = [
- "google-api-core[grpc] >= 1.32.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*",
+ "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*",
"google-cloud-core >= 1.4.1, < 3.0dev",
"grpc-google-iam-v1 >= 0.12.4, <1.0.0dev",
"proto-plus >= 1.22.0, <2.0.0dev",
"sqlparse >= 0.3.0",
- "packaging >= 14.3",
"protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5",
]
extras = {
@@ -46,8 +52,7 @@
"libcst": "libcst >= 0.2.5",
}
-
-# Setup boilerplate below this line.
+url = "https://github.com/googleapis/python-spanner"
package_root = os.path.abspath(os.path.dirname(__file__))
@@ -55,20 +60,16 @@
with io.open(readme_filename, encoding="utf-8") as readme_file:
readme = readme_file.read()
-# Only include packages under the 'google' namespace. Do not include tests,
-# benchmarks, etc.
packages = [
package
for package in setuptools.PEP420PackageFinder.find()
if package.startswith("google")
]
-# Determine which namespaces are needed.
namespaces = ["google"]
if "google.cloud" in packages:
namespaces.append("google.cloud")
-
setuptools.setup(
name=name,
version=version,
@@ -77,7 +78,7 @@
author="Google LLC",
author_email="googleapis-packages@google.com",
license="Apache 2.0",
- url="https://github.com/googleapis/python-spanner",
+ url=url,
classifiers=[
release_status,
"Intended Audience :: Developers",
diff --git a/testing/constraints-3.10.txt b/testing/constraints-3.10.txt
index e69de29bb2..ad3f0fa58e 100644
--- a/testing/constraints-3.10.txt
+++ b/testing/constraints-3.10.txt
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+# This constraints file is required for unit tests.
+# List all library dependencies and extras in this file.
+google-api-core
+proto-plus
+protobuf
+grpc-google-iam-v1
diff --git a/testing/constraints-3.11.txt b/testing/constraints-3.11.txt
index e69de29bb2..ad3f0fa58e 100644
--- a/testing/constraints-3.11.txt
+++ b/testing/constraints-3.11.txt
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+# This constraints file is required for unit tests.
+# List all library dependencies and extras in this file.
+google-api-core
+proto-plus
+protobuf
+grpc-google-iam-v1
diff --git a/testing/constraints-3.12.txt b/testing/constraints-3.12.txt
new file mode 100644
index 0000000000..ad3f0fa58e
--- /dev/null
+++ b/testing/constraints-3.12.txt
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+# This constraints file is required for unit tests.
+# List all library dependencies and extras in this file.
+google-api-core
+proto-plus
+protobuf
+grpc-google-iam-v1
diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt
index 5a63b04a4d..e061a1eadf 100644
--- a/testing/constraints-3.7.txt
+++ b/testing/constraints-3.7.txt
@@ -1,11 +1,10 @@
# This constraints file is used to check that lower bounds
# are correct in setup.py
-# List *all* library dependencies and extras in this file.
+# List all library dependencies and extras in this file.
# Pin the version to the lower bound.
-#
-# e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev",
-# Then this file should have foo==1.14.0
-google-api-core==1.32.0
+# e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev",
+# Then this file should have google-cloud-foo==1.14.0
+google-api-core==1.34.0
google-cloud-core==1.4.1
grpc-google-iam-v1==0.12.4
libcst==0.2.5
@@ -14,5 +13,4 @@ sqlparse==0.3.0
opentelemetry-api==1.1.0
opentelemetry-sdk==1.1.0
opentelemetry-instrumentation==0.20b0
-packaging==14.3
protobuf==3.19.5
diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt
index e69de29bb2..ad3f0fa58e 100644
--- a/testing/constraints-3.8.txt
+++ b/testing/constraints-3.8.txt
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+# This constraints file is required for unit tests.
+# List all library dependencies and extras in this file.
+google-api-core
+proto-plus
+protobuf
+grpc-google-iam-v1
diff --git a/testing/constraints-3.9.txt b/testing/constraints-3.9.txt
index e69de29bb2..ad3f0fa58e 100644
--- a/testing/constraints-3.9.txt
+++ b/testing/constraints-3.9.txt
@@ -0,0 +1,7 @@
+# -*- coding: utf-8 -*-
+# This constraints file is required for unit tests.
+# List all library dependencies and extras in this file.
+google-api-core
+proto-plus
+protobuf
+grpc-google-iam-v1
diff --git a/tests/_fixtures.py b/tests/_fixtures.py
index 7bf55ee232..0bd8fe163a 100644
--- a/tests/_fixtures.py
+++ b/tests/_fixtures.py
@@ -130,13 +130,23 @@
CREATE TABLE all_types (
pkey BIGINT NOT NULL,
int_value INT,
+ int_array INT[],
bool_value BOOL,
+ bool_array BOOL[],
bytes_value BYTEA,
+ bytes_array BYTEA[],
float_value DOUBLE PRECISION,
+ float_array DOUBLE PRECISION[],
string_value VARCHAR(16),
+ string_array VARCHAR(16)[],
+ date_value DATE,
+ date_array DATE[],
timestamp_value TIMESTAMPTZ,
+ timestamp_array TIMESTAMPTZ[],
numeric_value NUMERIC,
+ numeric_array NUMERIC[],
jsonb_value JSONB,
+ jsonb_array JSONB[],
PRIMARY KEY (pkey) );
CREATE TABLE counters (
name VARCHAR(1024),
diff --git a/tests/system/test_dbapi.py b/tests/system/test_dbapi.py
index 6354f2091f..cb5a11e89d 100644
--- a/tests/system/test_dbapi.py
+++ b/tests/system/test_dbapi.py
@@ -15,7 +15,6 @@
import datetime
import hashlib
import pickle
-import pkg_resources
import pytest
import time
@@ -25,6 +24,7 @@
from google.cloud.spanner_dbapi.connection import Connection
from google.cloud.spanner_dbapi.exceptions import ProgrammingError
from google.cloud.spanner_v1 import JsonObject
+from google.cloud.spanner_v1 import gapic_version as package_version
from . import _helpers
@@ -473,11 +473,11 @@ def test_user_agent(shared_instance, dbapi_database):
conn = connect(shared_instance.name, dbapi_database.name)
assert (
conn.instance._client._client_info.user_agent
- == "gl-dbapi/" + pkg_resources.get_distribution("google-cloud-spanner").version
+ == "gl-dbapi/" + package_version.__version__
)
assert (
conn.instance._client._client_info.client_library_version
- == pkg_resources.get_distribution("google-cloud-spanner").version
+ == package_version.__version__
)
diff --git a/tests/system/test_session_api.py b/tests/system/test_session_api.py
index c9c5c8a959..6b7afbe525 100644
--- a/tests/system/test_session_api.py
+++ b/tests/system/test_session_api.py
@@ -85,11 +85,9 @@
EMULATOR_ALL_TYPES_COLUMNS = LIVE_ALL_TYPES_COLUMNS[:-4]
# ToDo: Clean up generation of POSTGRES_ALL_TYPES_COLUMNS
-POSTGRES_ALL_TYPES_COLUMNS = (
- LIVE_ALL_TYPES_COLUMNS[:1]
- + LIVE_ALL_TYPES_COLUMNS[1:7:2]
- + LIVE_ALL_TYPES_COLUMNS[9:17:2]
- + ("jsonb_value",)
+POSTGRES_ALL_TYPES_COLUMNS = LIVE_ALL_TYPES_COLUMNS[:17] + (
+ "jsonb_value",
+ "jsonb_array",
)
AllTypesRowData = collections.namedtuple("AllTypesRowData", LIVE_ALL_TYPES_COLUMNS)
@@ -137,7 +135,9 @@
AllTypesRowData(pkey=302, bool_array=[True, False, None]),
AllTypesRowData(pkey=303, bytes_array=[BYTES_1, BYTES_2, None]),
AllTypesRowData(pkey=304, date_array=[SOME_DATE, None]),
- AllTypesRowData(pkey=305, float_array=[3.1415926, 2.71828, None]),
+ AllTypesRowData(
+ pkey=305, float_array=[3.1415926, 2.71828, math.inf, -math.inf, None]
+ ),
AllTypesRowData(pkey=306, string_array=["One", "Two", None]),
AllTypesRowData(pkey=307, timestamp_array=[SOME_TIME, NANO_TIME, None]),
AllTypesRowData(pkey=308, numeric_array=[NUMERIC_1, NUMERIC_2, None]),
@@ -168,7 +168,7 @@
EmulatorAllTypesRowData(pkey=302, bool_array=[True, False, None]),
EmulatorAllTypesRowData(pkey=303, bytes_array=[BYTES_1, BYTES_2, None]),
EmulatorAllTypesRowData(pkey=304, date_array=[SOME_DATE, None]),
- EmulatorAllTypesRowData(pkey=305, float_array=[3.1415926, 2.71828, None]),
+ EmulatorAllTypesRowData(pkey=305, float_array=[3.1415926, -2.71828, None]),
EmulatorAllTypesRowData(pkey=306, string_array=["One", "Two", None]),
EmulatorAllTypesRowData(pkey=307, timestamp_array=[SOME_TIME, NANO_TIME, None]),
)
@@ -180,12 +180,35 @@
PostGresAllTypesRowData(pkey=101, int_value=123),
PostGresAllTypesRowData(pkey=102, bool_value=False),
PostGresAllTypesRowData(pkey=103, bytes_value=BYTES_1),
+ PostGresAllTypesRowData(pkey=104, date_value=SOME_DATE),
PostGresAllTypesRowData(pkey=105, float_value=1.4142136),
PostGresAllTypesRowData(pkey=106, string_value="VALUE"),
PostGresAllTypesRowData(pkey=107, timestamp_value=SOME_TIME),
PostGresAllTypesRowData(pkey=108, timestamp_value=NANO_TIME),
PostGresAllTypesRowData(pkey=109, numeric_value=NUMERIC_1),
PostGresAllTypesRowData(pkey=110, jsonb_value=JSON_1),
+ # empty array values
+ PostGresAllTypesRowData(pkey=201, int_array=[]),
+ PostGresAllTypesRowData(pkey=202, bool_array=[]),
+ PostGresAllTypesRowData(pkey=203, bytes_array=[]),
+ PostGresAllTypesRowData(pkey=204, date_array=[]),
+ PostGresAllTypesRowData(pkey=205, float_array=[]),
+ PostGresAllTypesRowData(pkey=206, string_array=[]),
+ PostGresAllTypesRowData(pkey=207, timestamp_array=[]),
+ PostGresAllTypesRowData(pkey=208, numeric_array=[]),
+ PostGresAllTypesRowData(pkey=209, jsonb_array=[]),
+ # non-empty array values, including nulls
+ PostGresAllTypesRowData(pkey=301, int_array=[123, 456, None]),
+ PostGresAllTypesRowData(pkey=302, bool_array=[True, False, None]),
+ PostGresAllTypesRowData(pkey=303, bytes_array=[BYTES_1, BYTES_2, None]),
+ PostGresAllTypesRowData(pkey=304, date_array=[SOME_DATE, SOME_DATE, None]),
+ PostGresAllTypesRowData(
+ pkey=305, float_array=[3.1415926, -2.71828, math.inf, -math.inf, None]
+ ),
+ PostGresAllTypesRowData(pkey=306, string_array=["One", "Two", None]),
+ PostGresAllTypesRowData(pkey=307, timestamp_array=[SOME_TIME, NANO_TIME, None]),
+ PostGresAllTypesRowData(pkey=308, numeric_array=[NUMERIC_1, NUMERIC_2, None]),
+ PostGresAllTypesRowData(pkey=309, jsonb_array=[JSON_1, JSON_2, None]),
)
if _helpers.USE_EMULATOR:
diff --git a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py
index 116ec94771..b9041dd1d2 100644
--- a/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py
+++ b/tests/unit/gapic/spanner_admin_database_v1/test_database_admin.py
@@ -60,6 +60,7 @@
from google.longrunning import operations_pb2 # type: ignore
from google.oauth2 import service_account
from google.protobuf import any_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 google.rpc import status_pb2 # type: ignore