diff --git a/docs/requirements.txt b/docs/requirements.txt index eb6aa5b4a0db..732fda8a3e88 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -2,6 +2,7 @@ setuptools >= 36.4.0 sphinx >= 1.6.3 ipython >= 4 recommonmark >= 0.4.0 +grpcio-gcp >= 0.2.2 -e api_core/ -e core/ diff --git a/spanner/google/cloud/spanner_admin_database_v1/__init__.py b/spanner/google/cloud/spanner_admin_database_v1/__init__.py index 24c369f5f785..1c8be301fb5b 100644 --- a/spanner/google/cloud/spanner_admin_database_v1/__init__.py +++ b/spanner/google/cloud/spanner_admin_database_v1/__init__.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spanner/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py b/spanner/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py index f1cc599243a9..9811ead1f0c5 100644 --- a/spanner/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py +++ b/spanner/google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +17,9 @@ import functools import pkg_resources +import warnings +from google.oauth2 import service_account import google.api_core.gapic_v1.client_info import google.api_core.gapic_v1.config import google.api_core.gapic_v1.method @@ -24,12 +28,16 @@ import google.api_core.operations_v1 import google.api_core.page_iterator import google.api_core.path_template +import grpc from google.cloud.spanner_admin_database_v1.gapic import database_admin_client_config from google.cloud.spanner_admin_database_v1.gapic import enums +from google.cloud.spanner_admin_database_v1.gapic.transports import database_admin_grpc_transport from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2 +from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2_grpc from google.iam.v1 import iam_policy_pb2 from google.iam.v1 import policy_pb2 +from google.longrunning import operations_pb2 from google.protobuf import empty_pb2 _GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( @@ -48,17 +56,31 @@ class DatabaseAdminClient(object): SERVICE_ADDRESS = 'spanner.googleapis.com:443' """The default address of the service.""" - # The scopes needed to make gRPC calls to all of the methods defined in - # this service - _DEFAULT_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/spanner.admin', - ) - - # The name of the interface for this client. This is the key used to find - # method configuration in the client_config dictionary. + # The name of the interface for this client. This is the key used to + # find the method configuration in the client_config dictionary. _INTERFACE_NAME = 'google.spanner.admin.database.v1.DatabaseAdmin' + @classmethod + def from_service_account_file(cls, filename, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + DatabaseAdminClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file( + filename) + kwargs['credentials'] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + @classmethod def instance_path(cls, project, instance): """Return a fully-qualified instance string.""" @@ -79,6 +101,7 @@ def database_path(cls, project, instance, database): ) def __init__(self, + transport=None, channel=None, credentials=None, client_config=database_admin_client_config.config, @@ -86,116 +109,83 @@ def __init__(self, """Constructor. Args: - channel (grpc.Channel): A ``Channel`` instance through - which to make calls. This argument is mutually exclusive + transport (Union[~.DatabaseAdminGrpcTransport, + Callable[[~.Credentials, type], ~.DatabaseAdminGrpcTransport]): A transport + instance, responsible for actually making the API calls. + The default transport uses the gRPC protocol. + This argument may also be a callable which returns a + transport instance. Callables will be sent the credentials + as the first argument and the default transport class as + the second argument. + channel (grpc.Channel): DEPRECATED. A ``Channel`` instance + through which to make calls. This argument is mutually exclusive with ``credentials``; providing both will raise an exception. credentials (google.auth.credentials.Credentials): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. - client_config (dict): A dictionary of call options for each - method. If not specified, the default configuration is used. + This argument is mutually exclusive with providing a + transport instance to ``transport``; doing so will raise + an exception. + client_config (dict): DEPRECATED. A dictionary of call options for + each method. If not specified, the default configuration is used. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. """ - # If both `channel` and `credentials` are specified, raise an - # exception (channels come with credentials baked in already). - if channel is not None and credentials is not None: - raise ValueError( - 'The `channel` and `credentials` arguments to {} are mutually ' - 'exclusive.'.format(self.__class__.__name__), ) - - # Create the channel. - if channel is None: - channel = google.api_core.grpc_helpers.create_channel( - self.SERVICE_ADDRESS, + # Raise deprecation warnings for things we want to go away. + if client_config: + warnings.warn('The `client_config` argument is deprecated.', + PendingDeprecationWarning) + if channel: + warnings.warn( + 'The `channel` argument is deprecated; use ' + '`transport` instead.', PendingDeprecationWarning) + + # Instantiate the transport. + # The transport is responsible for handling serialization and + # deserialization and actually sending data to the service. + if transport: + if callable(transport): + self.transport = transport( + credentials=credentials, + default_class=database_admin_grpc_transport. + DatabaseAdminGrpcTransport, + ) + else: + if credentials: + raise ValueError( + 'Received both a transport instance and ' + 'credentials; these are mutually exclusive.') + self.transport = transport + else: + self.transport = database_admin_grpc_transport.DatabaseAdminGrpcTransport( + address=self.SERVICE_ADDRESS, + channel=channel, credentials=credentials, - scopes=self._DEFAULT_SCOPES, ) - # Create the gRPC stubs. - self.database_admin_stub = ( - spanner_database_admin_pb2.DatabaseAdminStub(channel)) - - # Operations client for methods that return long-running operations - # futures. - self.operations_client = ( - google.api_core.operations_v1.OperationsClient(channel)) - if client_info is None: client_info = ( google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO) client_info.gapic_version = _GAPIC_LIBRARY_VERSION + self._client_info = client_info # Parse out the default settings for retry and timeout for each RPC # from the client configuration. # (Ordinarily, these are the defaults specified in the `*_config.py` # file next to this one.) - method_configs = google.api_core.gapic_v1.config.parse_method_configs( + self._method_configs = google.api_core.gapic_v1.config.parse_method_configs( client_config['interfaces'][self._INTERFACE_NAME], ) - # Write the "inner API call" methods to the class. - # These are wrapped versions of the gRPC stub methods, with retry and - # timeout configuration applied, called by the public methods on - # this class. - self._list_databases = google.api_core.gapic_v1.method.wrap_method( - self.database_admin_stub.ListDatabases, - default_retry=method_configs['ListDatabases'].retry, - default_timeout=method_configs['ListDatabases'].timeout, - client_info=client_info, - ) - self._create_database = google.api_core.gapic_v1.method.wrap_method( - self.database_admin_stub.CreateDatabase, - default_retry=method_configs['CreateDatabase'].retry, - default_timeout=method_configs['CreateDatabase'].timeout, - client_info=client_info, - ) - self._get_database = google.api_core.gapic_v1.method.wrap_method( - self.database_admin_stub.GetDatabase, - default_retry=method_configs['GetDatabase'].retry, - default_timeout=method_configs['GetDatabase'].timeout, - client_info=client_info, - ) - self._update_database_ddl = google.api_core.gapic_v1.method.wrap_method( - self.database_admin_stub.UpdateDatabaseDdl, - default_retry=method_configs['UpdateDatabaseDdl'].retry, - default_timeout=method_configs['UpdateDatabaseDdl'].timeout, - client_info=client_info, - ) - self._drop_database = google.api_core.gapic_v1.method.wrap_method( - self.database_admin_stub.DropDatabase, - default_retry=method_configs['DropDatabase'].retry, - default_timeout=method_configs['DropDatabase'].timeout, - client_info=client_info, - ) - self._get_database_ddl = google.api_core.gapic_v1.method.wrap_method( - self.database_admin_stub.GetDatabaseDdl, - default_retry=method_configs['GetDatabaseDdl'].retry, - default_timeout=method_configs['GetDatabaseDdl'].timeout, - client_info=client_info, - ) - self._set_iam_policy = google.api_core.gapic_v1.method.wrap_method( - self.database_admin_stub.SetIamPolicy, - default_retry=method_configs['SetIamPolicy'].retry, - default_timeout=method_configs['SetIamPolicy'].timeout, - client_info=client_info, - ) - self._get_iam_policy = google.api_core.gapic_v1.method.wrap_method( - self.database_admin_stub.GetIamPolicy, - default_retry=method_configs['GetIamPolicy'].retry, - default_timeout=method_configs['GetIamPolicy'].timeout, - client_info=client_info, - ) - self._test_iam_permissions = google.api_core.gapic_v1.method.wrap_method( - self.database_admin_stub.TestIamPermissions, - default_retry=method_configs['TestIamPermissions'].retry, - default_timeout=method_configs['TestIamPermissions'].timeout, - client_info=client_info, - ) + # Save a dictionary of cached API call functions. + # These are the actual callables which invoke the proper + # transport methods, wrapped with `wrap_method` to add retry, + # timeout, and the like. + self._inner_api_calls = {} # Service calls def list_databases(self, @@ -214,13 +204,15 @@ def list_databases(self, >>> >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]') >>> - >>> >>> # Iterate over all results >>> for element in client.list_databases(parent): ... # process element ... pass >>> - >>> # Or iterate over results one page at a time + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time >>> for page in client.list_databases(parent, options=CallOptions(page_token=INITIAL_PAGE)): ... for element in page: ... # process element @@ -240,6 +232,8 @@ def list_databases(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.gax.PageIterator` instance. By default, this @@ -254,6 +248,17 @@ def list_databases(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'list_databases' not in self._inner_api_calls: + self._inner_api_calls[ + 'list_databases'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_databases, + default_retry=self._method_configs['ListDatabases'].retry, + default_timeout=self._method_configs['ListDatabases']. + timeout, + client_info=self._client_info, + ) + request = spanner_database_admin_pb2.ListDatabasesRequest( parent=parent, page_size=page_size, @@ -261,7 +266,9 @@ def list_databases(self, iterator = google.api_core.page_iterator.GRPCIterator( client=None, method=functools.partial( - self._list_databases, retry=retry, timeout=timeout, + self._inner_api_calls['list_databases'], + retry=retry, + timeout=timeout, metadata=metadata), request=request, items_field='databases', @@ -293,6 +300,8 @@ def create_database(self, >>> client = spanner_admin_database_v1.DatabaseAdminClient() >>> >>> parent = client.instance_path('[PROJECT]', '[INSTANCE]') + >>> + >>> # TODO: Initialize ``create_statement``: >>> create_statement = '' >>> >>> response = client.create_database(parent, create_statement) @@ -313,7 +322,7 @@ def create_database(self, new database. The database ID must conform to the regular expression ``[a-z][a-z0-9_\-]*[a-z0-9]`` and be between 2 and 30 characters in length. If the database ID is a reserved word or if it contains a hyphen, the - database ID must be enclosed in backticks ("`"). + database ID must be enclosed in backticks. extra_statements (list[str]): An optional list of DDL statements to run inside the newly created database. Statements can create tables, indexes, etc. These statements execute atomically with the creation of the database: @@ -324,6 +333,8 @@ def create_database(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_database_v1.types._OperationFuture` instance. @@ -335,16 +346,27 @@ def create_database(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'create_database' not in self._inner_api_calls: + self._inner_api_calls[ + 'create_database'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.create_database, + default_retry=self._method_configs['CreateDatabase'].retry, + default_timeout=self._method_configs['CreateDatabase']. + timeout, + client_info=self._client_info, + ) + request = spanner_database_admin_pb2.CreateDatabaseRequest( parent=parent, create_statement=create_statement, extra_statements=extra_statements, ) - operation = self._create_database( + operation = self._inner_api_calls['create_database']( request, retry=retry, timeout=timeout, metadata=metadata) return google.api_core.operation.from_gapic( operation, - self.operations_client, + self.transport._operations_client, spanner_database_admin_pb2.Database, metadata_type=spanner_database_admin_pb2.CreateDatabaseMetadata, ) @@ -375,6 +397,8 @@ def get_database(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_database_v1.types.Database` instance. @@ -386,8 +410,19 @@ def get_database(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'get_database' not in self._inner_api_calls: + self._inner_api_calls[ + 'get_database'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_database, + default_retry=self._method_configs['GetDatabase'].retry, + default_timeout=self._method_configs['GetDatabase']. + timeout, + client_info=self._client_info, + ) + request = spanner_database_admin_pb2.GetDatabaseRequest(name=name, ) - return self._get_database( + return self._inner_api_calls['get_database']( request, retry=retry, timeout=timeout, metadata=metadata) def update_database_ddl(self, @@ -412,6 +447,8 @@ def update_database_ddl(self, >>> client = spanner_admin_database_v1.DatabaseAdminClient() >>> >>> database = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]') + >>> + >>> # TODO: Initialize ``statements``: >>> statements = [] >>> >>> response = client.update_database_ddl(database, statements) @@ -453,6 +490,8 @@ def update_database_ddl(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_database_v1.types._OperationFuture` instance. @@ -464,16 +503,28 @@ def update_database_ddl(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'update_database_ddl' not in self._inner_api_calls: + self._inner_api_calls[ + 'update_database_ddl'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.update_database_ddl, + default_retry=self._method_configs['UpdateDatabaseDdl']. + retry, + default_timeout=self._method_configs['UpdateDatabaseDdl']. + timeout, + client_info=self._client_info, + ) + request = spanner_database_admin_pb2.UpdateDatabaseDdlRequest( database=database, statements=statements, operation_id=operation_id, ) - operation = self._update_database_ddl( + operation = self._inner_api_calls['update_database_ddl']( request, retry=retry, timeout=timeout, metadata=metadata) return google.api_core.operation.from_gapic( operation, - self.operations_client, + self.transport._operations_client, empty_pb2.Empty, metadata_type=spanner_database_admin_pb2.UpdateDatabaseDdlMetadata, ) @@ -503,6 +554,8 @@ def drop_database(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Raises: google.api_core.exceptions.GoogleAPICallError: If the request @@ -511,9 +564,20 @@ def drop_database(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'drop_database' not in self._inner_api_calls: + self._inner_api_calls[ + 'drop_database'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.drop_database, + default_retry=self._method_configs['DropDatabase'].retry, + default_timeout=self._method_configs['DropDatabase']. + timeout, + client_info=self._client_info, + ) + request = spanner_database_admin_pb2.DropDatabaseRequest( database=database, ) - self._drop_database( + self._inner_api_calls['drop_database']( request, retry=retry, timeout=timeout, metadata=metadata) def get_database_ddl(self, @@ -543,6 +607,8 @@ def get_database_ddl(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_database_v1.types.GetDatabaseDdlResponse` instance. @@ -554,9 +620,20 @@ def get_database_ddl(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'get_database_ddl' not in self._inner_api_calls: + self._inner_api_calls[ + 'get_database_ddl'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_database_ddl, + default_retry=self._method_configs['GetDatabaseDdl'].retry, + default_timeout=self._method_configs['GetDatabaseDdl']. + timeout, + client_info=self._client_info, + ) + request = spanner_database_admin_pb2.GetDatabaseDdlRequest( database=database, ) - return self._get_database_ddl( + return self._inner_api_calls['get_database_ddl']( request, retry=retry, timeout=timeout, metadata=metadata) def set_iam_policy(self, @@ -578,6 +655,8 @@ def set_iam_policy(self, >>> client = spanner_admin_database_v1.DatabaseAdminClient() >>> >>> resource = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]') + >>> + >>> # TODO: Initialize ``policy``: >>> policy = {} >>> >>> response = client.set_iam_policy(resource, policy) @@ -598,6 +677,8 @@ def set_iam_policy(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_database_v1.types.Policy` instance. @@ -609,11 +690,22 @@ def set_iam_policy(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'set_iam_policy' not in self._inner_api_calls: + self._inner_api_calls[ + 'set_iam_policy'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.set_iam_policy, + default_retry=self._method_configs['SetIamPolicy'].retry, + default_timeout=self._method_configs['SetIamPolicy']. + timeout, + client_info=self._client_info, + ) + request = iam_policy_pb2.SetIamPolicyRequest( resource=resource, policy=policy, ) - return self._set_iam_policy( + return self._inner_api_calls['set_iam_policy']( request, retry=retry, timeout=timeout, metadata=metadata) def get_iam_policy(self, @@ -647,6 +739,8 @@ def get_iam_policy(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_database_v1.types.Policy` instance. @@ -658,8 +752,19 @@ def get_iam_policy(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'get_iam_policy' not in self._inner_api_calls: + self._inner_api_calls[ + 'get_iam_policy'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_iam_policy, + default_retry=self._method_configs['GetIamPolicy'].retry, + default_timeout=self._method_configs['GetIamPolicy']. + timeout, + client_info=self._client_info, + ) + request = iam_policy_pb2.GetIamPolicyRequest(resource=resource, ) - return self._get_iam_policy( + return self._inner_api_calls['get_iam_policy']( request, retry=retry, timeout=timeout, metadata=metadata) def test_iam_permissions(self, @@ -682,6 +787,8 @@ def test_iam_permissions(self, >>> client = spanner_admin_database_v1.DatabaseAdminClient() >>> >>> resource = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]') + >>> + >>> # TODO: Initialize ``permissions``: >>> permissions = [] >>> >>> response = client.test_iam_permissions(resource, permissions) @@ -700,6 +807,8 @@ def test_iam_permissions(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_database_v1.types.TestIamPermissionsResponse` instance. @@ -711,9 +820,21 @@ def test_iam_permissions(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'test_iam_permissions' not in self._inner_api_calls: + self._inner_api_calls[ + 'test_iam_permissions'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.test_iam_permissions, + default_retry=self._method_configs['TestIamPermissions']. + retry, + default_timeout=self._method_configs['TestIamPermissions']. + timeout, + client_info=self._client_info, + ) + request = iam_policy_pb2.TestIamPermissionsRequest( resource=resource, permissions=permissions, ) - return self._test_iam_permissions( + return self._inner_api_calls['test_iam_permissions']( request, retry=retry, timeout=timeout, metadata=metadata) diff --git a/spanner/google/cloud/spanner_admin_database_v1/gapic/enums.py b/spanner/google/cloud/spanner_admin_database_v1/gapic/enums.py index 7a3efc133934..a09dcac45922 100644 --- a/spanner/google/cloud/spanner_admin_database_v1/gapic/enums.py +++ b/spanner/google/cloud/spanner_admin_database_v1/gapic/enums.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 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,9 +15,11 @@ # limitations under the License. """Wrappers for protocol buffer enum types.""" +import enum + class Database(object): - class State(object): + class State(enum.IntEnum): """ Indicates the current state of the database. diff --git a/spanner/google/cloud/spanner_admin_database_v1/gapic/transports/__init__.py b/spanner/google/cloud/spanner_admin_database_v1/gapic/transports/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/spanner/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py b/spanner/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py new file mode 100644 index 000000000000..956d1c5ca04a --- /dev/null +++ b/spanner/google/cloud/spanner_admin_database_v1/gapic/transports/database_admin_grpc_transport.py @@ -0,0 +1,248 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import google.api_core.grpc_helpers +import google.api_core.operations_v1 + +from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2_grpc + + +class DatabaseAdminGrpcTransport(object): + """gRPC transport class providing stubs for + google.spanner.admin.database.v1 DatabaseAdmin API. + + The transport provides access to the raw gRPC stubs, + which can be used to take advantage of advanced + features of gRPC. + """ + # The scopes needed to make gRPC calls to all of the methods defined + # in this service. + _OAUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.admin', + ) + + def __init__(self, + channel=None, + credentials=None, + address='spanner.googleapis.com:443'): + """Instantiate the transport class. + + Args: + channel (grpc.Channel): A ``Channel`` instance through + which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + address (str): The address where the service is hosted. + """ + # If both `channel` and `credentials` are specified, raise an + # exception (channels come with credentials baked in already). + if channel is not None and credentials is not None: + raise ValueError( + 'The `channel` and `credentials` arguments are mutually ' + 'exclusive.', ) + + # Create the channel. + if channel is None: + channel = self.create_channel( + address=address, + credentials=credentials, + ) + + # gRPC uses objects called "stubs" that are bound to the + # channel and provide a basic method for each RPC. + self._stubs = { + 'database_admin_stub': + spanner_database_admin_pb2_grpc.DatabaseAdminStub(channel), + } + + # Because this API includes a method that returns a + # long-running operation (proto: google.longrunning.Operation), + # instantiate an LRO client. + self._operations_client = google.api_core.operations_v1.OperationsClient( + channel) + + @classmethod + def create_channel(cls, + address='spanner.googleapis.com:443', + credentials=None): + """Create and return a gRPC channel object. + + Args: + address (str): The host for the channel to use. + credentials (~.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return google.api_core.grpc_helpers.create_channel( + address, + credentials=credentials, + scopes=cls._OAUTH_SCOPES, + ) + + @property + def list_databases(self): + """Return the gRPC stub for {$apiMethod.name}. + + Lists Cloud Spanner databases. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['database_admin_stub'].ListDatabases + + @property + def create_database(self): + """Return the gRPC stub for {$apiMethod.name}. + + Creates a new Cloud Spanner database and starts to prepare it for serving. + The returned ``long-running operation`` will + have a name of the format ``/operations/`` and + can be used to track preparation of the database. The + ``metadata`` field type is + ``CreateDatabaseMetadata``. The + ``response`` field type is + ``Database``, if successful. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['database_admin_stub'].CreateDatabase + + @property + def get_database(self): + """Return the gRPC stub for {$apiMethod.name}. + + Gets the state of a Cloud Spanner database. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['database_admin_stub'].GetDatabase + + @property + def update_database_ddl(self): + """Return the gRPC stub for {$apiMethod.name}. + + Updates the schema of a Cloud Spanner database by + creating/altering/dropping tables, columns, indexes, etc. The returned + ``long-running operation`` will have a name of + the format ``/operations/`` and can be used to + track execution of the schema change(s). The + ``metadata`` field type is + ``UpdateDatabaseDdlMetadata``. The operation has no response. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['database_admin_stub'].UpdateDatabaseDdl + + @property + def drop_database(self): + """Return the gRPC stub for {$apiMethod.name}. + + Drops (aka deletes) a Cloud Spanner database. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['database_admin_stub'].DropDatabase + + @property + def get_database_ddl(self): + """Return the gRPC stub for {$apiMethod.name}. + + Returns the schema of a Cloud Spanner database as a list of formatted + DDL statements. This method does not show pending schema updates, those may + be queried using the ``Operations`` API. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['database_admin_stub'].GetDatabaseDdl + + @property + def set_iam_policy(self): + """Return the gRPC stub for {$apiMethod.name}. + + Sets the access control policy on a database resource. Replaces any + existing policy. + + Authorization requires ``spanner.databases.setIamPolicy`` permission on + ``resource``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['database_admin_stub'].SetIamPolicy + + @property + def get_iam_policy(self): + """Return the gRPC stub for {$apiMethod.name}. + + Gets the access control policy for a database resource. Returns an empty + policy if a database exists but does not have a policy set. + + Authorization requires ``spanner.databases.getIamPolicy`` permission on + ``resource``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['database_admin_stub'].GetIamPolicy + + @property + def test_iam_permissions(self): + """Return the gRPC stub for {$apiMethod.name}. + + Returns permissions that the caller has on the specified database resource. + + Attempting this RPC on a non-existent Cloud Spanner database will result in + a NOT_FOUND error if the user has ``spanner.databases.list`` permission on + the containing Cloud Spanner instance. Otherwise returns an empty set of + permissions. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['database_admin_stub'].TestIamPermissions diff --git a/spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py b/spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py index 99e31abd901e..0c1a7fe52818 100644 --- a/spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py +++ b/spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2.py @@ -28,7 +28,6 @@ serialized_pb=_b('\nIgoogle/cloud/spanner/admin/database_v1/proto/spanner_database_admin.proto\x12 google.spanner.admin.database.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1egoogle/iam/v1/iam_policy.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a#google/longrunning/operations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\x92\x01\n\x08\x44\x61tabase\x12\x0c\n\x04name\x18\x01 \x01(\t\x12?\n\x05state\x18\x02 \x01(\x0e\x32\x30.google.spanner.admin.database.v1.Database.State\"7\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x43REATING\x10\x01\x12\t\n\x05READY\x10\x02\"M\n\x14ListDatabasesRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t\"o\n\x15ListDatabasesResponse\x12=\n\tdatabases\x18\x01 \x03(\x0b\x32*.google.spanner.admin.database.v1.Database\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"[\n\x15\x43reateDatabaseRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x18\n\x10\x63reate_statement\x18\x02 \x01(\t\x12\x18\n\x10\x65xtra_statements\x18\x03 \x03(\t\"*\n\x16\x43reateDatabaseMetadata\x12\x10\n\x08\x64\x61tabase\x18\x01 \x01(\t\"\"\n\x12GetDatabaseRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"V\n\x18UpdateDatabaseDdlRequest\x12\x10\n\x08\x64\x61tabase\x18\x01 \x01(\t\x12\x12\n\nstatements\x18\x02 \x03(\t\x12\x14\n\x0coperation_id\x18\x03 \x01(\t\"x\n\x19UpdateDatabaseDdlMetadata\x12\x10\n\x08\x64\x61tabase\x18\x01 \x01(\t\x12\x12\n\nstatements\x18\x02 \x03(\t\x12\x35\n\x11\x63ommit_timestamps\x18\x03 \x03(\x0b\x32\x1a.google.protobuf.Timestamp\"\'\n\x13\x44ropDatabaseRequest\x12\x10\n\x08\x64\x61tabase\x18\x01 \x01(\t\")\n\x15GetDatabaseDdlRequest\x12\x10\n\x08\x64\x61tabase\x18\x01 \x01(\t\",\n\x16GetDatabaseDdlResponse\x12\x12\n\nstatements\x18\x01 \x03(\t2\x95\x0c\n\rDatabaseAdmin\x12\xb7\x01\n\rListDatabases\x12\x36.google.spanner.admin.database.v1.ListDatabasesRequest\x1a\x37.google.spanner.admin.database.v1.ListDatabasesResponse\"5\x82\xd3\xe4\x93\x02/\x12-/v1/{parent=projects/*/instances/*}/databases\x12\xa2\x01\n\x0e\x43reateDatabase\x12\x37.google.spanner.admin.database.v1.CreateDatabaseRequest\x1a\x1d.google.longrunning.Operation\"8\x82\xd3\xe4\x93\x02\x32\"-/v1/{parent=projects/*/instances/*}/databases:\x01*\x12\xa6\x01\n\x0bGetDatabase\x12\x34.google.spanner.admin.database.v1.GetDatabaseRequest\x1a*.google.spanner.admin.database.v1.Database\"5\x82\xd3\xe4\x93\x02/\x12-/v1/{name=projects/*/instances/*/databases/*}\x12\xb0\x01\n\x11UpdateDatabaseDdl\x12:.google.spanner.admin.database.v1.UpdateDatabaseDdlRequest\x1a\x1d.google.longrunning.Operation\"@\x82\xd3\xe4\x93\x02:25/v1/{database=projects/*/instances/*/databases/*}/ddl:\x01*\x12\x98\x01\n\x0c\x44ropDatabase\x12\x35.google.spanner.admin.database.v1.DropDatabaseRequest\x1a\x16.google.protobuf.Empty\"9\x82\xd3\xe4\x93\x02\x33*1/v1/{database=projects/*/instances/*/databases/*}\x12\xc2\x01\n\x0eGetDatabaseDdl\x12\x37.google.spanner.admin.database.v1.GetDatabaseDdlRequest\x1a\x38.google.spanner.admin.database.v1.GetDatabaseDdlResponse\"=\x82\xd3\xe4\x93\x02\x37\x12\x35/v1/{database=projects/*/instances/*/databases/*}/ddl\x12\x94\x01\n\x0cSetIamPolicy\x12\".google.iam.v1.SetIamPolicyRequest\x1a\x15.google.iam.v1.Policy\"I\x82\xd3\xe4\x93\x02\x43\">/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy:\x01*\x12\x94\x01\n\x0cGetIamPolicy\x12\".google.iam.v1.GetIamPolicyRequest\x1a\x15.google.iam.v1.Policy\"I\x82\xd3\xe4\x93\x02\x43\">/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy:\x01*\x12\xba\x01\n\x12TestIamPermissions\x12(.google.iam.v1.TestIamPermissionsRequest\x1a).google.iam.v1.TestIamPermissionsResponse\"O\x82\xd3\xe4\x93\x02I\"D/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions:\x01*B\xdf\x01\n$com.google.spanner.admin.database.v1B\x19SpannerDatabaseAdminProtoP\x01ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\xaa\x02&Google.Cloud.Spanner.Admin.Database.V1\xca\x02&Google\\Cloud\\Spanner\\Admin\\Database\\V1b\x06proto3') , dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_iam_dot_v1_dot_iam__policy__pb2.DESCRIPTOR,google_dot_iam_dot_v1_dot_policy__pb2.DESCRIPTOR,google_dot_longrunning_dot_operations__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -72,14 +71,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='state', full_name='google.spanner.admin.database.v1.Database.state', index=1, number=2, type=14, cpp_type=8, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -111,21 +110,21 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='page_size', full_name='google.spanner.admin.database.v1.ListDatabasesRequest.page_size', index=1, number=3, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='page_token', full_name='google.spanner.admin.database.v1.ListDatabasesRequest.page_token', index=2, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -156,14 +155,14 @@ has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='next_page_token', full_name='google.spanner.admin.database.v1.ListDatabasesResponse.next_page_token', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -194,21 +193,21 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='create_statement', full_name='google.spanner.admin.database.v1.CreateDatabaseRequest.create_statement', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='extra_statements', full_name='google.spanner.admin.database.v1.CreateDatabaseRequest.extra_statements', index=2, number=3, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -239,7 +238,7 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -270,7 +269,7 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -301,21 +300,21 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='statements', full_name='google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.statements', index=1, number=2, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='operation_id', full_name='google.spanner.admin.database.v1.UpdateDatabaseDdlRequest.operation_id', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -346,21 +345,21 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='statements', full_name='google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata.statements', index=1, number=2, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='commit_timestamps', full_name='google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata.commit_timestamps', index=2, number=3, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -391,7 +390,7 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -422,7 +421,7 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -453,7 +452,7 @@ has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -485,6 +484,7 @@ DESCRIPTOR.message_types_by_name['DropDatabaseRequest'] = _DROPDATABASEREQUEST DESCRIPTOR.message_types_by_name['GetDatabaseDdlRequest'] = _GETDATABASEDDLREQUEST DESCRIPTOR.message_types_by_name['GetDatabaseDdlResponse'] = _GETDATABASEDDLRESPONSE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) Database = _reflection.GeneratedProtocolMessageType('Database', (_message.Message,), dict( DESCRIPTOR = _DATABASE, @@ -746,479 +746,100 @@ DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n$com.google.spanner.admin.database.v1B\031SpannerDatabaseAdminProtoP\001ZHgoogle.golang.org/genproto/googleapis/spanner/admin/database/v1;database\252\002&Google.Cloud.Spanner.Admin.Database.V1\312\002&Google\\Cloud\\Spanner\\Admin\\Database\\V1')) -try: - # THESE ELEMENTS WILL BE DEPRECATED. - # Please use the generated *_pb2_grpc.py files instead. - import grpc - from grpc.beta import implementations as beta_implementations - from grpc.beta import interfaces as beta_interfaces - from grpc.framework.common import cardinality - from grpc.framework.interfaces.face import utilities as face_utilities - - - class DatabaseAdminStub(object): - """Cloud Spanner Database Admin API - - The Cloud Spanner Database Admin API can be used to create, drop, and - list databases. It also enables updating the schema of pre-existing - databases. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.ListDatabases = channel.unary_unary( - '/google.spanner.admin.database.v1.DatabaseAdmin/ListDatabases', - request_serializer=ListDatabasesRequest.SerializeToString, - response_deserializer=ListDatabasesResponse.FromString, - ) - self.CreateDatabase = channel.unary_unary( - '/google.spanner.admin.database.v1.DatabaseAdmin/CreateDatabase', - request_serializer=CreateDatabaseRequest.SerializeToString, - response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, - ) - self.GetDatabase = channel.unary_unary( - '/google.spanner.admin.database.v1.DatabaseAdmin/GetDatabase', - request_serializer=GetDatabaseRequest.SerializeToString, - response_deserializer=Database.FromString, - ) - self.UpdateDatabaseDdl = channel.unary_unary( - '/google.spanner.admin.database.v1.DatabaseAdmin/UpdateDatabaseDdl', - request_serializer=UpdateDatabaseDdlRequest.SerializeToString, - response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, - ) - self.DropDatabase = channel.unary_unary( - '/google.spanner.admin.database.v1.DatabaseAdmin/DropDatabase', - request_serializer=DropDatabaseRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.GetDatabaseDdl = channel.unary_unary( - '/google.spanner.admin.database.v1.DatabaseAdmin/GetDatabaseDdl', - request_serializer=GetDatabaseDdlRequest.SerializeToString, - response_deserializer=GetDatabaseDdlResponse.FromString, - ) - self.SetIamPolicy = channel.unary_unary( - '/google.spanner.admin.database.v1.DatabaseAdmin/SetIamPolicy', - request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.SerializeToString, - response_deserializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString, - ) - self.GetIamPolicy = channel.unary_unary( - '/google.spanner.admin.database.v1.DatabaseAdmin/GetIamPolicy', - request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.SerializeToString, - response_deserializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString, - ) - self.TestIamPermissions = channel.unary_unary( - '/google.spanner.admin.database.v1.DatabaseAdmin/TestIamPermissions', - request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.SerializeToString, - response_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.FromString, - ) - - - class DatabaseAdminServicer(object): - """Cloud Spanner Database Admin API - - The Cloud Spanner Database Admin API can be used to create, drop, and - list databases. It also enables updating the schema of pre-existing - databases. - """ - - def ListDatabases(self, request, context): - """Lists Cloud Spanner databases. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateDatabase(self, request, context): - """Creates a new Cloud Spanner database and starts to prepare it for serving. - The returned [long-running operation][google.longrunning.Operation] will - have a name of the format `/operations/` and - can be used to track preparation of the database. The - [metadata][google.longrunning.Operation.metadata] field type is - [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The - [response][google.longrunning.Operation.response] field type is - [Database][google.spanner.admin.database.v1.Database], if successful. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetDatabase(self, request, context): - """Gets the state of a Cloud Spanner database. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def UpdateDatabaseDdl(self, request, context): - """Updates the schema of a Cloud Spanner database by - creating/altering/dropping tables, columns, indexes, etc. The returned - [long-running operation][google.longrunning.Operation] will have a name of - the format `/operations/` and can be used to - track execution of the schema change(s). The - [metadata][google.longrunning.Operation.metadata] field type is - [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DropDatabase(self, request, context): - """Drops (aka deletes) a Cloud Spanner database. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetDatabaseDdl(self, request, context): - """Returns the schema of a Cloud Spanner database as a list of formatted - DDL statements. This method does not show pending schema updates, those may - be queried using the [Operations][google.longrunning.Operations] API. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def SetIamPolicy(self, request, context): - """Sets the access control policy on a database resource. Replaces any - existing policy. - - Authorization requires `spanner.databases.setIamPolicy` permission on - [resource][google.iam.v1.SetIamPolicyRequest.resource]. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetIamPolicy(self, request, context): - """Gets the access control policy for a database resource. Returns an empty - policy if a database exists but does not have a policy set. - - Authorization requires `spanner.databases.getIamPolicy` permission on - [resource][google.iam.v1.GetIamPolicyRequest.resource]. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def TestIamPermissions(self, request, context): - """Returns permissions that the caller has on the specified database resource. - - Attempting this RPC on a non-existent Cloud Spanner database will result in - a NOT_FOUND error if the user has `spanner.databases.list` permission on - the containing Cloud Spanner instance. Otherwise returns an empty set of - permissions. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') +_DATABASEADMIN = _descriptor.ServiceDescriptor( + name='DatabaseAdmin', + full_name='google.spanner.admin.database.v1.DatabaseAdmin', + file=DESCRIPTOR, + index=0, + options=None, + serialized_start=1155, + serialized_end=2712, + methods=[ + _descriptor.MethodDescriptor( + name='ListDatabases', + full_name='google.spanner.admin.database.v1.DatabaseAdmin.ListDatabases', + index=0, + containing_service=None, + input_type=_LISTDATABASESREQUEST, + output_type=_LISTDATABASESRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002/\022-/v1/{parent=projects/*/instances/*}/databases')), + ), + _descriptor.MethodDescriptor( + name='CreateDatabase', + full_name='google.spanner.admin.database.v1.DatabaseAdmin.CreateDatabase', + index=1, + containing_service=None, + input_type=_CREATEDATABASEREQUEST, + output_type=google_dot_longrunning_dot_operations__pb2._OPERATION, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0022\"-/v1/{parent=projects/*/instances/*}/databases:\001*')), + ), + _descriptor.MethodDescriptor( + name='GetDatabase', + full_name='google.spanner.admin.database.v1.DatabaseAdmin.GetDatabase', + index=2, + containing_service=None, + input_type=_GETDATABASEREQUEST, + output_type=_DATABASE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002/\022-/v1/{name=projects/*/instances/*/databases/*}')), + ), + _descriptor.MethodDescriptor( + name='UpdateDatabaseDdl', + full_name='google.spanner.admin.database.v1.DatabaseAdmin.UpdateDatabaseDdl', + index=3, + containing_service=None, + input_type=_UPDATEDATABASEDDLREQUEST, + output_type=google_dot_longrunning_dot_operations__pb2._OPERATION, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002:25/v1/{database=projects/*/instances/*/databases/*}/ddl:\001*')), + ), + _descriptor.MethodDescriptor( + name='DropDatabase', + full_name='google.spanner.admin.database.v1.DatabaseAdmin.DropDatabase', + index=4, + containing_service=None, + input_type=_DROPDATABASEREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0023*1/v1/{database=projects/*/instances/*/databases/*}')), + ), + _descriptor.MethodDescriptor( + name='GetDatabaseDdl', + full_name='google.spanner.admin.database.v1.DatabaseAdmin.GetDatabaseDdl', + index=5, + containing_service=None, + input_type=_GETDATABASEDDLREQUEST, + output_type=_GETDATABASEDDLRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0027\0225/v1/{database=projects/*/instances/*/databases/*}/ddl')), + ), + _descriptor.MethodDescriptor( + name='SetIamPolicy', + full_name='google.spanner.admin.database.v1.DatabaseAdmin.SetIamPolicy', + index=6, + containing_service=None, + input_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._SETIAMPOLICYREQUEST, + output_type=google_dot_iam_dot_v1_dot_policy__pb2._POLICY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002C\">/v1/{resource=projects/*/instances/*/databases/*}:setIamPolicy:\001*')), + ), + _descriptor.MethodDescriptor( + name='GetIamPolicy', + full_name='google.spanner.admin.database.v1.DatabaseAdmin.GetIamPolicy', + index=7, + containing_service=None, + input_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._GETIAMPOLICYREQUEST, + output_type=google_dot_iam_dot_v1_dot_policy__pb2._POLICY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002C\">/v1/{resource=projects/*/instances/*/databases/*}:getIamPolicy:\001*')), + ), + _descriptor.MethodDescriptor( + name='TestIamPermissions', + full_name='google.spanner.admin.database.v1.DatabaseAdmin.TestIamPermissions', + index=8, + containing_service=None, + input_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._TESTIAMPERMISSIONSREQUEST, + output_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._TESTIAMPERMISSIONSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002I\"D/v1/{resource=projects/*/instances/*/databases/*}:testIamPermissions:\001*')), + ), +]) +_sym_db.RegisterServiceDescriptor(_DATABASEADMIN) + +DESCRIPTOR.services_by_name['DatabaseAdmin'] = _DATABASEADMIN - def add_DatabaseAdminServicer_to_server(servicer, server): - rpc_method_handlers = { - 'ListDatabases': grpc.unary_unary_rpc_method_handler( - servicer.ListDatabases, - request_deserializer=ListDatabasesRequest.FromString, - response_serializer=ListDatabasesResponse.SerializeToString, - ), - 'CreateDatabase': grpc.unary_unary_rpc_method_handler( - servicer.CreateDatabase, - request_deserializer=CreateDatabaseRequest.FromString, - response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - ), - 'GetDatabase': grpc.unary_unary_rpc_method_handler( - servicer.GetDatabase, - request_deserializer=GetDatabaseRequest.FromString, - response_serializer=Database.SerializeToString, - ), - 'UpdateDatabaseDdl': grpc.unary_unary_rpc_method_handler( - servicer.UpdateDatabaseDdl, - request_deserializer=UpdateDatabaseDdlRequest.FromString, - response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - ), - 'DropDatabase': grpc.unary_unary_rpc_method_handler( - servicer.DropDatabase, - request_deserializer=DropDatabaseRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'GetDatabaseDdl': grpc.unary_unary_rpc_method_handler( - servicer.GetDatabaseDdl, - request_deserializer=GetDatabaseDdlRequest.FromString, - response_serializer=GetDatabaseDdlResponse.SerializeToString, - ), - 'SetIamPolicy': grpc.unary_unary_rpc_method_handler( - servicer.SetIamPolicy, - request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.FromString, - response_serializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString, - ), - 'GetIamPolicy': grpc.unary_unary_rpc_method_handler( - servicer.GetIamPolicy, - request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.FromString, - response_serializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString, - ), - 'TestIamPermissions': grpc.unary_unary_rpc_method_handler( - servicer.TestIamPermissions, - request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.FromString, - response_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'google.spanner.admin.database.v1.DatabaseAdmin', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - class BetaDatabaseAdminServicer(object): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This class was generated - only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" - """Cloud Spanner Database Admin API - - The Cloud Spanner Database Admin API can be used to create, drop, and - list databases. It also enables updating the schema of pre-existing - databases. - """ - def ListDatabases(self, request, context): - """Lists Cloud Spanner databases. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def CreateDatabase(self, request, context): - """Creates a new Cloud Spanner database and starts to prepare it for serving. - The returned [long-running operation][google.longrunning.Operation] will - have a name of the format `/operations/` and - can be used to track preparation of the database. The - [metadata][google.longrunning.Operation.metadata] field type is - [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The - [response][google.longrunning.Operation.response] field type is - [Database][google.spanner.admin.database.v1.Database], if successful. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def GetDatabase(self, request, context): - """Gets the state of a Cloud Spanner database. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def UpdateDatabaseDdl(self, request, context): - """Updates the schema of a Cloud Spanner database by - creating/altering/dropping tables, columns, indexes, etc. The returned - [long-running operation][google.longrunning.Operation] will have a name of - the format `/operations/` and can be used to - track execution of the schema change(s). The - [metadata][google.longrunning.Operation.metadata] field type is - [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def DropDatabase(self, request, context): - """Drops (aka deletes) a Cloud Spanner database. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def GetDatabaseDdl(self, request, context): - """Returns the schema of a Cloud Spanner database as a list of formatted - DDL statements. This method does not show pending schema updates, those may - be queried using the [Operations][google.longrunning.Operations] API. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def SetIamPolicy(self, request, context): - """Sets the access control policy on a database resource. Replaces any - existing policy. - - Authorization requires `spanner.databases.setIamPolicy` permission on - [resource][google.iam.v1.SetIamPolicyRequest.resource]. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def GetIamPolicy(self, request, context): - """Gets the access control policy for a database resource. Returns an empty - policy if a database exists but does not have a policy set. - - Authorization requires `spanner.databases.getIamPolicy` permission on - [resource][google.iam.v1.GetIamPolicyRequest.resource]. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def TestIamPermissions(self, request, context): - """Returns permissions that the caller has on the specified database resource. - - Attempting this RPC on a non-existent Cloud Spanner database will result in - a NOT_FOUND error if the user has `spanner.databases.list` permission on - the containing Cloud Spanner instance. Otherwise returns an empty set of - permissions. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - - - class BetaDatabaseAdminStub(object): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This class was generated - only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" - """Cloud Spanner Database Admin API - - The Cloud Spanner Database Admin API can be used to create, drop, and - list databases. It also enables updating the schema of pre-existing - databases. - """ - def ListDatabases(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Lists Cloud Spanner databases. - """ - raise NotImplementedError() - ListDatabases.future = None - def CreateDatabase(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Creates a new Cloud Spanner database and starts to prepare it for serving. - The returned [long-running operation][google.longrunning.Operation] will - have a name of the format `/operations/` and - can be used to track preparation of the database. The - [metadata][google.longrunning.Operation.metadata] field type is - [CreateDatabaseMetadata][google.spanner.admin.database.v1.CreateDatabaseMetadata]. The - [response][google.longrunning.Operation.response] field type is - [Database][google.spanner.admin.database.v1.Database], if successful. - """ - raise NotImplementedError() - CreateDatabase.future = None - def GetDatabase(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Gets the state of a Cloud Spanner database. - """ - raise NotImplementedError() - GetDatabase.future = None - def UpdateDatabaseDdl(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Updates the schema of a Cloud Spanner database by - creating/altering/dropping tables, columns, indexes, etc. The returned - [long-running operation][google.longrunning.Operation] will have a name of - the format `/operations/` and can be used to - track execution of the schema change(s). The - [metadata][google.longrunning.Operation.metadata] field type is - [UpdateDatabaseDdlMetadata][google.spanner.admin.database.v1.UpdateDatabaseDdlMetadata]. The operation has no response. - """ - raise NotImplementedError() - UpdateDatabaseDdl.future = None - def DropDatabase(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Drops (aka deletes) a Cloud Spanner database. - """ - raise NotImplementedError() - DropDatabase.future = None - def GetDatabaseDdl(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Returns the schema of a Cloud Spanner database as a list of formatted - DDL statements. This method does not show pending schema updates, those may - be queried using the [Operations][google.longrunning.Operations] API. - """ - raise NotImplementedError() - GetDatabaseDdl.future = None - def SetIamPolicy(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Sets the access control policy on a database resource. Replaces any - existing policy. - - Authorization requires `spanner.databases.setIamPolicy` permission on - [resource][google.iam.v1.SetIamPolicyRequest.resource]. - """ - raise NotImplementedError() - SetIamPolicy.future = None - def GetIamPolicy(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Gets the access control policy for a database resource. Returns an empty - policy if a database exists but does not have a policy set. - - Authorization requires `spanner.databases.getIamPolicy` permission on - [resource][google.iam.v1.GetIamPolicyRequest.resource]. - """ - raise NotImplementedError() - GetIamPolicy.future = None - def TestIamPermissions(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Returns permissions that the caller has on the specified database resource. - - Attempting this RPC on a non-existent Cloud Spanner database will result in - a NOT_FOUND error if the user has `spanner.databases.list` permission on - the containing Cloud Spanner instance. Otherwise returns an empty set of - permissions. - """ - raise NotImplementedError() - TestIamPermissions.future = None - - - def beta_create_DatabaseAdmin_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This function was - generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" - request_deserializers = { - ('google.spanner.admin.database.v1.DatabaseAdmin', 'CreateDatabase'): CreateDatabaseRequest.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'DropDatabase'): DropDatabaseRequest.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetDatabase'): GetDatabaseRequest.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetDatabaseDdl'): GetDatabaseDdlRequest.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetIamPolicy'): google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'ListDatabases'): ListDatabasesRequest.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'SetIamPolicy'): google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'TestIamPermissions'): google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'UpdateDatabaseDdl'): UpdateDatabaseDdlRequest.FromString, - } - response_serializers = { - ('google.spanner.admin.database.v1.DatabaseAdmin', 'CreateDatabase'): google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'DropDatabase'): google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetDatabase'): Database.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetDatabaseDdl'): GetDatabaseDdlResponse.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetIamPolicy'): google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'ListDatabases'): ListDatabasesResponse.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'SetIamPolicy'): google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'TestIamPermissions'): google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'UpdateDatabaseDdl'): google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - } - method_implementations = { - ('google.spanner.admin.database.v1.DatabaseAdmin', 'CreateDatabase'): face_utilities.unary_unary_inline(servicer.CreateDatabase), - ('google.spanner.admin.database.v1.DatabaseAdmin', 'DropDatabase'): face_utilities.unary_unary_inline(servicer.DropDatabase), - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetDatabase'): face_utilities.unary_unary_inline(servicer.GetDatabase), - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetDatabaseDdl'): face_utilities.unary_unary_inline(servicer.GetDatabaseDdl), - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetIamPolicy'): face_utilities.unary_unary_inline(servicer.GetIamPolicy), - ('google.spanner.admin.database.v1.DatabaseAdmin', 'ListDatabases'): face_utilities.unary_unary_inline(servicer.ListDatabases), - ('google.spanner.admin.database.v1.DatabaseAdmin', 'SetIamPolicy'): face_utilities.unary_unary_inline(servicer.SetIamPolicy), - ('google.spanner.admin.database.v1.DatabaseAdmin', 'TestIamPermissions'): face_utilities.unary_unary_inline(servicer.TestIamPermissions), - ('google.spanner.admin.database.v1.DatabaseAdmin', 'UpdateDatabaseDdl'): face_utilities.unary_unary_inline(servicer.UpdateDatabaseDdl), - } - server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout) - return beta_implementations.server(method_implementations, options=server_options) - - - def beta_create_DatabaseAdmin_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This function was - generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" - request_serializers = { - ('google.spanner.admin.database.v1.DatabaseAdmin', 'CreateDatabase'): CreateDatabaseRequest.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'DropDatabase'): DropDatabaseRequest.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetDatabase'): GetDatabaseRequest.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetDatabaseDdl'): GetDatabaseDdlRequest.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetIamPolicy'): google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'ListDatabases'): ListDatabasesRequest.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'SetIamPolicy'): google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'TestIamPermissions'): google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.SerializeToString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'UpdateDatabaseDdl'): UpdateDatabaseDdlRequest.SerializeToString, - } - response_deserializers = { - ('google.spanner.admin.database.v1.DatabaseAdmin', 'CreateDatabase'): google_dot_longrunning_dot_operations__pb2.Operation.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'DropDatabase'): google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetDatabase'): Database.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetDatabaseDdl'): GetDatabaseDdlResponse.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'GetIamPolicy'): google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'ListDatabases'): ListDatabasesResponse.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'SetIamPolicy'): google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'TestIamPermissions'): google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.FromString, - ('google.spanner.admin.database.v1.DatabaseAdmin', 'UpdateDatabaseDdl'): google_dot_longrunning_dot_operations__pb2.Operation.FromString, - } - cardinalities = { - 'CreateDatabase': cardinality.Cardinality.UNARY_UNARY, - 'DropDatabase': cardinality.Cardinality.UNARY_UNARY, - 'GetDatabase': cardinality.Cardinality.UNARY_UNARY, - 'GetDatabaseDdl': cardinality.Cardinality.UNARY_UNARY, - 'GetIamPolicy': cardinality.Cardinality.UNARY_UNARY, - 'ListDatabases': cardinality.Cardinality.UNARY_UNARY, - 'SetIamPolicy': cardinality.Cardinality.UNARY_UNARY, - 'TestIamPermissions': cardinality.Cardinality.UNARY_UNARY, - 'UpdateDatabaseDdl': cardinality.Cardinality.UNARY_UNARY, - } - stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size) - return beta_implementations.dynamic_stub(channel, 'google.spanner.admin.database.v1.DatabaseAdmin', cardinalities, options=stub_options) -except ImportError: - pass # @@protoc_insertion_point(module_scope) diff --git a/spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2_grpc.py b/spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2_grpc.py index 5a88b9cb859f..2f6ad29f2734 100644 --- a/spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2_grpc.py +++ b/spanner/google/cloud/spanner_admin_database_v1/proto/spanner_database_admin_pb2_grpc.py @@ -1,11 +1,11 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! import grpc -import google.cloud.spanner.admin.database_v1.proto.spanner_database_admin_pb2 as google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2 -import google.iam.v1.iam_policy_pb2 as google_dot_iam_dot_v1_dot_iam__policy__pb2 -import google.iam.v1.policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2 -import google.longrunning.operations_pb2 as google_dot_longrunning_dot_operations__pb2 -import google.protobuf.empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.cloud.spanner_admin_database_v1.proto import spanner_database_admin_pb2 as google_dot_cloud_dot_spanner_dot_admin_dot_database__v1_dot_proto_dot_spanner__database__admin__pb2 +from google.iam.v1 import iam_policy_pb2 as google_dot_iam_dot_v1_dot_iam__policy__pb2 +from google.iam.v1 import policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2 +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 class DatabaseAdminStub(object): diff --git a/spanner/google/cloud/spanner_admin_database_v1/types.py b/spanner/google/cloud/spanner_admin_database_v1/types.py index 56ac4f8fb39a..9214e58cdc46 100644 --- a/spanner/google/cloud/spanner_admin_database_v1/types.py +++ b/spanner/google/cloud/spanner_admin_database_v1/types.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spanner/google/cloud/spanner_admin_instance_v1/__init__.py b/spanner/google/cloud/spanner_admin_instance_v1/__init__.py index 4bc788f6a392..d40da2651870 100644 --- a/spanner/google/cloud/spanner_admin_instance_v1/__init__.py +++ b/spanner/google/cloud/spanner_admin_instance_v1/__init__.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spanner/google/cloud/spanner_admin_instance_v1/gapic/enums.py b/spanner/google/cloud/spanner_admin_instance_v1/gapic/enums.py index 7c8b014a4d67..9dc8426526ed 100644 --- a/spanner/google/cloud/spanner_admin_instance_v1/gapic/enums.py +++ b/spanner/google/cloud/spanner_admin_instance_v1/gapic/enums.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 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,9 +15,11 @@ # limitations under the License. """Wrappers for protocol buffer enum types.""" +import enum + class Instance(object): - class State(object): + class State(enum.IntEnum): """ Indicates the current state of the instance. diff --git a/spanner/google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py b/spanner/google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py index 4080492a1ab6..0374e89566b7 100644 --- a/spanner/google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py +++ b/spanner/google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +17,9 @@ import functools import pkg_resources +import warnings +from google.oauth2 import service_account import google.api_core.gapic_v1.client_info import google.api_core.gapic_v1.config import google.api_core.gapic_v1.method @@ -24,12 +28,17 @@ import google.api_core.operations_v1 import google.api_core.page_iterator import google.api_core.path_template +import grpc from google.cloud.spanner_admin_instance_v1.gapic import enums from google.cloud.spanner_admin_instance_v1.gapic import instance_admin_client_config +from google.cloud.spanner_admin_instance_v1.gapic.transports import instance_admin_grpc_transport from google.cloud.spanner_admin_instance_v1.proto import spanner_instance_admin_pb2 +from google.cloud.spanner_admin_instance_v1.proto import spanner_instance_admin_pb2_grpc from google.iam.v1 import iam_policy_pb2 from google.iam.v1 import policy_pb2 +from google.longrunning import operations_pb2 +from google.protobuf import empty_pb2 from google.protobuf import field_mask_pb2 _GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( @@ -64,17 +73,31 @@ class InstanceAdminClient(object): SERVICE_ADDRESS = 'spanner.googleapis.com:443' """The default address of the service.""" - # The scopes needed to make gRPC calls to all of the methods defined in - # this service - _DEFAULT_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/spanner.admin', - ) - - # The name of the interface for this client. This is the key used to find - # method configuration in the client_config dictionary. + # The name of the interface for this client. This is the key used to + # find the method configuration in the client_config dictionary. _INTERFACE_NAME = 'google.spanner.admin.instance.v1.InstanceAdmin' + @classmethod + def from_service_account_file(cls, filename, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + InstanceAdminClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file( + filename) + kwargs['credentials'] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + @classmethod def project_path(cls, project): """Return a fully-qualified project string.""" @@ -102,6 +125,7 @@ def instance_path(cls, project, instance): ) def __init__(self, + transport=None, channel=None, credentials=None, client_config=instance_admin_client_config.config, @@ -109,122 +133,83 @@ def __init__(self, """Constructor. Args: - channel (grpc.Channel): A ``Channel`` instance through - which to make calls. This argument is mutually exclusive + transport (Union[~.InstanceAdminGrpcTransport, + Callable[[~.Credentials, type], ~.InstanceAdminGrpcTransport]): A transport + instance, responsible for actually making the API calls. + The default transport uses the gRPC protocol. + This argument may also be a callable which returns a + transport instance. Callables will be sent the credentials + as the first argument and the default transport class as + the second argument. + channel (grpc.Channel): DEPRECATED. A ``Channel`` instance + through which to make calls. This argument is mutually exclusive with ``credentials``; providing both will raise an exception. credentials (google.auth.credentials.Credentials): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. - client_config (dict): A dictionary of call options for each - method. If not specified, the default configuration is used. + This argument is mutually exclusive with providing a + transport instance to ``transport``; doing so will raise + an exception. + client_config (dict): DEPRECATED. A dictionary of call options for + each method. If not specified, the default configuration is used. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. """ - # If both `channel` and `credentials` are specified, raise an - # exception (channels come with credentials baked in already). - if channel is not None and credentials is not None: - raise ValueError( - 'The `channel` and `credentials` arguments to {} are mutually ' - 'exclusive.'.format(self.__class__.__name__), ) - - # Create the channel. - if channel is None: - channel = google.api_core.grpc_helpers.create_channel( - self.SERVICE_ADDRESS, + # Raise deprecation warnings for things we want to go away. + if client_config: + warnings.warn('The `client_config` argument is deprecated.', + PendingDeprecationWarning) + if channel: + warnings.warn( + 'The `channel` argument is deprecated; use ' + '`transport` instead.', PendingDeprecationWarning) + + # Instantiate the transport. + # The transport is responsible for handling serialization and + # deserialization and actually sending data to the service. + if transport: + if callable(transport): + self.transport = transport( + credentials=credentials, + default_class=instance_admin_grpc_transport. + InstanceAdminGrpcTransport, + ) + else: + if credentials: + raise ValueError( + 'Received both a transport instance and ' + 'credentials; these are mutually exclusive.') + self.transport = transport + else: + self.transport = instance_admin_grpc_transport.InstanceAdminGrpcTransport( + address=self.SERVICE_ADDRESS, + channel=channel, credentials=credentials, - scopes=self._DEFAULT_SCOPES, ) - # Create the gRPC stubs. - self.instance_admin_stub = ( - spanner_instance_admin_pb2.InstanceAdminStub(channel)) - - # Operations client for methods that return long-running operations - # futures. - self.operations_client = ( - google.api_core.operations_v1.OperationsClient(channel)) - if client_info is None: client_info = ( google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO) client_info.gapic_version = _GAPIC_LIBRARY_VERSION + self._client_info = client_info # Parse out the default settings for retry and timeout for each RPC # from the client configuration. # (Ordinarily, these are the defaults specified in the `*_config.py` # file next to this one.) - method_configs = google.api_core.gapic_v1.config.parse_method_configs( + self._method_configs = google.api_core.gapic_v1.config.parse_method_configs( client_config['interfaces'][self._INTERFACE_NAME], ) - # Write the "inner API call" methods to the class. - # These are wrapped versions of the gRPC stub methods, with retry and - # timeout configuration applied, called by the public methods on - # this class. - self._list_instance_configs = google.api_core.gapic_v1.method.wrap_method( - self.instance_admin_stub.ListInstanceConfigs, - default_retry=method_configs['ListInstanceConfigs'].retry, - default_timeout=method_configs['ListInstanceConfigs'].timeout, - client_info=client_info, - ) - self._get_instance_config = google.api_core.gapic_v1.method.wrap_method( - self.instance_admin_stub.GetInstanceConfig, - default_retry=method_configs['GetInstanceConfig'].retry, - default_timeout=method_configs['GetInstanceConfig'].timeout, - client_info=client_info, - ) - self._list_instances = google.api_core.gapic_v1.method.wrap_method( - self.instance_admin_stub.ListInstances, - default_retry=method_configs['ListInstances'].retry, - default_timeout=method_configs['ListInstances'].timeout, - client_info=client_info, - ) - self._get_instance = google.api_core.gapic_v1.method.wrap_method( - self.instance_admin_stub.GetInstance, - default_retry=method_configs['GetInstance'].retry, - default_timeout=method_configs['GetInstance'].timeout, - client_info=client_info, - ) - self._create_instance = google.api_core.gapic_v1.method.wrap_method( - self.instance_admin_stub.CreateInstance, - default_retry=method_configs['CreateInstance'].retry, - default_timeout=method_configs['CreateInstance'].timeout, - client_info=client_info, - ) - self._update_instance = google.api_core.gapic_v1.method.wrap_method( - self.instance_admin_stub.UpdateInstance, - default_retry=method_configs['UpdateInstance'].retry, - default_timeout=method_configs['UpdateInstance'].timeout, - client_info=client_info, - ) - self._delete_instance = google.api_core.gapic_v1.method.wrap_method( - self.instance_admin_stub.DeleteInstance, - default_retry=method_configs['DeleteInstance'].retry, - default_timeout=method_configs['DeleteInstance'].timeout, - client_info=client_info, - ) - self._set_iam_policy = google.api_core.gapic_v1.method.wrap_method( - self.instance_admin_stub.SetIamPolicy, - default_retry=method_configs['SetIamPolicy'].retry, - default_timeout=method_configs['SetIamPolicy'].timeout, - client_info=client_info, - ) - self._get_iam_policy = google.api_core.gapic_v1.method.wrap_method( - self.instance_admin_stub.GetIamPolicy, - default_retry=method_configs['GetIamPolicy'].retry, - default_timeout=method_configs['GetIamPolicy'].timeout, - client_info=client_info, - ) - self._test_iam_permissions = google.api_core.gapic_v1.method.wrap_method( - self.instance_admin_stub.TestIamPermissions, - default_retry=method_configs['TestIamPermissions'].retry, - default_timeout=method_configs['TestIamPermissions'].timeout, - client_info=client_info, - ) + # Save a dictionary of cached API call functions. + # These are the actual callables which invoke the proper + # transport methods, wrapped with `wrap_method` to add retry, + # timeout, and the like. + self._inner_api_calls = {} # Service calls def list_instance_configs(self, @@ -243,13 +228,15 @@ def list_instance_configs(self, >>> >>> parent = client.project_path('[PROJECT]') >>> - >>> >>> # Iterate over all results >>> for element in client.list_instance_configs(parent): ... # process element ... pass >>> - >>> # Or iterate over results one page at a time + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time >>> for page in client.list_instance_configs(parent, options=CallOptions(page_token=INITIAL_PAGE)): ... for element in page: ... # process element @@ -270,6 +257,8 @@ def list_instance_configs(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.gax.PageIterator` instance. By default, this @@ -284,6 +273,18 @@ def list_instance_configs(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'list_instance_configs' not in self._inner_api_calls: + self._inner_api_calls[ + 'list_instance_configs'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_instance_configs, + default_retry=self._method_configs['ListInstanceConfigs']. + retry, + default_timeout=self. + _method_configs['ListInstanceConfigs'].timeout, + client_info=self._client_info, + ) + request = spanner_instance_admin_pb2.ListInstanceConfigsRequest( parent=parent, page_size=page_size, @@ -291,7 +292,9 @@ def list_instance_configs(self, iterator = google.api_core.page_iterator.GRPCIterator( client=None, method=functools.partial( - self._list_instance_configs, retry=retry, timeout=timeout, + self._inner_api_calls['list_instance_configs'], + retry=retry, + timeout=timeout, metadata=metadata), request=request, items_field='instance_configs', @@ -326,6 +329,8 @@ def get_instance_config(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_instance_v1.types.InstanceConfig` instance. @@ -337,9 +342,21 @@ def get_instance_config(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'get_instance_config' not in self._inner_api_calls: + self._inner_api_calls[ + 'get_instance_config'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_instance_config, + default_retry=self._method_configs['GetInstanceConfig']. + retry, + default_timeout=self._method_configs['GetInstanceConfig']. + timeout, + client_info=self._client_info, + ) + request = spanner_instance_admin_pb2.GetInstanceConfigRequest( name=name, ) - return self._get_instance_config( + return self._inner_api_calls['get_instance_config']( request, retry=retry, timeout=timeout, metadata=metadata) def list_instances(self, @@ -359,13 +376,15 @@ def list_instances(self, >>> >>> parent = client.project_path('[PROJECT]') >>> - >>> >>> # Iterate over all results >>> for element in client.list_instances(parent): ... # process element ... pass >>> - >>> # Or iterate over results one page at a time + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time >>> for page in client.list_instances(parent, options=CallOptions(page_token=INITIAL_PAGE)): ... for element in page: ... # process element @@ -393,15 +412,19 @@ def list_instances(self, * ``name:HOWL`` --> Equivalent to above. * ``NAME:howl`` --> Equivalent to above. * ``labels.env:*`` --> The instance has the label \"env\". - * ``labels.env:dev`` --> The instance has the label \"env\" and the value of the label contains the string \"dev\". - * ``name:howl labels.env:dev`` --> The instance's name contains \"howl\" and it has the label \"env\" with its value containing \"dev\". - + * ``labels.env:dev`` --> The instance has the label \"env\" + and the value of the label contains the string \"dev\". + * ``name:howl labels.env:dev`` --> The instance's name + contains \"howl\" and it has the label \"env\" with + its value containing \"dev\". retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will not be retried. timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.gax.PageIterator` instance. By default, this @@ -416,6 +439,17 @@ def list_instances(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'list_instances' not in self._inner_api_calls: + self._inner_api_calls[ + 'list_instances'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_instances, + default_retry=self._method_configs['ListInstances'].retry, + default_timeout=self._method_configs['ListInstances']. + timeout, + client_info=self._client_info, + ) + request = spanner_instance_admin_pb2.ListInstancesRequest( parent=parent, page_size=page_size, @@ -424,7 +458,9 @@ def list_instances(self, iterator = google.api_core.page_iterator.GRPCIterator( client=None, method=functools.partial( - self._list_instances, retry=retry, timeout=timeout, + self._inner_api_calls['list_instances'], + retry=retry, + timeout=timeout, metadata=metadata), request=request, items_field='instances', @@ -459,6 +495,8 @@ def get_instance(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_instance_v1.types.Instance` instance. @@ -470,8 +508,19 @@ def get_instance(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'get_instance' not in self._inner_api_calls: + self._inner_api_calls[ + 'get_instance'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_instance, + default_retry=self._method_configs['GetInstance'].retry, + default_timeout=self._method_configs['GetInstance']. + timeout, + client_info=self._client_info, + ) + request = spanner_instance_admin_pb2.GetInstanceRequest(name=name, ) - return self._get_instance( + return self._inner_api_calls['get_instance']( request, retry=retry, timeout=timeout, metadata=metadata) def create_instance(self, @@ -523,7 +572,11 @@ def create_instance(self, >>> client = spanner_admin_instance_v1.InstanceAdminClient() >>> >>> parent = client.project_path('[PROJECT]') + >>> + >>> # TODO: Initialize ``instance_id``: >>> instance_id = '' + >>> + >>> # TODO: Initialize ``instance``: >>> instance = {} >>> >>> response = client.create_instance(parent, instance_id, instance) @@ -553,6 +606,8 @@ def create_instance(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_instance_v1.types._OperationFuture` instance. @@ -564,16 +619,27 @@ def create_instance(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'create_instance' not in self._inner_api_calls: + self._inner_api_calls[ + 'create_instance'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.create_instance, + default_retry=self._method_configs['CreateInstance'].retry, + default_timeout=self._method_configs['CreateInstance']. + timeout, + client_info=self._client_info, + ) + request = spanner_instance_admin_pb2.CreateInstanceRequest( parent=parent, instance_id=instance_id, instance=instance, ) - operation = self._create_instance( + operation = self._inner_api_calls['create_instance']( request, retry=retry, timeout=timeout, metadata=metadata) return google.api_core.operation.from_gapic( operation, - self.operations_client, + self.transport._operations_client, spanner_instance_admin_pb2.Instance, metadata_type=spanner_instance_admin_pb2.CreateInstanceMetadata, ) @@ -599,10 +665,10 @@ def update_instance(self, Until completion of the returned operation: * Cancelling the operation sets its metadata's - [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins - restoring resources to their pre-request values. The operation - is guaranteed to succeed at undoing all resource changes, - after which point it terminates with a `CANCELLED` status. + [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], + and begins restoring resources to their pre-request values. + The operation is guaranteed to succeed at undoing all resource + changes, after which point it terminates with a `CANCELLED` status. * All other attempts to modify the instance are rejected. * Reading the instance via the API continues to give the pre-request resource levels. @@ -631,7 +697,10 @@ def update_instance(self, >>> >>> client = spanner_admin_instance_v1.InstanceAdminClient() >>> + >>> # TODO: Initialize ``instance``: >>> instance = {} + >>> + >>> # TODO: Initialize ``field_mask``: >>> field_mask = {} >>> >>> response = client.update_instance(instance, field_mask) @@ -662,6 +731,8 @@ def update_instance(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_instance_v1.types._OperationFuture` instance. @@ -673,15 +744,26 @@ def update_instance(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'update_instance' not in self._inner_api_calls: + self._inner_api_calls[ + 'update_instance'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.update_instance, + default_retry=self._method_configs['UpdateInstance'].retry, + default_timeout=self._method_configs['UpdateInstance']. + timeout, + client_info=self._client_info, + ) + request = spanner_instance_admin_pb2.UpdateInstanceRequest( instance=instance, field_mask=field_mask, ) - operation = self._update_instance( + operation = self._inner_api_calls['update_instance']( request, retry=retry, timeout=timeout, metadata=metadata) return google.api_core.operation.from_gapic( operation, - self.operations_client, + self.transport._operations_client, spanner_instance_admin_pb2.Instance, metadata_type=spanner_instance_admin_pb2.UpdateInstanceMetadata, ) @@ -722,6 +804,8 @@ def delete_instance(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Raises: google.api_core.exceptions.GoogleAPICallError: If the request @@ -730,8 +814,19 @@ def delete_instance(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'delete_instance' not in self._inner_api_calls: + self._inner_api_calls[ + 'delete_instance'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.delete_instance, + default_retry=self._method_configs['DeleteInstance'].retry, + default_timeout=self._method_configs['DeleteInstance']. + timeout, + client_info=self._client_info, + ) + request = spanner_instance_admin_pb2.DeleteInstanceRequest(name=name, ) - self._delete_instance( + self._inner_api_calls['delete_instance']( request, retry=retry, timeout=timeout, metadata=metadata) def set_iam_policy(self, @@ -753,6 +848,8 @@ def set_iam_policy(self, >>> client = spanner_admin_instance_v1.InstanceAdminClient() >>> >>> resource = client.instance_path('[PROJECT]', '[INSTANCE]') + >>> + >>> # TODO: Initialize ``policy``: >>> policy = {} >>> >>> response = client.set_iam_policy(resource, policy) @@ -773,6 +870,8 @@ def set_iam_policy(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_instance_v1.types.Policy` instance. @@ -784,11 +883,22 @@ def set_iam_policy(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'set_iam_policy' not in self._inner_api_calls: + self._inner_api_calls[ + 'set_iam_policy'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.set_iam_policy, + default_retry=self._method_configs['SetIamPolicy'].retry, + default_timeout=self._method_configs['SetIamPolicy']. + timeout, + client_info=self._client_info, + ) + request = iam_policy_pb2.SetIamPolicyRequest( resource=resource, policy=policy, ) - return self._set_iam_policy( + return self._inner_api_calls['set_iam_policy']( request, retry=retry, timeout=timeout, metadata=metadata) def get_iam_policy(self, @@ -822,6 +932,8 @@ def get_iam_policy(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_instance_v1.types.Policy` instance. @@ -833,8 +945,19 @@ def get_iam_policy(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'get_iam_policy' not in self._inner_api_calls: + self._inner_api_calls[ + 'get_iam_policy'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_iam_policy, + default_retry=self._method_configs['GetIamPolicy'].retry, + default_timeout=self._method_configs['GetIamPolicy']. + timeout, + client_info=self._client_info, + ) + request = iam_policy_pb2.GetIamPolicyRequest(resource=resource, ) - return self._get_iam_policy( + return self._inner_api_calls['get_iam_policy']( request, retry=retry, timeout=timeout, metadata=metadata) def test_iam_permissions(self, @@ -857,6 +980,8 @@ def test_iam_permissions(self, >>> client = spanner_admin_instance_v1.InstanceAdminClient() >>> >>> resource = client.instance_path('[PROJECT]', '[INSTANCE]') + >>> + >>> # TODO: Initialize ``permissions``: >>> permissions = [] >>> >>> response = client.test_iam_permissions(resource, permissions) @@ -875,6 +1000,8 @@ def test_iam_permissions(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_admin_instance_v1.types.TestIamPermissionsResponse` instance. @@ -886,9 +1013,21 @@ def test_iam_permissions(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'test_iam_permissions' not in self._inner_api_calls: + self._inner_api_calls[ + 'test_iam_permissions'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.test_iam_permissions, + default_retry=self._method_configs['TestIamPermissions']. + retry, + default_timeout=self._method_configs['TestIamPermissions']. + timeout, + client_info=self._client_info, + ) + request = iam_policy_pb2.TestIamPermissionsRequest( resource=resource, permissions=permissions, ) - return self._test_iam_permissions( + return self._inner_api_calls['test_iam_permissions']( request, retry=retry, timeout=timeout, metadata=metadata) diff --git a/spanner/google/cloud/spanner_admin_instance_v1/gapic/transports/__init__.py b/spanner/google/cloud/spanner_admin_instance_v1/gapic/transports/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/spanner/google/cloud/spanner_admin_instance_v1/gapic/transports/instance_admin_grpc_transport.py b/spanner/google/cloud/spanner_admin_instance_v1/gapic/transports/instance_admin_grpc_transport.py new file mode 100644 index 000000000000..5f84d91d8453 --- /dev/null +++ b/spanner/google/cloud/spanner_admin_instance_v1/gapic/transports/instance_admin_grpc_transport.py @@ -0,0 +1,328 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import google.api_core.grpc_helpers +import google.api_core.operations_v1 + +from google.cloud.spanner_admin_instance_v1.proto import spanner_instance_admin_pb2_grpc + + +class InstanceAdminGrpcTransport(object): + """gRPC transport class providing stubs for + google.spanner.admin.instance.v1 InstanceAdmin API. + + The transport provides access to the raw gRPC stubs, + which can be used to take advantage of advanced + features of gRPC. + """ + # The scopes needed to make gRPC calls to all of the methods defined + # in this service. + _OAUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.admin', + ) + + def __init__(self, + channel=None, + credentials=None, + address='spanner.googleapis.com:443'): + """Instantiate the transport class. + + Args: + channel (grpc.Channel): A ``Channel`` instance through + which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + address (str): The address where the service is hosted. + """ + # If both `channel` and `credentials` are specified, raise an + # exception (channels come with credentials baked in already). + if channel is not None and credentials is not None: + raise ValueError( + 'The `channel` and `credentials` arguments are mutually ' + 'exclusive.', ) + + # Create the channel. + if channel is None: + channel = self.create_channel( + address=address, + credentials=credentials, + ) + + # gRPC uses objects called "stubs" that are bound to the + # channel and provide a basic method for each RPC. + self._stubs = { + 'instance_admin_stub': + spanner_instance_admin_pb2_grpc.InstanceAdminStub(channel), + } + + # Because this API includes a method that returns a + # long-running operation (proto: google.longrunning.Operation), + # instantiate an LRO client. + self._operations_client = google.api_core.operations_v1.OperationsClient( + channel) + + @classmethod + def create_channel(cls, + address='spanner.googleapis.com:443', + credentials=None): + """Create and return a gRPC channel object. + + Args: + address (str): The host for the channel to use. + credentials (~.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return google.api_core.grpc_helpers.create_channel( + address, + credentials=credentials, + scopes=cls._OAUTH_SCOPES, + ) + + @property + def list_instance_configs(self): + """Return the gRPC stub for {$apiMethod.name}. + + Lists the supported instance configurations for a given project. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['instance_admin_stub'].ListInstanceConfigs + + @property + def get_instance_config(self): + """Return the gRPC stub for {$apiMethod.name}. + + Gets information about a particular instance configuration. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['instance_admin_stub'].GetInstanceConfig + + @property + def list_instances(self): + """Return the gRPC stub for {$apiMethod.name}. + + Lists all instances in the given project. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['instance_admin_stub'].ListInstances + + @property + def get_instance(self): + """Return the gRPC stub for {$apiMethod.name}. + + Gets information about a particular instance. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['instance_admin_stub'].GetInstance + + @property + def create_instance(self): + """Return the gRPC stub for {$apiMethod.name}. + + Creates an instance and begins preparing it to begin serving. The + returned ``long-running operation`` + can be used to track the progress of preparing the new + instance. The instance name is assigned by the caller. If the + named instance already exists, ``CreateInstance`` returns + ``ALREADY_EXISTS``. + + Immediately upon completion of this request: + + * The instance is readable via the API, with all requested attributes + but no allocated resources. Its state is `CREATING`. + + Until completion of the returned operation: + + * Cancelling the operation renders the instance immediately unreadable + via the API. + * The instance can be deleted. + * All other attempts to modify the instance are rejected. + + Upon completion of the returned operation: + + * Billing for all successfully-allocated resources begins (some types + may have lower than the requested levels). + * Databases can be created in the instance. + * The instance's allocated resource levels are readable via the API. + * The instance's state becomes ``READY``. + + The returned ``long-running operation`` will + have a name of the format ``/operations/`` and + can be used to track creation of the instance. The + ``metadata`` field type is + ``CreateInstanceMetadata``. + The ``response`` field type is + ``Instance``, if successful. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['instance_admin_stub'].CreateInstance + + @property + def update_instance(self): + """Return the gRPC stub for {$apiMethod.name}. + + Updates an instance, and begins allocating or releasing resources + as requested. The returned [long-running + operation][google.longrunning.Operation] can be used to track the + progress of updating the instance. If the named instance does not + exist, returns ``NOT_FOUND``. + + Immediately upon completion of this request: + + * For resource types for which a decrease in the instance's allocation + has been requested, billing is based on the newly-requested level. + + Until completion of the returned operation: + + * Cancelling the operation sets its metadata's + [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins + restoring resources to their pre-request values. The operation + is guaranteed to succeed at undoing all resource changes, + after which point it terminates with a `CANCELLED` status. + * All other attempts to modify the instance are rejected. + * Reading the instance via the API continues to give the pre-request + resource levels. + + Upon completion of the returned operation: + + * Billing begins for all successfully-allocated resources (some types + may have lower than the requested levels). + * All newly-reserved resources are available for serving the instance's + tables. + * The instance's new resource levels are readable via the API. + + The returned ``long-running operation`` will + have a name of the format ``/operations/`` and + can be used to track the instance modification. The + ``metadata`` field type is + ``UpdateInstanceMetadata``. + The ``response`` field type is + ``Instance``, if successful. + + Authorization requires ``spanner.instances.update`` permission on + resource ``name``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['instance_admin_stub'].UpdateInstance + + @property + def delete_instance(self): + """Return the gRPC stub for {$apiMethod.name}. + + Deletes an instance. + + Immediately upon completion of the request: + + * Billing ceases for all of the instance's reserved resources. + + Soon afterward: + + * The instance and *all of its databases* immediately and + irrevocably disappear from the API. All data in the databases + is permanently deleted. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['instance_admin_stub'].DeleteInstance + + @property + def set_iam_policy(self): + """Return the gRPC stub for {$apiMethod.name}. + + Sets the access control policy on an instance resource. Replaces any + existing policy. + + Authorization requires ``spanner.instances.setIamPolicy`` on + ``resource``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['instance_admin_stub'].SetIamPolicy + + @property + def get_iam_policy(self): + """Return the gRPC stub for {$apiMethod.name}. + + Gets the access control policy for an instance resource. Returns an empty + policy if an instance exists but does not have a policy set. + + Authorization requires ``spanner.instances.getIamPolicy`` on + ``resource``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['instance_admin_stub'].GetIamPolicy + + @property + def test_iam_permissions(self): + """Return the gRPC stub for {$apiMethod.name}. + + Returns permissions that the caller has on the specified instance resource. + + Attempting this RPC on a non-existent Cloud Spanner instance resource will + result in a NOT_FOUND error if the user has ``spanner.instances.list`` + permission on the containing Google Cloud Project. Otherwise returns an + empty set of permissions. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['instance_admin_stub'].TestIamPermissions diff --git a/spanner/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2.py b/spanner/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2.py index 1725a77abb3c..4f8b3dd75318 100644 --- a/spanner/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2.py +++ b/spanner/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2.py @@ -29,7 +29,6 @@ serialized_pb=_b('\nIgoogle/cloud/spanner/admin/instance_v1/proto/spanner_instance_admin.proto\x12 google.spanner.admin.instance.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1egoogle/iam/v1/iam_policy.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a#google/longrunning/operations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"4\n\x0eInstanceConfig\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x02 \x01(\t\"\xc3\x02\n\x08Instance\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x0e\n\x06\x63onfig\x18\x02 \x01(\t\x12\x14\n\x0c\x64isplay_name\x18\x03 \x01(\t\x12\x12\n\nnode_count\x18\x05 \x01(\x05\x12?\n\x05state\x18\x06 \x01(\x0e\x32\x30.google.spanner.admin.instance.v1.Instance.State\x12\x46\n\x06labels\x18\x07 \x03(\x0b\x32\x36.google.spanner.admin.instance.v1.Instance.LabelsEntry\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"7\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x0c\n\x08\x43REATING\x10\x01\x12\t\n\x05READY\x10\x02\"S\n\x1aListInstanceConfigsRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\"\x82\x01\n\x1bListInstanceConfigsResponse\x12J\n\x10instance_configs\x18\x01 \x03(\x0b\x32\x30.google.spanner.admin.instance.v1.InstanceConfig\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"(\n\x18GetInstanceConfigRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\"\n\x12GetInstanceRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"z\n\x15\x43reateInstanceRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x13\n\x0binstance_id\x18\x02 \x01(\t\x12<\n\x08instance\x18\x03 \x01(\x0b\x32*.google.spanner.admin.instance.v1.Instance\"]\n\x14ListInstancesRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x04 \x01(\t\"o\n\x15ListInstancesResponse\x12=\n\tinstances\x18\x01 \x03(\x0b\x32*.google.spanner.admin.instance.v1.Instance\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"\x85\x01\n\x15UpdateInstanceRequest\x12<\n\x08instance\x18\x01 \x01(\x0b\x32*.google.spanner.admin.instance.v1.Instance\x12.\n\nfield_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMask\"%\n\x15\x44\x65leteInstanceRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\xe5\x01\n\x16\x43reateInstanceMetadata\x12<\n\x08instance\x18\x01 \x01(\x0b\x32*.google.spanner.admin.instance.v1.Instance\x12.\n\nstart_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12/\n\x0b\x63\x61ncel_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\xe5\x01\n\x16UpdateInstanceMetadata\x12<\n\x08instance\x18\x01 \x01(\x0b\x32*.google.spanner.admin.instance.v1.Instance\x12.\n\nstart_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12/\n\x0b\x63\x61ncel_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12,\n\x08\x65nd_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp2\xe6\x0c\n\rInstanceAdmin\x12\xc3\x01\n\x13ListInstanceConfigs\x12<.google.spanner.admin.instance.v1.ListInstanceConfigsRequest\x1a=.google.spanner.admin.instance.v1.ListInstanceConfigsResponse\"/\x82\xd3\xe4\x93\x02)\x12\'/v1/{parent=projects/*}/instanceConfigs\x12\xb2\x01\n\x11GetInstanceConfig\x12:.google.spanner.admin.instance.v1.GetInstanceConfigRequest\x1a\x30.google.spanner.admin.instance.v1.InstanceConfig\"/\x82\xd3\xe4\x93\x02)\x12\'/v1/{name=projects/*/instanceConfigs/*}\x12\xab\x01\n\rListInstances\x12\x36.google.spanner.admin.instance.v1.ListInstancesRequest\x1a\x37.google.spanner.admin.instance.v1.ListInstancesResponse\")\x82\xd3\xe4\x93\x02#\x12!/v1/{parent=projects/*}/instances\x12\x9a\x01\n\x0bGetInstance\x12\x34.google.spanner.admin.instance.v1.GetInstanceRequest\x1a*.google.spanner.admin.instance.v1.Instance\")\x82\xd3\xe4\x93\x02#\x12!/v1/{name=projects/*/instances/*}\x12\x96\x01\n\x0e\x43reateInstance\x12\x37.google.spanner.admin.instance.v1.CreateInstanceRequest\x1a\x1d.google.longrunning.Operation\",\x82\xd3\xe4\x93\x02&\"!/v1/{parent=projects/*}/instances:\x01*\x12\x9f\x01\n\x0eUpdateInstance\x12\x37.google.spanner.admin.instance.v1.UpdateInstanceRequest\x1a\x1d.google.longrunning.Operation\"5\x82\xd3\xe4\x93\x02/2*/v1/{instance.name=projects/*/instances/*}:\x01*\x12\x8c\x01\n\x0e\x44\x65leteInstance\x12\x37.google.spanner.admin.instance.v1.DeleteInstanceRequest\x1a\x16.google.protobuf.Empty\")\x82\xd3\xe4\x93\x02#*!/v1/{name=projects/*/instances/*}\x12\x88\x01\n\x0cSetIamPolicy\x12\".google.iam.v1.SetIamPolicyRequest\x1a\x15.google.iam.v1.Policy\"=\x82\xd3\xe4\x93\x02\x37\"2/v1/{resource=projects/*/instances/*}:setIamPolicy:\x01*\x12\x88\x01\n\x0cGetIamPolicy\x12\".google.iam.v1.GetIamPolicyRequest\x1a\x15.google.iam.v1.Policy\"=\x82\xd3\xe4\x93\x02\x37\"2/v1/{resource=projects/*/instances/*}:getIamPolicy:\x01*\x12\xae\x01\n\x12TestIamPermissions\x12(.google.iam.v1.TestIamPermissionsRequest\x1a).google.iam.v1.TestIamPermissionsResponse\"C\x82\xd3\xe4\x93\x02=\"8/v1/{resource=projects/*/instances/*}:testIamPermissions:\x01*B\xdf\x01\n$com.google.spanner.admin.instance.v1B\x19SpannerInstanceAdminProtoP\x01ZHgoogle.golang.org/genproto/googleapis/spanner/admin/instance/v1;instance\xaa\x02&Google.Cloud.Spanner.Admin.Instance.V1\xca\x02&Google\\Cloud\\Spanner\\Admin\\Instance\\V1b\x06proto3') , dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_iam_dot_v1_dot_iam__policy__pb2.DESCRIPTOR,google_dot_iam_dot_v1_dot_policy__pb2.DESCRIPTOR,google_dot_longrunning_dot_operations__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -73,14 +72,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='display_name', full_name='google.spanner.admin.instance.v1.InstanceConfig.display_name', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -111,14 +110,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='value', full_name='google.spanner.admin.instance.v1.Instance.LabelsEntry.value', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -148,42 +147,42 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='config', full_name='google.spanner.admin.instance.v1.Instance.config', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='display_name', full_name='google.spanner.admin.instance.v1.Instance.display_name', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='node_count', full_name='google.spanner.admin.instance.v1.Instance.node_count', index=3, number=5, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='state', full_name='google.spanner.admin.instance.v1.Instance.state', index=4, number=6, type=14, cpp_type=8, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='labels', full_name='google.spanner.admin.instance.v1.Instance.labels', index=5, number=7, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -215,21 +214,21 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='page_size', full_name='google.spanner.admin.instance.v1.ListInstanceConfigsRequest.page_size', index=1, number=2, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='page_token', full_name='google.spanner.admin.instance.v1.ListInstanceConfigsRequest.page_token', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -260,14 +259,14 @@ has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='next_page_token', full_name='google.spanner.admin.instance.v1.ListInstanceConfigsResponse.next_page_token', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -298,7 +297,7 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -329,7 +328,7 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -360,21 +359,21 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='instance_id', full_name='google.spanner.admin.instance.v1.CreateInstanceRequest.instance_id', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='instance', full_name='google.spanner.admin.instance.v1.CreateInstanceRequest.instance', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -405,28 +404,28 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='page_size', full_name='google.spanner.admin.instance.v1.ListInstancesRequest.page_size', index=1, number=2, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='page_token', full_name='google.spanner.admin.instance.v1.ListInstancesRequest.page_token', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='filter', full_name='google.spanner.admin.instance.v1.ListInstancesRequest.filter', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -457,14 +456,14 @@ has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='next_page_token', full_name='google.spanner.admin.instance.v1.ListInstancesResponse.next_page_token', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -495,14 +494,14 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='field_mask', full_name='google.spanner.admin.instance.v1.UpdateInstanceRequest.field_mask', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -533,7 +532,7 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -564,28 +563,28 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='start_time', full_name='google.spanner.admin.instance.v1.CreateInstanceMetadata.start_time', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='cancel_time', full_name='google.spanner.admin.instance.v1.CreateInstanceMetadata.cancel_time', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='end_time', full_name='google.spanner.admin.instance.v1.CreateInstanceMetadata.end_time', index=3, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -616,28 +615,28 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='start_time', full_name='google.spanner.admin.instance.v1.UpdateInstanceMetadata.start_time', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='cancel_time', full_name='google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='end_time', full_name='google.spanner.admin.instance.v1.UpdateInstanceMetadata.end_time', index=3, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -684,6 +683,7 @@ DESCRIPTOR.message_types_by_name['DeleteInstanceRequest'] = _DELETEINSTANCEREQUEST DESCRIPTOR.message_types_by_name['CreateInstanceMetadata'] = _CREATEINSTANCEMETADATA DESCRIPTOR.message_types_by_name['UpdateInstanceMetadata'] = _UPDATEINSTANCEMETADATA +_sym_db.RegisterFileDescriptor(DESCRIPTOR) InstanceConfig = _reflection.GeneratedProtocolMessageType('InstanceConfig', (_message.Message,), dict( DESCRIPTOR = _INSTANCECONFIG, @@ -1047,776 +1047,109 @@ DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n$com.google.spanner.admin.instance.v1B\031SpannerInstanceAdminProtoP\001ZHgoogle.golang.org/genproto/googleapis/spanner/admin/instance/v1;instance\252\002&Google.Cloud.Spanner.Admin.Instance.V1\312\002&Google\\Cloud\\Spanner\\Admin\\Instance\\V1')) _INSTANCE_LABELSENTRY.has_options = True _INSTANCE_LABELSENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) -try: - # THESE ELEMENTS WILL BE DEPRECATED. - # Please use the generated *_pb2_grpc.py files instead. - import grpc - from grpc.beta import implementations as beta_implementations - from grpc.beta import interfaces as beta_interfaces - from grpc.framework.common import cardinality - from grpc.framework.interfaces.face import utilities as face_utilities - - - class InstanceAdminStub(object): - """Cloud Spanner Instance Admin API - - The Cloud Spanner Instance Admin API can be used to create, delete, - modify and list instances. Instances are dedicated Cloud Spanner serving - and storage resources to be used by Cloud Spanner databases. - - Each instance has a "configuration", which dictates where the - serving resources for the Cloud Spanner instance are located (e.g., - US-central, Europe). Configurations are created by Google based on - resource availability. - - Cloud Spanner billing is based on the instances that exist and their - sizes. After an instance exists, there are no additional - per-database or per-operation charges for use of the instance - (though there may be additional network bandwidth charges). - Instances offer isolation: problems with databases in one instance - will not affect other instances. However, within an instance - databases can affect each other. For example, if one database in an - instance receives a lot of requests and consumes most of the - instance resources, fewer resources are available for other - databases in that instance, and their performance may suffer. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.ListInstanceConfigs = channel.unary_unary( - '/google.spanner.admin.instance.v1.InstanceAdmin/ListInstanceConfigs', - request_serializer=ListInstanceConfigsRequest.SerializeToString, - response_deserializer=ListInstanceConfigsResponse.FromString, - ) - self.GetInstanceConfig = channel.unary_unary( - '/google.spanner.admin.instance.v1.InstanceAdmin/GetInstanceConfig', - request_serializer=GetInstanceConfigRequest.SerializeToString, - response_deserializer=InstanceConfig.FromString, - ) - self.ListInstances = channel.unary_unary( - '/google.spanner.admin.instance.v1.InstanceAdmin/ListInstances', - request_serializer=ListInstancesRequest.SerializeToString, - response_deserializer=ListInstancesResponse.FromString, - ) - self.GetInstance = channel.unary_unary( - '/google.spanner.admin.instance.v1.InstanceAdmin/GetInstance', - request_serializer=GetInstanceRequest.SerializeToString, - response_deserializer=Instance.FromString, - ) - self.CreateInstance = channel.unary_unary( - '/google.spanner.admin.instance.v1.InstanceAdmin/CreateInstance', - request_serializer=CreateInstanceRequest.SerializeToString, - response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, - ) - self.UpdateInstance = channel.unary_unary( - '/google.spanner.admin.instance.v1.InstanceAdmin/UpdateInstance', - request_serializer=UpdateInstanceRequest.SerializeToString, - response_deserializer=google_dot_longrunning_dot_operations__pb2.Operation.FromString, - ) - self.DeleteInstance = channel.unary_unary( - '/google.spanner.admin.instance.v1.InstanceAdmin/DeleteInstance', - request_serializer=DeleteInstanceRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.SetIamPolicy = channel.unary_unary( - '/google.spanner.admin.instance.v1.InstanceAdmin/SetIamPolicy', - request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.SerializeToString, - response_deserializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString, - ) - self.GetIamPolicy = channel.unary_unary( - '/google.spanner.admin.instance.v1.InstanceAdmin/GetIamPolicy', - request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.SerializeToString, - response_deserializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString, - ) - self.TestIamPermissions = channel.unary_unary( - '/google.spanner.admin.instance.v1.InstanceAdmin/TestIamPermissions', - request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.SerializeToString, - response_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.FromString, - ) - - - class InstanceAdminServicer(object): - """Cloud Spanner Instance Admin API - - The Cloud Spanner Instance Admin API can be used to create, delete, - modify and list instances. Instances are dedicated Cloud Spanner serving - and storage resources to be used by Cloud Spanner databases. - - Each instance has a "configuration", which dictates where the - serving resources for the Cloud Spanner instance are located (e.g., - US-central, Europe). Configurations are created by Google based on - resource availability. - - Cloud Spanner billing is based on the instances that exist and their - sizes. After an instance exists, there are no additional - per-database or per-operation charges for use of the instance - (though there may be additional network bandwidth charges). - Instances offer isolation: problems with databases in one instance - will not affect other instances. However, within an instance - databases can affect each other. For example, if one database in an - instance receives a lot of requests and consumes most of the - instance resources, fewer resources are available for other - databases in that instance, and their performance may suffer. - """ - - def ListInstanceConfigs(self, request, context): - """Lists the supported instance configurations for a given project. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetInstanceConfig(self, request, context): - """Gets information about a particular instance configuration. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListInstances(self, request, context): - """Lists all instances in the given project. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetInstance(self, request, context): - """Gets information about a particular instance. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def CreateInstance(self, request, context): - """Creates an instance and begins preparing it to begin serving. The - returned [long-running operation][google.longrunning.Operation] - can be used to track the progress of preparing the new - instance. The instance name is assigned by the caller. If the - named instance already exists, `CreateInstance` returns - `ALREADY_EXISTS`. - - Immediately upon completion of this request: - - * The instance is readable via the API, with all requested attributes - but no allocated resources. Its state is `CREATING`. - - Until completion of the returned operation: - - * Cancelling the operation renders the instance immediately unreadable - via the API. - * The instance can be deleted. - * All other attempts to modify the instance are rejected. - - Upon completion of the returned operation: - - * Billing for all successfully-allocated resources begins (some types - may have lower than the requested levels). - * Databases can be created in the instance. - * The instance's allocated resource levels are readable via the API. - * The instance's state becomes `READY`. - - The returned [long-running operation][google.longrunning.Operation] will - have a name of the format `/operations/` and - can be used to track creation of the instance. The - [metadata][google.longrunning.Operation.metadata] field type is - [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. - The [response][google.longrunning.Operation.response] field type is - [Instance][google.spanner.admin.instance.v1.Instance], if successful. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def UpdateInstance(self, request, context): - """Updates an instance, and begins allocating or releasing resources - as requested. The returned [long-running - operation][google.longrunning.Operation] can be used to track the - progress of updating the instance. If the named instance does not - exist, returns `NOT_FOUND`. - - Immediately upon completion of this request: - - * For resource types for which a decrease in the instance's allocation - has been requested, billing is based on the newly-requested level. - - Until completion of the returned operation: - - * Cancelling the operation sets its metadata's - [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins - restoring resources to their pre-request values. The operation - is guaranteed to succeed at undoing all resource changes, - after which point it terminates with a `CANCELLED` status. - * All other attempts to modify the instance are rejected. - * Reading the instance via the API continues to give the pre-request - resource levels. - - Upon completion of the returned operation: - - * Billing begins for all successfully-allocated resources (some types - may have lower than the requested levels). - * All newly-reserved resources are available for serving the instance's - tables. - * The instance's new resource levels are readable via the API. - - The returned [long-running operation][google.longrunning.Operation] will - have a name of the format `/operations/` and - can be used to track the instance modification. The - [metadata][google.longrunning.Operation.metadata] field type is - [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. - The [response][google.longrunning.Operation.response] field type is - [Instance][google.spanner.admin.instance.v1.Instance], if successful. - - Authorization requires `spanner.instances.update` permission on - resource [name][google.spanner.admin.instance.v1.Instance.name]. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteInstance(self, request, context): - """Deletes an instance. - - Immediately upon completion of the request: - - * Billing ceases for all of the instance's reserved resources. - - Soon afterward: - - * The instance and *all of its databases* immediately and - irrevocably disappear from the API. All data in the databases - is permanently deleted. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def SetIamPolicy(self, request, context): - """Sets the access control policy on an instance resource. Replaces any - existing policy. - - Authorization requires `spanner.instances.setIamPolicy` on - [resource][google.iam.v1.SetIamPolicyRequest.resource]. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetIamPolicy(self, request, context): - """Gets the access control policy for an instance resource. Returns an empty - policy if an instance exists but does not have a policy set. - - Authorization requires `spanner.instances.getIamPolicy` on - [resource][google.iam.v1.GetIamPolicyRequest.resource]. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def TestIamPermissions(self, request, context): - """Returns permissions that the caller has on the specified instance resource. - - Attempting this RPC on a non-existent Cloud Spanner instance resource will - result in a NOT_FOUND error if the user has `spanner.instances.list` - permission on the containing Google Cloud Project. Otherwise returns an - empty set of permissions. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - - def add_InstanceAdminServicer_to_server(servicer, server): - rpc_method_handlers = { - 'ListInstanceConfigs': grpc.unary_unary_rpc_method_handler( - servicer.ListInstanceConfigs, - request_deserializer=ListInstanceConfigsRequest.FromString, - response_serializer=ListInstanceConfigsResponse.SerializeToString, - ), - 'GetInstanceConfig': grpc.unary_unary_rpc_method_handler( - servicer.GetInstanceConfig, - request_deserializer=GetInstanceConfigRequest.FromString, - response_serializer=InstanceConfig.SerializeToString, - ), - 'ListInstances': grpc.unary_unary_rpc_method_handler( - servicer.ListInstances, - request_deserializer=ListInstancesRequest.FromString, - response_serializer=ListInstancesResponse.SerializeToString, - ), - 'GetInstance': grpc.unary_unary_rpc_method_handler( - servicer.GetInstance, - request_deserializer=GetInstanceRequest.FromString, - response_serializer=Instance.SerializeToString, - ), - 'CreateInstance': grpc.unary_unary_rpc_method_handler( - servicer.CreateInstance, - request_deserializer=CreateInstanceRequest.FromString, - response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - ), - 'UpdateInstance': grpc.unary_unary_rpc_method_handler( - servicer.UpdateInstance, - request_deserializer=UpdateInstanceRequest.FromString, - response_serializer=google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - ), - 'DeleteInstance': grpc.unary_unary_rpc_method_handler( - servicer.DeleteInstance, - request_deserializer=DeleteInstanceRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'SetIamPolicy': grpc.unary_unary_rpc_method_handler( - servicer.SetIamPolicy, - request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.FromString, - response_serializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString, - ), - 'GetIamPolicy': grpc.unary_unary_rpc_method_handler( - servicer.GetIamPolicy, - request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.FromString, - response_serializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString, - ), - 'TestIamPermissions': grpc.unary_unary_rpc_method_handler( - servicer.TestIamPermissions, - request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.FromString, - response_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'google.spanner.admin.instance.v1.InstanceAdmin', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - class BetaInstanceAdminServicer(object): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This class was generated - only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" - """Cloud Spanner Instance Admin API - - The Cloud Spanner Instance Admin API can be used to create, delete, - modify and list instances. Instances are dedicated Cloud Spanner serving - and storage resources to be used by Cloud Spanner databases. - - Each instance has a "configuration", which dictates where the - serving resources for the Cloud Spanner instance are located (e.g., - US-central, Europe). Configurations are created by Google based on - resource availability. - - Cloud Spanner billing is based on the instances that exist and their - sizes. After an instance exists, there are no additional - per-database or per-operation charges for use of the instance - (though there may be additional network bandwidth charges). - Instances offer isolation: problems with databases in one instance - will not affect other instances. However, within an instance - databases can affect each other. For example, if one database in an - instance receives a lot of requests and consumes most of the - instance resources, fewer resources are available for other - databases in that instance, and their performance may suffer. - """ - def ListInstanceConfigs(self, request, context): - """Lists the supported instance configurations for a given project. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def GetInstanceConfig(self, request, context): - """Gets information about a particular instance configuration. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def ListInstances(self, request, context): - """Lists all instances in the given project. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def GetInstance(self, request, context): - """Gets information about a particular instance. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def CreateInstance(self, request, context): - """Creates an instance and begins preparing it to begin serving. The - returned [long-running operation][google.longrunning.Operation] - can be used to track the progress of preparing the new - instance. The instance name is assigned by the caller. If the - named instance already exists, `CreateInstance` returns - `ALREADY_EXISTS`. - - Immediately upon completion of this request: - * The instance is readable via the API, with all requested attributes - but no allocated resources. Its state is `CREATING`. - - Until completion of the returned operation: - - * Cancelling the operation renders the instance immediately unreadable - via the API. - * The instance can be deleted. - * All other attempts to modify the instance are rejected. - - Upon completion of the returned operation: - - * Billing for all successfully-allocated resources begins (some types - may have lower than the requested levels). - * Databases can be created in the instance. - * The instance's allocated resource levels are readable via the API. - * The instance's state becomes `READY`. - - The returned [long-running operation][google.longrunning.Operation] will - have a name of the format `/operations/` and - can be used to track creation of the instance. The - [metadata][google.longrunning.Operation.metadata] field type is - [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. - The [response][google.longrunning.Operation.response] field type is - [Instance][google.spanner.admin.instance.v1.Instance], if successful. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def UpdateInstance(self, request, context): - """Updates an instance, and begins allocating or releasing resources - as requested. The returned [long-running - operation][google.longrunning.Operation] can be used to track the - progress of updating the instance. If the named instance does not - exist, returns `NOT_FOUND`. - - Immediately upon completion of this request: - - * For resource types for which a decrease in the instance's allocation - has been requested, billing is based on the newly-requested level. - - Until completion of the returned operation: - - * Cancelling the operation sets its metadata's - [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins - restoring resources to their pre-request values. The operation - is guaranteed to succeed at undoing all resource changes, - after which point it terminates with a `CANCELLED` status. - * All other attempts to modify the instance are rejected. - * Reading the instance via the API continues to give the pre-request - resource levels. - - Upon completion of the returned operation: - - * Billing begins for all successfully-allocated resources (some types - may have lower than the requested levels). - * All newly-reserved resources are available for serving the instance's - tables. - * The instance's new resource levels are readable via the API. - - The returned [long-running operation][google.longrunning.Operation] will - have a name of the format `/operations/` and - can be used to track the instance modification. The - [metadata][google.longrunning.Operation.metadata] field type is - [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. - The [response][google.longrunning.Operation.response] field type is - [Instance][google.spanner.admin.instance.v1.Instance], if successful. - - Authorization requires `spanner.instances.update` permission on - resource [name][google.spanner.admin.instance.v1.Instance.name]. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def DeleteInstance(self, request, context): - """Deletes an instance. - - Immediately upon completion of the request: - - * Billing ceases for all of the instance's reserved resources. - - Soon afterward: - - * The instance and *all of its databases* immediately and - irrevocably disappear from the API. All data in the databases - is permanently deleted. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def SetIamPolicy(self, request, context): - """Sets the access control policy on an instance resource. Replaces any - existing policy. - - Authorization requires `spanner.instances.setIamPolicy` on - [resource][google.iam.v1.SetIamPolicyRequest.resource]. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def GetIamPolicy(self, request, context): - """Gets the access control policy for an instance resource. Returns an empty - policy if an instance exists but does not have a policy set. - - Authorization requires `spanner.instances.getIamPolicy` on - [resource][google.iam.v1.GetIamPolicyRequest.resource]. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def TestIamPermissions(self, request, context): - """Returns permissions that the caller has on the specified instance resource. - - Attempting this RPC on a non-existent Cloud Spanner instance resource will - result in a NOT_FOUND error if the user has `spanner.instances.list` - permission on the containing Google Cloud Project. Otherwise returns an - empty set of permissions. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - - - class BetaInstanceAdminStub(object): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This class was generated - only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" - """Cloud Spanner Instance Admin API - - The Cloud Spanner Instance Admin API can be used to create, delete, - modify and list instances. Instances are dedicated Cloud Spanner serving - and storage resources to be used by Cloud Spanner databases. - - Each instance has a "configuration", which dictates where the - serving resources for the Cloud Spanner instance are located (e.g., - US-central, Europe). Configurations are created by Google based on - resource availability. - - Cloud Spanner billing is based on the instances that exist and their - sizes. After an instance exists, there are no additional - per-database or per-operation charges for use of the instance - (though there may be additional network bandwidth charges). - Instances offer isolation: problems with databases in one instance - will not affect other instances. However, within an instance - databases can affect each other. For example, if one database in an - instance receives a lot of requests and consumes most of the - instance resources, fewer resources are available for other - databases in that instance, and their performance may suffer. - """ - def ListInstanceConfigs(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Lists the supported instance configurations for a given project. - """ - raise NotImplementedError() - ListInstanceConfigs.future = None - def GetInstanceConfig(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Gets information about a particular instance configuration. - """ - raise NotImplementedError() - GetInstanceConfig.future = None - def ListInstances(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Lists all instances in the given project. - """ - raise NotImplementedError() - ListInstances.future = None - def GetInstance(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Gets information about a particular instance. - """ - raise NotImplementedError() - GetInstance.future = None - def CreateInstance(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Creates an instance and begins preparing it to begin serving. The - returned [long-running operation][google.longrunning.Operation] - can be used to track the progress of preparing the new - instance. The instance name is assigned by the caller. If the - named instance already exists, `CreateInstance` returns - `ALREADY_EXISTS`. - - Immediately upon completion of this request: - - * The instance is readable via the API, with all requested attributes - but no allocated resources. Its state is `CREATING`. - - Until completion of the returned operation: - - * Cancelling the operation renders the instance immediately unreadable - via the API. - * The instance can be deleted. - * All other attempts to modify the instance are rejected. - - Upon completion of the returned operation: - - * Billing for all successfully-allocated resources begins (some types - may have lower than the requested levels). - * Databases can be created in the instance. - * The instance's allocated resource levels are readable via the API. - * The instance's state becomes `READY`. - - The returned [long-running operation][google.longrunning.Operation] will - have a name of the format `/operations/` and - can be used to track creation of the instance. The - [metadata][google.longrunning.Operation.metadata] field type is - [CreateInstanceMetadata][google.spanner.admin.instance.v1.CreateInstanceMetadata]. - The [response][google.longrunning.Operation.response] field type is - [Instance][google.spanner.admin.instance.v1.Instance], if successful. - """ - raise NotImplementedError() - CreateInstance.future = None - def UpdateInstance(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Updates an instance, and begins allocating or releasing resources - as requested. The returned [long-running - operation][google.longrunning.Operation] can be used to track the - progress of updating the instance. If the named instance does not - exist, returns `NOT_FOUND`. - - Immediately upon completion of this request: - - * For resource types for which a decrease in the instance's allocation - has been requested, billing is based on the newly-requested level. - - Until completion of the returned operation: - - * Cancelling the operation sets its metadata's - [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], and begins - restoring resources to their pre-request values. The operation - is guaranteed to succeed at undoing all resource changes, - after which point it terminates with a `CANCELLED` status. - * All other attempts to modify the instance are rejected. - * Reading the instance via the API continues to give the pre-request - resource levels. - - Upon completion of the returned operation: - - * Billing begins for all successfully-allocated resources (some types - may have lower than the requested levels). - * All newly-reserved resources are available for serving the instance's - tables. - * The instance's new resource levels are readable via the API. - - The returned [long-running operation][google.longrunning.Operation] will - have a name of the format `/operations/` and - can be used to track the instance modification. The - [metadata][google.longrunning.Operation.metadata] field type is - [UpdateInstanceMetadata][google.spanner.admin.instance.v1.UpdateInstanceMetadata]. - The [response][google.longrunning.Operation.response] field type is - [Instance][google.spanner.admin.instance.v1.Instance], if successful. - - Authorization requires `spanner.instances.update` permission on - resource [name][google.spanner.admin.instance.v1.Instance.name]. - """ - raise NotImplementedError() - UpdateInstance.future = None - def DeleteInstance(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Deletes an instance. - - Immediately upon completion of the request: - - * Billing ceases for all of the instance's reserved resources. - - Soon afterward: - - * The instance and *all of its databases* immediately and - irrevocably disappear from the API. All data in the databases - is permanently deleted. - """ - raise NotImplementedError() - DeleteInstance.future = None - def SetIamPolicy(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Sets the access control policy on an instance resource. Replaces any - existing policy. - - Authorization requires `spanner.instances.setIamPolicy` on - [resource][google.iam.v1.SetIamPolicyRequest.resource]. - """ - raise NotImplementedError() - SetIamPolicy.future = None - def GetIamPolicy(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Gets the access control policy for an instance resource. Returns an empty - policy if an instance exists but does not have a policy set. - - Authorization requires `spanner.instances.getIamPolicy` on - [resource][google.iam.v1.GetIamPolicyRequest.resource]. - """ - raise NotImplementedError() - GetIamPolicy.future = None - def TestIamPermissions(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Returns permissions that the caller has on the specified instance resource. - - Attempting this RPC on a non-existent Cloud Spanner instance resource will - result in a NOT_FOUND error if the user has `spanner.instances.list` - permission on the containing Google Cloud Project. Otherwise returns an - empty set of permissions. - """ - raise NotImplementedError() - TestIamPermissions.future = None - - - def beta_create_InstanceAdmin_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This function was - generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" - request_deserializers = { - ('google.spanner.admin.instance.v1.InstanceAdmin', 'CreateInstance'): CreateInstanceRequest.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'DeleteInstance'): DeleteInstanceRequest.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetIamPolicy'): google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetInstance'): GetInstanceRequest.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetInstanceConfig'): GetInstanceConfigRequest.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'ListInstanceConfigs'): ListInstanceConfigsRequest.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'ListInstances'): ListInstancesRequest.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'SetIamPolicy'): google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'TestIamPermissions'): google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'UpdateInstance'): UpdateInstanceRequest.FromString, - } - response_serializers = { - ('google.spanner.admin.instance.v1.InstanceAdmin', 'CreateInstance'): google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'DeleteInstance'): google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetIamPolicy'): google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetInstance'): Instance.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetInstanceConfig'): InstanceConfig.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'ListInstanceConfigs'): ListInstanceConfigsResponse.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'ListInstances'): ListInstancesResponse.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'SetIamPolicy'): google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'TestIamPermissions'): google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'UpdateInstance'): google_dot_longrunning_dot_operations__pb2.Operation.SerializeToString, - } - method_implementations = { - ('google.spanner.admin.instance.v1.InstanceAdmin', 'CreateInstance'): face_utilities.unary_unary_inline(servicer.CreateInstance), - ('google.spanner.admin.instance.v1.InstanceAdmin', 'DeleteInstance'): face_utilities.unary_unary_inline(servicer.DeleteInstance), - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetIamPolicy'): face_utilities.unary_unary_inline(servicer.GetIamPolicy), - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetInstance'): face_utilities.unary_unary_inline(servicer.GetInstance), - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetInstanceConfig'): face_utilities.unary_unary_inline(servicer.GetInstanceConfig), - ('google.spanner.admin.instance.v1.InstanceAdmin', 'ListInstanceConfigs'): face_utilities.unary_unary_inline(servicer.ListInstanceConfigs), - ('google.spanner.admin.instance.v1.InstanceAdmin', 'ListInstances'): face_utilities.unary_unary_inline(servicer.ListInstances), - ('google.spanner.admin.instance.v1.InstanceAdmin', 'SetIamPolicy'): face_utilities.unary_unary_inline(servicer.SetIamPolicy), - ('google.spanner.admin.instance.v1.InstanceAdmin', 'TestIamPermissions'): face_utilities.unary_unary_inline(servicer.TestIamPermissions), - ('google.spanner.admin.instance.v1.InstanceAdmin', 'UpdateInstance'): face_utilities.unary_unary_inline(servicer.UpdateInstance), - } - server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout) - return beta_implementations.server(method_implementations, options=server_options) - - - def beta_create_InstanceAdmin_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None): - """The Beta API is deprecated for 0.15.0 and later. +_INSTANCEADMIN = _descriptor.ServiceDescriptor( + name='InstanceAdmin', + full_name='google.spanner.admin.instance.v1.InstanceAdmin', + file=DESCRIPTOR, + index=0, + options=None, + serialized_start=1982, + serialized_end=3620, + methods=[ + _descriptor.MethodDescriptor( + name='ListInstanceConfigs', + full_name='google.spanner.admin.instance.v1.InstanceAdmin.ListInstanceConfigs', + index=0, + containing_service=None, + input_type=_LISTINSTANCECONFIGSREQUEST, + output_type=_LISTINSTANCECONFIGSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002)\022\'/v1/{parent=projects/*}/instanceConfigs')), + ), + _descriptor.MethodDescriptor( + name='GetInstanceConfig', + full_name='google.spanner.admin.instance.v1.InstanceAdmin.GetInstanceConfig', + index=1, + containing_service=None, + input_type=_GETINSTANCECONFIGREQUEST, + output_type=_INSTANCECONFIG, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002)\022\'/v1/{name=projects/*/instanceConfigs/*}')), + ), + _descriptor.MethodDescriptor( + name='ListInstances', + full_name='google.spanner.admin.instance.v1.InstanceAdmin.ListInstances', + index=2, + containing_service=None, + input_type=_LISTINSTANCESREQUEST, + output_type=_LISTINSTANCESRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002#\022!/v1/{parent=projects/*}/instances')), + ), + _descriptor.MethodDescriptor( + name='GetInstance', + full_name='google.spanner.admin.instance.v1.InstanceAdmin.GetInstance', + index=3, + containing_service=None, + input_type=_GETINSTANCEREQUEST, + output_type=_INSTANCE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002#\022!/v1/{name=projects/*/instances/*}')), + ), + _descriptor.MethodDescriptor( + name='CreateInstance', + full_name='google.spanner.admin.instance.v1.InstanceAdmin.CreateInstance', + index=4, + containing_service=None, + input_type=_CREATEINSTANCEREQUEST, + output_type=google_dot_longrunning_dot_operations__pb2._OPERATION, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002&\"!/v1/{parent=projects/*}/instances:\001*')), + ), + _descriptor.MethodDescriptor( + name='UpdateInstance', + full_name='google.spanner.admin.instance.v1.InstanceAdmin.UpdateInstance', + index=5, + containing_service=None, + input_type=_UPDATEINSTANCEREQUEST, + output_type=google_dot_longrunning_dot_operations__pb2._OPERATION, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002/2*/v1/{instance.name=projects/*/instances/*}:\001*')), + ), + _descriptor.MethodDescriptor( + name='DeleteInstance', + full_name='google.spanner.admin.instance.v1.InstanceAdmin.DeleteInstance', + index=6, + containing_service=None, + input_type=_DELETEINSTANCEREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002#*!/v1/{name=projects/*/instances/*}')), + ), + _descriptor.MethodDescriptor( + name='SetIamPolicy', + full_name='google.spanner.admin.instance.v1.InstanceAdmin.SetIamPolicy', + index=7, + containing_service=None, + input_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._SETIAMPOLICYREQUEST, + output_type=google_dot_iam_dot_v1_dot_policy__pb2._POLICY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0027\"2/v1/{resource=projects/*/instances/*}:setIamPolicy:\001*')), + ), + _descriptor.MethodDescriptor( + name='GetIamPolicy', + full_name='google.spanner.admin.instance.v1.InstanceAdmin.GetIamPolicy', + index=8, + containing_service=None, + input_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._GETIAMPOLICYREQUEST, + output_type=google_dot_iam_dot_v1_dot_policy__pb2._POLICY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\0027\"2/v1/{resource=projects/*/instances/*}:getIamPolicy:\001*')), + ), + _descriptor.MethodDescriptor( + name='TestIamPermissions', + full_name='google.spanner.admin.instance.v1.InstanceAdmin.TestIamPermissions', + index=9, + containing_service=None, + input_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._TESTIAMPERMISSIONSREQUEST, + output_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._TESTIAMPERMISSIONSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002=\"8/v1/{resource=projects/*/instances/*}:testIamPermissions:\001*')), + ), +]) +_sym_db.RegisterServiceDescriptor(_INSTANCEADMIN) + +DESCRIPTOR.services_by_name['InstanceAdmin'] = _INSTANCEADMIN - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This function was - generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" - request_serializers = { - ('google.spanner.admin.instance.v1.InstanceAdmin', 'CreateInstance'): CreateInstanceRequest.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'DeleteInstance'): DeleteInstanceRequest.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetIamPolicy'): google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetInstance'): GetInstanceRequest.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetInstanceConfig'): GetInstanceConfigRequest.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'ListInstanceConfigs'): ListInstanceConfigsRequest.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'ListInstances'): ListInstancesRequest.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'SetIamPolicy'): google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'TestIamPermissions'): google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.SerializeToString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'UpdateInstance'): UpdateInstanceRequest.SerializeToString, - } - response_deserializers = { - ('google.spanner.admin.instance.v1.InstanceAdmin', 'CreateInstance'): google_dot_longrunning_dot_operations__pb2.Operation.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'DeleteInstance'): google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetIamPolicy'): google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetInstance'): Instance.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'GetInstanceConfig'): InstanceConfig.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'ListInstanceConfigs'): ListInstanceConfigsResponse.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'ListInstances'): ListInstancesResponse.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'SetIamPolicy'): google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'TestIamPermissions'): google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.FromString, - ('google.spanner.admin.instance.v1.InstanceAdmin', 'UpdateInstance'): google_dot_longrunning_dot_operations__pb2.Operation.FromString, - } - cardinalities = { - 'CreateInstance': cardinality.Cardinality.UNARY_UNARY, - 'DeleteInstance': cardinality.Cardinality.UNARY_UNARY, - 'GetIamPolicy': cardinality.Cardinality.UNARY_UNARY, - 'GetInstance': cardinality.Cardinality.UNARY_UNARY, - 'GetInstanceConfig': cardinality.Cardinality.UNARY_UNARY, - 'ListInstanceConfigs': cardinality.Cardinality.UNARY_UNARY, - 'ListInstances': cardinality.Cardinality.UNARY_UNARY, - 'SetIamPolicy': cardinality.Cardinality.UNARY_UNARY, - 'TestIamPermissions': cardinality.Cardinality.UNARY_UNARY, - 'UpdateInstance': cardinality.Cardinality.UNARY_UNARY, - } - stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size) - return beta_implementations.dynamic_stub(channel, 'google.spanner.admin.instance.v1.InstanceAdmin', cardinalities, options=stub_options) -except ImportError: - pass # @@protoc_insertion_point(module_scope) diff --git a/spanner/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2_grpc.py b/spanner/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2_grpc.py index 5c98eb40642a..368e0abcf017 100644 --- a/spanner/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2_grpc.py +++ b/spanner/google/cloud/spanner_admin_instance_v1/proto/spanner_instance_admin_pb2_grpc.py @@ -1,11 +1,11 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! import grpc -import google.cloud.spanner.admin.instance_v1.proto.spanner_instance_admin_pb2 as google_dot_cloud_dot_spanner_dot_admin_dot_instance__v1_dot_proto_dot_spanner__instance__admin__pb2 -import google.iam.v1.iam_policy_pb2 as google_dot_iam_dot_v1_dot_iam__policy__pb2 -import google.iam.v1.policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2 -import google.longrunning.operations_pb2 as google_dot_longrunning_dot_operations__pb2 -import google.protobuf.empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.cloud.spanner_admin_instance_v1.proto import spanner_instance_admin_pb2 as google_dot_cloud_dot_spanner_dot_admin_dot_instance__v1_dot_proto_dot_spanner__instance__admin__pb2 +from google.iam.v1 import iam_policy_pb2 as google_dot_iam_dot_v1_dot_iam__policy__pb2 +from google.iam.v1 import policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2 +from google.longrunning import operations_pb2 as google_dot_longrunning_dot_operations__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 class InstanceAdminStub(object): diff --git a/spanner/google/cloud/spanner_admin_instance_v1/types.py b/spanner/google/cloud/spanner_admin_instance_v1/types.py index 8725bcba6369..fdc6c5495595 100644 --- a/spanner/google/cloud/spanner_admin_instance_v1/types.py +++ b/spanner/google/cloud/spanner_admin_instance_v1/types.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spanner/google/cloud/spanner_v1/gapic/enums.py b/spanner/google/cloud/spanner_v1/gapic/enums.py index 614df4e9b226..3a7d0b7b58a1 100644 --- a/spanner/google/cloud/spanner_v1/gapic/enums.py +++ b/spanner/google/cloud/spanner_v1/gapic/enums.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 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,8 +15,10 @@ # limitations under the License. """Wrappers for protocol buffer enum types.""" +import enum + -class NullValue(object): +class NullValue(enum.IntEnum): """ ``NullValue`` is a singleton enumeration to represent the null value for the ``Value`` type union. @@ -27,7 +31,7 @@ class NullValue(object): NULL_VALUE = 0 -class TypeCode(object): +class TypeCode(enum.IntEnum): """ ``TypeCode`` is used as part of ``Type`` to indicate the type of a Cloud Spanner value. @@ -45,6 +49,12 @@ class TypeCode(object): ``\"-Infinity\"``. TIMESTAMP (int): Encoded as ``string`` in RFC 3339 timestamp format. The time zone must be present, and must be ``\"Z\"``. + + If the schema has the column option + ``allow_commit_timestamp=true``, the placeholder string + ``\"spanner.commit_timestamp()\"`` can be used to instruct the system + to insert the commit timestamp associated with the transaction + commit. DATE (int): Encoded as ``string`` in RFC 3339 date format. STRING (int): Encoded as ``string``. BYTES (int): Encoded as a base64-encoded ``string``, as described in RFC 4648, @@ -67,7 +77,7 @@ class TypeCode(object): class PlanNode(object): - class Kind(object): + class Kind(enum.IntEnum): """ The kind of ``PlanNode``. Distinguishes between the two different kinds of nodes that can appear in a query plan. @@ -88,17 +98,16 @@ class Kind(object): class ExecuteSqlRequest(object): - class QueryMode(object): + class QueryMode(enum.IntEnum): """ - Mode in which the query must be processed. + Mode in which the statement must be processed. Attributes: - NORMAL (int): The default mode where only the query result, without any information - about the query plan is returned. - PLAN (int): This mode returns only the query plan, without any result rows or + NORMAL (int): The default mode. Only the statement results are returned. + PLAN (int): This mode returns only the query plan, without any results or execution statistics information. PROFILE (int): This mode returns both the query plan and the execution statistics along - with the result rows. + with the results. """ NORMAL = 0 PLAN = 1 diff --git a/spanner/google/cloud/spanner_v1/gapic/spanner_client.py b/spanner/google/cloud/spanner_v1/gapic/spanner_client.py index cc4734d2b209..be7dc587d7be 100644 --- a/spanner/google/cloud/spanner_v1/gapic/spanner_client.py +++ b/spanner/google/cloud/spanner_v1/gapic/spanner_client.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,7 +17,9 @@ import functools import pkg_resources +import warnings +from google.oauth2 import service_account import google.api_core.gapic_v1.client_info import google.api_core.gapic_v1.config import google.api_core.gapic_v1.method @@ -23,24 +27,22 @@ import google.api_core.page_iterator import google.api_core.path_template import google.api_core.protobuf_helpers +import grpc from google.cloud.spanner_v1.gapic import enums from google.cloud.spanner_v1.gapic import spanner_client_config +from google.cloud.spanner_v1.gapic.transports import spanner_grpc_transport from google.cloud.spanner_v1.proto import keys_pb2 from google.cloud.spanner_v1.proto import mutation_pb2 +from google.cloud.spanner_v1.proto import result_set_pb2 from google.cloud.spanner_v1.proto import spanner_pb2 +from google.cloud.spanner_v1.proto import spanner_pb2_grpc from google.cloud.spanner_v1.proto import transaction_pb2 +from google.protobuf import empty_pb2 from google.protobuf import struct_pb2 -try: - import grpc_gcp - HAS_GRPC_GCP = True -except ImportError: - HAS_GRPC_GCP = False - _GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( 'google-cloud-spanner', ).version -_SPANNER_GRPC_CONFIG = 'spanner.grpc.config' class SpannerClient(object): @@ -54,18 +56,31 @@ class SpannerClient(object): SERVICE_ADDRESS = 'spanner.googleapis.com:443' """The default address of the service.""" - # The scopes needed to make gRPC calls to all of the methods defined in - # this service - _DEFAULT_SCOPES = ( - 'https://www.googleapis.com/auth/cloud-platform', - 'https://www.googleapis.com/auth/spanner.admin', - 'https://www.googleapis.com/auth/spanner.data', - ) - - # The name of the interface for this client. This is the key used to find - # method configuration in the client_config dictionary. + # The name of the interface for this client. This is the key used to + # find the method configuration in the client_config dictionary. _INTERFACE_NAME = 'google.spanner.v1.Spanner' + @classmethod + def from_service_account_file(cls, filename, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + SpannerClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file( + filename) + kwargs['credentials'] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + @classmethod def database_path(cls, project, instance, database): """Return a fully-qualified database string.""" @@ -88,6 +103,7 @@ def session_path(cls, project, instance, database, session): ) def __init__(self, + transport=None, channel=None, credentials=None, client_config=spanner_client_config.config, @@ -95,144 +111,82 @@ def __init__(self, """Constructor. Args: - channel (grpc.Channel): A ``Channel`` instance through - which to make calls. This argument is mutually exclusive + transport (Union[~.SpannerGrpcTransport, + Callable[[~.Credentials, type], ~.SpannerGrpcTransport]): A transport + instance, responsible for actually making the API calls. + The default transport uses the gRPC protocol. + This argument may also be a callable which returns a + transport instance. Callables will be sent the credentials + as the first argument and the default transport class as + the second argument. + channel (grpc.Channel): DEPRECATED. A ``Channel`` instance + through which to make calls. This argument is mutually exclusive with ``credentials``; providing both will raise an exception. credentials (google.auth.credentials.Credentials): The authorization credentials to attach to requests. These credentials identify this application to the service. If none are specified, the client will attempt to ascertain the credentials from the environment. - client_config (dict): A dictionary of call options for each - method. If not specified, the default configuration is used. + This argument is mutually exclusive with providing a + transport instance to ``transport``; doing so will raise + an exception. + client_config (dict): DEPRECATED. A dictionary of call options for + each method. If not specified, the default configuration is used. client_info (google.api_core.gapic_v1.client_info.ClientInfo): The client info used to send a user-agent string along with API requests. If ``None``, then default info will be used. Generally, you only need to set this if you're developing your own client library. """ - # If both `channel` and `credentials` are specified, raise an - # exception (channels come with credentials baked in already). - if channel is not None and credentials is not None: - raise ValueError( - 'The `channel` and `credentials` arguments to {} are mutually ' - 'exclusive.'.format(self.__class__.__name__), ) - - # Create the channel. - if channel is None: - options = None - - if HAS_GRPC_GCP: - # Initialize grpc gcp config for spanner api. - grpc_gcp_config = grpc_gcp.api_config_from_text_pb( - pkg_resources.resource_string(__name__, - _SPANNER_GRPC_CONFIG)) - options = [(grpc_gcp.API_CONFIG_CHANNEL_ARG, grpc_gcp_config)] - - channel = google.api_core.grpc_helpers.create_channel( - self.SERVICE_ADDRESS, + # Raise deprecation warnings for things we want to go away. + if client_config: + warnings.warn('The `client_config` argument is deprecated.', + PendingDeprecationWarning) + if channel: + warnings.warn( + 'The `channel` argument is deprecated; use ' + '`transport` instead.', PendingDeprecationWarning) + + # Instantiate the transport. + # The transport is responsible for handling serialization and + # deserialization and actually sending data to the service. + if transport: + if callable(transport): + self.transport = transport( + credentials=credentials, + default_class=spanner_grpc_transport.SpannerGrpcTransport, + ) + else: + if credentials: + raise ValueError( + 'Received both a transport instance and ' + 'credentials; these are mutually exclusive.') + self.transport = transport + else: + self.transport = spanner_grpc_transport.SpannerGrpcTransport( + address=self.SERVICE_ADDRESS, + channel=channel, credentials=credentials, - scopes=self._DEFAULT_SCOPES, - options=options, ) - # Create the gRPC stubs. - self.spanner_stub = (spanner_pb2.SpannerStub(channel)) - if client_info is None: client_info = ( google.api_core.gapic_v1.client_info.DEFAULT_CLIENT_INFO) client_info.gapic_version = _GAPIC_LIBRARY_VERSION + self._client_info = client_info # Parse out the default settings for retry and timeout for each RPC # from the client configuration. # (Ordinarily, these are the defaults specified in the `*_config.py` # file next to this one.) - method_configs = google.api_core.gapic_v1.config.parse_method_configs( + self._method_configs = google.api_core.gapic_v1.config.parse_method_configs( client_config['interfaces'][self._INTERFACE_NAME], ) - # Write the "inner API call" methods to the class. - # These are wrapped versions of the gRPC stub methods, with retry and - # timeout configuration applied, called by the public methods on - # this class. - self._create_session = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.CreateSession, - default_retry=method_configs['CreateSession'].retry, - default_timeout=method_configs['CreateSession'].timeout, - client_info=client_info, - ) - self._get_session = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.GetSession, - default_retry=method_configs['GetSession'].retry, - default_timeout=method_configs['GetSession'].timeout, - client_info=client_info, - ) - self._list_sessions = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.ListSessions, - default_retry=method_configs['ListSessions'].retry, - default_timeout=method_configs['ListSessions'].timeout, - client_info=client_info, - ) - self._delete_session = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.DeleteSession, - default_retry=method_configs['DeleteSession'].retry, - default_timeout=method_configs['DeleteSession'].timeout, - client_info=client_info, - ) - self._execute_sql = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.ExecuteSql, - default_retry=method_configs['ExecuteSql'].retry, - default_timeout=method_configs['ExecuteSql'].timeout, - client_info=client_info, - ) - self._execute_streaming_sql = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.ExecuteStreamingSql, - default_retry=method_configs['ExecuteStreamingSql'].retry, - default_timeout=method_configs['ExecuteStreamingSql'].timeout, - client_info=client_info, - ) - self._read = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.Read, - default_retry=method_configs['Read'].retry, - default_timeout=method_configs['Read'].timeout, - client_info=client_info, - ) - self._streaming_read = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.StreamingRead, - default_retry=method_configs['StreamingRead'].retry, - default_timeout=method_configs['StreamingRead'].timeout, - client_info=client_info, - ) - self._begin_transaction = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.BeginTransaction, - default_retry=method_configs['BeginTransaction'].retry, - default_timeout=method_configs['BeginTransaction'].timeout, - client_info=client_info, - ) - self._commit = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.Commit, - default_retry=method_configs['Commit'].retry, - default_timeout=method_configs['Commit'].timeout, - client_info=client_info, - ) - self._rollback = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.Rollback, - default_retry=method_configs['Rollback'].retry, - default_timeout=method_configs['Rollback'].timeout, - client_info=client_info, - ) - self._partition_query = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.PartitionQuery, - default_retry=method_configs['PartitionQuery'].retry, - default_timeout=method_configs['PartitionQuery'].timeout, - client_info=client_info, - ) - self._partition_read = google.api_core.gapic_v1.method.wrap_method( - self.spanner_stub.PartitionRead, - default_retry=method_configs['PartitionRead'].retry, - default_timeout=method_configs['PartitionRead'].timeout, - client_info=client_info, - ) + # Save a dictionary of cached API call functions. + # These are the actual callables which invoke the proper + # transport methods, wrapped with `wrap_method` to add retry, + # timeout, and the like. + self._inner_api_calls = {} # Service calls def create_session(self, @@ -282,6 +236,8 @@ def create_session(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_v1.types.Session` instance. @@ -293,11 +249,22 @@ def create_session(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'create_session' not in self._inner_api_calls: + self._inner_api_calls[ + 'create_session'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.create_session, + default_retry=self._method_configs['CreateSession'].retry, + default_timeout=self._method_configs['CreateSession']. + timeout, + client_info=self._client_info, + ) + request = spanner_pb2.CreateSessionRequest( database=database, session=session, ) - return self._create_session( + return self._inner_api_calls['create_session']( request, retry=retry, timeout=timeout, metadata=metadata) def get_session(self, @@ -327,6 +294,8 @@ def get_session(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_v1.types.Session` instance. @@ -338,8 +307,18 @@ def get_session(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'get_session' not in self._inner_api_calls: + self._inner_api_calls[ + 'get_session'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_session, + default_retry=self._method_configs['GetSession'].retry, + default_timeout=self._method_configs['GetSession'].timeout, + client_info=self._client_info, + ) + request = spanner_pb2.GetSessionRequest(name=name, ) - return self._get_session( + return self._inner_api_calls['get_session']( request, retry=retry, timeout=timeout, metadata=metadata) def list_sessions(self, @@ -359,13 +338,15 @@ def list_sessions(self, >>> >>> database = client.database_path('[PROJECT]', '[INSTANCE]', '[DATABASE]') >>> - >>> >>> # Iterate over all results >>> for element in client.list_sessions(database): ... # process element ... pass >>> - >>> # Or iterate over results one page at a time + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time >>> for page in client.list_sessions(database, options=CallOptions(page_token=INITIAL_PAGE)): ... for element in page: ... # process element @@ -396,6 +377,8 @@ def list_sessions(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.gax.PageIterator` instance. By default, this @@ -410,6 +393,17 @@ def list_sessions(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'list_sessions' not in self._inner_api_calls: + self._inner_api_calls[ + 'list_sessions'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_sessions, + default_retry=self._method_configs['ListSessions'].retry, + default_timeout=self._method_configs['ListSessions']. + timeout, + client_info=self._client_info, + ) + request = spanner_pb2.ListSessionsRequest( database=database, page_size=page_size, @@ -418,9 +412,10 @@ def list_sessions(self, iterator = google.api_core.page_iterator.GRPCIterator( client=None, method=functools.partial( - self._list_sessions, - retry=retry, timeout=timeout, metadata=metadata, - ), + self._inner_api_calls['list_sessions'], + retry=retry, + timeout=timeout, + metadata=metadata), request=request, items_field='sessions', request_token_field='page_token', @@ -453,6 +448,8 @@ def delete_session(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Raises: google.api_core.exceptions.GoogleAPICallError: If the request @@ -461,8 +458,19 @@ def delete_session(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'delete_session' not in self._inner_api_calls: + self._inner_api_calls[ + 'delete_session'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.delete_session, + default_retry=self._method_configs['DeleteSession'].retry, + default_timeout=self._method_configs['DeleteSession']. + timeout, + client_info=self._client_info, + ) + request = spanner_pb2.DeleteSessionRequest(name=name, ) - self._delete_session( + self._inner_api_calls['delete_session']( request, retry=retry, timeout=timeout, metadata=metadata) def execute_sql(self, @@ -474,16 +482,17 @@ def execute_sql(self, resume_token=None, query_mode=None, partition_token=None, + seqno=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): """ - Executes an SQL query, returning all rows in a single reply. This + Executes an SQL statement, returning all results in a single reply. This method cannot be used to return a result set larger than 10 MiB; if the query yields more data than that, the query fails with a ``FAILED_PRECONDITION`` error. - Queries inside read-write transactions might return ``ABORTED``. If + Operations inside read-write transactions might return ``ABORTED``. If this occurs, the application should restart the transaction from the beginning. See ``Transaction`` for more details. @@ -496,18 +505,31 @@ def execute_sql(self, >>> client = spanner_v1.SpannerClient() >>> >>> session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') + >>> + >>> # TODO: Initialize ``sql``: >>> sql = '' >>> >>> response = client.execute_sql(session, sql) Args: session (str): Required. The session in which the SQL query should be performed. - sql (str): Required. The SQL query string. + sql (str): Required. The SQL string. transaction (Union[dict, ~google.cloud.spanner_v1.types.TransactionSelector]): The transaction to use. If none is provided, the default is a temporary read-only transaction with strong concurrency. + + The transaction to use. + + For queries, if none is provided, the default is a temporary read-only + transaction with strong concurrency. + + Standard DML statements require a ReadWrite transaction. Single-use + transactions are not supported (to avoid replay). The caller must + either supply an existing transaction ID or begin a new transaction. + + Partitioned DML requires an existing PartitionedDml transaction ID. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.spanner_v1.types.TransactionSelector` - params (Union[dict, ~google.cloud.spanner_v1.types.Struct]): The SQL query string can contain parameter placeholders. A parameter + params (Union[dict, ~google.cloud.spanner_v1.types.Struct]): The SQL string can contain parameter placeholders. A parameter placeholder consists of ``'@'`` followed by the parameter name. Parameter names consist of any combination of letters, numbers, and underscores. @@ -516,7 +538,7 @@ def execute_sql(self, parameter name can be used more than once, for example: ``\"WHERE id > @msg_id AND id < @msg_id + 100\"`` - It is an error to execute an SQL query with unbound parameters. + It is an error to execute an SQL statement with unbound parameters. Parameter values are specified using ``params``, which is a JSON object whose keys are parameter names, and whose values are the @@ -528,29 +550,42 @@ def execute_sql(self, of type ``STRING`` both appear in ``params`` as JSON strings. In these cases, ``param_types`` can be used to specify the exact - SQL type for some or all of the SQL query parameters. See the + SQL type for some or all of the SQL statement parameters. See the definition of ``Type`` for more information about SQL types. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.spanner_v1.types.Type` - resume_token (bytes): If this request is resuming a previously interrupted SQL query + resume_token (bytes): If this request is resuming a previously interrupted SQL statement execution, ``resume_token`` should be copied from the last ``PartialResultSet`` yielded before the interruption. Doing this - enables the new SQL query execution to resume where the last one left + enables the new SQL statement execution to resume where the last one left off. The rest of the request parameters must exactly match the request that yielded this token. query_mode (~google.cloud.spanner_v1.types.QueryMode): Used to control the amount of debugging information returned in - ``ResultSetStats``. + ``ResultSetStats``. If ``partition_token`` is set, ``query_mode`` can only + be set to ``QueryMode.NORMAL``. partition_token (bytes): If present, results will be restricted to the specified partition previously created using PartitionQuery(). There must be an exact match for the values of fields common to this message and the PartitionQueryRequest message used to create this partition_token. + seqno (long): A per-transaction sequence number used to identify this request. This + makes each request idempotent such that if the request is received multiple + times, at most one will succeed. + + The sequence number must be monotonically increasing within the + transaction. If a request arrives for the first time with an out-of-order + sequence number, the transaction may be aborted. Replays of previously + handled requests will yield the same response as the first execution. + + Required for DML statements. Ignored for queries. retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will not be retried. timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_v1.types.ResultSet` instance. @@ -562,6 +597,16 @@ def execute_sql(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'execute_sql' not in self._inner_api_calls: + self._inner_api_calls[ + 'execute_sql'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.execute_sql, + default_retry=self._method_configs['ExecuteSql'].retry, + default_timeout=self._method_configs['ExecuteSql'].timeout, + client_info=self._client_info, + ) + request = spanner_pb2.ExecuteSqlRequest( session=session, sql=sql, @@ -571,8 +616,9 @@ def execute_sql(self, resume_token=resume_token, query_mode=query_mode, partition_token=partition_token, + seqno=seqno, ) - return self._execute_sql( + return self._inner_api_calls['execute_sql']( request, retry=retry, timeout=timeout, metadata=metadata) def execute_streaming_sql(self, @@ -584,6 +630,7 @@ def execute_streaming_sql(self, resume_token=None, query_mode=None, partition_token=None, + seqno=None, retry=google.api_core.gapic_v1.method.DEFAULT, timeout=google.api_core.gapic_v1.method.DEFAULT, metadata=None): @@ -600,6 +647,8 @@ def execute_streaming_sql(self, >>> client = spanner_v1.SpannerClient() >>> >>> session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') + >>> + >>> # TODO: Initialize ``sql``: >>> sql = '' >>> >>> for element in client.execute_streaming_sql(session, sql): @@ -608,12 +657,23 @@ def execute_streaming_sql(self, Args: session (str): Required. The session in which the SQL query should be performed. - sql (str): Required. The SQL query string. + sql (str): Required. The SQL string. transaction (Union[dict, ~google.cloud.spanner_v1.types.TransactionSelector]): The transaction to use. If none is provided, the default is a temporary read-only transaction with strong concurrency. + + The transaction to use. + + For queries, if none is provided, the default is a temporary read-only + transaction with strong concurrency. + + Standard DML statements require a ReadWrite transaction. Single-use + transactions are not supported (to avoid replay). The caller must + either supply an existing transaction ID or begin a new transaction. + + Partitioned DML requires an existing PartitionedDml transaction ID. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.spanner_v1.types.TransactionSelector` - params (Union[dict, ~google.cloud.spanner_v1.types.Struct]): The SQL query string can contain parameter placeholders. A parameter + params (Union[dict, ~google.cloud.spanner_v1.types.Struct]): The SQL string can contain parameter placeholders. A parameter placeholder consists of ``'@'`` followed by the parameter name. Parameter names consist of any combination of letters, numbers, and underscores. @@ -622,7 +682,7 @@ def execute_streaming_sql(self, parameter name can be used more than once, for example: ``\"WHERE id > @msg_id AND id < @msg_id + 100\"`` - It is an error to execute an SQL query with unbound parameters. + It is an error to execute an SQL statement with unbound parameters. Parameter values are specified using ``params``, which is a JSON object whose keys are parameter names, and whose values are the @@ -634,29 +694,42 @@ def execute_streaming_sql(self, of type ``STRING`` both appear in ``params`` as JSON strings. In these cases, ``param_types`` can be used to specify the exact - SQL type for some or all of the SQL query parameters. See the + SQL type for some or all of the SQL statement parameters. See the definition of ``Type`` for more information about SQL types. If a dict is provided, it must be of the same form as the protobuf message :class:`~google.cloud.spanner_v1.types.Type` - resume_token (bytes): If this request is resuming a previously interrupted SQL query + resume_token (bytes): If this request is resuming a previously interrupted SQL statement execution, ``resume_token`` should be copied from the last ``PartialResultSet`` yielded before the interruption. Doing this - enables the new SQL query execution to resume where the last one left + enables the new SQL statement execution to resume where the last one left off. The rest of the request parameters must exactly match the request that yielded this token. query_mode (~google.cloud.spanner_v1.types.QueryMode): Used to control the amount of debugging information returned in - ``ResultSetStats``. + ``ResultSetStats``. If ``partition_token`` is set, ``query_mode`` can only + be set to ``QueryMode.NORMAL``. partition_token (bytes): If present, results will be restricted to the specified partition previously created using PartitionQuery(). There must be an exact match for the values of fields common to this message and the PartitionQueryRequest message used to create this partition_token. + seqno (long): A per-transaction sequence number used to identify this request. This + makes each request idempotent such that if the request is received multiple + times, at most one will succeed. + + The sequence number must be monotonically increasing within the + transaction. If a request arrives for the first time with an out-of-order + sequence number, the transaction may be aborted. Replays of previously + handled requests will yield the same response as the first execution. + + Required for DML statements. Ignored for queries. retry (Optional[google.api_core.retry.Retry]): A retry object used to retry requests. If ``None`` is specified, requests will not be retried. timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: Iterable[~google.cloud.spanner_v1.types.PartialResultSet]. @@ -668,6 +741,18 @@ def execute_streaming_sql(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'execute_streaming_sql' not in self._inner_api_calls: + self._inner_api_calls[ + 'execute_streaming_sql'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.execute_streaming_sql, + default_retry=self._method_configs['ExecuteStreamingSql']. + retry, + default_timeout=self. + _method_configs['ExecuteStreamingSql'].timeout, + client_info=self._client_info, + ) + request = spanner_pb2.ExecuteSqlRequest( session=session, sql=sql, @@ -677,8 +762,9 @@ def execute_streaming_sql(self, resume_token=resume_token, query_mode=query_mode, partition_token=partition_token, + seqno=seqno, ) - return self._execute_streaming_sql( + return self._inner_api_calls['execute_streaming_sql']( request, retry=retry, timeout=timeout, metadata=metadata) def read(self, @@ -715,8 +801,14 @@ def read(self, >>> client = spanner_v1.SpannerClient() >>> >>> session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') + >>> + >>> # TODO: Initialize ``table``: >>> table = '' + >>> + >>> # TODO: Initialize ``columns``: >>> columns = [] + >>> + >>> # TODO: Initialize ``key_set``: >>> key_set = {} >>> >>> response = client.read(session, table, columns, key_set) @@ -766,6 +858,8 @@ def read(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_v1.types.ResultSet` instance. @@ -777,6 +871,16 @@ def read(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'read' not in self._inner_api_calls: + self._inner_api_calls[ + 'read'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.read, + default_retry=self._method_configs['Read'].retry, + default_timeout=self._method_configs['Read'].timeout, + client_info=self._client_info, + ) + request = spanner_pb2.ReadRequest( session=session, table=table, @@ -788,7 +892,7 @@ def read(self, resume_token=resume_token, partition_token=partition_token, ) - return self._read( + return self._inner_api_calls['read']( request, retry=retry, timeout=timeout, metadata=metadata) def streaming_read(self, @@ -817,8 +921,14 @@ def streaming_read(self, >>> client = spanner_v1.SpannerClient() >>> >>> session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') + >>> + >>> # TODO: Initialize ``table``: >>> table = '' + >>> + >>> # TODO: Initialize ``columns``: >>> columns = [] + >>> + >>> # TODO: Initialize ``key_set``: >>> key_set = {} >>> >>> for element in client.streaming_read(session, table, columns, key_set): @@ -870,6 +980,8 @@ def streaming_read(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: Iterable[~google.cloud.spanner_v1.types.PartialResultSet]. @@ -881,6 +993,17 @@ def streaming_read(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'streaming_read' not in self._inner_api_calls: + self._inner_api_calls[ + 'streaming_read'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.streaming_read, + default_retry=self._method_configs['StreamingRead'].retry, + default_timeout=self._method_configs['StreamingRead']. + timeout, + client_info=self._client_info, + ) + request = spanner_pb2.ReadRequest( session=session, table=table, @@ -892,7 +1015,7 @@ def streaming_read(self, resume_token=resume_token, partition_token=partition_token, ) - return self._streaming_read( + return self._inner_api_calls['streaming_read']( request, retry=retry, timeout=timeout, metadata=metadata) def begin_transaction(self, @@ -913,6 +1036,8 @@ def begin_transaction(self, >>> client = spanner_v1.SpannerClient() >>> >>> session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') + >>> + >>> # TODO: Initialize ``options_``: >>> options_ = {} >>> >>> response = client.begin_transaction(session, options_) @@ -928,6 +1053,8 @@ def begin_transaction(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_v1.types.Transaction` instance. @@ -939,11 +1066,23 @@ def begin_transaction(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'begin_transaction' not in self._inner_api_calls: + self._inner_api_calls[ + 'begin_transaction'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.begin_transaction, + default_retry=self._method_configs['BeginTransaction']. + retry, + default_timeout=self._method_configs['BeginTransaction']. + timeout, + client_info=self._client_info, + ) + request = spanner_pb2.BeginTransactionRequest( session=session, options=options_, ) - return self._begin_transaction( + return self._inner_api_calls['begin_transaction']( request, retry=retry, timeout=timeout, metadata=metadata) def commit(self, @@ -970,6 +1109,8 @@ def commit(self, >>> client = spanner_v1.SpannerClient() >>> >>> session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') + >>> + >>> # TODO: Initialize ``mutations``: >>> mutations = [] >>> >>> response = client.commit(session, mutations) @@ -999,6 +1140,8 @@ def commit(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_v1.types.CommitResponse` instance. @@ -1010,6 +1153,16 @@ def commit(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'commit' not in self._inner_api_calls: + self._inner_api_calls[ + 'commit'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.commit, + default_retry=self._method_configs['Commit'].retry, + default_timeout=self._method_configs['Commit'].timeout, + client_info=self._client_info, + ) + # Sanity check: We have some fields which are mutually exclusive; # raise ValueError if more than one is sent. google.api_core.protobuf_helpers.check_oneof( @@ -1023,7 +1176,7 @@ def commit(self, transaction_id=transaction_id, single_use_transaction=single_use_transaction, ) - return self._commit( + return self._inner_api_calls['commit']( request, retry=retry, timeout=timeout, metadata=metadata) def rollback(self, @@ -1048,6 +1201,8 @@ def rollback(self, >>> client = spanner_v1.SpannerClient() >>> >>> session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') + >>> + >>> # TODO: Initialize ``transaction_id``: >>> transaction_id = b'' >>> >>> client.rollback(session, transaction_id) @@ -1061,6 +1216,8 @@ def rollback(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Raises: google.api_core.exceptions.GoogleAPICallError: If the request @@ -1069,11 +1226,21 @@ def rollback(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'rollback' not in self._inner_api_calls: + self._inner_api_calls[ + 'rollback'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.rollback, + default_retry=self._method_configs['Rollback'].retry, + default_timeout=self._method_configs['Rollback'].timeout, + client_info=self._client_info, + ) + request = spanner_pb2.RollbackRequest( session=session, transaction_id=transaction_id, ) - self._rollback( + self._inner_api_calls['rollback']( request, retry=retry, timeout=timeout, metadata=metadata) def partition_query(self, @@ -1093,8 +1260,11 @@ def partition_query(self, of the query result to read. The same session and read-only transaction must be used by the PartitionQueryRequest used to create the partition tokens and the ExecuteSqlRequests that use the partition tokens. + Partition tokens become invalid when the session used to create them - is deleted or begins a new transaction. + is deleted, is idle for too long, begins a new transaction, or becomes too + old. When any of these happen, it is not possible to resume the query, and + the whole operation must be restarted from the beginning. Example: >>> from google.cloud import spanner_v1 @@ -1102,6 +1272,8 @@ def partition_query(self, >>> client = spanner_v1.SpannerClient() >>> >>> session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') + >>> + >>> # TODO: Initialize ``sql``: >>> sql = '' >>> >>> response = client.partition_query(session, sql) @@ -1114,6 +1286,10 @@ def partition_query(self, union operator conceptually divides one or more tables into multiple splits, remotely evaluates a subquery independently on each split, and then unions all results. + + This must not contain DML commands, such as INSERT, UPDATE, or + DELETE. Use ``ExecuteStreamingSql`` with a + PartitionedDml transaction for large, partition-friendly DML operations. transaction (Union[dict, ~google.cloud.spanner_v1.types.TransactionSelector]): Read only snapshot transactions are supported, read/write and single use transactions are not. If a dict is provided, it must be of the same form as the protobuf @@ -1153,6 +1329,8 @@ def partition_query(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_v1.types.PartitionResponse` instance. @@ -1164,6 +1342,17 @@ def partition_query(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'partition_query' not in self._inner_api_calls: + self._inner_api_calls[ + 'partition_query'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.partition_query, + default_retry=self._method_configs['PartitionQuery'].retry, + default_timeout=self._method_configs['PartitionQuery']. + timeout, + client_info=self._client_info, + ) + request = spanner_pb2.PartitionQueryRequest( session=session, sql=sql, @@ -1172,7 +1361,7 @@ def partition_query(self, param_types=param_types, partition_options=partition_options, ) - return self._partition_query( + return self._inner_api_calls['partition_query']( request, retry=retry, timeout=timeout, metadata=metadata) def partition_read(self, @@ -1192,9 +1381,14 @@ def partition_read(self, by ``StreamingRead`` to specify a subset of the read result to read. The same session and read-only transaction must be used by the PartitionReadRequest used to create the partition tokens and the - ReadRequests that use the partition tokens. + ReadRequests that use the partition tokens. There are no ordering + guarantees on rows returned among the returned partition tokens, or even + within each individual StreamingRead call issued with a partition_token. + Partition tokens become invalid when the session used to create them - is deleted or begins a new transaction. + is deleted, is idle for too long, begins a new transaction, or becomes too + old. When any of these happen, it is not possible to resume the read, and + the whole operation must be restarted from the beginning. Example: >>> from google.cloud import spanner_v1 @@ -1202,7 +1396,11 @@ def partition_read(self, >>> client = spanner_v1.SpannerClient() >>> >>> session = client.session_path('[PROJECT]', '[INSTANCE]', '[DATABASE]', '[SESSION]') + >>> + >>> # TODO: Initialize ``table``: >>> table = '' + >>> + >>> # TODO: Initialize ``key_set``: >>> key_set = {} >>> >>> response = client.partition_read(session, table, key_set) @@ -1237,6 +1435,8 @@ def partition_read(self, timeout (Optional[float]): The amount of time, in seconds, to wait for the request to complete. Note that if ``retry`` is specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. Returns: A :class:`~google.cloud.spanner_v1.types.PartitionResponse` instance. @@ -1248,6 +1448,17 @@ def partition_read(self, to a retryable error and retry attempts failed. ValueError: If the parameters are invalid. """ + # Wrap the transport method to add retry and timeout logic. + if 'partition_read' not in self._inner_api_calls: + self._inner_api_calls[ + 'partition_read'] = google.api_core.gapic_v1.method.wrap_method( + self.transport.partition_read, + default_retry=self._method_configs['PartitionRead'].retry, + default_timeout=self._method_configs['PartitionRead']. + timeout, + client_info=self._client_info, + ) + request = spanner_pb2.PartitionReadRequest( session=session, table=table, @@ -1257,5 +1468,5 @@ def partition_read(self, columns=columns, partition_options=partition_options, ) - return self._partition_read( + return self._inner_api_calls['partition_read']( request, retry=retry, timeout=timeout, metadata=metadata) diff --git a/spanner/google/cloud/spanner_v1/gapic/spanner_client_config.py b/spanner/google/cloud/spanner_v1/gapic/spanner_client_config.py index 87c78989e20a..722730296615 100644 --- a/spanner/google/cloud/spanner_v1/gapic/spanner_client_config.py +++ b/spanner/google/cloud/spanner_v1/gapic/spanner_client_config.py @@ -83,7 +83,7 @@ "retry_params_name": "default" }, "PartitionQuery": { - "timeout_millis": 3600000, + "timeout_millis": 30000, "retry_codes_name": "idempotent", "retry_params_name": "default" }, diff --git a/spanner/google/cloud/spanner_v1/gapic/transports/__init__.py b/spanner/google/cloud/spanner_v1/gapic/transports/__init__.py new file mode 100644 index 000000000000..e69de29bb2d1 diff --git a/spanner/google/cloud/spanner_v1/gapic/spanner.grpc.config b/spanner/google/cloud/spanner_v1/gapic/transports/spanner.grpc.config similarity index 100% rename from spanner/google/cloud/spanner_v1/gapic/spanner.grpc.config rename to spanner/google/cloud/spanner_v1/gapic/transports/spanner.grpc.config diff --git a/spanner/google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py b/spanner/google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py new file mode 100644 index 000000000000..b6d2fe623eff --- /dev/null +++ b/spanner/google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py @@ -0,0 +1,362 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import pkg_resources +import grpc_gcp + +import google.api_core.grpc_helpers + +from google.cloud.spanner_v1.proto import spanner_pb2_grpc + + +_SPANNER_GRPC_CONFIG = 'spanner.grpc.config' + + +class SpannerGrpcTransport(object): + """gRPC transport class providing stubs for + google.spanner.v1 Spanner API. + + The transport provides access to the raw gRPC stubs, + which can be used to take advantage of advanced + features of gRPC. + """ + # The scopes needed to make gRPC calls to all of the methods defined + # in this service. + _OAUTH_SCOPES = ( + 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/spanner.data', + ) + + def __init__(self, + channel=None, + credentials=None, + address='spanner.googleapis.com:443'): + """Instantiate the transport class. + + Args: + channel (grpc.Channel): A ``Channel`` instance through + which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + address (str): The address where the service is hosted. + """ + # If both `channel` and `credentials` are specified, raise an + # exception (channels come with credentials baked in already). + if channel is not None and credentials is not None: + raise ValueError( + 'The `channel` and `credentials` arguments are mutually ' + 'exclusive.', ) + + # Create the channel. + if channel is None: + channel = self.create_channel( + address=address, + credentials=credentials, + ) + + # gRPC uses objects called "stubs" that are bound to the + # channel and provide a basic method for each RPC. + self._stubs = { + 'spanner_stub': spanner_pb2_grpc.SpannerStub(channel), + } + + @classmethod + def create_channel(cls, + address='spanner.googleapis.com:443', + credentials=None): + """Create and return a gRPC channel object. + + Args: + address (str): The host for the channel to use. + credentials (~.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + + Returns: + grpc.Channel: A gRPC channel object. + """ + grpc_gcp_config = grpc_gcp.api_config_from_text_pb( + pkg_resources.resource_string(__name__, _SPANNER_GRPC_CONFIG)) + options = [(grpc_gcp.API_CONFIG_CHANNEL_ARG, grpc_gcp_config)] + return google.api_core.grpc_helpers.create_channel( + address, + credentials=credentials, + scopes=cls._OAUTH_SCOPES, + ) + + @property + def create_session(self): + """Return the gRPC stub for {$apiMethod.name}. + + Creates a new session. A session can be used to perform + transactions that read and/or modify data in a Cloud Spanner database. + Sessions are meant to be reused for many consecutive + transactions. + + Sessions can only execute one transaction at a time. To execute + multiple concurrent read-write/write-only transactions, create + multiple sessions. Note that standalone reads and queries use a + transaction internally, and count toward the one transaction + limit. + + Cloud Spanner limits the number of sessions that can exist at any given + time; thus, it is a good idea to delete idle and/or unneeded sessions. + Aside from explicit deletes, Cloud Spanner can delete sessions for which no + operations are sent for more than an hour. If a session is deleted, + requests to it return ``NOT_FOUND``. + + Idle sessions can be kept alive by sending a trivial SQL query + periodically, e.g., ``\"SELECT 1\"``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].CreateSession + + @property + def get_session(self): + """Return the gRPC stub for {$apiMethod.name}. + + Gets a session. Returns ``NOT_FOUND`` if the session does not exist. + This is mainly useful for determining whether a session is still + alive. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].GetSession + + @property + def list_sessions(self): + """Return the gRPC stub for {$apiMethod.name}. + + Lists all sessions in a given database. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].ListSessions + + @property + def delete_session(self): + """Return the gRPC stub for {$apiMethod.name}. + + Ends a session, releasing server resources associated with it. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].DeleteSession + + @property + def execute_sql(self): + """Return the gRPC stub for {$apiMethod.name}. + + Executes an SQL statement, returning all results in a single reply. This + method cannot be used to return a result set larger than 10 MiB; + if the query yields more data than that, the query fails with + a ``FAILED_PRECONDITION`` error. + + Operations inside read-write transactions might return ``ABORTED``. If + this occurs, the application should restart the transaction from + the beginning. See ``Transaction`` for more details. + + Larger result sets can be fetched in streaming fashion by calling + ``ExecuteStreamingSql`` instead. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].ExecuteSql + + @property + def execute_streaming_sql(self): + """Return the gRPC stub for {$apiMethod.name}. + + Like ``ExecuteSql``, except returns the result + set as a stream. Unlike ``ExecuteSql``, there + is no limit on the size of the returned result set. However, no + individual row in the result set can exceed 100 MiB, and no + column value can exceed 10 MiB. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].ExecuteStreamingSql + + @property + def read(self): + """Return the gRPC stub for {$apiMethod.name}. + + Reads rows from the database using key lookups and scans, as a + simple key/value style alternative to + ``ExecuteSql``. This method cannot be used to + return a result set larger than 10 MiB; if the read matches more + data than that, the read fails with a ``FAILED_PRECONDITION`` + error. + + Reads inside read-write transactions might return ``ABORTED``. If + this occurs, the application should restart the transaction from + the beginning. See ``Transaction`` for more details. + + Larger result sets can be yielded in streaming fashion by calling + ``StreamingRead`` instead. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].Read + + @property + def streaming_read(self): + """Return the gRPC stub for {$apiMethod.name}. + + Like ``Read``, except returns the result set as a + stream. Unlike ``Read``, there is no limit on the + size of the returned result set. However, no individual row in + the result set can exceed 100 MiB, and no column value can exceed + 10 MiB. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].StreamingRead + + @property + def begin_transaction(self): + """Return the gRPC stub for {$apiMethod.name}. + + Begins a new transaction. This step can often be skipped: + ``Read``, ``ExecuteSql`` and + ``Commit`` can begin a new transaction as a + side-effect. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].BeginTransaction + + @property + def commit(self): + """Return the gRPC stub for {$apiMethod.name}. + + Commits a transaction. The request includes the mutations to be + applied to rows in the database. + + ``Commit`` might return an ``ABORTED`` error. This can occur at any time; + commonly, the cause is conflicts with concurrent + transactions. However, it can also happen for a variety of other + reasons. If ``Commit`` returns ``ABORTED``, the caller should re-attempt + the transaction from the beginning, re-using the same session. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].Commit + + @property + def rollback(self): + """Return the gRPC stub for {$apiMethod.name}. + + Rolls back a transaction, releasing any locks it holds. It is a good + idea to call this for any transaction that includes one or more + ``Read`` or ``ExecuteSql`` requests and + ultimately decides not to commit. + + ``Rollback`` returns ``OK`` if it successfully aborts the transaction, the + transaction was already aborted, or the transaction is not + found. ``Rollback`` never returns ``ABORTED``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].Rollback + + @property + def partition_query(self): + """Return the gRPC stub for {$apiMethod.name}. + + Creates a set of partition tokens that can be used to execute a query + operation in parallel. Each of the returned partition tokens can be used + by ``ExecuteStreamingSql`` to specify a subset + of the query result to read. The same session and read-only transaction + must be used by the PartitionQueryRequest used to create the + partition tokens and the ExecuteSqlRequests that use the partition tokens. + + Partition tokens become invalid when the session used to create them + is deleted, is idle for too long, begins a new transaction, or becomes too + old. When any of these happen, it is not possible to resume the query, and + the whole operation must be restarted from the beginning. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].PartitionQuery + + @property + def partition_read(self): + """Return the gRPC stub for {$apiMethod.name}. + + Creates a set of partition tokens that can be used to execute a read + operation in parallel. Each of the returned partition tokens can be used + by ``StreamingRead`` to specify a subset of the read + result to read. The same session and read-only transaction must be used by + the PartitionReadRequest used to create the partition tokens and the + ReadRequests that use the partition tokens. There are no ordering + guarantees on rows returned among the returned partition tokens, or even + within each individual StreamingRead call issued with a partition_token. + + Partition tokens become invalid when the session used to create them + is deleted, is idle for too long, begins a new transaction, or becomes too + old. When any of these happen, it is not possible to resume the read, and + the whole operation must be restarted from the beginning. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs['spanner_stub'].PartitionRead diff --git a/spanner/google/cloud/spanner_v1/proto/keys_pb2.py b/spanner/google/cloud/spanner_v1/proto/keys_pb2.py index b20d88dce2d4..24068c49083f 100644 --- a/spanner/google/cloud/spanner_v1/proto/keys_pb2.py +++ b/spanner/google/cloud/spanner_v1/proto/keys_pb2.py @@ -24,7 +24,6 @@ serialized_pb=_b('\n(google/cloud/spanner_v1/proto/keys.proto\x12\x11google.spanner.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1cgoogle/protobuf/struct.proto\"\xf4\x01\n\x08KeyRange\x12\x32\n\x0cstart_closed\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.ListValueH\x00\x12\x30\n\nstart_open\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.ListValueH\x00\x12\x30\n\nend_closed\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.ListValueH\x01\x12.\n\x08\x65nd_open\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.ListValueH\x01\x42\x10\n\x0estart_key_typeB\x0e\n\x0c\x65nd_key_type\"l\n\x06KeySet\x12(\n\x04keys\x18\x01 \x03(\x0b\x32\x1a.google.protobuf.ListValue\x12+\n\x06ranges\x18\x02 \x03(\x0b\x32\x1b.google.spanner.v1.KeyRange\x12\x0b\n\x03\x61ll\x18\x03 \x01(\x08\x42\x92\x01\n\x15\x63om.google.spanner.v1B\tKeysProtoP\x01Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\xaa\x02\x17Google.Cloud.Spanner.V1\xca\x02\x17Google\\Cloud\\Spanner\\V1b\x06proto3') , dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -42,28 +41,28 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='start_open', full_name='google.spanner.v1.KeyRange.start_open', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='end_closed', full_name='google.spanner.v1.KeyRange.end_closed', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='end_open', full_name='google.spanner.v1.KeyRange.end_open', index=3, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -100,21 +99,21 @@ has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='ranges', full_name='google.spanner.v1.KeySet.ranges', index=1, number=2, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='all', full_name='google.spanner.v1.KeySet.all', index=2, number=3, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -151,6 +150,7 @@ _KEYSET.fields_by_name['ranges'].message_type = _KEYRANGE DESCRIPTOR.message_types_by_name['KeyRange'] = _KEYRANGE DESCRIPTOR.message_types_by_name['KeySet'] = _KEYSET +_sym_db.RegisterFileDescriptor(DESCRIPTOR) KeyRange = _reflection.GeneratedProtocolMessageType('KeyRange', (_message.Message,), dict( DESCRIPTOR = _KEYRANGE, @@ -330,14 +330,4 @@ DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\025com.google.spanner.v1B\tKeysProtoP\001Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\252\002\027Google.Cloud.Spanner.V1\312\002\027Google\\Cloud\\Spanner\\V1')) -try: - # THESE ELEMENTS WILL BE DEPRECATED. - # Please use the generated *_pb2_grpc.py files instead. - import grpc - from grpc.beta import implementations as beta_implementations - from grpc.beta import interfaces as beta_interfaces - from grpc.framework.common import cardinality - from grpc.framework.interfaces.face import utilities as face_utilities -except ImportError: - pass # @@protoc_insertion_point(module_scope) diff --git a/spanner/google/cloud/spanner_v1/proto/mutation_pb2.py b/spanner/google/cloud/spanner_v1/proto/mutation_pb2.py index afa738be6bca..a5dd27f52f4d 100644 --- a/spanner/google/cloud/spanner_v1/proto/mutation_pb2.py +++ b/spanner/google/cloud/spanner_v1/proto/mutation_pb2.py @@ -25,7 +25,6 @@ serialized_pb=_b('\n,google/cloud/spanner_v1/proto/mutation.proto\x12\x11google.spanner.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a(google/cloud/spanner_v1/proto/keys.proto\"\xc6\x03\n\x08Mutation\x12\x33\n\x06insert\x18\x01 \x01(\x0b\x32!.google.spanner.v1.Mutation.WriteH\x00\x12\x33\n\x06update\x18\x02 \x01(\x0b\x32!.google.spanner.v1.Mutation.WriteH\x00\x12=\n\x10insert_or_update\x18\x03 \x01(\x0b\x32!.google.spanner.v1.Mutation.WriteH\x00\x12\x34\n\x07replace\x18\x04 \x01(\x0b\x32!.google.spanner.v1.Mutation.WriteH\x00\x12\x34\n\x06\x64\x65lete\x18\x05 \x01(\x0b\x32\".google.spanner.v1.Mutation.DeleteH\x00\x1aS\n\x05Write\x12\r\n\x05table\x18\x01 \x01(\t\x12\x0f\n\x07\x63olumns\x18\x02 \x03(\t\x12*\n\x06values\x18\x03 \x03(\x0b\x32\x1a.google.protobuf.ListValue\x1a\x43\n\x06\x44\x65lete\x12\r\n\x05table\x18\x01 \x01(\t\x12*\n\x07key_set\x18\x02 \x01(\x0b\x32\x19.google.spanner.v1.KeySetB\x0b\n\toperationB\x96\x01\n\x15\x63om.google.spanner.v1B\rMutationProtoP\x01Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\xaa\x02\x17Google.Cloud.Spanner.V1\xca\x02\x17Google\\Cloud\\Spanner\\V1b\x06proto3') , dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_cloud_dot_spanner__v1_dot_proto_dot_keys__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -43,21 +42,21 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='columns', full_name='google.spanner.v1.Mutation.Write.columns', index=1, number=2, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='values', full_name='google.spanner.v1.Mutation.Write.values', index=2, number=3, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -87,14 +86,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='key_set', full_name='google.spanner.v1.Mutation.Delete.key_set', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -124,35 +123,35 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='update', full_name='google.spanner.v1.Mutation.update', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='insert_or_update', full_name='google.spanner.v1.Mutation.insert_or_update', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='replace', full_name='google.spanner.v1.Mutation.replace', index=3, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='delete', full_name='google.spanner.v1.Mutation.delete', index=4, number=5, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -197,6 +196,7 @@ _MUTATION.fields_by_name['delete']) _MUTATION.fields_by_name['delete'].containing_oneof = _MUTATION.oneofs_by_name['operation'] DESCRIPTOR.message_types_by_name['Mutation'] = _MUTATION +_sym_db.RegisterFileDescriptor(DESCRIPTOR) Mutation = _reflection.GeneratedProtocolMessageType('Mutation', (_message.Message,), dict( @@ -249,6 +249,8 @@ key_set: Required. The primary keys of the rows within [table][google.spanner.v1.Mutation.Delete.table] to delete. + Delete is idempotent. The transaction will succeed even if + some or all rows do not exist. """, # @@protoc_insertion_point(class_scope:google.spanner.v1.Mutation.Delete) )) @@ -294,14 +296,4 @@ DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\025com.google.spanner.v1B\rMutationProtoP\001Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\252\002\027Google.Cloud.Spanner.V1\312\002\027Google\\Cloud\\Spanner\\V1')) -try: - # THESE ELEMENTS WILL BE DEPRECATED. - # Please use the generated *_pb2_grpc.py files instead. - import grpc - from grpc.beta import implementations as beta_implementations - from grpc.beta import interfaces as beta_interfaces - from grpc.framework.common import cardinality - from grpc.framework.interfaces.face import utilities as face_utilities -except ImportError: - pass # @@protoc_insertion_point(module_scope) diff --git a/spanner/google/cloud/spanner_v1/proto/query_plan_pb2.py b/spanner/google/cloud/spanner_v1/proto/query_plan_pb2.py index 5472e099c2ce..0053796baea7 100644 --- a/spanner/google/cloud/spanner_v1/proto/query_plan_pb2.py +++ b/spanner/google/cloud/spanner_v1/proto/query_plan_pb2.py @@ -24,7 +24,6 @@ serialized_pb=_b('\n.google/cloud/spanner_v1/proto/query_plan.proto\x12\x11google.spanner.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1cgoogle/protobuf/struct.proto\"\xf8\x04\n\x08PlanNode\x12\r\n\x05index\x18\x01 \x01(\x05\x12.\n\x04kind\x18\x02 \x01(\x0e\x32 .google.spanner.v1.PlanNode.Kind\x12\x14\n\x0c\x64isplay_name\x18\x03 \x01(\t\x12:\n\x0b\x63hild_links\x18\x04 \x03(\x0b\x32%.google.spanner.v1.PlanNode.ChildLink\x12M\n\x14short_representation\x18\x05 \x01(\x0b\x32/.google.spanner.v1.PlanNode.ShortRepresentation\x12)\n\x08metadata\x18\x06 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x30\n\x0f\x65xecution_stats\x18\x07 \x01(\x0b\x32\x17.google.protobuf.Struct\x1a@\n\tChildLink\x12\x13\n\x0b\x63hild_index\x18\x01 \x01(\x05\x12\x0c\n\x04type\x18\x02 \x01(\t\x12\x10\n\x08variable\x18\x03 \x01(\t\x1a\xb2\x01\n\x13ShortRepresentation\x12\x13\n\x0b\x64\x65scription\x18\x01 \x01(\t\x12S\n\nsubqueries\x18\x02 \x03(\x0b\x32?.google.spanner.v1.PlanNode.ShortRepresentation.SubqueriesEntry\x1a\x31\n\x0fSubqueriesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\x05:\x02\x38\x01\"8\n\x04Kind\x12\x14\n\x10KIND_UNSPECIFIED\x10\x00\x12\x0e\n\nRELATIONAL\x10\x01\x12\n\n\x06SCALAR\x10\x02\"<\n\tQueryPlan\x12/\n\nplan_nodes\x18\x01 \x03(\x0b\x32\x1b.google.spanner.v1.PlanNodeB\x97\x01\n\x15\x63om.google.spanner.v1B\x0eQueryPlanProtoP\x01Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\xaa\x02\x17Google.Cloud.Spanner.V1\xca\x02\x17Google\\Cloud\\Spanner\\V1b\x06proto3') , dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -68,21 +67,21 @@ has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='type', full_name='google.spanner.v1.PlanNode.ChildLink.type', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='variable', full_name='google.spanner.v1.PlanNode.ChildLink.variable', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -112,14 +111,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='value', full_name='google.spanner.v1.PlanNode.ShortRepresentation.SubqueriesEntry.value', index=1, number=2, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -149,14 +148,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='subqueries', full_name='google.spanner.v1.PlanNode.ShortRepresentation.subqueries', index=1, number=2, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -186,49 +185,49 @@ has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='kind', full_name='google.spanner.v1.PlanNode.kind', index=1, number=2, type=14, cpp_type=8, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='display_name', full_name='google.spanner.v1.PlanNode.display_name', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='child_links', full_name='google.spanner.v1.PlanNode.child_links', index=3, number=4, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='short_representation', full_name='google.spanner.v1.PlanNode.short_representation', index=4, number=5, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='metadata', full_name='google.spanner.v1.PlanNode.metadata', index=5, number=6, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='execution_stats', full_name='google.spanner.v1.PlanNode.execution_stats', index=6, number=7, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -260,7 +259,7 @@ has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -290,6 +289,7 @@ _QUERYPLAN.fields_by_name['plan_nodes'].message_type = _PLANNODE DESCRIPTOR.message_types_by_name['PlanNode'] = _PLANNODE DESCRIPTOR.message_types_by_name['QueryPlan'] = _QUERYPLAN +_sym_db.RegisterFileDescriptor(DESCRIPTOR) PlanNode = _reflection.GeneratedProtocolMessageType('PlanNode', (_message.Message,), dict( @@ -421,14 +421,4 @@ DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\025com.google.spanner.v1B\016QueryPlanProtoP\001Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\252\002\027Google.Cloud.Spanner.V1\312\002\027Google\\Cloud\\Spanner\\V1')) _PLANNODE_SHORTREPRESENTATION_SUBQUERIESENTRY.has_options = True _PLANNODE_SHORTREPRESENTATION_SUBQUERIESENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) -try: - # THESE ELEMENTS WILL BE DEPRECATED. - # Please use the generated *_pb2_grpc.py files instead. - import grpc - from grpc.beta import implementations as beta_implementations - from grpc.beta import interfaces as beta_interfaces - from grpc.framework.common import cardinality - from grpc.framework.interfaces.face import utilities as face_utilities -except ImportError: - pass # @@protoc_insertion_point(module_scope) diff --git a/spanner/google/cloud/spanner_v1/proto/result_set_pb2.py b/spanner/google/cloud/spanner_v1/proto/result_set_pb2.py index 3bb9339f4cb2..c06d54734b4d 100644 --- a/spanner/google/cloud/spanner_v1/proto/result_set_pb2.py +++ b/spanner/google/cloud/spanner_v1/proto/result_set_pb2.py @@ -24,10 +24,9 @@ name='google/cloud/spanner_v1/proto/result_set.proto', package='google.spanner.v1', syntax='proto3', - serialized_pb=_b('\n.google/cloud/spanner_v1/proto/result_set.proto\x12\x11google.spanner.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a.google/cloud/spanner_v1/proto/query_plan.proto\x1a/google/cloud/spanner_v1/proto/transaction.proto\x1a(google/cloud/spanner_v1/proto/type.proto\"\x9f\x01\n\tResultSet\x12\x36\n\x08metadata\x18\x01 \x01(\x0b\x32$.google.spanner.v1.ResultSetMetadata\x12(\n\x04rows\x18\x02 \x03(\x0b\x32\x1a.google.protobuf.ListValue\x12\x30\n\x05stats\x18\x03 \x01(\x0b\x32!.google.spanner.v1.ResultSetStats\"\xd1\x01\n\x10PartialResultSet\x12\x36\n\x08metadata\x18\x01 \x01(\x0b\x32$.google.spanner.v1.ResultSetMetadata\x12&\n\x06values\x18\x02 \x03(\x0b\x32\x16.google.protobuf.Value\x12\x15\n\rchunked_value\x18\x03 \x01(\x08\x12\x14\n\x0cresume_token\x18\x04 \x01(\x0c\x12\x30\n\x05stats\x18\x05 \x01(\x0b\x32!.google.spanner.v1.ResultSetStats\"y\n\x11ResultSetMetadata\x12/\n\x08row_type\x18\x01 \x01(\x0b\x32\x1d.google.spanner.v1.StructType\x12\x33\n\x0btransaction\x18\x02 \x01(\x0b\x32\x1e.google.spanner.v1.Transaction\"p\n\x0eResultSetStats\x12\x30\n\nquery_plan\x18\x01 \x01(\x0b\x32\x1c.google.spanner.v1.QueryPlan\x12,\n\x0bquery_stats\x18\x02 \x01(\x0b\x32\x17.google.protobuf.StructB\x9a\x01\n\x15\x63om.google.spanner.v1B\x0eResultSetProtoP\x01Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\xf8\x01\x01\xaa\x02\x17Google.Cloud.Spanner.V1\xca\x02\x17Google\\Cloud\\Spanner\\V1b\x06proto3') + serialized_pb=_b('\n.google/cloud/spanner_v1/proto/result_set.proto\x12\x11google.spanner.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a.google/cloud/spanner_v1/proto/query_plan.proto\x1a/google/cloud/spanner_v1/proto/transaction.proto\x1a(google/cloud/spanner_v1/proto/type.proto\"\x9f\x01\n\tResultSet\x12\x36\n\x08metadata\x18\x01 \x01(\x0b\x32$.google.spanner.v1.ResultSetMetadata\x12(\n\x04rows\x18\x02 \x03(\x0b\x32\x1a.google.protobuf.ListValue\x12\x30\n\x05stats\x18\x03 \x01(\x0b\x32!.google.spanner.v1.ResultSetStats\"\xd1\x01\n\x10PartialResultSet\x12\x36\n\x08metadata\x18\x01 \x01(\x0b\x32$.google.spanner.v1.ResultSetMetadata\x12&\n\x06values\x18\x02 \x03(\x0b\x32\x16.google.protobuf.Value\x12\x15\n\rchunked_value\x18\x03 \x01(\x08\x12\x14\n\x0cresume_token\x18\x04 \x01(\x0c\x12\x30\n\x05stats\x18\x05 \x01(\x0b\x32!.google.spanner.v1.ResultSetStats\"y\n\x11ResultSetMetadata\x12/\n\x08row_type\x18\x01 \x01(\x0b\x32\x1d.google.spanner.v1.StructType\x12\x33\n\x0btransaction\x18\x02 \x01(\x0b\x32\x1e.google.spanner.v1.Transaction\"\xb9\x01\n\x0eResultSetStats\x12\x30\n\nquery_plan\x18\x01 \x01(\x0b\x32\x1c.google.spanner.v1.QueryPlan\x12,\n\x0bquery_stats\x18\x02 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x19\n\x0frow_count_exact\x18\x03 \x01(\x03H\x00\x12\x1f\n\x15row_count_lower_bound\x18\x04 \x01(\x03H\x00\x42\x0b\n\trow_countB\x9a\x01\n\x15\x63om.google.spanner.v1B\x0eResultSetProtoP\x01Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\xf8\x01\x01\xaa\x02\x17Google.Cloud.Spanner.V1\xca\x02\x17Google\\Cloud\\Spanner\\V1b\x06proto3') , dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_cloud_dot_spanner__v1_dot_proto_dot_query__plan__pb2.DESCRIPTOR,google_dot_cloud_dot_spanner__v1_dot_proto_dot_transaction__pb2.DESCRIPTOR,google_dot_cloud_dot_spanner__v1_dot_proto_dot_type__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -45,21 +44,21 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='rows', full_name='google.spanner.v1.ResultSet.rows', index=1, number=2, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='stats', full_name='google.spanner.v1.ResultSet.stats', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -90,35 +89,35 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='values', full_name='google.spanner.v1.PartialResultSet.values', index=1, number=2, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='chunked_value', full_name='google.spanner.v1.PartialResultSet.chunked_value', index=2, number=3, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='resume_token', full_name='google.spanner.v1.PartialResultSet.resume_token', index=3, number=4, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='stats', full_name='google.spanner.v1.PartialResultSet.stats', index=4, number=5, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -149,14 +148,14 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='transaction', full_name='google.spanner.v1.ResultSetMetadata.transaction', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -187,14 +186,28 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='query_stats', full_name='google.spanner.v1.ResultSetStats.query_stats', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='row_count_exact', full_name='google.spanner.v1.ResultSetStats.row_count_exact', index=2, + number=3, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='row_count_lower_bound', full_name='google.spanner.v1.ResultSetStats.row_count_lower_bound', index=3, + number=4, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -206,9 +219,12 @@ syntax='proto3', extension_ranges=[], oneofs=[ + _descriptor.OneofDescriptor( + name='row_count', full_name='google.spanner.v1.ResultSetStats.row_count', + index=0, containing_type=None, fields=[]), ], - serialized_start=765, - serialized_end=877, + serialized_start=766, + serialized_end=951, ) _RESULTSET.fields_by_name['metadata'].message_type = _RESULTSETMETADATA @@ -221,10 +237,17 @@ _RESULTSETMETADATA.fields_by_name['transaction'].message_type = google_dot_cloud_dot_spanner__v1_dot_proto_dot_transaction__pb2._TRANSACTION _RESULTSETSTATS.fields_by_name['query_plan'].message_type = google_dot_cloud_dot_spanner__v1_dot_proto_dot_query__plan__pb2._QUERYPLAN _RESULTSETSTATS.fields_by_name['query_stats'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT +_RESULTSETSTATS.oneofs_by_name['row_count'].fields.append( + _RESULTSETSTATS.fields_by_name['row_count_exact']) +_RESULTSETSTATS.fields_by_name['row_count_exact'].containing_oneof = _RESULTSETSTATS.oneofs_by_name['row_count'] +_RESULTSETSTATS.oneofs_by_name['row_count'].fields.append( + _RESULTSETSTATS.fields_by_name['row_count_lower_bound']) +_RESULTSETSTATS.fields_by_name['row_count_lower_bound'].containing_oneof = _RESULTSETSTATS.oneofs_by_name['row_count'] DESCRIPTOR.message_types_by_name['ResultSet'] = _RESULTSET DESCRIPTOR.message_types_by_name['PartialResultSet'] = _PARTIALRESULTSET DESCRIPTOR.message_types_by_name['ResultSetMetadata'] = _RESULTSETMETADATA DESCRIPTOR.message_types_by_name['ResultSetStats'] = _RESULTSETSTATS +_sym_db.RegisterFileDescriptor(DESCRIPTOR) ResultSet = _reflection.GeneratedProtocolMessageType('ResultSet', (_message.Message,), dict( DESCRIPTOR = _RESULTSET, @@ -245,10 +268,16 @@ e]. Elements are encoded based on type as described [here][google.spanner.v1.TypeCode]. stats: - Query plan and execution statistics for the query that + Query plan and execution statistics for the SQL statement that produced this result set. These can be requested by setting [E xecuteSqlRequest.query\_mode][google.spanner.v1.ExecuteSqlRequ - est.query\_mode]. + est.query\_mode]. DML statements always produce stats + containing the number of rows modified, unless executed using + the [ExecuteSqlRequest.QueryMode.PLAN][google.spanner.v1.Execu + teSqlRequest.QueryMode.PLAN] [ExecuteSqlRequest.query\_mode][g + oogle.spanner.v1.ExecuteSqlRequest.query\_mode]. Other fields + may or may not be populated, based on the [ExecuteSqlRequest.q + uery\_mode][google.spanner.v1.ExecuteSqlRequest.query\_mode]. """, # @@protoc_insertion_point(class_scope:google.spanner.v1.ResultSet) )) @@ -326,11 +355,12 @@ including ``resume_token``. Note that executing any other transaction in the same session invalidates the token. stats: - Query plan and execution statistics for the query that + Query plan and execution statistics for the statement that produced this streaming result set. These can be requested by setting [ExecuteSqlRequest.query\_mode][google.spanner.v1.Exec uteSqlRequest.query\_mode] and are sent only once with the - last response in the stream. + last response in the stream. This field will also be present + in the last response for DML statements. """, # @@protoc_insertion_point(class_scope:google.spanner.v1.PartialResultSet) )) @@ -378,6 +408,14 @@ return the statistics as follows: :: { "rows_returned": "3", "elapsed_time": "1.22 secs", "cpu_time": "1.19 secs" } + row_count: + The number of rows modified by the DML statement. + row_count_exact: + Standard DML returns an exact count of rows that were + modified. + row_count_lower_bound: + Partitioned DML does not offer exactly-once semantics, so it + returns a lower bound of the rows modified. """, # @@protoc_insertion_point(class_scope:google.spanner.v1.ResultSetStats) )) @@ -386,14 +424,4 @@ DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\025com.google.spanner.v1B\016ResultSetProtoP\001Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\370\001\001\252\002\027Google.Cloud.Spanner.V1\312\002\027Google\\Cloud\\Spanner\\V1')) -try: - # THESE ELEMENTS WILL BE DEPRECATED. - # Please use the generated *_pb2_grpc.py files instead. - import grpc - from grpc.beta import implementations as beta_implementations - from grpc.beta import interfaces as beta_interfaces - from grpc.framework.common import cardinality - from grpc.framework.interfaces.face import utilities as face_utilities -except ImportError: - pass # @@protoc_insertion_point(module_scope) diff --git a/spanner/google/cloud/spanner_v1/proto/spanner_pb2.py b/spanner/google/cloud/spanner_v1/proto/spanner_pb2.py index 14d55bb7f704..19b5a70ffca5 100644 --- a/spanner/google/cloud/spanner_v1/proto/spanner_pb2.py +++ b/spanner/google/cloud/spanner_v1/proto/spanner_pb2.py @@ -28,10 +28,9 @@ name='google/cloud/spanner_v1/proto/spanner.proto', package='google.spanner.v1', syntax='proto3', - serialized_pb=_b('\n+google/cloud/spanner_v1/proto/spanner.proto\x12\x11google.spanner.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a(google/cloud/spanner_v1/proto/keys.proto\x1a,google/cloud/spanner_v1/proto/mutation.proto\x1a.google/cloud/spanner_v1/proto/result_set.proto\x1a/google/cloud/spanner_v1/proto/transaction.proto\x1a(google/cloud/spanner_v1/proto/type.proto\"U\n\x14\x43reateSessionRequest\x12\x10\n\x08\x64\x61tabase\x18\x01 \x01(\t\x12+\n\x07session\x18\x02 \x01(\x0b\x32\x1a.google.spanner.v1.Session\"\xee\x01\n\x07Session\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x36\n\x06labels\x18\x02 \x03(\x0b\x32&.google.spanner.v1.Session.LabelsEntry\x12/\n\x0b\x63reate_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12=\n\x19\x61pproximate_last_use_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"!\n\x11GetSessionRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"^\n\x13ListSessionsRequest\x12\x10\n\x08\x64\x61tabase\x18\x01 \x01(\t\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x04 \x01(\t\"]\n\x14ListSessionsResponse\x12,\n\x08sessions\x18\x01 \x03(\x0b\x32\x1a.google.spanner.v1.Session\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"$\n\x14\x44\x65leteSessionRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\xd1\x03\n\x11\x45xecuteSqlRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\x0b\n\x03sql\x18\x03 \x01(\t\x12\'\n\x06params\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct\x12I\n\x0bparam_types\x18\x05 \x03(\x0b\x32\x34.google.spanner.v1.ExecuteSqlRequest.ParamTypesEntry\x12\x14\n\x0cresume_token\x18\x06 \x01(\x0c\x12\x42\n\nquery_mode\x18\x07 \x01(\x0e\x32..google.spanner.v1.ExecuteSqlRequest.QueryMode\x12\x17\n\x0fpartition_token\x18\x08 \x01(\x0c\x1aJ\n\x0fParamTypesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.google.spanner.v1.Type:\x02\x38\x01\".\n\tQueryMode\x12\n\n\x06NORMAL\x10\x00\x12\x08\n\x04PLAN\x10\x01\x12\x0b\n\x07PROFILE\x10\x02\"H\n\x10PartitionOptions\x12\x1c\n\x14partition_size_bytes\x18\x01 \x01(\x03\x12\x16\n\x0emax_partitions\x18\x02 \x01(\x03\"\xf6\x02\n\x15PartitionQueryRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\x0b\n\x03sql\x18\x03 \x01(\t\x12\'\n\x06params\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct\x12M\n\x0bparam_types\x18\x05 \x03(\x0b\x32\x38.google.spanner.v1.PartitionQueryRequest.ParamTypesEntry\x12>\n\x11partition_options\x18\x06 \x01(\x0b\x32#.google.spanner.v1.PartitionOptions\x1aJ\n\x0fParamTypesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.google.spanner.v1.Type:\x02\x38\x01\"\xff\x01\n\x14PartitionReadRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\r\n\x05table\x18\x03 \x01(\t\x12\r\n\x05index\x18\x04 \x01(\t\x12\x0f\n\x07\x63olumns\x18\x05 \x03(\t\x12*\n\x07key_set\x18\x06 \x01(\x0b\x32\x19.google.spanner.v1.KeySet\x12>\n\x11partition_options\x18\t \x01(\x0b\x32#.google.spanner.v1.PartitionOptions\"$\n\tPartition\x12\x17\n\x0fpartition_token\x18\x01 \x01(\x0c\"z\n\x11PartitionResponse\x12\x30\n\npartitions\x18\x01 \x03(\x0b\x32\x1c.google.spanner.v1.Partition\x12\x33\n\x0btransaction\x18\x02 \x01(\x0b\x32\x1e.google.spanner.v1.Transaction\"\xf4\x01\n\x0bReadRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\r\n\x05table\x18\x03 \x01(\t\x12\r\n\x05index\x18\x04 \x01(\t\x12\x0f\n\x07\x63olumns\x18\x05 \x03(\t\x12*\n\x07key_set\x18\x06 \x01(\x0b\x32\x19.google.spanner.v1.KeySet\x12\r\n\x05limit\x18\x08 \x01(\x03\x12\x14\n\x0cresume_token\x18\t \x01(\x0c\x12\x17\n\x0fpartition_token\x18\n \x01(\x0c\"b\n\x17\x42\x65ginTransactionRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12\x36\n\x07options\x18\x02 \x01(\x0b\x32%.google.spanner.v1.TransactionOptions\"\xc2\x01\n\rCommitRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12\x18\n\x0etransaction_id\x18\x02 \x01(\x0cH\x00\x12G\n\x16single_use_transaction\x18\x03 \x01(\x0b\x32%.google.spanner.v1.TransactionOptionsH\x00\x12.\n\tmutations\x18\x04 \x03(\x0b\x32\x1b.google.spanner.v1.MutationB\r\n\x0btransaction\"F\n\x0e\x43ommitResponse\x12\x34\n\x10\x63ommit_timestamp\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\":\n\x0fRollbackRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12\x16\n\x0etransaction_id\x18\x02 \x01(\x0c\x32\x83\x11\n\x07Spanner\x12\x9b\x01\n\rCreateSession\x12\'.google.spanner.v1.CreateSessionRequest\x1a\x1a.google.spanner.v1.Session\"E\x82\xd3\xe4\x93\x02?\":/v1/{database=projects/*/instances/*/databases/*}/sessions:\x01*\x12\x90\x01\n\nGetSession\x12$.google.spanner.v1.GetSessionRequest\x1a\x1a.google.spanner.v1.Session\"@\x82\xd3\xe4\x93\x02:\x12\x38/v1/{name=projects/*/instances/*/databases/*/sessions/*}\x12\xa3\x01\n\x0cListSessions\x12&.google.spanner.v1.ListSessionsRequest\x1a\'.google.spanner.v1.ListSessionsResponse\"B\x82\xd3\xe4\x93\x02<\x12:/v1/{database=projects/*/instances/*/databases/*}/sessions\x12\x92\x01\n\rDeleteSession\x12\'.google.spanner.v1.DeleteSessionRequest\x1a\x16.google.protobuf.Empty\"@\x82\xd3\xe4\x93\x02:*8/v1/{name=projects/*/instances/*/databases/*/sessions/*}\x12\xa3\x01\n\nExecuteSql\x12$.google.spanner.v1.ExecuteSqlRequest\x1a\x1c.google.spanner.v1.ResultSet\"Q\x82\xd3\xe4\x93\x02K\"F/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql:\x01*\x12\xbe\x01\n\x13\x45xecuteStreamingSql\x12$.google.spanner.v1.ExecuteSqlRequest\x1a#.google.spanner.v1.PartialResultSet\"Z\x82\xd3\xe4\x93\x02T\"O/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql:\x01*0\x01\x12\x91\x01\n\x04Read\x12\x1e.google.spanner.v1.ReadRequest\x1a\x1c.google.spanner.v1.ResultSet\"K\x82\xd3\xe4\x93\x02\x45\"@/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read:\x01*\x12\xac\x01\n\rStreamingRead\x12\x1e.google.spanner.v1.ReadRequest\x1a#.google.spanner.v1.PartialResultSet\"T\x82\xd3\xe4\x93\x02N\"I/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead:\x01*0\x01\x12\xb7\x01\n\x10\x42\x65ginTransaction\x12*.google.spanner.v1.BeginTransactionRequest\x1a\x1e.google.spanner.v1.Transaction\"W\x82\xd3\xe4\x93\x02Q\"L/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction:\x01*\x12\x9c\x01\n\x06\x43ommit\x12 .google.spanner.v1.CommitRequest\x1a!.google.spanner.v1.CommitResponse\"M\x82\xd3\xe4\x93\x02G\"B/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit:\x01*\x12\x97\x01\n\x08Rollback\x12\".google.spanner.v1.RollbackRequest\x1a\x16.google.protobuf.Empty\"O\x82\xd3\xe4\x93\x02I\"D/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback:\x01*\x12\xb7\x01\n\x0ePartitionQuery\x12(.google.spanner.v1.PartitionQueryRequest\x1a$.google.spanner.v1.PartitionResponse\"U\x82\xd3\xe4\x93\x02O\"J/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery:\x01*\x12\xb4\x01\n\rPartitionRead\x12\'.google.spanner.v1.PartitionReadRequest\x1a$.google.spanner.v1.PartitionResponse\"T\x82\xd3\xe4\x93\x02N\"I/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionRead:\x01*B\x95\x01\n\x15\x63om.google.spanner.v1B\x0cSpannerProtoP\x01Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\xaa\x02\x17Google.Cloud.Spanner.V1\xca\x02\x17Google\\Cloud\\Spanner\\V1b\x06proto3') + serialized_pb=_b('\n+google/cloud/spanner_v1/proto/spanner.proto\x12\x11google.spanner.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a(google/cloud/spanner_v1/proto/keys.proto\x1a,google/cloud/spanner_v1/proto/mutation.proto\x1a.google/cloud/spanner_v1/proto/result_set.proto\x1a/google/cloud/spanner_v1/proto/transaction.proto\x1a(google/cloud/spanner_v1/proto/type.proto\"U\n\x14\x43reateSessionRequest\x12\x10\n\x08\x64\x61tabase\x18\x01 \x01(\t\x12+\n\x07session\x18\x02 \x01(\x0b\x32\x1a.google.spanner.v1.Session\"\xee\x01\n\x07Session\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x36\n\x06labels\x18\x02 \x03(\x0b\x32&.google.spanner.v1.Session.LabelsEntry\x12/\n\x0b\x63reate_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12=\n\x19\x61pproximate_last_use_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x1a-\n\x0bLabelsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01\"!\n\x11GetSessionRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"^\n\x13ListSessionsRequest\x12\x10\n\x08\x64\x61tabase\x18\x01 \x01(\t\x12\x11\n\tpage_size\x18\x02 \x01(\x05\x12\x12\n\npage_token\x18\x03 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x04 \x01(\t\"]\n\x14ListSessionsResponse\x12,\n\x08sessions\x18\x01 \x03(\x0b\x32\x1a.google.spanner.v1.Session\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t\"$\n\x14\x44\x65leteSessionRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\"\xe0\x03\n\x11\x45xecuteSqlRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\x0b\n\x03sql\x18\x03 \x01(\t\x12\'\n\x06params\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct\x12I\n\x0bparam_types\x18\x05 \x03(\x0b\x32\x34.google.spanner.v1.ExecuteSqlRequest.ParamTypesEntry\x12\x14\n\x0cresume_token\x18\x06 \x01(\x0c\x12\x42\n\nquery_mode\x18\x07 \x01(\x0e\x32..google.spanner.v1.ExecuteSqlRequest.QueryMode\x12\x17\n\x0fpartition_token\x18\x08 \x01(\x0c\x12\r\n\x05seqno\x18\t \x01(\x03\x1aJ\n\x0fParamTypesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.google.spanner.v1.Type:\x02\x38\x01\".\n\tQueryMode\x12\n\n\x06NORMAL\x10\x00\x12\x08\n\x04PLAN\x10\x01\x12\x0b\n\x07PROFILE\x10\x02\"H\n\x10PartitionOptions\x12\x1c\n\x14partition_size_bytes\x18\x01 \x01(\x03\x12\x16\n\x0emax_partitions\x18\x02 \x01(\x03\"\xf6\x02\n\x15PartitionQueryRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\x0b\n\x03sql\x18\x03 \x01(\t\x12\'\n\x06params\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct\x12M\n\x0bparam_types\x18\x05 \x03(\x0b\x32\x38.google.spanner.v1.PartitionQueryRequest.ParamTypesEntry\x12>\n\x11partition_options\x18\x06 \x01(\x0b\x32#.google.spanner.v1.PartitionOptions\x1aJ\n\x0fParamTypesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12&\n\x05value\x18\x02 \x01(\x0b\x32\x17.google.spanner.v1.Type:\x02\x38\x01\"\xff\x01\n\x14PartitionReadRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\r\n\x05table\x18\x03 \x01(\t\x12\r\n\x05index\x18\x04 \x01(\t\x12\x0f\n\x07\x63olumns\x18\x05 \x03(\t\x12*\n\x07key_set\x18\x06 \x01(\x0b\x32\x19.google.spanner.v1.KeySet\x12>\n\x11partition_options\x18\t \x01(\x0b\x32#.google.spanner.v1.PartitionOptions\"$\n\tPartition\x12\x17\n\x0fpartition_token\x18\x01 \x01(\x0c\"z\n\x11PartitionResponse\x12\x30\n\npartitions\x18\x01 \x03(\x0b\x32\x1c.google.spanner.v1.Partition\x12\x33\n\x0btransaction\x18\x02 \x01(\x0b\x32\x1e.google.spanner.v1.Transaction\"\xf4\x01\n\x0bReadRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12;\n\x0btransaction\x18\x02 \x01(\x0b\x32&.google.spanner.v1.TransactionSelector\x12\r\n\x05table\x18\x03 \x01(\t\x12\r\n\x05index\x18\x04 \x01(\t\x12\x0f\n\x07\x63olumns\x18\x05 \x03(\t\x12*\n\x07key_set\x18\x06 \x01(\x0b\x32\x19.google.spanner.v1.KeySet\x12\r\n\x05limit\x18\x08 \x01(\x03\x12\x14\n\x0cresume_token\x18\t \x01(\x0c\x12\x17\n\x0fpartition_token\x18\n \x01(\x0c\"b\n\x17\x42\x65ginTransactionRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12\x36\n\x07options\x18\x02 \x01(\x0b\x32%.google.spanner.v1.TransactionOptions\"\xc2\x01\n\rCommitRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12\x18\n\x0etransaction_id\x18\x02 \x01(\x0cH\x00\x12G\n\x16single_use_transaction\x18\x03 \x01(\x0b\x32%.google.spanner.v1.TransactionOptionsH\x00\x12.\n\tmutations\x18\x04 \x03(\x0b\x32\x1b.google.spanner.v1.MutationB\r\n\x0btransaction\"F\n\x0e\x43ommitResponse\x12\x34\n\x10\x63ommit_timestamp\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\":\n\x0fRollbackRequest\x12\x0f\n\x07session\x18\x01 \x01(\t\x12\x16\n\x0etransaction_id\x18\x02 \x01(\x0c\x32\x83\x11\n\x07Spanner\x12\x9b\x01\n\rCreateSession\x12\'.google.spanner.v1.CreateSessionRequest\x1a\x1a.google.spanner.v1.Session\"E\x82\xd3\xe4\x93\x02?\":/v1/{database=projects/*/instances/*/databases/*}/sessions:\x01*\x12\x90\x01\n\nGetSession\x12$.google.spanner.v1.GetSessionRequest\x1a\x1a.google.spanner.v1.Session\"@\x82\xd3\xe4\x93\x02:\x12\x38/v1/{name=projects/*/instances/*/databases/*/sessions/*}\x12\xa3\x01\n\x0cListSessions\x12&.google.spanner.v1.ListSessionsRequest\x1a\'.google.spanner.v1.ListSessionsResponse\"B\x82\xd3\xe4\x93\x02<\x12:/v1/{database=projects/*/instances/*/databases/*}/sessions\x12\x92\x01\n\rDeleteSession\x12\'.google.spanner.v1.DeleteSessionRequest\x1a\x16.google.protobuf.Empty\"@\x82\xd3\xe4\x93\x02:*8/v1/{name=projects/*/instances/*/databases/*/sessions/*}\x12\xa3\x01\n\nExecuteSql\x12$.google.spanner.v1.ExecuteSqlRequest\x1a\x1c.google.spanner.v1.ResultSet\"Q\x82\xd3\xe4\x93\x02K\"F/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql:\x01*\x12\xbe\x01\n\x13\x45xecuteStreamingSql\x12$.google.spanner.v1.ExecuteSqlRequest\x1a#.google.spanner.v1.PartialResultSet\"Z\x82\xd3\xe4\x93\x02T\"O/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql:\x01*0\x01\x12\x91\x01\n\x04Read\x12\x1e.google.spanner.v1.ReadRequest\x1a\x1c.google.spanner.v1.ResultSet\"K\x82\xd3\xe4\x93\x02\x45\"@/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read:\x01*\x12\xac\x01\n\rStreamingRead\x12\x1e.google.spanner.v1.ReadRequest\x1a#.google.spanner.v1.PartialResultSet\"T\x82\xd3\xe4\x93\x02N\"I/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead:\x01*0\x01\x12\xb7\x01\n\x10\x42\x65ginTransaction\x12*.google.spanner.v1.BeginTransactionRequest\x1a\x1e.google.spanner.v1.Transaction\"W\x82\xd3\xe4\x93\x02Q\"L/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction:\x01*\x12\x9c\x01\n\x06\x43ommit\x12 .google.spanner.v1.CommitRequest\x1a!.google.spanner.v1.CommitResponse\"M\x82\xd3\xe4\x93\x02G\"B/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit:\x01*\x12\x97\x01\n\x08Rollback\x12\".google.spanner.v1.RollbackRequest\x1a\x16.google.protobuf.Empty\"O\x82\xd3\xe4\x93\x02I\"D/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback:\x01*\x12\xb7\x01\n\x0ePartitionQuery\x12(.google.spanner.v1.PartitionQueryRequest\x1a$.google.spanner.v1.PartitionResponse\"U\x82\xd3\xe4\x93\x02O\"J/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery:\x01*\x12\xb4\x01\n\rPartitionRead\x12\'.google.spanner.v1.PartitionReadRequest\x1a$.google.spanner.v1.PartitionResponse\"T\x82\xd3\xe4\x93\x02N\"I/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionRead:\x01*B\x95\x01\n\x15\x63om.google.spanner.v1B\x0cSpannerProtoP\x01Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\xaa\x02\x17Google.Cloud.Spanner.V1\xca\x02\x17Google\\Cloud\\Spanner\\V1b\x06proto3') , dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_protobuf_dot_empty__pb2.DESCRIPTOR,google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,google_dot_cloud_dot_spanner__v1_dot_proto_dot_keys__pb2.DESCRIPTOR,google_dot_cloud_dot_spanner__v1_dot_proto_dot_mutation__pb2.DESCRIPTOR,google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.DESCRIPTOR,google_dot_cloud_dot_spanner__v1_dot_proto_dot_transaction__pb2.DESCRIPTOR,google_dot_cloud_dot_spanner__v1_dot_proto_dot_type__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -56,8 +55,8 @@ ], containing_type=None, options=None, - serialized_start=1427, - serialized_end=1473, + serialized_start=1442, + serialized_end=1488, ) _sym_db.RegisterEnumDescriptor(_EXECUTESQLREQUEST_QUERYMODE) @@ -75,14 +74,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='session', full_name='google.spanner.v1.CreateSessionRequest.session', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -113,14 +112,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='value', full_name='google.spanner.v1.Session.LabelsEntry.value', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -150,28 +149,28 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='labels', full_name='google.spanner.v1.Session.labels', index=1, number=2, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='create_time', full_name='google.spanner.v1.Session.create_time', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='approximate_last_use_time', full_name='google.spanner.v1.Session.approximate_last_use_time', index=3, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -202,7 +201,7 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -233,28 +232,28 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='page_size', full_name='google.spanner.v1.ListSessionsRequest.page_size', index=1, number=2, type=5, cpp_type=1, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='page_token', full_name='google.spanner.v1.ListSessionsRequest.page_token', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='filter', full_name='google.spanner.v1.ListSessionsRequest.filter', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -285,14 +284,14 @@ has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='next_page_token', full_name='google.spanner.v1.ListSessionsResponse.next_page_token', index=1, number=2, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -323,7 +322,7 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -354,14 +353,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='value', full_name='google.spanner.v1.ExecuteSqlRequest.ParamTypesEntry.value', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -374,8 +373,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1351, - serialized_end=1425, + serialized_start=1366, + serialized_end=1440, ) _EXECUTESQLREQUEST = _descriptor.Descriptor( @@ -391,56 +390,63 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='transaction', full_name='google.spanner.v1.ExecuteSqlRequest.transaction', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='sql', full_name='google.spanner.v1.ExecuteSqlRequest.sql', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='params', full_name='google.spanner.v1.ExecuteSqlRequest.params', index=3, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='param_types', full_name='google.spanner.v1.ExecuteSqlRequest.param_types', index=4, number=5, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='resume_token', full_name='google.spanner.v1.ExecuteSqlRequest.resume_token', index=5, number=6, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='query_mode', full_name='google.spanner.v1.ExecuteSqlRequest.query_mode', index=6, number=7, type=14, cpp_type=8, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='partition_token', full_name='google.spanner.v1.ExecuteSqlRequest.partition_token', index=7, number=8, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='seqno', full_name='google.spanner.v1.ExecuteSqlRequest.seqno', index=8, + number=9, type=3, cpp_type=2, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -455,7 +461,7 @@ oneofs=[ ], serialized_start=1008, - serialized_end=1473, + serialized_end=1488, ) @@ -472,14 +478,14 @@ has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='max_partitions', full_name='google.spanner.v1.PartitionOptions.max_partitions', index=1, number=2, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -492,8 +498,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1475, - serialized_end=1547, + serialized_start=1490, + serialized_end=1562, ) @@ -510,14 +516,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='value', full_name='google.spanner.v1.PartitionQueryRequest.ParamTypesEntry.value', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -530,8 +536,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1351, - serialized_end=1425, + serialized_start=1366, + serialized_end=1440, ) _PARTITIONQUERYREQUEST = _descriptor.Descriptor( @@ -547,42 +553,42 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='transaction', full_name='google.spanner.v1.PartitionQueryRequest.transaction', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='sql', full_name='google.spanner.v1.PartitionQueryRequest.sql', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='params', full_name='google.spanner.v1.PartitionQueryRequest.params', index=3, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='param_types', full_name='google.spanner.v1.PartitionQueryRequest.param_types', index=4, number=5, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='partition_options', full_name='google.spanner.v1.PartitionQueryRequest.partition_options', index=5, number=6, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -595,8 +601,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1550, - serialized_end=1924, + serialized_start=1565, + serialized_end=1939, ) @@ -613,49 +619,49 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='transaction', full_name='google.spanner.v1.PartitionReadRequest.transaction', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='table', full_name='google.spanner.v1.PartitionReadRequest.table', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='index', full_name='google.spanner.v1.PartitionReadRequest.index', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='columns', full_name='google.spanner.v1.PartitionReadRequest.columns', index=4, number=5, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='key_set', full_name='google.spanner.v1.PartitionReadRequest.key_set', index=5, number=6, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='partition_options', full_name='google.spanner.v1.PartitionReadRequest.partition_options', index=6, number=9, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -668,8 +674,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=1927, - serialized_end=2182, + serialized_start=1942, + serialized_end=2197, ) @@ -686,7 +692,7 @@ has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -699,8 +705,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2184, - serialized_end=2220, + serialized_start=2199, + serialized_end=2235, ) @@ -717,14 +723,14 @@ has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='transaction', full_name='google.spanner.v1.PartitionResponse.transaction', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -737,8 +743,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2222, - serialized_end=2344, + serialized_start=2237, + serialized_end=2359, ) @@ -755,63 +761,63 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='transaction', full_name='google.spanner.v1.ReadRequest.transaction', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='table', full_name='google.spanner.v1.ReadRequest.table', index=2, number=3, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='index', full_name='google.spanner.v1.ReadRequest.index', index=3, number=4, type=9, cpp_type=9, label=1, has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='columns', full_name='google.spanner.v1.ReadRequest.columns', index=4, number=5, type=9, cpp_type=9, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='key_set', full_name='google.spanner.v1.ReadRequest.key_set', index=5, number=6, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='limit', full_name='google.spanner.v1.ReadRequest.limit', index=6, number=8, type=3, cpp_type=2, label=1, has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='resume_token', full_name='google.spanner.v1.ReadRequest.resume_token', index=7, number=9, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='partition_token', full_name='google.spanner.v1.ReadRequest.partition_token', index=8, number=10, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -824,8 +830,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2347, - serialized_end=2591, + serialized_start=2362, + serialized_end=2606, ) @@ -842,14 +848,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='options', full_name='google.spanner.v1.BeginTransactionRequest.options', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -862,8 +868,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2593, - serialized_end=2691, + serialized_start=2608, + serialized_end=2706, ) @@ -880,28 +886,28 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='transaction_id', full_name='google.spanner.v1.CommitRequest.transaction_id', index=1, number=2, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='single_use_transaction', full_name='google.spanner.v1.CommitRequest.single_use_transaction', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='mutations', full_name='google.spanner.v1.CommitRequest.mutations', index=3, number=4, type=11, cpp_type=10, label=3, has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -917,8 +923,8 @@ name='transaction', full_name='google.spanner.v1.CommitRequest.transaction', index=0, containing_type=None, fields=[]), ], - serialized_start=2694, - serialized_end=2888, + serialized_start=2709, + serialized_end=2903, ) @@ -935,7 +941,7 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -948,8 +954,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2890, - serialized_end=2960, + serialized_start=2905, + serialized_end=2975, ) @@ -966,14 +972,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='transaction_id', full_name='google.spanner.v1.RollbackRequest.transaction_id', index=1, number=2, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -986,8 +992,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=2962, - serialized_end=3020, + serialized_start=2977, + serialized_end=3035, ) _CREATESESSIONREQUEST.fields_by_name['session'].message_type = _SESSION @@ -1043,6 +1049,7 @@ DESCRIPTOR.message_types_by_name['CommitRequest'] = _COMMITREQUEST DESCRIPTOR.message_types_by_name['CommitResponse'] = _COMMITRESPONSE DESCRIPTOR.message_types_by_name['RollbackRequest'] = _ROLLBACKREQUEST +_sym_db.RegisterFileDescriptor(DESCRIPTOR) CreateSessionRequest = _reflection.GeneratedProtocolMessageType('CreateSessionRequest', (_message.Message,), dict( DESCRIPTOR = _CREATESESSIONREQUEST, @@ -1204,48 +1211,71 @@ performed. transaction: The transaction to use. If none is provided, the default is a - temporary read-only transaction with strong concurrency. + temporary read-only transaction with strong concurrency. The + transaction to use. For queries, if none is provided, the + default is a temporary read-only transaction with strong + concurrency. Standard DML statements require a ReadWrite + transaction. Single-use transactions are not supported (to + avoid replay). The caller must either supply an existing + transaction ID or begin a new transaction. Partitioned DML + requires an existing PartitionedDml transaction ID. sql: - Required. The SQL query string. + Required. The SQL string. params: - The SQL query string can contain parameter placeholders. A - parameter placeholder consists of ``'@'`` followed by the - parameter name. Parameter names consist of any combination of - letters, numbers, and underscores. Parameters can appear - anywhere that a literal value is expected. The same parameter - name can be used more than once, for example: ``"WHERE id > - @msg_id AND id < @msg_id + 100"`` It is an error to execute - an SQL query with unbound parameters. Parameter values are - specified using ``params``, which is a JSON object whose keys - are parameter names, and whose values are the corresponding - parameter values. + The SQL string can contain parameter placeholders. A parameter + placeholder consists of ``'@'`` followed by the parameter + name. Parameter names consist of any combination of letters, + numbers, and underscores. Parameters can appear anywhere that + a literal value is expected. The same parameter name can be + used more than once, for example: ``"WHERE id > @msg_id AND id + < @msg_id + 100"`` It is an error to execute an SQL statement + with unbound parameters. Parameter values are specified using + ``params``, which is a JSON object whose keys are parameter + names, and whose values are the corresponding parameter + values. param_types: 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 [params][google.spanner.v1.ExecuteSqlRequest.params] as JSON strings. In these cases, ``param_types`` can be used to - specify the exact SQL type for some or all of the SQL query - parameters. See the definition of + specify the exact SQL type for some or all of the SQL + statement parameters. See the definition of [Type][google.spanner.v1.Type] for more information about SQL types. resume_token: - If this request is resuming a previously interrupted SQL query - execution, ``resume_token`` should be copied from the last + If this request is resuming a previously interrupted SQL + statement execution, ``resume_token`` should be copied from + the last [PartialResultSet][google.spanner.v1.PartialResultSet] yielded - before the interruption. Doing this enables the new SQL query - execution to resume where the last one left off. The rest of - the request parameters must exactly match the request that - yielded this token. + before the interruption. Doing this enables the new SQL + statement execution to resume where the last one left off. The + rest of the request parameters must exactly match the request + that yielded this token. query_mode: Used to control the amount of debugging information returned - in [ResultSetStats][google.spanner.v1.ResultSetStats]. + in [ResultSetStats][google.spanner.v1.ResultSetStats]. If [par + tition\_token][google.spanner.v1.ExecuteSqlRequest.partition\_ + token] is set, + [query\_mode][google.spanner.v1.ExecuteSqlRequest.query\_mode] + can only be set to [QueryMode.NORMAL][google.spanner.v1.Execut + eSqlRequest.QueryMode.NORMAL]. partition_token: If present, results will be restricted to the specified partition previously created using PartitionQuery(). There must be an exact match for the values of fields common to this message and the PartitionQueryRequest message used to create this partition\_token. + seqno: + A per-transaction sequence number used to identify this + request. This makes each request idempotent such that if the + request is received multiple times, at most one will succeed. + The sequence number must be monotonically increasing within + the transaction. If a request arrives for the first time with + an out-of-order sequence number, the transaction may be + aborted. Replays of previously handled requests will yield the + same response as the first execution. Required for DML + statements. Ignored for queries. """, # @@protoc_insertion_point(class_scope:google.spanner.v1.ExecuteSqlRequest) )) @@ -1261,17 +1291,19 @@ Attributes: partition_size_bytes: - The desired data size for each partition generated. The - default for this option is currently 1 GiB. This is only a - hint. The actual size of each partition may be smaller or - larger than this size request. + **Note:** This hint is currently ignored by PartitionQuery and + PartitionRead requests. The desired data size for each + partition generated. The default for this option is currently + 1 GiB. This is only a hint. The actual size of each partition + may be smaller or larger than this size request. max_partitions: - The desired maximum number of partitions to return. For - example, this may be set to the number of workers available. - The default for this option is currently 10,000. The maximum - value is currently 200,000. This is only a hint. The actual - number of partitions returned may be smaller than this maximum - count request. + **Note:** This hint is currently ignored by PartitionQuery and + PartitionRead requests. The desired maximum number of + partitions to return. For example, this may be set to the + number of workers available. The default for this option is + currently 10,000. The maximum value is currently 200,000. This + is only a hint. The actual number of partitions returned may + be smaller or larger than this maximum count request. """, # @@protoc_insertion_point(class_scope:google.spanner.v1.PartitionOptions) )) @@ -1305,7 +1337,10 @@ operator. A distributed union operator conceptually divides one or more tables into multiple splits, remotely evaluates a subquery independently on each split, and then unions all - results. + results. This must not contain DML commands, such as INSERT, + UPDATE, or DELETE. Use [ExecuteStreamingSql][google.spanner.v1 + .Spanner.ExecuteStreamingSql] with a PartitionedDml + transaction for large, partition-friendly DML operations. params: The SQL query string can contain parameter placeholders. A parameter placeholder consists of ``'@'`` followed by the @@ -1589,760 +1624,136 @@ _EXECUTESQLREQUEST_PARAMTYPESENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) _PARTITIONQUERYREQUEST_PARAMTYPESENTRY.has_options = True _PARTITIONQUERYREQUEST_PARAMTYPESENTRY._options = _descriptor._ParseOptions(descriptor_pb2.MessageOptions(), _b('8\001')) -try: - # THESE ELEMENTS WILL BE DEPRECATED. - # Please use the generated *_pb2_grpc.py files instead. - import grpc - from grpc.beta import implementations as beta_implementations - from grpc.beta import interfaces as beta_interfaces - from grpc.framework.common import cardinality - from grpc.framework.interfaces.face import utilities as face_utilities - - - class SpannerStub(object): - """Cloud Spanner API - - The Cloud Spanner API can be used to manage sessions and execute - transactions on data stored in Cloud Spanner databases. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.CreateSession = channel.unary_unary( - '/google.spanner.v1.Spanner/CreateSession', - request_serializer=CreateSessionRequest.SerializeToString, - response_deserializer=Session.FromString, - ) - self.GetSession = channel.unary_unary( - '/google.spanner.v1.Spanner/GetSession', - request_serializer=GetSessionRequest.SerializeToString, - response_deserializer=Session.FromString, - ) - self.ListSessions = channel.unary_unary( - '/google.spanner.v1.Spanner/ListSessions', - request_serializer=ListSessionsRequest.SerializeToString, - response_deserializer=ListSessionsResponse.FromString, - ) - self.DeleteSession = channel.unary_unary( - '/google.spanner.v1.Spanner/DeleteSession', - request_serializer=DeleteSessionRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.ExecuteSql = channel.unary_unary( - '/google.spanner.v1.Spanner/ExecuteSql', - request_serializer=ExecuteSqlRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.ResultSet.FromString, - ) - self.ExecuteStreamingSql = channel.unary_stream( - '/google.spanner.v1.Spanner/ExecuteStreamingSql', - request_serializer=ExecuteSqlRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.PartialResultSet.FromString, - ) - self.Read = channel.unary_unary( - '/google.spanner.v1.Spanner/Read', - request_serializer=ReadRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.ResultSet.FromString, - ) - self.StreamingRead = channel.unary_stream( - '/google.spanner.v1.Spanner/StreamingRead', - request_serializer=ReadRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.PartialResultSet.FromString, - ) - self.BeginTransaction = channel.unary_unary( - '/google.spanner.v1.Spanner/BeginTransaction', - request_serializer=BeginTransactionRequest.SerializeToString, - response_deserializer=google_dot_cloud_dot_spanner__v1_dot_proto_dot_transaction__pb2.Transaction.FromString, - ) - self.Commit = channel.unary_unary( - '/google.spanner.v1.Spanner/Commit', - request_serializer=CommitRequest.SerializeToString, - response_deserializer=CommitResponse.FromString, - ) - self.Rollback = channel.unary_unary( - '/google.spanner.v1.Spanner/Rollback', - request_serializer=RollbackRequest.SerializeToString, - response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ) - self.PartitionQuery = channel.unary_unary( - '/google.spanner.v1.Spanner/PartitionQuery', - request_serializer=PartitionQueryRequest.SerializeToString, - response_deserializer=PartitionResponse.FromString, - ) - self.PartitionRead = channel.unary_unary( - '/google.spanner.v1.Spanner/PartitionRead', - request_serializer=PartitionReadRequest.SerializeToString, - response_deserializer=PartitionResponse.FromString, - ) - - - class SpannerServicer(object): - """Cloud Spanner API - - The Cloud Spanner API can be used to manage sessions and execute - transactions on data stored in Cloud Spanner databases. - """ - - def CreateSession(self, request, context): - """Creates a new session. A session can be used to perform - transactions that read and/or modify data in a Cloud Spanner database. - Sessions are meant to be reused for many consecutive - transactions. - - Sessions can only execute one transaction at a time. To execute - multiple concurrent read-write/write-only transactions, create - multiple sessions. Note that standalone reads and queries use a - transaction internally, and count toward the one transaction - limit. - - Cloud Spanner limits the number of sessions that can exist at any given - time; thus, it is a good idea to delete idle and/or unneeded sessions. - Aside from explicit deletes, Cloud Spanner can delete sessions for which no - operations are sent for more than an hour. If a session is deleted, - requests to it return `NOT_FOUND`. - - Idle sessions can be kept alive by sending a trivial SQL query - periodically, e.g., `"SELECT 1"`. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def GetSession(self, request, context): - """Gets a session. Returns `NOT_FOUND` if the session does not exist. - This is mainly useful for determining whether a session is still - alive. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ListSessions(self, request, context): - """Lists all sessions in a given database. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def DeleteSession(self, request, context): - """Ends a session, releasing server resources associated with it. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ExecuteSql(self, request, context): - """Executes an SQL query, returning all rows in a single reply. This - method cannot be used to return a result set larger than 10 MiB; - if the query yields more data than that, the query fails with - a `FAILED_PRECONDITION` error. - - Queries inside read-write transactions might return `ABORTED`. If - this occurs, the application should restart the transaction from - the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. - - Larger result sets can be fetched in streaming fashion by calling - [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def ExecuteStreamingSql(self, request, context): - """Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the result - set as a stream. Unlike [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there - is no limit on the size of the returned result set. However, no - individual row in the result set can exceed 100 MiB, and no - column value can exceed 10 MiB. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Read(self, request, context): - """Reads rows from the database using key lookups and scans, as a - simple key/value style alternative to - [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be used to - return a result set larger than 10 MiB; if the read matches more - data than that, the read fails with a `FAILED_PRECONDITION` - error. - - Reads inside read-write transactions might return `ABORTED`. If - this occurs, the application should restart the transaction from - the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. - - Larger result sets can be yielded in streaming fashion by calling - [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def StreamingRead(self, request, context): - """Like [Read][google.spanner.v1.Spanner.Read], except returns the result set as a - stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no limit on the - size of the returned result set. However, no individual row in - the result set can exceed 100 MiB, and no column value can exceed - 10 MiB. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def BeginTransaction(self, request, context): - """Begins a new transaction. This step can often be skipped: - [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and - [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a - side-effect. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Commit(self, request, context): - """Commits a transaction. The request includes the mutations to be - applied to rows in the database. - - `Commit` might return an `ABORTED` error. This can occur at any time; - commonly, the cause is conflicts with concurrent - transactions. However, it can also happen for a variety of other - reasons. If `Commit` returns `ABORTED`, the caller should re-attempt - the transaction from the beginning, re-using the same session. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def Rollback(self, request, context): - """Rolls back a transaction, releasing any locks it holds. It is a good - idea to call this for any transaction that includes one or more - [Read][google.spanner.v1.Spanner.Read] or [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and - ultimately decides not to commit. - - `Rollback` returns `OK` if it successfully aborts the transaction, the - transaction was already aborted, or the transaction is not - found. `Rollback` never returns `ABORTED`. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def PartitionQuery(self, request, context): - """Creates a set of partition tokens that can be used to execute a query - operation in parallel. Each of the returned partition tokens can be used - by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to specify a subset - of the query result to read. The same session and read-only transaction - must be used by the PartitionQueryRequest used to create the - partition tokens and the ExecuteSqlRequests that use the partition tokens. - Partition tokens become invalid when the session used to create them - is deleted or begins a new transaction. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - def PartitionRead(self, request, context): - """Creates a set of partition tokens that can be used to execute a read - operation in parallel. Each of the returned partition tokens can be used - by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a subset of the read - result to read. The same session and read-only transaction must be used by - the PartitionReadRequest used to create the partition tokens and the - ReadRequests that use the partition tokens. - Partition tokens become invalid when the session used to create them - is deleted or begins a new transaction. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details('Method not implemented!') - raise NotImplementedError('Method not implemented!') - - - def add_SpannerServicer_to_server(servicer, server): - rpc_method_handlers = { - 'CreateSession': grpc.unary_unary_rpc_method_handler( - servicer.CreateSession, - request_deserializer=CreateSessionRequest.FromString, - response_serializer=Session.SerializeToString, - ), - 'GetSession': grpc.unary_unary_rpc_method_handler( - servicer.GetSession, - request_deserializer=GetSessionRequest.FromString, - response_serializer=Session.SerializeToString, - ), - 'ListSessions': grpc.unary_unary_rpc_method_handler( - servicer.ListSessions, - request_deserializer=ListSessionsRequest.FromString, - response_serializer=ListSessionsResponse.SerializeToString, - ), - 'DeleteSession': grpc.unary_unary_rpc_method_handler( - servicer.DeleteSession, - request_deserializer=DeleteSessionRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'ExecuteSql': grpc.unary_unary_rpc_method_handler( - servicer.ExecuteSql, - request_deserializer=ExecuteSqlRequest.FromString, - response_serializer=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.ResultSet.SerializeToString, - ), - 'ExecuteStreamingSql': grpc.unary_stream_rpc_method_handler( - servicer.ExecuteStreamingSql, - request_deserializer=ExecuteSqlRequest.FromString, - response_serializer=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.PartialResultSet.SerializeToString, - ), - 'Read': grpc.unary_unary_rpc_method_handler( - servicer.Read, - request_deserializer=ReadRequest.FromString, - response_serializer=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.ResultSet.SerializeToString, - ), - 'StreamingRead': grpc.unary_stream_rpc_method_handler( - servicer.StreamingRead, - request_deserializer=ReadRequest.FromString, - response_serializer=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.PartialResultSet.SerializeToString, - ), - 'BeginTransaction': grpc.unary_unary_rpc_method_handler( - servicer.BeginTransaction, - request_deserializer=BeginTransactionRequest.FromString, - response_serializer=google_dot_cloud_dot_spanner__v1_dot_proto_dot_transaction__pb2.Transaction.SerializeToString, - ), - 'Commit': grpc.unary_unary_rpc_method_handler( - servicer.Commit, - request_deserializer=CommitRequest.FromString, - response_serializer=CommitResponse.SerializeToString, - ), - 'Rollback': grpc.unary_unary_rpc_method_handler( - servicer.Rollback, - request_deserializer=RollbackRequest.FromString, - response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ), - 'PartitionQuery': grpc.unary_unary_rpc_method_handler( - servicer.PartitionQuery, - request_deserializer=PartitionQueryRequest.FromString, - response_serializer=PartitionResponse.SerializeToString, - ), - 'PartitionRead': grpc.unary_unary_rpc_method_handler( - servicer.PartitionRead, - request_deserializer=PartitionReadRequest.FromString, - response_serializer=PartitionResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler( - 'google.spanner.v1.Spanner', rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - - class BetaSpannerServicer(object): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This class was generated - only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" - """Cloud Spanner API - - The Cloud Spanner API can be used to manage sessions and execute - transactions on data stored in Cloud Spanner databases. - """ - def CreateSession(self, request, context): - """Creates a new session. A session can be used to perform - transactions that read and/or modify data in a Cloud Spanner database. - Sessions are meant to be reused for many consecutive - transactions. - - Sessions can only execute one transaction at a time. To execute - multiple concurrent read-write/write-only transactions, create - multiple sessions. Note that standalone reads and queries use a - transaction internally, and count toward the one transaction - limit. - - Cloud Spanner limits the number of sessions that can exist at any given - time; thus, it is a good idea to delete idle and/or unneeded sessions. - Aside from explicit deletes, Cloud Spanner can delete sessions for which no - operations are sent for more than an hour. If a session is deleted, - requests to it return `NOT_FOUND`. - - Idle sessions can be kept alive by sending a trivial SQL query - periodically, e.g., `"SELECT 1"`. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def GetSession(self, request, context): - """Gets a session. Returns `NOT_FOUND` if the session does not exist. - This is mainly useful for determining whether a session is still - alive. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def ListSessions(self, request, context): - """Lists all sessions in a given database. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def DeleteSession(self, request, context): - """Ends a session, releasing server resources associated with it. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def ExecuteSql(self, request, context): - """Executes an SQL query, returning all rows in a single reply. This - method cannot be used to return a result set larger than 10 MiB; - if the query yields more data than that, the query fails with - a `FAILED_PRECONDITION` error. - - Queries inside read-write transactions might return `ABORTED`. If - this occurs, the application should restart the transaction from - the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. - - Larger result sets can be fetched in streaming fashion by calling - [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def ExecuteStreamingSql(self, request, context): - """Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the result - set as a stream. Unlike [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there - is no limit on the size of the returned result set. However, no - individual row in the result set can exceed 100 MiB, and no - column value can exceed 10 MiB. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def Read(self, request, context): - """Reads rows from the database using key lookups and scans, as a - simple key/value style alternative to - [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be used to - return a result set larger than 10 MiB; if the read matches more - data than that, the read fails with a `FAILED_PRECONDITION` - error. - - Reads inside read-write transactions might return `ABORTED`. If - this occurs, the application should restart the transaction from - the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. - - Larger result sets can be yielded in streaming fashion by calling - [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def StreamingRead(self, request, context): - """Like [Read][google.spanner.v1.Spanner.Read], except returns the result set as a - stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no limit on the - size of the returned result set. However, no individual row in - the result set can exceed 100 MiB, and no column value can exceed - 10 MiB. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def BeginTransaction(self, request, context): - """Begins a new transaction. This step can often be skipped: - [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and - [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a - side-effect. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def Commit(self, request, context): - """Commits a transaction. The request includes the mutations to be - applied to rows in the database. - - `Commit` might return an `ABORTED` error. This can occur at any time; - commonly, the cause is conflicts with concurrent - transactions. However, it can also happen for a variety of other - reasons. If `Commit` returns `ABORTED`, the caller should re-attempt - the transaction from the beginning, re-using the same session. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def Rollback(self, request, context): - """Rolls back a transaction, releasing any locks it holds. It is a good - idea to call this for any transaction that includes one or more - [Read][google.spanner.v1.Spanner.Read] or [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and - ultimately decides not to commit. - - `Rollback` returns `OK` if it successfully aborts the transaction, the - transaction was already aborted, or the transaction is not - found. `Rollback` never returns `ABORTED`. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def PartitionQuery(self, request, context): - """Creates a set of partition tokens that can be used to execute a query - operation in parallel. Each of the returned partition tokens can be used - by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to specify a subset - of the query result to read. The same session and read-only transaction - must be used by the PartitionQueryRequest used to create the - partition tokens and the ExecuteSqlRequests that use the partition tokens. - Partition tokens become invalid when the session used to create them - is deleted or begins a new transaction. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - def PartitionRead(self, request, context): - """Creates a set of partition tokens that can be used to execute a read - operation in parallel. Each of the returned partition tokens can be used - by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a subset of the read - result to read. The same session and read-only transaction must be used by - the PartitionReadRequest used to create the partition tokens and the - ReadRequests that use the partition tokens. - Partition tokens become invalid when the session used to create them - is deleted or begins a new transaction. - """ - context.code(beta_interfaces.StatusCode.UNIMPLEMENTED) - - - class BetaSpannerStub(object): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This class was generated - only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0.""" - """Cloud Spanner API - - The Cloud Spanner API can be used to manage sessions and execute - transactions on data stored in Cloud Spanner databases. - """ - def CreateSession(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Creates a new session. A session can be used to perform - transactions that read and/or modify data in a Cloud Spanner database. - Sessions are meant to be reused for many consecutive - transactions. - - Sessions can only execute one transaction at a time. To execute - multiple concurrent read-write/write-only transactions, create - multiple sessions. Note that standalone reads and queries use a - transaction internally, and count toward the one transaction - limit. - - Cloud Spanner limits the number of sessions that can exist at any given - time; thus, it is a good idea to delete idle and/or unneeded sessions. - Aside from explicit deletes, Cloud Spanner can delete sessions for which no - operations are sent for more than an hour. If a session is deleted, - requests to it return `NOT_FOUND`. - - Idle sessions can be kept alive by sending a trivial SQL query - periodically, e.g., `"SELECT 1"`. - """ - raise NotImplementedError() - CreateSession.future = None - def GetSession(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Gets a session. Returns `NOT_FOUND` if the session does not exist. - This is mainly useful for determining whether a session is still - alive. - """ - raise NotImplementedError() - GetSession.future = None - def ListSessions(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Lists all sessions in a given database. - """ - raise NotImplementedError() - ListSessions.future = None - def DeleteSession(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Ends a session, releasing server resources associated with it. - """ - raise NotImplementedError() - DeleteSession.future = None - def ExecuteSql(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Executes an SQL query, returning all rows in a single reply. This - method cannot be used to return a result set larger than 10 MiB; - if the query yields more data than that, the query fails with - a `FAILED_PRECONDITION` error. - - Queries inside read-write transactions might return `ABORTED`. If - this occurs, the application should restart the transaction from - the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. - - Larger result sets can be fetched in streaming fashion by calling - [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] instead. - """ - raise NotImplementedError() - ExecuteSql.future = None - def ExecuteStreamingSql(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Like [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], except returns the result - set as a stream. Unlike [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql], there - is no limit on the size of the returned result set. However, no - individual row in the result set can exceed 100 MiB, and no - column value can exceed 10 MiB. - """ - raise NotImplementedError() - def Read(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Reads rows from the database using key lookups and scans, as a - simple key/value style alternative to - [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql]. This method cannot be used to - return a result set larger than 10 MiB; if the read matches more - data than that, the read fails with a `FAILED_PRECONDITION` - error. - - Reads inside read-write transactions might return `ABORTED`. If - this occurs, the application should restart the transaction from - the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. - - Larger result sets can be yielded in streaming fashion by calling - [StreamingRead][google.spanner.v1.Spanner.StreamingRead] instead. - """ - raise NotImplementedError() - Read.future = None - def StreamingRead(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Like [Read][google.spanner.v1.Spanner.Read], except returns the result set as a - stream. Unlike [Read][google.spanner.v1.Spanner.Read], there is no limit on the - size of the returned result set. However, no individual row in - the result set can exceed 100 MiB, and no column value can exceed - 10 MiB. - """ - raise NotImplementedError() - def BeginTransaction(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Begins a new transaction. This step can often be skipped: - [Read][google.spanner.v1.Spanner.Read], [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] and - [Commit][google.spanner.v1.Spanner.Commit] can begin a new transaction as a - side-effect. - """ - raise NotImplementedError() - BeginTransaction.future = None - def Commit(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Commits a transaction. The request includes the mutations to be - applied to rows in the database. - - `Commit` might return an `ABORTED` error. This can occur at any time; - commonly, the cause is conflicts with concurrent - transactions. However, it can also happen for a variety of other - reasons. If `Commit` returns `ABORTED`, the caller should re-attempt - the transaction from the beginning, re-using the same session. - """ - raise NotImplementedError() - Commit.future = None - def Rollback(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Rolls back a transaction, releasing any locks it holds. It is a good - idea to call this for any transaction that includes one or more - [Read][google.spanner.v1.Spanner.Read] or [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] requests and - ultimately decides not to commit. - - `Rollback` returns `OK` if it successfully aborts the transaction, the - transaction was already aborted, or the transaction is not - found. `Rollback` never returns `ABORTED`. - """ - raise NotImplementedError() - Rollback.future = None - def PartitionQuery(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Creates a set of partition tokens that can be used to execute a query - operation in parallel. Each of the returned partition tokens can be used - by [ExecuteStreamingSql][google.spanner.v1.Spanner.ExecuteStreamingSql] to specify a subset - of the query result to read. The same session and read-only transaction - must be used by the PartitionQueryRequest used to create the - partition tokens and the ExecuteSqlRequests that use the partition tokens. - Partition tokens become invalid when the session used to create them - is deleted or begins a new transaction. - """ - raise NotImplementedError() - PartitionQuery.future = None - def PartitionRead(self, request, timeout, metadata=None, with_call=False, protocol_options=None): - """Creates a set of partition tokens that can be used to execute a read - operation in parallel. Each of the returned partition tokens can be used - by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a subset of the read - result to read. The same session and read-only transaction must be used by - the PartitionReadRequest used to create the partition tokens and the - ReadRequests that use the partition tokens. - Partition tokens become invalid when the session used to create them - is deleted or begins a new transaction. - """ - raise NotImplementedError() - PartitionRead.future = None - - - def beta_create_Spanner_server(servicer, pool=None, pool_size=None, default_timeout=None, maximum_timeout=None): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This function was - generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" - request_deserializers = { - ('google.spanner.v1.Spanner', 'BeginTransaction'): BeginTransactionRequest.FromString, - ('google.spanner.v1.Spanner', 'Commit'): CommitRequest.FromString, - ('google.spanner.v1.Spanner', 'CreateSession'): CreateSessionRequest.FromString, - ('google.spanner.v1.Spanner', 'DeleteSession'): DeleteSessionRequest.FromString, - ('google.spanner.v1.Spanner', 'ExecuteSql'): ExecuteSqlRequest.FromString, - ('google.spanner.v1.Spanner', 'ExecuteStreamingSql'): ExecuteSqlRequest.FromString, - ('google.spanner.v1.Spanner', 'GetSession'): GetSessionRequest.FromString, - ('google.spanner.v1.Spanner', 'ListSessions'): ListSessionsRequest.FromString, - ('google.spanner.v1.Spanner', 'PartitionQuery'): PartitionQueryRequest.FromString, - ('google.spanner.v1.Spanner', 'PartitionRead'): PartitionReadRequest.FromString, - ('google.spanner.v1.Spanner', 'Read'): ReadRequest.FromString, - ('google.spanner.v1.Spanner', 'Rollback'): RollbackRequest.FromString, - ('google.spanner.v1.Spanner', 'StreamingRead'): ReadRequest.FromString, - } - response_serializers = { - ('google.spanner.v1.Spanner', 'BeginTransaction'): google_dot_cloud_dot_spanner__v1_dot_proto_dot_transaction__pb2.Transaction.SerializeToString, - ('google.spanner.v1.Spanner', 'Commit'): CommitResponse.SerializeToString, - ('google.spanner.v1.Spanner', 'CreateSession'): Session.SerializeToString, - ('google.spanner.v1.Spanner', 'DeleteSession'): google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ('google.spanner.v1.Spanner', 'ExecuteSql'): google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.ResultSet.SerializeToString, - ('google.spanner.v1.Spanner', 'ExecuteStreamingSql'): google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.PartialResultSet.SerializeToString, - ('google.spanner.v1.Spanner', 'GetSession'): Session.SerializeToString, - ('google.spanner.v1.Spanner', 'ListSessions'): ListSessionsResponse.SerializeToString, - ('google.spanner.v1.Spanner', 'PartitionQuery'): PartitionResponse.SerializeToString, - ('google.spanner.v1.Spanner', 'PartitionRead'): PartitionResponse.SerializeToString, - ('google.spanner.v1.Spanner', 'Read'): google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.ResultSet.SerializeToString, - ('google.spanner.v1.Spanner', 'Rollback'): google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, - ('google.spanner.v1.Spanner', 'StreamingRead'): google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.PartialResultSet.SerializeToString, - } - method_implementations = { - ('google.spanner.v1.Spanner', 'BeginTransaction'): face_utilities.unary_unary_inline(servicer.BeginTransaction), - ('google.spanner.v1.Spanner', 'Commit'): face_utilities.unary_unary_inline(servicer.Commit), - ('google.spanner.v1.Spanner', 'CreateSession'): face_utilities.unary_unary_inline(servicer.CreateSession), - ('google.spanner.v1.Spanner', 'DeleteSession'): face_utilities.unary_unary_inline(servicer.DeleteSession), - ('google.spanner.v1.Spanner', 'ExecuteSql'): face_utilities.unary_unary_inline(servicer.ExecuteSql), - ('google.spanner.v1.Spanner', 'ExecuteStreamingSql'): face_utilities.unary_stream_inline(servicer.ExecuteStreamingSql), - ('google.spanner.v1.Spanner', 'GetSession'): face_utilities.unary_unary_inline(servicer.GetSession), - ('google.spanner.v1.Spanner', 'ListSessions'): face_utilities.unary_unary_inline(servicer.ListSessions), - ('google.spanner.v1.Spanner', 'PartitionQuery'): face_utilities.unary_unary_inline(servicer.PartitionQuery), - ('google.spanner.v1.Spanner', 'PartitionRead'): face_utilities.unary_unary_inline(servicer.PartitionRead), - ('google.spanner.v1.Spanner', 'Read'): face_utilities.unary_unary_inline(servicer.Read), - ('google.spanner.v1.Spanner', 'Rollback'): face_utilities.unary_unary_inline(servicer.Rollback), - ('google.spanner.v1.Spanner', 'StreamingRead'): face_utilities.unary_stream_inline(servicer.StreamingRead), - } - server_options = beta_implementations.server_options(request_deserializers=request_deserializers, response_serializers=response_serializers, thread_pool=pool, thread_pool_size=pool_size, default_timeout=default_timeout, maximum_timeout=maximum_timeout) - return beta_implementations.server(method_implementations, options=server_options) - - - def beta_create_Spanner_stub(channel, host=None, metadata_transformer=None, pool=None, pool_size=None): - """The Beta API is deprecated for 0.15.0 and later. - - It is recommended to use the GA API (classes and functions in this - file not marked beta) for all further purposes. This function was - generated only to ease transition from grpcio<0.15.0 to grpcio>=0.15.0""" - request_serializers = { - ('google.spanner.v1.Spanner', 'BeginTransaction'): BeginTransactionRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'Commit'): CommitRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'CreateSession'): CreateSessionRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'DeleteSession'): DeleteSessionRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'ExecuteSql'): ExecuteSqlRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'ExecuteStreamingSql'): ExecuteSqlRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'GetSession'): GetSessionRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'ListSessions'): ListSessionsRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'PartitionQuery'): PartitionQueryRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'PartitionRead'): PartitionReadRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'Read'): ReadRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'Rollback'): RollbackRequest.SerializeToString, - ('google.spanner.v1.Spanner', 'StreamingRead'): ReadRequest.SerializeToString, - } - response_deserializers = { - ('google.spanner.v1.Spanner', 'BeginTransaction'): google_dot_cloud_dot_spanner__v1_dot_proto_dot_transaction__pb2.Transaction.FromString, - ('google.spanner.v1.Spanner', 'Commit'): CommitResponse.FromString, - ('google.spanner.v1.Spanner', 'CreateSession'): Session.FromString, - ('google.spanner.v1.Spanner', 'DeleteSession'): google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ('google.spanner.v1.Spanner', 'ExecuteSql'): google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.ResultSet.FromString, - ('google.spanner.v1.Spanner', 'ExecuteStreamingSql'): google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.PartialResultSet.FromString, - ('google.spanner.v1.Spanner', 'GetSession'): Session.FromString, - ('google.spanner.v1.Spanner', 'ListSessions'): ListSessionsResponse.FromString, - ('google.spanner.v1.Spanner', 'PartitionQuery'): PartitionResponse.FromString, - ('google.spanner.v1.Spanner', 'PartitionRead'): PartitionResponse.FromString, - ('google.spanner.v1.Spanner', 'Read'): google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.ResultSet.FromString, - ('google.spanner.v1.Spanner', 'Rollback'): google_dot_protobuf_dot_empty__pb2.Empty.FromString, - ('google.spanner.v1.Spanner', 'StreamingRead'): google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2.PartialResultSet.FromString, - } - cardinalities = { - 'BeginTransaction': cardinality.Cardinality.UNARY_UNARY, - 'Commit': cardinality.Cardinality.UNARY_UNARY, - 'CreateSession': cardinality.Cardinality.UNARY_UNARY, - 'DeleteSession': cardinality.Cardinality.UNARY_UNARY, - 'ExecuteSql': cardinality.Cardinality.UNARY_UNARY, - 'ExecuteStreamingSql': cardinality.Cardinality.UNARY_STREAM, - 'GetSession': cardinality.Cardinality.UNARY_UNARY, - 'ListSessions': cardinality.Cardinality.UNARY_UNARY, - 'PartitionQuery': cardinality.Cardinality.UNARY_UNARY, - 'PartitionRead': cardinality.Cardinality.UNARY_UNARY, - 'Read': cardinality.Cardinality.UNARY_UNARY, - 'Rollback': cardinality.Cardinality.UNARY_UNARY, - 'StreamingRead': cardinality.Cardinality.UNARY_STREAM, - } - stub_options = beta_implementations.stub_options(host=host, metadata_transformer=metadata_transformer, request_serializers=request_serializers, response_deserializers=response_deserializers, thread_pool=pool, thread_pool_size=pool_size) - return beta_implementations.dynamic_stub(channel, 'google.spanner.v1.Spanner', cardinalities, options=stub_options) -except ImportError: - pass + +_SPANNER = _descriptor.ServiceDescriptor( + name='Spanner', + full_name='google.spanner.v1.Spanner', + file=DESCRIPTOR, + index=0, + options=None, + serialized_start=3038, + serialized_end=5217, + methods=[ + _descriptor.MethodDescriptor( + name='CreateSession', + full_name='google.spanner.v1.Spanner.CreateSession', + index=0, + containing_service=None, + input_type=_CREATESESSIONREQUEST, + output_type=_SESSION, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002?\":/v1/{database=projects/*/instances/*/databases/*}/sessions:\001*')), + ), + _descriptor.MethodDescriptor( + name='GetSession', + full_name='google.spanner.v1.Spanner.GetSession', + index=1, + containing_service=None, + input_type=_GETSESSIONREQUEST, + output_type=_SESSION, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002:\0228/v1/{name=projects/*/instances/*/databases/*/sessions/*}')), + ), + _descriptor.MethodDescriptor( + name='ListSessions', + full_name='google.spanner.v1.Spanner.ListSessions', + index=2, + containing_service=None, + input_type=_LISTSESSIONSREQUEST, + output_type=_LISTSESSIONSRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002<\022:/v1/{database=projects/*/instances/*/databases/*}/sessions')), + ), + _descriptor.MethodDescriptor( + name='DeleteSession', + full_name='google.spanner.v1.Spanner.DeleteSession', + index=3, + containing_service=None, + input_type=_DELETESESSIONREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002:*8/v1/{name=projects/*/instances/*/databases/*/sessions/*}')), + ), + _descriptor.MethodDescriptor( + name='ExecuteSql', + full_name='google.spanner.v1.Spanner.ExecuteSql', + index=4, + containing_service=None, + input_type=_EXECUTESQLREQUEST, + output_type=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2._RESULTSET, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002K\"F/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeSql:\001*')), + ), + _descriptor.MethodDescriptor( + name='ExecuteStreamingSql', + full_name='google.spanner.v1.Spanner.ExecuteStreamingSql', + index=5, + containing_service=None, + input_type=_EXECUTESQLREQUEST, + output_type=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2._PARTIALRESULTSET, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002T\"O/v1/{session=projects/*/instances/*/databases/*/sessions/*}:executeStreamingSql:\001*')), + ), + _descriptor.MethodDescriptor( + name='Read', + full_name='google.spanner.v1.Spanner.Read', + index=6, + containing_service=None, + input_type=_READREQUEST, + output_type=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2._RESULTSET, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002E\"@/v1/{session=projects/*/instances/*/databases/*/sessions/*}:read:\001*')), + ), + _descriptor.MethodDescriptor( + name='StreamingRead', + full_name='google.spanner.v1.Spanner.StreamingRead', + index=7, + containing_service=None, + input_type=_READREQUEST, + output_type=google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2._PARTIALRESULTSET, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002N\"I/v1/{session=projects/*/instances/*/databases/*/sessions/*}:streamingRead:\001*')), + ), + _descriptor.MethodDescriptor( + name='BeginTransaction', + full_name='google.spanner.v1.Spanner.BeginTransaction', + index=8, + containing_service=None, + input_type=_BEGINTRANSACTIONREQUEST, + output_type=google_dot_cloud_dot_spanner__v1_dot_proto_dot_transaction__pb2._TRANSACTION, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002Q\"L/v1/{session=projects/*/instances/*/databases/*/sessions/*}:beginTransaction:\001*')), + ), + _descriptor.MethodDescriptor( + name='Commit', + full_name='google.spanner.v1.Spanner.Commit', + index=9, + containing_service=None, + input_type=_COMMITREQUEST, + output_type=_COMMITRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002G\"B/v1/{session=projects/*/instances/*/databases/*/sessions/*}:commit:\001*')), + ), + _descriptor.MethodDescriptor( + name='Rollback', + full_name='google.spanner.v1.Spanner.Rollback', + index=10, + containing_service=None, + input_type=_ROLLBACKREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002I\"D/v1/{session=projects/*/instances/*/databases/*/sessions/*}:rollback:\001*')), + ), + _descriptor.MethodDescriptor( + name='PartitionQuery', + full_name='google.spanner.v1.Spanner.PartitionQuery', + index=11, + containing_service=None, + input_type=_PARTITIONQUERYREQUEST, + output_type=_PARTITIONRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002O\"J/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionQuery:\001*')), + ), + _descriptor.MethodDescriptor( + name='PartitionRead', + full_name='google.spanner.v1.Spanner.PartitionRead', + index=12, + containing_service=None, + input_type=_PARTITIONREADREQUEST, + output_type=_PARTITIONRESPONSE, + options=_descriptor._ParseOptions(descriptor_pb2.MethodOptions(), _b('\202\323\344\223\002N\"I/v1/{session=projects/*/instances/*/databases/*/sessions/*}:partitionRead:\001*')), + ), +]) +_sym_db.RegisterServiceDescriptor(_SPANNER) + +DESCRIPTOR.services_by_name['Spanner'] = _SPANNER + # @@protoc_insertion_point(module_scope) diff --git a/spanner/google/cloud/spanner_v1/proto/spanner_pb2_grpc.py b/spanner/google/cloud/spanner_v1/proto/spanner_pb2_grpc.py index 5304d1910dcc..90e89f2f7c6a 100644 --- a/spanner/google/cloud/spanner_v1/proto/spanner_pb2_grpc.py +++ b/spanner/google/cloud/spanner_v1/proto/spanner_pb2_grpc.py @@ -1,10 +1,10 @@ # Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! import grpc -import google.cloud.spanner_v1.proto.result_set_pb2 as google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2 -import google.cloud.spanner_v1.proto.spanner_pb2 as google_dot_cloud_dot_spanner__v1_dot_proto_dot_spanner__pb2 -import google.cloud.spanner_v1.proto.transaction_pb2 as google_dot_cloud_dot_spanner__v1_dot_proto_dot_transaction__pb2 -import google.protobuf.empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.cloud.spanner_v1.proto import result_set_pb2 as google_dot_cloud_dot_spanner__v1_dot_proto_dot_result__set__pb2 +from google.cloud.spanner_v1.proto import spanner_pb2 as google_dot_cloud_dot_spanner__v1_dot_proto_dot_spanner__pb2 +from google.cloud.spanner_v1.proto import transaction_pb2 as google_dot_cloud_dot_spanner__v1_dot_proto_dot_transaction__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 class SpannerStub(object): @@ -143,12 +143,12 @@ def DeleteSession(self, request, context): raise NotImplementedError('Method not implemented!') def ExecuteSql(self, request, context): - """Executes an SQL query, returning all rows in a single reply. This + """Executes an SQL statement, returning all results in a single reply. This method cannot be used to return a result set larger than 10 MiB; if the query yields more data than that, the query fails with a `FAILED_PRECONDITION` error. - Queries inside read-write transactions might return `ABORTED`. If + Operations inside read-write transactions might return `ABORTED`. If this occurs, the application should restart the transaction from the beginning. See [Transaction][google.spanner.v1.Transaction] for more details. @@ -245,8 +245,11 @@ def PartitionQuery(self, request, context): of the query result to read. The same session and read-only transaction must be used by the PartitionQueryRequest used to create the partition tokens and the ExecuteSqlRequests that use the partition tokens. + Partition tokens become invalid when the session used to create them - is deleted or begins a new transaction. + is deleted, is idle for too long, begins a new transaction, or becomes too + old. When any of these happen, it is not possible to resume the query, and + the whole operation must be restarted from the beginning. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') @@ -258,9 +261,14 @@ def PartitionRead(self, request, context): by [StreamingRead][google.spanner.v1.Spanner.StreamingRead] to specify a subset of the read result to read. The same session and read-only transaction must be used by the PartitionReadRequest used to create the partition tokens and the - ReadRequests that use the partition tokens. + ReadRequests that use the partition tokens. There are no ordering + guarantees on rows returned among the returned partition tokens, or even + within each individual StreamingRead call issued with a partition_token. + Partition tokens become invalid when the session used to create them - is deleted or begins a new transaction. + is deleted, is idle for too long, begins a new transaction, or becomes too + old. When any of these happen, it is not possible to resume the read, and + the whole operation must be restarted from the beginning. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) context.set_details('Method not implemented!') diff --git a/spanner/google/cloud/spanner_v1/proto/transaction_pb2.py b/spanner/google/cloud/spanner_v1/proto/transaction_pb2.py index 3715d50de3f0..5ccfa5160f15 100644 --- a/spanner/google/cloud/spanner_v1/proto/transaction_pb2.py +++ b/spanner/google/cloud/spanner_v1/proto/transaction_pb2.py @@ -22,10 +22,9 @@ name='google/cloud/spanner_v1/proto/transaction.proto', package='google.spanner.v1', syntax='proto3', - serialized_pb=_b('\n/google/cloud/spanner_v1/proto/transaction.proto\x12\x11google.spanner.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xe0\x03\n\x12TransactionOptions\x12\x45\n\nread_write\x18\x01 \x01(\x0b\x32/.google.spanner.v1.TransactionOptions.ReadWriteH\x00\x12\x43\n\tread_only\x18\x02 \x01(\x0b\x32..google.spanner.v1.TransactionOptions.ReadOnlyH\x00\x1a\x0b\n\tReadWrite\x1a\xa8\x02\n\x08ReadOnly\x12\x10\n\x06strong\x18\x01 \x01(\x08H\x00\x12\x38\n\x12min_read_timestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x12\x32\n\rmax_staleness\x18\x03 \x01(\x0b\x32\x19.google.protobuf.DurationH\x00\x12\x34\n\x0eread_timestamp\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x12\x34\n\x0f\x65xact_staleness\x18\x05 \x01(\x0b\x32\x19.google.protobuf.DurationH\x00\x12\x1d\n\x15return_read_timestamp\x18\x06 \x01(\x08\x42\x11\n\x0ftimestamp_boundB\x06\n\x04mode\"M\n\x0bTransaction\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\x32\n\x0eread_timestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\xa4\x01\n\x13TransactionSelector\x12;\n\nsingle_use\x18\x01 \x01(\x0b\x32%.google.spanner.v1.TransactionOptionsH\x00\x12\x0c\n\x02id\x18\x02 \x01(\x0cH\x00\x12\x36\n\x05\x62\x65gin\x18\x03 \x01(\x0b\x32%.google.spanner.v1.TransactionOptionsH\x00\x42\n\n\x08selectorB\x99\x01\n\x15\x63om.google.spanner.v1B\x10TransactionProtoP\x01Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\xaa\x02\x17Google.Cloud.Spanner.V1\xca\x02\x17Google\\Cloud\\Spanner\\V1b\x06proto3') + serialized_pb=_b('\n/google/cloud/spanner_v1/proto/transaction.proto\x12\x11google.spanner.v1\x1a\x1cgoogle/api/annotations.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\"\xc3\x04\n\x12TransactionOptions\x12\x45\n\nread_write\x18\x01 \x01(\x0b\x32/.google.spanner.v1.TransactionOptions.ReadWriteH\x00\x12O\n\x0fpartitioned_dml\x18\x03 \x01(\x0b\x32\x34.google.spanner.v1.TransactionOptions.PartitionedDmlH\x00\x12\x43\n\tread_only\x18\x02 \x01(\x0b\x32..google.spanner.v1.TransactionOptions.ReadOnlyH\x00\x1a\x0b\n\tReadWrite\x1a\x10\n\x0ePartitionedDml\x1a\xa8\x02\n\x08ReadOnly\x12\x10\n\x06strong\x18\x01 \x01(\x08H\x00\x12\x38\n\x12min_read_timestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x12\x32\n\rmax_staleness\x18\x03 \x01(\x0b\x32\x19.google.protobuf.DurationH\x00\x12\x34\n\x0eread_timestamp\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.TimestampH\x00\x12\x34\n\x0f\x65xact_staleness\x18\x05 \x01(\x0b\x32\x19.google.protobuf.DurationH\x00\x12\x1d\n\x15return_read_timestamp\x18\x06 \x01(\x08\x42\x11\n\x0ftimestamp_boundB\x06\n\x04mode\"M\n\x0bTransaction\x12\n\n\x02id\x18\x01 \x01(\x0c\x12\x32\n\x0eread_timestamp\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\"\xa4\x01\n\x13TransactionSelector\x12;\n\nsingle_use\x18\x01 \x01(\x0b\x32%.google.spanner.v1.TransactionOptionsH\x00\x12\x0c\n\x02id\x18\x02 \x01(\x0cH\x00\x12\x36\n\x05\x62\x65gin\x18\x03 \x01(\x0b\x32%.google.spanner.v1.TransactionOptionsH\x00\x42\n\n\x08selectorB\x99\x01\n\x15\x63om.google.spanner.v1B\x10TransactionProtoP\x01Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\xaa\x02\x17Google.Cloud.Spanner.V1\xca\x02\x17Google\\Cloud\\Spanner\\V1b\x06proto3') , dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_protobuf_dot_duration__pb2.DESCRIPTOR,google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) @@ -49,8 +48,31 @@ extension_ranges=[], oneofs=[ ], - serialized_start=328, - serialized_end=339, + serialized_start=409, + serialized_end=420, +) + +_TRANSACTIONOPTIONS_PARTITIONEDDML = _descriptor.Descriptor( + name='PartitionedDml', + full_name='google.spanner.v1.TransactionOptions.PartitionedDml', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=422, + serialized_end=438, ) _TRANSACTIONOPTIONS_READONLY = _descriptor.Descriptor( @@ -66,42 +88,42 @@ has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='min_read_timestamp', full_name='google.spanner.v1.TransactionOptions.ReadOnly.min_read_timestamp', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='max_staleness', full_name='google.spanner.v1.TransactionOptions.ReadOnly.max_staleness', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='read_timestamp', full_name='google.spanner.v1.TransactionOptions.ReadOnly.read_timestamp', index=3, number=4, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='exact_staleness', full_name='google.spanner.v1.TransactionOptions.ReadOnly.exact_staleness', index=4, number=5, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='return_read_timestamp', full_name='google.spanner.v1.TransactionOptions.ReadOnly.return_read_timestamp', index=5, number=6, type=8, cpp_type=7, label=1, has_default_value=False, default_value=False, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -117,8 +139,8 @@ name='timestamp_bound', full_name='google.spanner.v1.TransactionOptions.ReadOnly.timestamp_bound', index=0, containing_type=None, fields=[]), ], - serialized_start=342, - serialized_end=638, + serialized_start=441, + serialized_end=737, ) _TRANSACTIONOPTIONS = _descriptor.Descriptor( @@ -134,18 +156,25 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( - name='read_only', full_name='google.spanner.v1.TransactionOptions.read_only', index=1, + name='partitioned_dml', full_name='google.spanner.v1.TransactionOptions.partitioned_dml', index=1, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None, file=DESCRIPTOR), + _descriptor.FieldDescriptor( + name='read_only', full_name='google.spanner.v1.TransactionOptions.read_only', index=2, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], - nested_types=[_TRANSACTIONOPTIONS_READWRITE, _TRANSACTIONOPTIONS_READONLY, ], + nested_types=[_TRANSACTIONOPTIONS_READWRITE, _TRANSACTIONOPTIONS_PARTITIONEDDML, _TRANSACTIONOPTIONS_READONLY, ], enum_types=[ ], options=None, @@ -158,7 +187,7 @@ index=0, containing_type=None, fields=[]), ], serialized_start=166, - serialized_end=646, + serialized_end=745, ) @@ -175,14 +204,14 @@ has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='read_timestamp', full_name='google.spanner.v1.Transaction.read_timestamp', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -195,8 +224,8 @@ extension_ranges=[], oneofs=[ ], - serialized_start=648, - serialized_end=725, + serialized_start=747, + serialized_end=824, ) @@ -213,21 +242,21 @@ has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='id', full_name='google.spanner.v1.TransactionSelector.id', index=1, number=2, type=12, cpp_type=9, label=1, has_default_value=False, default_value=_b(""), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='begin', full_name='google.spanner.v1.TransactionSelector.begin', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -243,11 +272,12 @@ name='selector', full_name='google.spanner.v1.TransactionSelector.selector', index=0, containing_type=None, fields=[]), ], - serialized_start=728, - serialized_end=892, + serialized_start=827, + serialized_end=991, ) _TRANSACTIONOPTIONS_READWRITE.containing_type = _TRANSACTIONOPTIONS +_TRANSACTIONOPTIONS_PARTITIONEDDML.containing_type = _TRANSACTIONOPTIONS _TRANSACTIONOPTIONS_READONLY.fields_by_name['min_read_timestamp'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP _TRANSACTIONOPTIONS_READONLY.fields_by_name['max_staleness'].message_type = google_dot_protobuf_dot_duration__pb2._DURATION _TRANSACTIONOPTIONS_READONLY.fields_by_name['read_timestamp'].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP @@ -269,10 +299,14 @@ _TRANSACTIONOPTIONS_READONLY.fields_by_name['exact_staleness']) _TRANSACTIONOPTIONS_READONLY.fields_by_name['exact_staleness'].containing_oneof = _TRANSACTIONOPTIONS_READONLY.oneofs_by_name['timestamp_bound'] _TRANSACTIONOPTIONS.fields_by_name['read_write'].message_type = _TRANSACTIONOPTIONS_READWRITE +_TRANSACTIONOPTIONS.fields_by_name['partitioned_dml'].message_type = _TRANSACTIONOPTIONS_PARTITIONEDDML _TRANSACTIONOPTIONS.fields_by_name['read_only'].message_type = _TRANSACTIONOPTIONS_READONLY _TRANSACTIONOPTIONS.oneofs_by_name['mode'].fields.append( _TRANSACTIONOPTIONS.fields_by_name['read_write']) _TRANSACTIONOPTIONS.fields_by_name['read_write'].containing_oneof = _TRANSACTIONOPTIONS.oneofs_by_name['mode'] +_TRANSACTIONOPTIONS.oneofs_by_name['mode'].fields.append( + _TRANSACTIONOPTIONS.fields_by_name['partitioned_dml']) +_TRANSACTIONOPTIONS.fields_by_name['partitioned_dml'].containing_oneof = _TRANSACTIONOPTIONS.oneofs_by_name['mode'] _TRANSACTIONOPTIONS.oneofs_by_name['mode'].fields.append( _TRANSACTIONOPTIONS.fields_by_name['read_only']) _TRANSACTIONOPTIONS.fields_by_name['read_only'].containing_oneof = _TRANSACTIONOPTIONS.oneofs_by_name['mode'] @@ -291,6 +325,7 @@ DESCRIPTOR.message_types_by_name['TransactionOptions'] = _TRANSACTIONOPTIONS DESCRIPTOR.message_types_by_name['Transaction'] = _TRANSACTION DESCRIPTOR.message_types_by_name['TransactionSelector'] = _TRANSACTIONSELECTOR +_sym_db.RegisterFileDescriptor(DESCRIPTOR) TransactionOptions = _reflection.GeneratedProtocolMessageType('TransactionOptions', (_message.Message,), dict( @@ -305,13 +340,23 @@ )) , + PartitionedDml = _reflection.GeneratedProtocolMessageType('PartitionedDml', (_message.Message,), dict( + DESCRIPTOR = _TRANSACTIONOPTIONS_PARTITIONEDDML, + __module__ = 'google.cloud.spanner_v1.proto.transaction_pb2' + , + __doc__ = """Message type to initiate a Partitioned DML transaction. + """, + # @@protoc_insertion_point(class_scope:google.spanner.v1.TransactionOptions.PartitionedDml) + )) + , + ReadOnly = _reflection.GeneratedProtocolMessageType('ReadOnly', (_message.Message,), dict( DESCRIPTOR = _TRANSACTIONOPTIONS_READONLY, __module__ = 'google.cloud.spanner_v1.proto.transaction_pb2' , __doc__ = """Message type to initiate a read-only transaction. - - + + Attributes: timestamp_bound: How to choose the timestamp for the read-only transaction. @@ -369,8 +414,294 @@ DESCRIPTOR = _TRANSACTIONOPTIONS, __module__ = 'google.cloud.spanner_v1.proto.transaction_pb2' , - __doc__ = """ See :ref:`spanner-txn` for more information about transactions. - + __doc__ = """Transactions + + + Each session can have at most one active transaction at a time. After + the active transaction is completed, the session can immediately be + re-used for the next transaction. It is not necessary to create a new + session for each transaction. + + Transaction Modes + + + Cloud Spanner supports three transaction modes: + + 1. Locking read-write. This type of transaction is the only way to write + data into Cloud Spanner. These transactions rely on pessimistic + locking and, if necessary, two-phase commit. Locking read-write + transactions may abort, requiring the application to retry. + + 2. Snapshot read-only. This transaction type provides guaranteed + consistency across several reads, but does not allow writes. Snapshot + read-only transactions can be configured to read at timestamps in the + past. Snapshot read-only transactions do not need to be committed. + + 3. Partitioned DML. This type of transaction is used to execute a single + Partitioned DML statement. Partitioned DML partitions the key space + and runs the DML statement over each partition in parallel using + separate, internal transactions that commit independently. + Partitioned DML transactions do not need to be committed. + + For transactions that only read, snapshot read-only transactions provide + simpler semantics and are almost always faster. In particular, read-only + transactions do not take locks, so they do not conflict with read-write + transactions. As a consequence of not taking locks, they also do not + abort, so retry loops are not needed. + + Transactions may only read/write data in a single database. They may, + however, read/write data in different tables within that database. + + Locking Read-Write Transactions + + + Locking transactions may be used to atomically read-modify-write data + anywhere in a database. This type of transaction is externally + consistent. + + Clients should attempt to minimize the amount of time a transaction is + active. Faster transactions commit with higher probability and cause + less contention. Cloud Spanner attempts to keep read locks active as + long as the transaction continues to do reads, and the transaction has + not been terminated by [Commit][google.spanner.v1.Spanner.Commit] or + [Rollback][google.spanner.v1.Spanner.Rollback]. Long periods of + inactivity at the client may cause Cloud Spanner to release a + transaction's locks and abort it. + + Conceptually, a read-write transaction consists of zero or more reads or + SQL statements followed by [Commit][google.spanner.v1.Spanner.Commit]. + At any time before [Commit][google.spanner.v1.Spanner.Commit], the + client can send a [Rollback][google.spanner.v1.Spanner.Rollback] request + to abort the transaction. + + Semantics + + + Cloud Spanner can commit the transaction if all read locks it acquired + are still valid at commit time, and it is able to acquire write locks + for all writes. Cloud Spanner can abort the transaction for any reason. + If a commit attempt returns ``ABORTED``, Cloud Spanner guarantees that + the transaction has not modified any user data in Cloud Spanner. + + Unless the transaction commits, Cloud Spanner makes no guarantees about + how long the transaction's locks were held for. It is an error to use + Cloud Spanner locks for any sort of mutual exclusion other than between + Cloud Spanner transactions themselves. + + Retrying Aborted Transactions + + + When a transaction aborts, the application can choose to retry the whole + transaction again. To maximize the chances of successfully committing + the retry, the client should execute the retry in the same session as + the original attempt. The original session's lock priority increases + with each consecutive abort, meaning that each attempt has a slightly + better chance of success than the previous. + + Under some circumstances (e.g., many transactions attempting to modify + the same row(s)), a transaction can abort many times in a short period + before successfully committing. Thus, it is not a good idea to cap the + number of retries a transaction can attempt; instead, it is better to + limit the total amount of wall time spent retrying. + + Idle Transactions + + + A transaction is considered idle if it has no outstanding reads or SQL + queries and has not started a read or SQL query within the last 10 + seconds. Idle transactions can be aborted by Cloud Spanner so that they + don't hold on to locks indefinitely. In that case, the commit will fail + with error ``ABORTED``. + + If this behavior is undesirable, periodically executing a simple SQL + query in the transaction (e.g., ``SELECT 1``) prevents the transaction + from becoming idle. + + Snapshot Read-Only Transactions + + + Snapshot read-only transactions provides a simpler method than locking + read-write transactions for doing several consistent reads. However, + this type of transaction does not support writes. + + Snapshot transactions do not take locks. Instead, they work by choosing + a Cloud Spanner timestamp, then executing all reads at that timestamp. + Since they do not acquire locks, they do not block concurrent read-write + transactions. + + Unlike locking read-write transactions, snapshot read-only transactions + never abort. They can fail if the chosen read timestamp is garbage + collected; however, the default garbage collection policy is generous + enough that most applications do not need to worry about this in + practice. + + Snapshot read-only transactions do not need to call + [Commit][google.spanner.v1.Spanner.Commit] or + [Rollback][google.spanner.v1.Spanner.Rollback] (and in fact are not + permitted to do so). + + To execute a snapshot transaction, the client specifies a timestamp + bound, which tells Cloud Spanner how to choose a read timestamp. + + The types of timestamp bound are: + + - Strong (the default). + - Bounded staleness. + - Exact staleness. + + If the Cloud Spanner database to be read is geographically distributed, + stale read-only transactions can execute more quickly than strong or + read-write transaction, because they are able to execute far from the + leader replica. + + Each type of timestamp bound is discussed in detail below. + + Strong + + + Strong reads are guaranteed to see the effects of all transactions that + have committed before the start of the read. Furthermore, all rows + yielded by a single read are consistent with each other -- if any part + of the read observes a transaction, all parts of the read see the + transaction. + + Strong reads are not repeatable: two consecutive strong read-only + transactions might return inconsistent results if there are concurrent + writes. If consistency across reads is required, the reads should be + executed within a transaction or at an exact read timestamp. + + See + [TransactionOptions.ReadOnly.strong][google.spanner.v1.TransactionOptions.ReadOnly.strong]. + + Exact Staleness + + + These timestamp bounds execute reads at a user-specified timestamp. + Reads at a timestamp are guaranteed to see a consistent prefix of the + global transaction history: they observe modifications done by all + transactions with a commit timestamp <= the read timestamp, and observe + none of the modifications done by transactions with a larger commit + timestamp. They will block until all conflicting transactions that may + be assigned commit timestamps <= the read timestamp have finished. + + The timestamp can either be expressed as an absolute Cloud Spanner + commit timestamp or a staleness relative to the current time. + + These modes do not require a "negotiation phase" to pick a timestamp. As + a result, they execute slightly faster than the equivalent boundedly + stale concurrency modes. On the other hand, boundedly stale reads + usually return fresher results. + + See + [TransactionOptions.ReadOnly.read\_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.read\_timestamp] + and + [TransactionOptions.ReadOnly.exact\_staleness][google.spanner.v1.TransactionOptions.ReadOnly.exact\_staleness]. + + Bounded Staleness + + + Bounded staleness modes allow Cloud Spanner to pick the read timestamp, + subject to a user-provided staleness bound. Cloud Spanner chooses the + newest timestamp within the staleness bound that allows execution of the + reads at the closest available replica without blocking. + + All rows yielded are consistent with each other -- if any part of the + read observes a transaction, all parts of the read see the transaction. + Boundedly stale reads are not repeatable: two stale reads, even if they + use the same staleness bound, can execute at different timestamps and + thus return inconsistent results. + + Boundedly stale reads execute in two phases: the first phase negotiates + a timestamp among all replicas needed to serve the read. In the second + phase, reads are executed at the negotiated timestamp. + + As a result of the two phase execution, bounded staleness reads are + usually a little slower than comparable exact staleness reads. However, + they are typically able to return fresher results, and are more likely + to execute at the closest replica. + + Because the timestamp negotiation requires up-front knowledge of which + rows will be read, it can only be used with single-use read-only + transactions. + + See + [TransactionOptions.ReadOnly.max\_staleness][google.spanner.v1.TransactionOptions.ReadOnly.max\_staleness] + and + [TransactionOptions.ReadOnly.min\_read\_timestamp][google.spanner.v1.TransactionOptions.ReadOnly.min\_read\_timestamp]. + + Old Read Timestamps and Garbage Collection + + + Cloud Spanner continuously garbage collects deleted and overwritten data + in the background to reclaim storage space. This process is known as + "version GC". By default, version GC reclaims versions after they are + one hour old. Because of this, Cloud Spanner cannot perform reads at + read timestamps more than one hour in the past. This restriction also + applies to in-progress reads and/or SQL queries whose timestamp become + too old while executing. Reads and SQL queries with too-old read + timestamps fail with the error ``FAILED_PRECONDITION``. + + Partitioned DML Transactions + + + Partitioned DML transactions are used to execute DML statements with a + different execution strategy that provides different, and often better, + scalability properties for large, table-wide operations than DML in a + ReadWrite transaction. Smaller scoped statements, such as an OLTP + workload, should prefer using ReadWrite transactions. + + Partitioned DML partitions the keyspace and runs the DML statement on + each partition in separate, internal transactions. These transactions + commit automatically when complete, and run independently from one + another. + + To reduce lock contention, this execution strategy only acquires read + locks on rows that match the WHERE clause of the statement. + Additionally, the smaller per-partition transactions hold locks for less + time. + + That said, Partitioned DML is not a drop-in replacement for standard DML + used in ReadWrite transactions. + + - The DML statement must be fully-partitionable. Specifically, the + statement must be expressible as the union of many statements which + each access only a single row of the table. + + - The statement is not applied atomically to all rows of the table. + Rather, the statement is applied atomically to partitions of the + table, in independent transactions. Secondary index rows are updated + atomically with the base table rows. + + - Partitioned DML does not guarantee exactly-once execution semantics + against a partition. The statement will be applied at least once to + each partition. It is strongly recommended that the DML statement + should be idempotent to avoid unexpected results. For instance, it is + potentially dangerous to run a statement such as + ``UPDATE table SET column = column + 1`` as it could be run multiple + times against some rows. + + - The partitions are committed automatically - there is no support for + Commit or Rollback. If the call returns an error, or if the client + issuing the ExecuteSql call dies, it is possible that some rows had + the statement executed on them successfully. It is also possible that + statement was never executed against other rows. + + - Partitioned DML transactions may only contain the execution of a + single DML statement via ExecuteSql or ExecuteStreamingSql. + + - If any error is encountered during the execution of the partitioned + DML operation (for instance, a UNIQUE INDEX violation, division by + zero, or a value that cannot be stored due to schema constraints), + then the operation is stopped at that point and an error is returned. + It is possible that at this point, some partitions have been + committed (or even committed multiple times), and other partitions + have not been run at all. + + Given the above, Partitioned DML is good fit for large, database-wide, + operations that are idempotent, such as deleting old rows from a very + large table. + + Attributes: mode: Required. The type of transaction. @@ -379,6 +710,11 @@ transaction requires ``spanner.databases.beginOrRollbackReadWriteTransaction`` permission on the ``session`` resource. + partitioned_dml: + Partitioned DML transaction. Authorization to begin a + Partitioned DML transaction requires + ``spanner.databases.beginPartitionedDmlTransaction`` + permission on the ``session`` resource. read_only: Transaction will not write. Authorization to begin a read- only transaction requires @@ -389,15 +725,16 @@ )) _sym_db.RegisterMessage(TransactionOptions) _sym_db.RegisterMessage(TransactionOptions.ReadWrite) +_sym_db.RegisterMessage(TransactionOptions.PartitionedDml) _sym_db.RegisterMessage(TransactionOptions.ReadOnly) Transaction = _reflection.GeneratedProtocolMessageType('Transaction', (_message.Message,), dict( DESCRIPTOR = _TRANSACTION, __module__ = 'google.cloud.spanner_v1.proto.transaction_pb2' , - __doc__ = """A transaction. See :ref:`spanner-txn` for more information. - - + __doc__ = """A transaction. + + Attributes: id: ``id`` may be used to identify the transaction in subsequent @@ -426,11 +763,11 @@ __doc__ = """This message is used to select the transaction in which a [Read][google.spanner.v1.Spanner.Read] or [ExecuteSql][google.spanner.v1.Spanner.ExecuteSql] call runs. - + See [TransactionOptions][google.spanner.v1.TransactionOptions] for more information about transactions. - - + + Attributes: selector: If no fields are set, the default is a single use transaction @@ -456,14 +793,4 @@ DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\025com.google.spanner.v1B\020TransactionProtoP\001Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\252\002\027Google.Cloud.Spanner.V1\312\002\027Google\\Cloud\\Spanner\\V1')) -try: - # THESE ELEMENTS WILL BE DEPRECATED. - # Please use the generated *_pb2_grpc.py files instead. - import grpc - from grpc.beta import implementations as beta_implementations - from grpc.beta import interfaces as beta_interfaces - from grpc.framework.common import cardinality - from grpc.framework.interfaces.face import utilities as face_utilities -except ImportError: - pass # @@protoc_insertion_point(module_scope) diff --git a/spanner/google/cloud/spanner_v1/proto/type_pb2.py b/spanner/google/cloud/spanner_v1/proto/type_pb2.py index 40dcdce81a24..5467deb39e1f 100644 --- a/spanner/google/cloud/spanner_v1/proto/type_pb2.py +++ b/spanner/google/cloud/spanner_v1/proto/type_pb2.py @@ -24,7 +24,6 @@ serialized_pb=_b('\n(google/cloud/spanner_v1/proto/type.proto\x12\x11google.spanner.v1\x1a\x1cgoogle/api/annotations.proto\"\x9a\x01\n\x04Type\x12)\n\x04\x63ode\x18\x01 \x01(\x0e\x32\x1b.google.spanner.v1.TypeCode\x12\x33\n\x12\x61rray_element_type\x18\x02 \x01(\x0b\x32\x17.google.spanner.v1.Type\x12\x32\n\x0bstruct_type\x18\x03 \x01(\x0b\x32\x1d.google.spanner.v1.StructType\"\x7f\n\nStructType\x12\x33\n\x06\x66ields\x18\x01 \x03(\x0b\x32#.google.spanner.v1.StructType.Field\x1a<\n\x05\x46ield\x12\x0c\n\x04name\x18\x01 \x01(\t\x12%\n\x04type\x18\x02 \x01(\x0b\x32\x17.google.spanner.v1.Type*\x8e\x01\n\x08TypeCode\x12\x19\n\x15TYPE_CODE_UNSPECIFIED\x10\x00\x12\x08\n\x04\x42OOL\x10\x01\x12\t\n\x05INT64\x10\x02\x12\x0b\n\x07\x46LOAT64\x10\x03\x12\r\n\tTIMESTAMP\x10\x04\x12\x08\n\x04\x44\x41TE\x10\x05\x12\n\n\x06STRING\x10\x06\x12\t\n\x05\x42YTES\x10\x07\x12\t\n\x05\x41RRAY\x10\x08\x12\n\n\x06STRUCT\x10\tB\x92\x01\n\x15\x63om.google.spanner.v1B\tTypeProtoP\x01Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\xaa\x02\x17Google.Cloud.Spanner.V1\xca\x02\x17Google\\Cloud\\Spanner\\V1b\x06proto3') , dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR,]) -_sym_db.RegisterFileDescriptor(DESCRIPTOR) _TYPECODE = _descriptor.EnumDescriptor( name='TypeCode', @@ -107,21 +106,21 @@ has_default_value=False, default_value=0, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='array_element_type', full_name='google.spanner.v1.Type.array_element_type', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='struct_type', full_name='google.spanner.v1.Type.struct_type', index=2, number=3, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -152,14 +151,14 @@ has_default_value=False, default_value=_b("").decode('utf-8'), message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), _descriptor.FieldDescriptor( name='type', full_name='google.spanner.v1.StructType.Field.type', index=1, number=2, type=11, cpp_type=10, label=1, has_default_value=False, default_value=None, message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -189,7 +188,7 @@ has_default_value=False, default_value=[], message_type=None, enum_type=None, containing_type=None, is_extension=False, extension_scope=None, - options=None), + options=None, file=DESCRIPTOR), ], extensions=[ ], @@ -215,6 +214,7 @@ DESCRIPTOR.message_types_by_name['Type'] = _TYPE DESCRIPTOR.message_types_by_name['StructType'] = _STRUCTTYPE DESCRIPTOR.enum_types_by_name['TypeCode'] = _TYPECODE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) Type = _reflection.GeneratedProtocolMessageType('Type', (_message.Message,), dict( DESCRIPTOR = _TYPE, @@ -291,14 +291,4 @@ DESCRIPTOR.has_options = True DESCRIPTOR._options = _descriptor._ParseOptions(descriptor_pb2.FileOptions(), _b('\n\025com.google.spanner.v1B\tTypeProtoP\001Z8google.golang.org/genproto/googleapis/spanner/v1;spanner\252\002\027Google.Cloud.Spanner.V1\312\002\027Google\\Cloud\\Spanner\\V1')) -try: - # THESE ELEMENTS WILL BE DEPRECATED. - # Please use the generated *_pb2_grpc.py files instead. - import grpc - from grpc.beta import implementations as beta_implementations - from grpc.beta import interfaces as beta_interfaces - from grpc.framework.common import cardinality - from grpc.framework.interfaces.face import utilities as face_utilities -except ImportError: - pass # @@protoc_insertion_point(module_scope) diff --git a/spanner/synth.py b/spanner/synth.py new file mode 100644 index 000000000000..4af69ce0a111 --- /dev/null +++ b/spanner/synth.py @@ -0,0 +1,248 @@ +# Copyright 2018 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. + +"""This script is used to synthesize generated parts of this library.""" +import synthtool as s +from synthtool import gcp + +gapic = gcp.GAPICGenerator() + + +#---------------------------------------------------------------------------- +# Generate spanner client +#---------------------------------------------------------------------------- +library = gapic.py_library( + 'spanner', + 'v1', + config_path='/google/spanner/artman_spanner.yaml', + artman_output_name='spanner-v1') + +s.move(library / 'google/cloud/spanner_v1/proto') +s.move(library / 'google/cloud/spanner_v1/gapic') + +# Add grpcio-gcp options +s.replace( + "google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py", + '# limitations under the License.\n' + '\n' + 'import google.api_core.grpc_helpers\n', + '# limitations under the License.\n' + '\n' + 'import pkg_resources\n' + 'import grpc_gcp\n' + '\n' + 'import google.api_core.grpc_helpers\n', +) +s.replace( + "google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py", + 'from google.cloud.spanner_v1.proto import spanner_pb2_grpc\n', + "\g<0>\n\n_SPANNER_GRPC_CONFIG = 'spanner.grpc.config'\n", +) + +s.replace( + "google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py", + '(\s+)return google.api_core.grpc_helpers.create_channel\(\n', + '\g<1>grpc_gcp_config = grpc_gcp.api_config_from_text_pb(' + '\g<1> pkg_resources.resource_string(__name__, _SPANNER_GRPC_CONFIG))' + '\g<1>options = [(grpc_gcp.API_CONFIG_CHANNEL_ARG, grpc_gcp_config)]' + '\g<0>', +) + +#---------------------------------------------------------------------------- +# Generate instance admin client +#---------------------------------------------------------------------------- +library = gapic.py_library( + 'spanner_admin_instance', + 'v1', + config_path='/google/spanner/admin/instance' + '/artman_spanner_admin_instance.yaml', + artman_output_name='spanner-admin-instance-v1') + +s.move(library / 'google/cloud/spanner_admin_instance_v1/gapic') +s.move(library / 'google/cloud/spanner_admin_instance_v1/proto') +s.move(library / 'tests') + +# Fix up the _GAPIC_LIBRARY_VERSION targets +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + "'google-cloud-spanner-admin-instance'", + "'google-cloud-spanner'", +) + +# Fix up generated imports +s.replace( + "google/**/*.py", + 'from google\.cloud\.spanner\.admin\.instance_v1.proto', + 'from google.cloud.spanner_admin_instance_v1.proto', +) + +# Fix docstrings +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + r""" + \* The instance is readable via the API, with all requested attributes + but no allocated resources. Its state is `CREATING`.""", + r""" + * The instance is readable via the API, with all requested attributes + but no allocated resources. Its state is `CREATING`.""", +) +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + r""" + \* Cancelling the operation renders the instance immediately unreadable + via the API.""", + r""" + * Cancelling the operation renders the instance immediately unreadable + via the API.""", +) +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + r""" + \* Billing for all successfully-allocated resources begins \(some types + may have lower than the requested levels\).""", + r""" + * Billing for all successfully-allocated resources begins (some types + may have lower than the requested levels).""", +) +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + r""" + \* The instance and \*all of its databases\* immediately and + irrevocably disappear from the API. All data in the databases + is permanently deleted.""", + r""" + * The instance and *all of its databases* immediately and + irrevocably disappear from the API. All data in the databases + is permanently deleted.""", +) +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + r""" + \* ``labels.env:dev`` --> The instance has the label \\"env\\" and the value of + :: + + the label contains the string \\"dev\\".""", + r""" + * ``labels.env:dev`` --> The instance has the label \\"env\\" + and the value of the label contains the string \\"dev\\".""", +) +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + r""" + \* ``name:howl labels.env:dev`` --> The instance's name contains \\"howl\\" and + :: + + it has the label \\"env\\" with its value + containing \\"dev\\".""", + r""" + * ``name:howl labels.env:dev`` --> The instance's name + contains \\"howl\\" and it has the label \\"env\\" with + its value containing \\"dev\\".""", +) +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + r""" + \* For resource types for which a decrease in the instance's allocation + has been requested, billing is based on the newly-requested level.""", + r""" + * For resource types for which a decrease in the instance's allocation + has been requested, billing is based on the newly-requested level.""", +) +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + r""" + \* Cancelling the operation sets its metadata's + \[cancel_time\]\[google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time\], and begins + restoring resources to their pre-request values. The operation + is guaranteed to succeed at undoing all resource changes, + after which point it terminates with a `CANCELLED` status.""", + r""" + * Cancelling the operation sets its metadata's + [cancel_time][google.spanner.admin.instance.v1.UpdateInstanceMetadata.cancel_time], + and begins restoring resources to their pre-request values. + The operation is guaranteed to succeed at undoing all resource + changes, after which point it terminates with a `CANCELLED` status.""", +) +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + r""" + \* Reading the instance via the API continues to give the pre-request + resource levels.""", + r""" + * Reading the instance via the API continues to give the pre-request + resource levels.""", +) +s.replace( + 'google/cloud/spanner_admin_instance_v1/gapic/instance_admin_client.py', + r""" + \* Billing begins for all successfully-allocated resources \(some types + may have lower than the requested levels\). + \* All newly-reserved resources are available for serving the instance's + tables.""", + r""" + * Billing begins for all successfully-allocated resources (some types + may have lower than the requested levels). + * All newly-reserved resources are available for serving the instance's + tables.""", +) +s.replace( + 'google/cloud/spanner_v1/proto/transaction_pb2.py', + r"""====*""", + r"", +) +s.replace( + 'google/cloud/spanner_v1/proto/transaction_pb2.py', + r"""----*""", + r"", +) +s.replace( + 'google/cloud/spanner_v1/proto/transaction_pb2.py', + r"""~~~~*""", + r"", +) + +#---------------------------------------------------------------------------- +# Generate database admin client +#---------------------------------------------------------------------------- +library = gapic.py_library( + 'spanner_admin_database', + 'v1', + config_path='/google/spanner/admin/database' + '/artman_spanner_admin_database.yaml', + artman_output_name='spanner-admin-database-v1') + +s.move(library / 'google/cloud/spanner_admin_database_v1/gapic') +s.move(library / 'google/cloud/spanner_admin_database_v1/proto') +s.move(library / 'tests') + +# Fix up the _GAPIC_LIBRARY_VERSION targets +s.replace( + 'google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py', + "'google-cloud-spanner-admin-database'", + "'google-cloud-spanner'", +) + +# Fix up the _GAPIC_LIBRARY_VERSION targets +s.replace( + "google/**/*.py", + 'from google\.cloud\.spanner\.admin\.database_v1.proto', + 'from google.cloud.spanner_admin_database_v1.proto', +) + +# Fix docstrings +s.replace( + 'google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py', + r'database ID must be enclosed in backticks \(`` `` ``\).', + r'database ID must be enclosed in backticks.', +) diff --git a/spanner/tests/unit/gapic/v1/test_database_admin_client_v1.py b/spanner/tests/unit/gapic/v1/test_database_admin_client_v1.py index 3de37e8cbd20..b3f9d90cea08 100644 --- a/spanner/tests/unit/gapic/v1/test_database_admin_client_v1.py +++ b/spanner/tests/unit/gapic/v1/test_database_admin_client_v1.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spanner/tests/unit/gapic/v1/test_instance_admin_client_v1.py b/spanner/tests/unit/gapic/v1/test_instance_admin_client_v1.py index b4d60420dc6f..2a52e4e6b335 100644 --- a/spanner/tests/unit/gapic/v1/test_instance_admin_client_v1.py +++ b/spanner/tests/unit/gapic/v1/test_instance_admin_client_v1.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/spanner/tests/unit/gapic/v1/test_spanner_client_v1.py b/spanner/tests/unit/gapic/v1/test_spanner_client_v1.py index aa47c9530591..6dc82a5d04aa 100644 --- a/spanner/tests/unit/gapic/v1/test_spanner_client_v1.py +++ b/spanner/tests/unit/gapic/v1/test_spanner_client_v1.py @@ -1,4 +1,6 @@ -# Copyright 2017 Google LLC +# -*- coding: utf-8 -*- +# +# Copyright 2018 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -555,24 +557,3 @@ def test_partition_read_exception(self): with pytest.raises(CustomException): client.partition_read(session, table, key_set) - - @pytest.mark.skipif(not spanner_v1.HAS_GRPC_GCP, - reason='grpc_gcp module not available') - @mock.patch( - 'google.auth.default', - return_value=(mock.sentinel.credentials, mock.sentinel.projet)) - @mock.patch('google.protobuf.text_format.Merge') - @mock.patch('grpc_gcp.proto.grpc_gcp_pb2.ApiConfig', - return_value=mock.sentinel.api_config) - @mock.patch('grpc_gcp.secure_channel') - def test_client_with_grpc_gcp_channel(self, - grpc_gcp_secure_channel, - api_config, - merge, - auth_default): - spanner_target = spanner_v1.SpannerClient.SERVICE_ADDRESS - client = spanner_v1.SpannerClient() - merge.assert_called_once_with(mock.ANY, mock.sentinel.api_config) - options = [('grpc_gcp.api_config', mock.sentinel.api_config)] - grpc_gcp_secure_channel.assert_called_once_with( - spanner_target, mock.ANY, options=options) diff --git a/spanner/tests/unit/test_client.py b/spanner/tests/unit/test_client.py index 4bff711b3c9f..354fead25b0d 100644 --- a/spanner/tests/unit/test_client.py +++ b/spanner/tests/unit/test_client.py @@ -200,7 +200,7 @@ def test_list_instance_configs(self): ) ) - api._list_instance_configs = mock.Mock( + lic_api = api._inner_api_calls['list_instance_configs'] = mock.Mock( return_value=instance_config_pbs) response = client.list_instance_configs() @@ -211,7 +211,7 @@ def test_list_instance_configs(self): self.assertEqual(instance_config.name, self.CONFIGURATION_NAME) self.assertEqual(instance_config.display_name, self.DISPLAY_NAME) - api._list_instance_configs.assert_called_once_with( + lic_api.assert_called_once_with( spanner_instance_admin_pb2.ListInstanceConfigsRequest( parent=self.PATH), metadata=[('google-cloud-resource-prefix', client.project_name)], @@ -239,14 +239,14 @@ def test_list_instance_configs_w_options(self): ) ) - api._list_instance_configs = mock.Mock( + lic_api = api._inner_api_calls['list_instance_configs'] = mock.Mock( return_value=instance_config_pbs) token = 'token' page_size = 42 list(client.list_instance_configs(page_token=token, page_size=42)) - api._list_instance_configs.assert_called_once_with( + lic_api.assert_called_once_with( spanner_instance_admin_pb2.ListInstanceConfigsRequest( parent=self.PATH, page_size=page_size, @@ -312,7 +312,7 @@ def test_list_instances(self): ) ) - api._list_instances = mock.Mock( + li_api = api._inner_api_calls['list_instances'] = mock.Mock( return_value=instance_pbs) response = client.list_instances() @@ -325,7 +325,7 @@ def test_list_instances(self): self.assertEqual(instance.display_name, self.DISPLAY_NAME) self.assertEqual(instance.node_count, self.NODE_COUNT) - api._list_instances.assert_called_once_with( + li_api.assert_called_once_with( spanner_instance_admin_pb2.ListInstancesRequest( parent=self.PATH), metadata=[('google-cloud-resource-prefix', client.project_name)], @@ -349,14 +349,14 @@ def test_list_instances_w_options(self): ) ) - api._list_instances = mock.Mock( + li_api = api._inner_api_calls['list_instances'] = mock.Mock( return_value=instance_pbs) token = 'token' page_size = 42 list(client.list_instances(page_token=token, page_size=42)) - api._list_instances.assert_called_once_with( + li_api.assert_called_once_with( spanner_instance_admin_pb2.ListInstancesRequest( parent=self.PATH, page_size=page_size, diff --git a/spanner/tests/unit/test_instance.py b/spanner/tests/unit/test_instance.py index c15febadf7ca..78c97967635b 100644 --- a/spanner/tests/unit/test_instance.py +++ b/spanner/tests/unit/test_instance.py @@ -502,7 +502,8 @@ def test_list_databases(self): ] ) - api._list_databases = mock.Mock(return_value=databases_pb) + ld_api = api._inner_api_calls['list_databases'] = mock.Mock( + return_value=databases_pb) response = instance.list_databases() databases = list(response) @@ -511,7 +512,7 @@ def test_list_databases(self): self.assertTrue(databases[0].name.endswith('/aa')) self.assertTrue(databases[1].name.endswith('/bb')) - api._list_databases.assert_called_once_with( + ld_api.assert_called_once_with( spanner_database_admin_pb2.ListDatabasesRequest( parent=self.INSTANCE_NAME), metadata=[('google-cloud-resource-prefix', instance.name)], @@ -533,7 +534,8 @@ def test_list_databases_w_options(self): databases=[] ) - api._list_databases = mock.Mock(return_value=databases_pb) + ld_api = api._inner_api_calls['list_databases'] = mock.Mock( + return_value=databases_pb) page_size = 42 page_token = 'token' @@ -543,7 +545,7 @@ def test_list_databases_w_options(self): self.assertEqual(databases, []) - api._list_databases.assert_called_once_with( + ld_api.assert_called_once_with( spanner_database_admin_pb2.ListDatabasesRequest( parent=self.INSTANCE_NAME, page_size=page_size,